org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectParentDataImpl. 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 4 votes vote down vote up
/**
 * 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);
	}
}
 
Example #2
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 4 votes vote down vote up
@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;
}