org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler.
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 |
/** * CMIS updateProperties * * @param context the call context * @param objectId identifier of the object * @param properties the properties * @param objectInfos informations * * @return the updated object */ public ObjectData updateProperties(CallContext context, Holder<String> objectId, Properties properties, ObjectInfoHandler objectInfos) { debug("updateProperties " + objectId); validatePermission(objectId.getValue(), context, Permission.WRITE); try { // get the document or folder PersistentObject object = getObject(objectId.getValue()); // get old properties Properties oldProperties = compileProperties(object, null, new ObjectInfoImpl()); update(object, oldProperties, properties); return compileObjectType(context, object, null, false, false, objectInfos); } catch (Throwable t) { return (ObjectData) catchError(t); } }
Example #2
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 7 votes |
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 #3
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 7 votes |
/** * Create dispatch for AtomPub * * @param context call context * @param properties the properties * @param folderId identifier of the parent folder * @param contentStream stream of the document to create * @param versioningState state of the version * @param objectInfos informations * * @return the newly created object */ public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream, VersioningState versioningState, ObjectInfoHandler objectInfos) { debug("create " + folderId); validatePermission(folderId, context, Permission.WRITE); String typeId = getTypeId(properties); TypeDefinition type = types.getType(typeId); if (type == null) throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); String objectId = null; if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { objectId = createDocument(context, properties, folderId, contentStream, versioningState); return compileObjectType(context, getDocument(objectId), null, false, false, objectInfos); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { objectId = createFolder(context, properties, folderId); return compileObjectType(context, getFolder(objectId), null, false, false, objectInfos); } else { throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!"); } }
Example #4
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 7 votes |
/** * Compiles an object type object from a document or folder * * @param context the call context * @param object the persistent object * @param filter optional filter * @param includeAllowableActions if the allowable actions must be included * @param includeAcl if the ACL must be included * @param objectInfos informations * * @return the object */ private ObjectData compileObjectType(CallContext context, PersistentObject object, Set<String> filter, boolean includeAllowableActions, boolean includeAcl, ObjectInfoHandler objectInfos) { ObjectDataImpl result = new ObjectDataImpl(); ObjectInfoImpl objectInfo = new ObjectInfoImpl(); result.setProperties(compileProperties(object, filter, objectInfo)); if (includeAllowableActions) { result.setAllowableActions(compileAllowableActions(object)); } if (includeAcl) { result.setAcl(compileAcl(object)); result.setIsExactAcl(true); } if ((context != null) && context.isObjectInfoRequired() && (objectInfos != null)) { objectInfo.setObject(result); // objectInfo.setVersionSeriesId(getId(object)); objectInfos.addObjectInfo(objectInfo); } return result; }
Example #5
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
static ObjectDataImpl toObjectData(CmisRepositoryConfiguration config, CallContext context, TypeDefinition type, Object object, boolean root, Set<String> filter, ObjectInfoHandler objectInfos) { ObjectDataImpl result = new ObjectDataImpl(); ObjectInfoImpl objectInfo = new ObjectInfoImpl(); compileObjectMetadata(objectInfo, type); result.setProperties(compileProperties(config, type, object, root, filter, objectInfo)); result.setAllowableActions(compileAllowableActions(type, object, false, false)); if (context.isObjectInfoRequired()) { objectInfo.setObject(result); objectInfos.addObjectInfo(objectInfo); } return result; }
Example #6
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
ObjectInFolderList toObjectInFolderList(CmisRepositoryConfiguration config, CallContext callContext, Collection children, Set<String> filter, boolean root, ObjectInfoHandler objectInfos) { List<ObjectInFolderData> objectInFolderList = new ArrayList<>(); ObjectInFolderListImpl list = new ObjectInFolderListImpl(); list.setObjects(objectInFolderList); if (children == null) { return list; } for (Object child : children) { ObjectInFolderDataImpl folderData = new ObjectInFolderDataImpl(); ObjectData object = toObjectData(config, callContext, getType(child), child, root, filter, objectInfos); folderData.setObject(object); objectInFolderList.add(folderData); } return list; }
Example #7
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
@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); }
Example #8
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 6 votes |
/** * Compiles an object type object from a file or folder. */ private ObjectData compileObjectType(CallContext context, Node node, Set<String> filter, boolean includeAllowableActions, boolean includeAcl, ObjectInfoHandler objectInfos) { ObjectDataImpl result = new ObjectDataImpl(); ObjectInfoImpl objectInfo = new ObjectInfoImpl(); result.setProperties(compileProperties(node, filter, objectInfo)); if (includeAllowableActions) { result.setAllowableActions(compileAllowableActions(node)); } if (includeAcl) { result.setAcl(compileAcl(node)); result.setIsExactAcl(true); } if (context.isObjectInfoRequired()) { objectInfo.setObject(result); objectInfos.addObjectInfo(objectInfo); } return result; }
Example #9
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 6 votes |
/** * CMIS getObjectByPath. */ public ObjectData getObjectByPath(CallContext context, String folderPath, String filter, boolean includeAllowableActions, boolean includeACL, ObjectInfoHandler objectInfos) { log.debug("getObjectByPath({}, {}, {})", new Object[]{folderPath, filter, includeAllowableActions}); // split filter Set<String> filterCollection = splitFilter(filter); // check path if (folderPath == null || !folderPath.startsWith("/")) { throw new CmisInvalidArgumentException("Invalid folder path!"); } // get the document or folder Node node = getNode(folderPath); return compileObjectType(context, node, filterCollection, includeAllowableActions, includeACL, objectInfos); }
Example #10
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 6 votes |
/** * Create* dispatch for AtomPub. */ public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream, VersioningState versioningState, ObjectInfoHandler objectInfos) { log.debug("create({}, {})", properties, folderId); String typeId = getTypeId(properties); TypeDefinition type = types.getType(typeId); if (type == null) { throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); } String objectId = null; if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { objectId = createDocument(context, properties, folderId, contentStream, versioningState); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { objectId = createFolder(context, properties, folderId); } else { throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!"); } return compileObjectType(context, getNode(objectId), null, false, false, objectInfos); }
Example #11
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS getFolderParent. */ public ObjectData getFolderParent(CallContext context, String folderId, String filter, ObjectInfoHandler objectInfos) { List<ObjectParentData> parents = getObjectParents(context, folderId, filter, false, false, objectInfos); if (parents.size() == 0) { throw new CmisInvalidArgumentException("The root folder has no parent!"); } return parents.get(0).getObject(); }
Example #12
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS getObject. */ public ObjectData getObject(CallContext context, String objectId, String versionServicesId, String filter, Boolean includeAllowableActions, Boolean includeAcl, ObjectInfoHandler objectInfos) { log.debug("getObject({}, {}, {})", new Object[]{objectId, versionServicesId, filter}); // check id if ((objectId == null) && (versionServicesId == null)) { throw new CmisInvalidArgumentException("Object Id must be set."); } if (objectId == null) { // this works only because there are no versions in a file system // and the object id and version series id are the same objectId = versionServicesId; } // get the document or folder Node node = getNode(objectId); // set defaults if values not set boolean iaa = (includeAllowableActions == null ? false : includeAllowableActions.booleanValue()); boolean iacl = (includeAcl == null ? false : includeAcl.booleanValue()); // split filter Set<String> filterCollection = splitFilter(filter); // gather properties return compileObjectType(context, node, filterCollection, iaa, iacl, objectInfos); }
Example #13
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
@Transactional public ObjectInFolderList getChildren(CmisRepositoryConfiguration config, String folderId, String filter, String orderBy, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegment, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension, CallContext context, ObjectInfoHandler handler) { Set<String> filterCol = splitFilter(filter); Object parent = null; List<Object> children = new ArrayList<>(); if (folderId.equals(getRootId()) == false) { parent = getObjectInternal(config, folderId, filterCol, false, IncludeRelationships.NONE, null, false, false, null ); } children = config.getCmisNavigationService().getChildren(parent); return toObjectInFolderList(config, context, children, filterCol,true, handler); }
Example #14
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
@Transactional public ObjectData getObjectInternal(CmisRepositoryConfiguration config, String objectId, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension, CallContext context, ObjectInfoHandler handler) { Set<String> filterCol = splitFilter(filter); Object object = null; ObjectDataImpl result = null; ObjectInfoImpl objectInfo = new ObjectInfoImpl(); if (objectId.equals(getRootId())) { object = new Root(); result = toObjectData(config, context, getType(object), object, true, filterCol, handler); } else { object = this.getObjectInternal(config, objectId, filterCol, includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl, extension); result = toObjectData(config, context, getType(object), object, false, filterCol, handler); } return result; }
Example #15
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * CMIS getObject * * @param context the call context * @param objectId identifier of the file/foler * @param versionServicesId version specification * @param filter optional filter * @param includeAllowableActions if the allowable actions must be included * @param includeAcl if the ACL must be included * @param objectInfos informations * * @return the file/folder */ public ObjectData getObject(CallContext context, String objectId, String versionServicesId, String filter, Boolean includeAllowableActions, Boolean includeAcl, ObjectInfoHandler objectInfos) { debug("getObject " + objectId); try { validatePermission(objectId, context, null); if (objectId == null) { // this works only because there are no versions in a file // system // and the object id and version series id are the same objectId = versionServicesId; } PersistentObject obj = getObject(objectId); if (obj == null) throw new CmisObjectNotFoundException(String.format("Object ID %s not found", objectId)); // set defaults if values not set boolean iaa = (includeAllowableActions == null ? false : includeAllowableActions.booleanValue()); boolean iacl = (includeAcl == null ? false : includeAcl.booleanValue()); // split filter Set<String> filterCollection = splitFilter(filter); // gather properties return compileObjectType(context, obj, filterCollection, iaa, iacl, objectInfos); } catch (Throwable t) { t.printStackTrace(); return (ObjectData) catchError(t); } }
Example #16
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 4 votes |
@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; }
Example #17
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 4 votes |
@Transactional public ObjectData getObjectByPath(CmisRepositoryConfiguration config, String path, String filter, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeAcl, ExtensionsData extension, CallContext context, ObjectInfoHandler handler) { if (path.equals("/")) { return toObjectData(config, context, typeMap.get("cmis:folder"), new Root(), true, null, handler); } if (path.startsWith("/")) { path = path.replaceFirst("/",""); } String[] segments = path.split("/"); Object object = null; for (int i=0; i < segments.length; i++) { List children = config.getCmisNavigationService().getChildren(object); object = null; for (int j=0; j < children.size() && object == null; j++) { Object child = children.get(j); String name = getAsString(child, CmisName.class); if (segments[i].equals(name)) { object = child; } } } if (object == null) { throw new CmisObjectNotFoundException(format("object not found for path %s", path)); } return toObjectData(config, context, getType(object), object, false, null, handler); }
Example #18
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
/** * 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); } }