org.apache.chemistry.opencmis.commons.server.ObjectInfo Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.server.ObjectInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 7 votes vote down vote up
public ObjectInfo getObjectInfo(String objectId, ObjectInfoHandler handler) {
	debug("getObjectInfo " + objectId);
	validatePermission(objectId, null, null);

	try {
		// check id
		if ((objectId == null))
			throw new CmisInvalidArgumentException("Object Id must be set.");

		ObjectInfoImpl info = new ObjectInfoImpl();
		PersistentObject object = getObject(objectId);
		compileProperties(object, null, info);
		ObjectData data = compileObjectType(null, object, null, true, true, handler);
		info.setObject(data);
		return info;
	} catch (Throwable t) {
		log.warn("Not able to retrieve object {}", objectId);
		return (ObjectInfo) catchError(t);
	}
}
 
Example #2
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
	validateSession();
	return getRepository().getObjectInfo(objectId, this);
}
 
Example #3
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Collects the {@link ObjectInfo} about an object.
 * 
 * (Provided by OpenCMIS, but optimized for Alfresco.)
 */
@Override
public ObjectInfo getObjectInfo(String repositoryId, String objectId)
{
    return getObjectInfo(repositoryId, objectId, null, IncludeRelationships.BOTH);
}
 
Example #4
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected ObjectInfo getObjectInfo(String repositoryId, String objectId, IncludeRelationships includeRelationships)
{
    return getObjectInfo(repositoryId, objectId, null, includeRelationships);
}
 
Example #5
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected ObjectInfo getObjectInfo(
        String repositoryId, String objectId, String filter,
        IncludeRelationships includeRelationships)
{
    ObjectInfo info = objectInfoMap.get(objectId);
    if (info == null)
    {
        CMISNodeInfo nodeInfo = getOrCreateNodeInfo(objectId);

        if (nodeInfo.getObjectVariant() == CMISObjectVariant.INVALID_ID
                || nodeInfo.getObjectVariant() == CMISObjectVariant.NOT_EXISTING
                || nodeInfo.getObjectVariant() == CMISObjectVariant.NOT_A_CMIS_OBJECT
                || nodeInfo.getObjectVariant() == CMISObjectVariant.PERMISSION_DENIED)
        {
            info = null;
        } else
        {
            // object info has not been found -> create one
            try
            {
                if (filter == null)
                {
                    filter = MIN_FILTER;
                }
                else if (!filter.equals("*"))
                {
                    filter = filter + "," + MIN_FILTER;
                }

                // get the object and its info
                ObjectData object = connector.createCMISObject(
                        nodeInfo, filter, false, includeRelationships, null, false, false);

                info = getObjectInfoIntern(repositoryId, object);

                // add object info
                objectInfoMap.put(objectId, info);
            }
            catch (Exception e)
            {
                e.printStackTrace();
                info = null;
            }
        }
    }
    return info;
}
 
Example #6
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
    return service.getObjectInfo(repositoryId, objectId);
}
 
Example #7
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Test auto version behavior for setContentStream, deleteContentStream and appendContentStream according to ALF-21852.
 */
@Test
public void testSetDeleteAppendContentStreamVersioning() throws Exception
{
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

    final String DOC1 = "documentProperties1-" + GUID.generate();

    try
    {
        final FileInfo doc = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
        {
            @Override
            public FileInfo execute() throws Throwable
            {
                FileInfo document;
                // create document
                document = fileFolderService.create(repositoryHelper.getCompanyHome(), DOC1, ContentModel.TYPE_CONTENT);
                nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, DOC1);

                Map<QName, Serializable> props = new HashMap<QName, Serializable>();
                props.put(ContentModel.PROP_TITLE, "Initial Title");
                props.put(ContentModel.PROP_DESCRIPTION, "Initial Description");

                nodeService.addAspect(document.getNodeRef(), ContentModel.ASPECT_TITLED, props);

                // apply versionable aspect with properties
                props = new HashMap<QName, Serializable>();
                // ContentModel.PROP_INITIAL_VERSION always true
                props.put(ContentModel.PROP_INITIAL_VERSION, true);
                props.put(ContentModel.PROP_AUTO_VERSION, true);
                props.put(ContentModel.PROP_AUTO_VERSION_PROPS, true);
                versionService.ensureVersioningEnabled(document.getNodeRef(), props);

                return document;
            }
        });
        withCmisService(new CmisServiceCallback<Void>()
        {
            @Override public Void execute(CmisService cmisService)
            {
                final String documentNodeRefId = doc.getNodeRef().toString();
                final String repositoryId = cmisService.getRepositoryInfos(null).get(0).getId();

                ObjectInfo objInfoInitialVersion = cmisService.getObjectInfo(repositoryId, documentNodeRefId);
                assertTrue("We had just created the document - it should be version 1.0", objInfoInitialVersion.getId().endsWith("1.0"));

                ContentStreamImpl contentStream = new ContentStreamImpl(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Content " + GUID.generate());
                Holder<String> objectIdHolder = new Holder<>(documentNodeRefId);
                // Test setContentStream
                cmisService.setContentStream(repositoryId, objectIdHolder, true, null, contentStream, null);
                assertTrue("The \"output\" parameter should returns the newly created version id: 1.1", objectIdHolder.getValue().endsWith("1.1"));
                // we can use this new version id to get information about the cmis object
                ObjectInfo objInfoAfterSetContentStream = cmisService.getObjectInfo(repositoryId, objectIdHolder.getValue());
                assertTrue("The object info should reflect the version requested: 1.1", objInfoAfterSetContentStream.getId().endsWith("1.1"));

                // Test deleteContentStream
                cmisService.deleteContentStream(repositoryId, objectIdHolder, null, null);
                assertTrue("The \"output\" parameter should returns the newly created version id: 1.2", objectIdHolder.getValue().endsWith("1.2"));
                // we can use this new version id to get information about the cmis object
                objInfoAfterSetContentStream = cmisService.getObjectInfo(repositoryId, objectIdHolder.getValue());
                assertTrue("The object info should reflect the version requested: 1.2", objInfoAfterSetContentStream.getId().endsWith("1.2"));

                // Test appendContentStream
                cmisService.appendContentStream(repositoryId, objectIdHolder, null, contentStream, true, null);
                assertTrue("The \"output\" parameter should returns the newly created version id: 1.3", objectIdHolder.getValue().endsWith("1.3"));
                // we can use this new version id to get information about the cmis object
                objInfoAfterSetContentStream = cmisService.getObjectInfo(repositoryId, objectIdHolder.getValue());
                assertTrue("The object info should reflect the version requested: 1.3", objInfoAfterSetContentStream.getId().endsWith("1.3"));

                return null;
            }
        }, CmisVersion.CMIS_1_1);
    }
    finally
    {
        AuthenticationUtil.popAuthentication();
    }
}
 
Example #8
Source File: FilterCmisService.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
public ObjectInfo getObjectInfo(String repositoryId, String objectId) {
	// TODO: add intelligent object info cache
	return super.getObjectInfo(repositoryId, objectId);
}
 
Example #9
Source File: FilterCmisService.java    From iaf with Apache License 2.0 4 votes vote down vote up
@Override
protected ObjectInfo getObjectInfoIntern(String repositoryId, ObjectData object) {
	// TODO: add intelligent object info cache
	return super.getObjectInfoIntern(repositoryId, object);
}