当前位置: 首页>>代码示例>>Java>>正文


Java Session.getObject方法代码示例

本文整理汇总了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");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:PublicApiClient.java

示例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;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:21,代码来源:FileManagerCmisImpl.java

示例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 + ")");
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:18,代码来源:AlfrescoHelper.java

示例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");
	}
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:25,代码来源:PublicApiClient.java

示例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;
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:36,代码来源:TheBlendHelper.java

示例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 + ")");
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:9,代码来源:AlfrescoHelper.java

示例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;
	}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:29,代码来源:AlfrescoHelper.java

示例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);
	}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:14,代码来源:AlfrescoHelper.java

示例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());
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:36,代码来源:AlfrescoHelper.java

示例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;
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:13,代码来源:AlfrescoHelper.java

示例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;
}
 
开发者ID:sueastside,项目名称:BEIDSign,代码行数:10,代码来源:SignatureRequest.java

示例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);
	}
}
 
开发者ID:fmui,项目名称:ApacheChemistryInAction,代码行数:42,代码来源:CMISHelper.java

示例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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:54,代码来源:OpenCmisLocalTest.java

示例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;
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:69,代码来源:AlfrescoHelper.java

示例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;
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:44,代码来源:AlfrescoHelper.java


注:本文中的org.apache.chemistry.opencmis.client.api.Session.getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。