本文整理汇总了Java中org.apache.chemistry.opencmis.client.api.Session.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getObject方法的具体用法?Java Session.getObject怎么用?Java Session.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.chemistry.opencmis.client.api.Session
的用法示例。
在下文中一共展示了Session.getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDescendants
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public FolderNode getDescendants(String folderId, int depth)
{
Session session = getCMISSession();
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
OperationContextImpl ctx = new OperationContextImpl();
List<Tree<FileableCmisObject>> res = f.getDescendants(depth, ctx);
FolderNode ret = (FolderNode)CMISNode.createNode(f);
for(Tree<FileableCmisObject> t : res)
{
addChildren(ret, t);
}
return ret;
}
else
{
throw new IllegalArgumentException("Folder does not exist or is not a folder");
}
}
示例2: directoryExistCMIS
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/** Verifie qu'un dossier existe en mode CMIS
* @param idFolder
* @return
*/
private Boolean directoryExistCMIS(String idFolder, Session cmisSession) {
if (idFolder == null || idFolder.equals("")) {
return false;
}
try{
CmisObject object = cmisSession.getObject(cmisSession.createObjectId(idFolder));
if (!(object instanceof Folder)){
logger.error("Stockage de fichier - CMIS : l'object CMIS "+idFolder+" n'est pas un dossier");
return false;
}
}catch(Exception e){
logger.error("Stockage de fichier - CMIS : erreur sur l'object CMIS "+idFolder, e);
return false;
}
return true;
}
示例3: renameFolder
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static void renameFolder(Session pSession, String pStrNodeRef, String pStrNewName) {
mLog.debug("ENTER renameFolder(<Session>, " + pStrNodeRef + ", " + pStrNewName + ")");
Folder lFolder = (Folder) pSession.getObject(pStrNodeRef);
Map<String, String> lMapProperties = new HashMap<String, String>();
lMapProperties.put(PropertyIds.NAME, pStrNewName);
try {
lFolder.updateProperties(lMapProperties, true);
} catch (CmisContentAlreadyExistsException e) {
mLog.error("Impossibile aggiornare le proprietà del documento", e);
throw new AlfrescoException(e, AlfrescoException.FOLDER_ALREADY_EXISTS_EXCEPTION);
}
mLog.debug("EXIT renameFolder(<Session>, " + pStrNodeRef + ", " + pStrNewName + ")");
}
示例4: getDescendants
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public FolderNode getDescendants(String folderId, int depth)
{
Session session = getCMISSession();
CmisObject o = session.getObject(folderId);
if(o instanceof Folder)
{
Folder f = (Folder)o;
OperationContextImpl ctx = new OperationContextImpl();
List<Tree<FileableCmisObject>> res = f.getDescendants(depth, ctx);
FolderNode ret = (FolderNode)CMISNode.createNode(f);
for(Tree<FileableCmisObject> t : res)
{
addChildren(ret, t);
}
return ret;
}
else
{
throw new IllegalArgumentException("Folder does not exist or is not a folder");
}
}
示例5: getTracks
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Returns tracks of an album.
*
* @param session
* OpenCMIS session
* @param albumObject
* the album object
* @return a list of track documents, or an empty list if the object
* is not an album or the album has no tracks
*/
public static List<Document> getTracks(Session session,
CmisObject albumObject) {
List<Document> tracks = new ArrayList<Document>();
@SuppressWarnings("unchecked")
List<String> trackIds = (List<String>) albumObject
.getPropertyValue(IdMapping
.getRepositoryPropertyId("cmisbook:tracks"));
if (trackIds != null) {
for (String trackId : trackIds) {
try {
CmisObject track = session.getObject(trackId,
CMISHelper.FULL_OPERATION_CONTEXT);
if (track instanceof Document) {
tracks.add((Document) track);
}
} catch (CmisBaseException cbe) {
// ignore
}
}
}
return tracks;
}
示例6: deleteDocument
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static void deleteDocument(Session pSession, String pStrNodeRef, boolean pBlnAllVersions) {
mLog.debug("ENTER deleteDocument(<Session>, " + pStrNodeRef + ", " + pBlnAllVersions + ")");
Document lDocument = (Document) pSession.getObject(pStrNodeRef);
lDocument.delete(pBlnAllVersions);
mLog.debug("EXIT deleteDocument(<Session>, " + pStrNodeRef + ", " + pBlnAllVersions + ")");
}
示例7: createFolder
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static String createFolder(Session pSession, String pStrParentFolderId, String pStrFolderName) {
String lStrFolderId = null;
mLog.debug("Start createFolder(", pSession, ",", pStrParentFolderId, ",", pStrFolderName, ")");
// recupero la cartella padre
Folder lFolder = (Folder) pSession.getObject(pStrParentFolderId);
// creo la cartella
Map<String, String> lMapProperties = new HashMap<String, String>();
lMapProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
lMapProperties.put(PropertyIds.NAME, pStrFolderName);
Folder lFolderNew;
try {
lFolderNew = lFolder.createFolder(lMapProperties);
lStrFolderId = lFolderNew.getId();
} catch (CmisContentAlreadyExistsException e) {
mLog.error("Il documento esiste già", e);
throw new AlfrescoException(e, AlfrescoException.FOLDER_ALREADY_EXISTS_EXCEPTION);
}
mLog.debug("End createFolder(", pSession, ",", pStrParentFolderId, ",", pStrFolderName, "): return ",
lStrFolderId);
return lStrFolderId;
}
示例8: createRelation
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static Relationship createRelation(Session pSession, String pStrRelationTypeId, String pStrSourceId, String pStrTargetId) {
mLog.debug("Start createRelation(<Session>, " + pStrRelationTypeId + ", " + pStrSourceId + ", " + pStrTargetId + ")");
Map<String, Serializable> lRelationProperties = new HashMap<String, Serializable>();
lRelationProperties.put(PropertyIds.SOURCE_ID, pStrSourceId);
lRelationProperties.put(PropertyIds.TARGET_ID, pStrTargetId);
lRelationProperties.put(PropertyIds.OBJECT_TYPE_ID, pStrRelationTypeId);
ObjectId lRelationId = pSession.createRelationship(lRelationProperties);
mLog.debug("End createRelation()");
return (Relationship) pSession.getObject(lRelationId);
}
示例9: searchDocuments
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static List<Document> searchDocuments(Session pSession, String pQuery) {
mLog.debug("START searchDocuments(String");
mLog.debug("CMIS query: {}", pQuery);
// per evitare il problema dei documenti duplicati
LinkedHashMap<String, Document> lHashMapResults = new LinkedHashMap<String, Document>();
ItemIterable<QueryResult> lResults = pSession.query(pQuery, false);
// XXX (Alessio): sarà il modo giusto? Prestazioni?
if (lResults != null) {
int i = 0;
//
for (Iterator<QueryResult> iterator = lResults.iterator(); i < ((CollectionIterator<QueryResult>)iterator).getTotalNumItems();) {
QueryResult qResult = iterator.next();
//} (QueryResult qResult : lResults) {
if (qResult != null) {
PropertyData<?> lPropData = qResult.getPropertyById("cmis:objectId");
if (lPropData != null) {
String lObjectId = (String) lPropData.getFirstValue();
CmisObject lObj = pSession.getObject(pSession.createObjectId(lObjectId));
lHashMapResults.put(lObjectId, (Document) lObj);
}
}
i++;
}
}
mLog.debug("END searchDocuments(String");
return new ArrayList<Document>(lHashMapResults.values());
}
示例10: getDocumentRenditions
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public static List<Rendition> getDocumentRenditions(Session pSession, String pStrDocumentId, String pStrFilter) {
mLog.debug("START getDocumentRenditions(String, String)");
OperationContext operationContext = pSession.createOperationContext();
operationContext.setFilterString(PropertyIds.NAME);
operationContext.setRenditionFilterString(pStrFilter);
CmisObject lCmisObject = pSession.getObject(pStrDocumentId);
List<Rendition> lListResults = lCmisObject.getRenditions();
mLog.debug("END getDocumentRenditions(String)");
return lListResults;
}
示例11: getDocument
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public Document getDocument()
{
Session cmisSession = CMISHelper.getCMISSession(ticket);
CmisObject object = cmisSession.getObject(nodeRef);
Document doc = (Document) object;
return doc;
}
示例12: getCmisObject
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Gets a CMIS object from the repository.
*
* @param session
* the OpenCMIS session
* @param id
* the id of the object
* @param context
* the Operation Context
* @param what
* string that describes the object, used for error
* messages
* @return the CMIS object
* @throws TheBlendException
*/
public static CmisObject getCmisObject(final Session session,
final String id, final OperationContext context,
final String what) throws TheBlendException {
if (session == null) {
throw new IllegalArgumentException("Session must be set!");
}
if (id == null || id.length() == 0) {
throw new TheBlendException("Invalid id for " + what + "!");
}
OperationContext oc = context;
if (oc == null) {
oc = session.getDefaultContext();
}
try {
return session.getObject(id, oc);
} catch (CmisObjectNotFoundException onfe) {
throw new TheBlendException("The " + what + " does not exist!",
onfe);
} catch (CmisBaseException cbe) {
throw new TheBlendException("Could not retrieve the " + what
+ ":" + cbe.getMessage(), cbe);
}
}
示例13: testALF10085
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
public void testALF10085() throws InterruptedException
{
Repository repository = getRepository("admin", "admin");
Session session = repository.createSession();
Folder rootFolder = session.getRootFolder();
Map<String, String> props = new HashMap<String, String>();
{
props.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
props.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
}
Document doc1 = rootFolder.createDocument(props, null, null);
props = new HashMap<String, String>();
{
props.put(PropertyIds.OBJECT_TYPE_ID, "D:cmiscustom:document");
props.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt");
}
Document doc2 = rootFolder.createDocument(props, null, null);
Thread.sleep(6000);
session.getObject(doc1);
doc1.refresh();
Calendar doc1LastModifiedBefore = (Calendar)doc1.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
assertNotNull(doc1LastModifiedBefore);
doc2.refresh();
Calendar doc2LastModifiedBefore = (Calendar)doc2.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
assertNotNull(doc2LastModifiedBefore);
// Add relationship A to B
props = new HashMap<String, String>();
{
props.put(PropertyIds.OBJECT_TYPE_ID, "R:cmiscustom:assoc");
props.put(PropertyIds.NAME, "A Relationship");
props.put(PropertyIds.SOURCE_ID, doc1.getId());
props.put(PropertyIds.TARGET_ID, doc2.getId());
}
session.createRelationship(props);
doc1.refresh();
Calendar doc1LastModifiedAfter = (Calendar)doc1.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
assertNotNull(doc1LastModifiedAfter);
doc2.refresh();
Calendar doc2LastModifiedAfter = (Calendar)doc2.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
assertNotNull(doc2LastModifiedAfter);
assertEquals(doc1LastModifiedBefore, doc1LastModifiedAfter);
assertEquals(doc2LastModifiedBefore, doc2LastModifiedAfter);
}
示例14: createDocument
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Crea un nuovo documento in Alfresco.
* <p>
* Lo stream in {@code pInputStream} sarà concumato ma non chiuso.
*
* @param pSession
* La sessione da utilizzare.
* @param pStrParentFolderId
* L'id della cartella in cui creare il nuovo documento.
* @param pStrFileName
* Il nome del file da utilizzare.
* @param pLngFileLength
* La lunghezza in byte dello stream, o -1 se ignota.
* @param pStrContentType
* Il <i>content type</i> del file. Se nullo sarà impostato a
* {@code application/octet-stream}
* @param pInputStream
* Lo {@code InputStream} del nuovo contenuto.
* @param pMapProperties
* L'eventuale mappa delle proprietà del nuovo documento.
* @param pCollectionAspects
* L'eventuale lista degli aspetti da applicare al nuovo documento.
* @param pStrObjectType
* L'eventuale tipo documento da utizzare (predefinito: {@code cmis:document}.
* @return Il documento creato.
*/
// XXX (Alessio): ha senso consentire già qui di impostare gli aspetti?
public static Document createDocument(Session pSession, String pStrParentFolderId, String pStrFileName,
long pLngFileLength, String pStrContentType, InputStream pInputStream, Map<String, Object> pMapProperties,
Collection<String> pCollectionAspects, String pStrObjectType) {
mLog.debug("START createDocument(String, String, String, long, InputStream)");
String lStrEffectiveContentType = pStrContentType != null ? pStrContentType : "application/octet-stream";
mLog.debug("Creazione documento '{}'({} - {} B) nella cartella '{}')", pStrFileName, pStrContentType,
pLngFileLength, pStrParentFolderId);
// recupero la cartella padre
// TODO (Alessio): gestire CmisObjectNotFoundException
Folder lFolder = (Folder) pSession.getObject(pStrParentFolderId);
// creo il content stream, se necessario
ContentStream lContentStream = null;
if (pInputStream != null) {
lContentStream =
pSession.getObjectFactory().createContentStream(pStrFileName, pLngFileLength,
lStrEffectiveContentType, pInputStream);
}
if (pMapProperties == null) {
// La mappa delle proprietà è necessaria per la creazione
pMapProperties = new HashMap<String, Object>();
}
// Aggiornamento proprietà con tipo ed eventuali aspetti
String lStrObjectType = (pStrObjectType == null) ? "cmis:document" : pStrObjectType;
pMapProperties.put(PropertyIds.OBJECT_TYPE_ID, lStrObjectType);
if (pCollectionAspects != null) {
updatePropertiesWithAspects(pSession, pMapProperties, pStrObjectType, pCollectionAspects);
}
pMapProperties.put(PropertyIds.NAME, pStrFileName);
// Creazione effettiva
Document lDocument = lFolder.createDocument(pMapProperties, lContentStream, VersioningState.MAJOR);
mLog.debug("END createDocument(String, String, String, long, InputStream)");
return lDocument;
}
示例15: getDocumentVersions
import org.apache.chemistry.opencmis.client.api.Session; //导入方法依赖的package包/类
/**
* Recupera l'elenco delle versioni di un documento.
* <p>
* La lista dei documenti restituiti ha solo un sottoinsieme delle loro proprietà, ovvero:
* <ul>
* <li>{@code cmis:objectId}</li>
* <li>{@code cmis:name}</li>
* <li>{@code cmis:versionLabel}</li>
* <li>{@code cmis:isLatestVersion}</li>
* <li>{@code cmis:isMajorVersion}</li>
* <li>{@code cmis:creationDate}</li>
* <li>{@code cmis:createdBy}</li>
* <li>{@code cmis:lastModificationDate}</li>
* <li>{@code cmis:lastModififiedBy}</li>
* </ul>
*
* @param pSession
* La sessione da utilizzare.
* @param pStrDocumentId
* L'id del documento di cui recuperare le versioni.
*
* @return La lista delle versioni del documento.
*/
public static List<Document> getDocumentVersions(Session pSession, String pStrDocumentId) {
mLog.debug("START getDocumentVersions(String)");
Document lDocument = (Document) pSession.getObject(pStrDocumentId);
// Filtro sulle proprietà restituite
OperationContext lOperationContext = pSession.createOperationContext();
Set<String> lPropertyFilter = new HashSet<>();
lPropertyFilter.addAll(Arrays.asList(PropertyIds.OBJECT_ID, PropertyIds.NAME, PropertyIds.VERSION_LABEL,
PropertyIds.IS_LATEST_VERSION, PropertyIds.IS_MAJOR_VERSION, PropertyIds.CREATION_DATE,
PropertyIds.CREATED_BY, PropertyIds.LAST_MODIFICATION_DATE, PropertyIds.LAST_MODIFIED_BY));
lOperationContext.setFilter(lPropertyFilter);
lOperationContext.setIncludeAllowableActions(false);
lOperationContext.setIncludePathSegments(false);
List<Document> lListResults = lDocument.getAllVersions(lOperationContext);
mLog.debug("Trovate {} versioni per il documento {}", lListResults.size(), pStrDocumentId);
mLog.debug("END getDocumentVersions(String)");
return lListResults;
}