org.apache.chemistry.opencmis.commons.server.CallContext Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.server.CallContext.
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 |
/** * 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 #2
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 #3
Source File: PublicApiCallContextHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public Map<String, String> getCallContextMap(HttpServletRequest request) { Map<String, String> map = new HashMap<String, String>(); Map<String, String> basicAuthMap = super.getCallContextMap(request); if (basicAuthMap != null && !basicAuthMap.isEmpty()) { map.putAll(basicAuthMap); } // Adding the username in the context is needed because of the following reasons: // - CMISServletDispatcher is configured to ALWAYS use this class (PublicApiCallContextHandler) // - this class extends the BasicAuthCallContextHandler class which only puts the username in the context ONLY IF the request is having Basic auth // - therefor in the case of a Bearer auth, the username is never in the context, fact that ultimately leads to bugs when the response should be provided if (map.get(CallContext.USERNAME) == null && AuthenticationUtil.getFullyAuthenticatedUser() != null) { map.put(CallContext.USERNAME, AuthenticationUtil.getFullyAuthenticatedUser()); } map.put("isPublicApi", "true"); return map; }
Example #4
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 #5
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 #6
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 #7
Source File: CmisServiceFactory.java From document-management-system with GNU General Public License v2.0 | 6 votes |
@Override public CmisService getService(CallContext context) { // authentication can go here String user = context.getUsername(); String password = context.getPassword(); log.debug("User: {}", user); log.debug("Password: {}", password); // if the authentication fails, throw a CmisPermissionDeniedException // create a new service object (can also be pooled or stored in a ThreadLocal) CmisServiceImpl service = new CmisServiceImpl(repository); // add the CMIS service wrapper // (The wrapper catches invalid CMIS requests and sets default values // for parameters that have not been provided by the client.) CmisServiceWrapper<CmisService> wrapperService = new CmisServiceWrapper<CmisService>(service, DEFAULT_MAX_ITEMS_TYPES, DEFAULT_DEPTH_TYPES, DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS); // hand over the call context to the service object service.setCallContext(context); return wrapperService; }
Example #8
Source File: ServiceFactory.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
@Override public CmisService getService(CallContext context) { Session session = SessionManager.get().getSession( (HttpServletRequest) context.get(CallContext.HTTP_SERVLET_REQUEST)); CmisService wrapperService = null; if (session != null) { if (context.getRepositoryId() != null) session.getDictionary().put(KEY_REPO_ID, context.getRepositoryId()); log.debug("Using session " + session.getSid() + " for user " + session.getUsername()); wrapperService = new CmisServiceWrapper<LDCmisService>(new LDCmisService(context, session.getSid()), DEFAULT_MAX_ITEMS_TYPES, BigInteger.valueOf(Context.get().getProperties() .getInt("cmis.maxitems", 200)), DEFAULT_MAX_ITEMS_OBJECTS, DEFAULT_DEPTH_OBJECTS); } else { log.warn("No session was found for this request"); } return wrapperService; }
Example #9
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 #10
Source File: LDCmisService.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Constructor * * @param context the call context * @param sid identifier of the session */ public LDCmisService(CallContext context, String sid) { this.context = context; this.sid = sid; try { historyDao = (DocumentHistoryDAO) Context.get().getBean(DocumentHistoryDAO.class); FolderDAO fdao = (FolderDAO) Context.get().getBean(FolderDAO.class); Session session = SessionManager.get().get(sid); Folder root = fdao.findRoot(session.getTenantId()); repositories.put(Long.toString(root.getId()), new LDRepository(root, sid)); } catch (Throwable t) { log.error(t.getMessage(), t); } }
Example #11
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 #12
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
public String createDocumentFromSource(CallContext context, String sourceId, String folderId) { debug("createDocumentFromSource"); validatePermission(folderId, context, Permission.WRITE); try { Folder target = getFolder(folderId); if (target == null) throw new CmisObjectNotFoundException("Folder '" + folderId + "' is unknown!"); Document doc = (Document) getDocument(sourceId); if (doc == null) throw new CmisObjectNotFoundException("Document '" + sourceId + "' is unknown!"); DocumentHistory transaction = new DocumentHistory(); transaction.setSessionId(sid); transaction.setEvent(DocumentEvent.STORED.toString()); transaction.setUser(getSessionUser()); transaction.setComment(""); Document newDoc = documentManager.copyToFolder(doc, target, transaction); return getId(newDoc); } catch (Throwable t) { return (String) catchError(t); } }
Example #13
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 #14
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback, CmisVersion cmisVersion) { CmisService cmisService = null; try { CallContext context = new SimpleCallContext("admin", "admin", cmisVersion); cmisService = factory.getService(context); T ret = callback.execute(cmisService); return ret; } finally { if(cmisService != null) { cmisService.close(); } } }
Example #15
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 #16
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS getTypeDefinition. */ public TypeDefinition getTypeDefinition(CallContext context, String typeId) { TypeDefinitionContainer tc = types.get(typeId); if (tc == null) { throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); } return copyTypeDefintion(tc.getTypeDefinition()); }
Example #17
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * CMIS getTypesDescendants * * @param context call context * @param typeId id of the type * @param depth depth specification * @param includePropertyDefinitions if the properties definition must be included * * @return list of definitions */ public List<TypeDefinitionContainer> getTypesDescendants(CallContext context, String typeId, BigInteger depth, Boolean includePropertyDefinitions) { List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>(); // check depth int d = (depth == null ? -1 : depth.intValue()); if (d == 0) { throw new CmisInvalidArgumentException("Depth must not be 0!"); } // set property definition flag to default value if not set boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); if (typeId == null) { result.add(getTypesDescendants(d, types.get(FOLDER_TYPE_ID), ipd)); result.add(getTypesDescendants(d, types.get(DOCUMENT_TYPE_ID), ipd)); // result.add(getTypesDescendants(depth, // fTypes.get(RELATIONSHIP_TYPE_ID), includePropertyDefinitions)); // result.add(getTypesDescendants(depth, fTypes.get(POLICY_TYPE_ID), // includePropertyDefinitions)); } else { TypeDefinitionContainer tc = types.get(typeId); if (tc != null) { result.add(getTypesDescendants(d, tc, ipd)); } } return result; }
Example #18
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS getTypesDescendants. */ public List<TypeDefinitionContainer> getTypesDescendants(CallContext context, String typeId, BigInteger depth, Boolean includePropertyDefinitions) { List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>(); // check depth int d = (depth == null ? -1 : depth.intValue()); if (d == 0) { throw new CmisInvalidArgumentException("Depth must not be 0!"); } if (typeId == null) { d = -1; } // set property definition flag to default value if not set boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); if (typeId == null) { result.add(getTypesDescendants(d, types.get(FOLDER_TYPE_ID), ipd)); result.add(getTypesDescendants(d, types.get(DOCUMENT_TYPE_ID), ipd)); // result.add(getTypesDescendants(depth, // fTypes.get(RELATIONSHIP_TYPE_ID), includePropertyDefinitions)); // result.add(getTypesDescendants(depth, fTypes.get(POLICY_TYPE_ID), // includePropertyDefinitions)); } else { TypeDefinitionContainer tc = types.get(typeId); if (tc != null) { result.add(getTypesDescendants(d, tc, ipd)); } } return result; }
Example #19
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS getAllowableActions. */ public AllowableActions getAllowableActions(CallContext context, String objectId) { log.debug("getAllowableActions({})", objectId); // get the document or folder Node node = getNode(objectId); return compileAllowableActions(node); }
Example #20
Source File: ContentCmisServiceFactory.java From spring-content with Apache License 2.0 | 5 votes |
@Override public CmisService getService(CallContext context) { CallContextAwareCmisService service = threadLocalService.get(); if (service == null) { service = new ContentCmisService(config, bridge); threadLocalService.set(service); } service.setCallContext(context); return service; }
Example #21
Source File: CmisUtils.java From iaf with Apache License 2.0 | 5 votes |
public static void populateCmisAttributes(IPipeLineSession session) { CallContext callContext = (CallContext) session.get(CMIS_CALLCONTEXT_KEY); if(callContext != null) { session.put(CMIS_VERSION_KEY, callContext.getCmisVersion()); session.put(CMIS_BINDING_KEY, callContext.getBinding()); if("basic".equalsIgnoreCase(CMIS_SECURITYHANDLER)) { HttpServletRequest request = (HttpServletRequest) callContext.get(CallContext.HTTP_SERVLET_REQUEST); session.setSecurityHandler(new HttpSecurityHandler(request)); } else if("wsse".equalsIgnoreCase(CMIS_SECURITYHANDLER)) { session.setSecurityHandler(new CmisSecurityHandler(callContext)); } } }
Example #22
Source File: CachedBindingCmisService.java From iaf with Apache License 2.0 | 5 votes |
@Override public void setCallContext(CallContext context) { super.setCallContext(context); clientBinding = getCmisBindingFromCache(); if (clientBinding == null) { clientBinding = putCmisBindingIntoCache(createCmisBinding()); } }
Example #23
Source File: RepositoryConnectorFactory.java From iaf with Apache License 2.0 | 5 votes |
@Override public CmisService getService(CallContext context) { LOG.debug("Retrieve proxy repository service"); CallContextAwareCmisService service = threadLocalService.get(); if (service == null) { service = new ConformanceCmisServiceWrapper(createService(context)); threadLocalService.set(service); LOG.info("Create service wrapper"); } service.setCallContext(context); //Update the CallContext return service; }
Example #24
Source File: RepositoryConnectorFactory.java From iaf with Apache License 2.0 | 5 votes |
protected FilterCmisService createService(CallContext context) { HttpSessionCmisService service = null; try { service = new HttpSessionCmisService(context); LOG.info("Created proxy repository service"); } catch (Exception e) { throw new CmisRuntimeException("Could not create service instance: " + e, e); } return service; }
Example #25
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 #26
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 #27
Source File: CmisRepository.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS setContentStream and deleteContentStream. */ public void setContentStream(CallContext context, Holder<String> objectId, Boolean overwriteFlag, ContentStream contentStream) { log.debug("setContentStream({}, {})", objectId, overwriteFlag); if (objectId == null) { throw new CmisInvalidArgumentException("Id is not valid!"); } // check overwrite // boolean owf = (overwriteFlag == null ? true : overwriteFlag.booleanValue()); // if (!owf && file.length() > 0) { // throw new CmisContentAlreadyExistsException("Content already exists!"); // } try { if (!OKMDocument.getInstance().isValid(null, objectId.getValue())) { throw new CmisStreamNotSupportedException("Not a document"); } if (!OKMDocument.getInstance().isCheckedOut(null, objectId.getValue())) { OKMDocument.getInstance().checkout(null, objectId.getValue()); } new DbDocumentModule().checkin(null, objectId.getValue(), contentStream.getStream(), contentStream.getLength(), "CMIS Client", null); } catch (Exception e) { throw new CmisStorageException("Could not write content: " + e.getMessage(), e); } }
Example #28
Source File: AbstractCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets the call context and propagates it down to the next service wrapper * or service if it implements the {@link CallContextAwareCmisService} * interface. */ @Override public void setCallContext(CallContext callContext) { this.context = callContext; if (service instanceof CallContextAwareCmisService) { ((CallContextAwareCmisService) service).setCallContext(callContext); } }
Example #29
Source File: AlfrescoLocalCmisServiceFactory.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public CmisService getService(CallContext context) { ConformanceCmisServiceWrapper wrapperService = THREAD_LOCAL_SERVICE.get(); if (wrapperService == null) { AlfrescoCmisService cmisService = new AlfrescoCmisServiceImpl(CMIS_CONNECTOR); wrapperService = new ConformanceCmisServiceWrapper(cmisService, CMIS_CONNECTOR.getTypesDefaultMaxItems(), CMIS_CONNECTOR.getTypesDefaultDepth(), CMIS_CONNECTOR.getObjectsDefaultMaxItems(), CMIS_CONNECTOR.getObjectsDefaultDepth()); THREAD_LOCAL_SERVICE.set(wrapperService); } ((AlfrescoCmisService)wrapperService.getWrappedService()).open(context); return wrapperService; }
Example #30
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private String convertAspectPropertyValue(Object value) { if (value instanceof Date) { GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); cal.setTime((Date) value); value = cal; } if (value instanceof GregorianCalendar) { DatatypeFactory df; try { df = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new IllegalArgumentException("Aspect conversation exception: " + e.getMessage(), e); } return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat(); } // MNT-12496 MNT-15044 // Filter for AtomPub and Web services bindings only. Browser/json binding already encodes. if (AlfrescoCmisServiceCall.get() != null && (CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) || CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding()))) { return filterXmlRestrictedCharacters(value.toString()); } else { return value.toString(); } }