Java源码示例:org.apache.chemistry.opencmis.commons.data.ObjectParentData

示例1
@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
        Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
        Boolean includeRelativePathSegment, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkId("Object Id", objectId);
    includeAllowableActions = getDefaultFalse(includeAllowableActions);
    includeRelationships = getDefault(includeRelationships);
    renditionFilter = getDefaultRenditionFilter(renditionFilter);
    includeRelativePathSegment = getDefaultFalse(includeRelativePathSegment);

    try {
        return getWrappedService().getObjectParents(repositoryId, objectId, filter, includeAllowableActions,
                includeRelationships, renditionFilter, includeRelativePathSegment, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
示例2
@Transactional
public ObjectData getFolderParent(CmisRepositoryConfiguration config,
		String folderId,
		String filter,
		ExtensionsData extension,
		CallContext context,
		ObjectInfoHandler handler) {

	List<ObjectParentData> parentData = this.getObjectParents(config,
			folderId,
			filter,
			false,
			IncludeRelationships.NONE,
			null,
			false,
			extension,
			context,
			handler);

	if (parentData != null && parentData.size() > 0) {
		return parentData.get(0).getObject();
	}

	return toObjectData(config, context, typeMap.get("cmis:folder"), new Root(), true, null, handler);
}
 
示例3
@Override
public List<ObjectParentData> getObjectParents(String repositoryId,
											   String objectId, String filter, Boolean includeAllowableActions,
											   IncludeRelationships includeRelationships, String renditionFilter,
											   Boolean includeRelativePathSegment, ExtensionsData extension) {
	return bridge.getObjectParents(config,
			objectId,
			filter,
			includeAllowableActions,
			includeRelationships,
			renditionFilter,
			includeRelativePathSegment,
			extension,
			this.getCallContext(),
			this);
}
 
示例4
@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
		Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
		Boolean includeRelativePathSegment, ExtensionsData extension) {
	validateSession();
	return getRepository().getObjectParents(getCallContext(), objectId, filter, includeAllowableActions,
			includeRelativePathSegment, this);
}
 
示例5
@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
        Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
        Boolean includeRelativePathSegment, ExtensionsData extension) {
    return service.getObjectParents(repositoryId, objectId, filter, includeAllowableActions, includeRelationships,
            renditionFilter, includeRelativePathSegment, extension);
}
 
示例6
@Override
public List<ObjectParentData> getObjectParents(String repositoryId, String objectId, String filter,
		Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
		Boolean includeRelativePathSegment, ExtensionsData extension) {
	return getNavigationService().getObjectParents(repositoryId, objectId, filter, includeAllowableActions,
			includeRelationships, renditionFilter, includeRelativePathSegment, extension);
}
 
示例7
@Override
public List<ObjectParentData> getObjectParents(String repositoryId,
		String objectId, String filter, Boolean includeAllowableActions,
		IncludeRelationships includeRelationships, String renditionFilter,
		Boolean includeRelativePathSegment, ExtensionsData extension) {
	// TODO Auto-generated method stub
	return navigationService.getObjectParents(repositoryId, objectId, filter, includeAllowableActions, includeRelationships, renditionFilter, includeRelativePathSegment, extension);
}
 
示例8
/**
 * CMIS getObjectParents
 * 
 * @param context the call context
 * @param objectId identifier of the file/folder
 * @param filter an optional filter
 * @param includeAllowableActions if the allowable actions must be included
 * @param includeRelativePathSegment if the path segment must be included
 * @param objectInfos informations
 * 
 * @return list of parents
 */
@SuppressWarnings("unchecked")
public List<ObjectParentData> getObjectParents(CallContext context, String objectId, String filter,
		Boolean includeAllowableActions, Boolean includeRelativePathSegment, ObjectInfoHandler objectInfos) {
	debug("getObjectParents " + objectId + " " + filter);
	validatePermission(objectId, context, null);

	try {
		// split filter
		Set<String> filterCollection = splitFilter(filter);

		// set defaults if values not set
		boolean iaa = (includeAllowableActions == null ? false : includeAllowableActions.booleanValue());
		boolean irps = (includeRelativePathSegment == null ? false : includeRelativePathSegment.booleanValue());

		// get the file or folder
		PersistentObject object = getObject(objectId);

		// don't climb above the root folder
		if (root.equals(object))
			return Collections.emptyList();

		// set object info of the the object
		if (context.isObjectInfoRequired())
			compileObjectType(context, object, null, false, false, objectInfos);

		Folder parent;
		if (object instanceof AbstractDocument)
			parent = ((AbstractDocument) object).getFolder();
		else
			parent = folderDao.findFolder(((Folder) object).getParentId());

		// get parent folder
		ObjectData obj = compileObjectType(context, parent, filterCollection, iaa, false, objectInfos);

		ObjectParentDataImpl result = new ObjectParentDataImpl();
		result.setObject(obj);
		if (irps) {
			if (object instanceof Document)
				result.setRelativePathSegment(((Document) object).getFileName());
			else
				result.setRelativePathSegment(((Folder) object).getName());
		}

		return Collections.singletonList((ObjectParentData) result);
	} catch (Throwable t) {
		return (List<ObjectParentData>) catchError(t);
	}
}
 
示例9
/**
 * MNT-14951: Test that the list of parents can be retrieved for a folder.
 */
@Test
public void testCMISGetObjectParents() throws Exception
{
    // setUp audit subsystem
    setupAudit();
    
    AuthenticationUtil.pushAuthentication();
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    try
    {
        final NodeRef folderWithTwoParents = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>()
        {
            @Override
            public NodeRef execute() throws Throwable
            {
                NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();

                String folder1 = GUID.generate();
                FileInfo folderInfo1 = fileFolderService.create(companyHomeNodeRef, folder1, ContentModel.TYPE_FOLDER);
                assertNotNull(folderInfo1);
                
                String folder2 = GUID.generate();
                FileInfo folderInfo2 = fileFolderService.create(companyHomeNodeRef, folder2, ContentModel.TYPE_FOLDER);
                assertNotNull(folderInfo2);
                
                // Create folder11 as a subfolder of folder1
                String folder11 = GUID.generate();
                FileInfo folderInfo11 = fileFolderService.create(folderInfo1.getNodeRef(), folder11, ContentModel.TYPE_FOLDER);
                assertNotNull(folderInfo11);
                
                // Add folder2 as second parent for folder11
                nodeService.addChild(folderInfo2.getNodeRef(), folderInfo11.getNodeRef(), ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS);
                
                return folderInfo11.getNodeRef();
            }
        });
        
        withCmisService(new CmisServiceCallback<Void>()
        {
            @Override
            public Void execute(CmisService cmisService)
            {
                List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
                assertNotNull(repositories);
                assertTrue(repositories.size() > 0);
                String repositoryId = repositories.iterator().next().getId();

                List<ObjectParentData> parents = cmisService.getObjectParents(repositoryId, folderWithTwoParents.getId(), null, Boolean.FALSE, IncludeRelationships.NONE,
                                                                              "cmis:none", Boolean.FALSE, null);
                // Check if the second parent was also returned.
                assertEquals(2, parents.size());

                return null;
            }
        }, CmisVersion.CMIS_1_1);
    }
    finally
    {
        auditSubsystem.destroy();
        AuthenticationUtil.popAuthentication();
    }
}
 
示例10
@Transactional
public List<ObjectParentData> getObjectParents(CmisRepositoryConfiguration config,
		String objectId,
		String filter,
		Boolean includeAllowableActions,
		IncludeRelationships includeRelationships,
		String renditionFilter,
		Boolean includeRelativePathSegment,
		ExtensionsData extension,
		CallContext context,
		ObjectInfoHandler handler) {

	if (objectId.equals(getRootId())) {
		throw new CmisInvalidArgumentException("The root folder has no parent!");
	}

	Set<String> filterCol = splitFilter(filter);

	Object object = getObjectInternal(config,
			objectId,
			filterCol,
			false,
			IncludeRelationships.NONE,
			renditionFilter,
			false,
			false,
			extension);

	String parentProperty = findParentProperty(object);
	BeanWrapper wrapper = new BeanWrapperImpl(object);
	Object parents = wrapper.getPropertyValue(parentProperty);

	if (parents == null) {
		return Collections.emptyList();
	}

	if (context.isObjectInfoRequired()) {
		toObjectData(config, context, getType(object), object, false, filterCol, handler);
	}

	List<ObjectParentData> results = new ArrayList<>();

	ObjectParentDataImpl result = new ObjectParentDataImpl();

	// TODO: handle parents when it is a collection
	//
	result.setObject(toObjectData(config, context, typeMap.get("cmis:folder"), parents /* singleton only!*/, false, filterCol, handler));

	if (includeRelativePathSegment) {
		result.setRelativePathSegment(getName(object));
	}
	results.add(result);

	return results;
}