public Folder getFolderById(String id) { try { return (Folder) session.getObject(session.createObjectId(id)); } catch (CmisObjectNotFoundException e) { //great idea Chemistry developers - use RUNTIME exceptions to control the flow return null; } }
public ObjectId createDocumentById(@NotNull(value = "No folderId was specified in the request.") String folderId, @NotNull(value = "No filename was specified in the request.") String filename, @NotNull(value = "No document content was specified in the payload.") Object content, @NotNull(value = "No file mime type was specified in the request.") String mimeType, org.mule.modules.cmis.model.VersioningState versioningState, @NotNull(value = "No object type was specified in the request.") String objectType, Map<String, Object> properties) { ObjectId returnId = null; Session session = this.getSession(this.connectionParameters); if (session != null) { logger.debug("Preparing to create a document with file name \"" + filename + "\" in the folder with ID \"" + folderId + "\"."); returnId = createDocument(session.getObject(session.createObjectId(folderId)), filename, content, mimeType, versioningState, objectType, properties); logger.debug("The ID of the repository node after document creation is \"" + returnId.getId() + "\"."); } return returnId; }
protected UgcService createUgcService(Session session, WebsiteInfo siteInfo) { UgcServiceCmisImpl ugcService = new UgcServiceCmisImpl(session .createObjectId(siteInfo.feedbackFolderId)); ugcService.setFormIdCache(formIdCache); return ugcService; }
/** * create a document */ protected ObjectId createDocument(@NotNull(value = "No folder was specified in the request.") CmisObject folder, @NotNull(value = "No filename was specified in the request.") String filename, @NotNull(value = "No document content was specified in the payload.") Object content, @NotNull(value = "No file mime type was specified in the request.") String mimeType, @NotNull(value = "No versioning state was specified in the request.") org.mule.modules.cmis.model.VersioningState versioningState, String objectType, Map<String, Object> extraProperties) { ObjectId returnId = null; Session session = this.getSession(this.connectionParameters); if (session != null) { VersioningState vs; try { vs = VersioningState.valueOf(versioningState.name()); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(String.format("Illegal value for versioningState. Given `%s' could be: %s", versioningState, Arrays.toString(VersioningState.values())), e); } Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, objectType); properties.put(PropertyIds.NAME, filename); if (extraProperties != null) { properties.putAll(extraProperties); } returnId = session.createDocument(properties, session.createObjectId(folder.getId()), createContentStream(filename, mimeType, content), vs); } return returnId; // End createDocument }
public CmisObject getObjectById(String objectId) { CmisObject returnObj = null; Session session = this.getSession(this.connectionParameters); if (session != null) { returnObj = session.getObject(session.createObjectId(objectId), createOperationContext(null, null)); } return returnObj; }
public ObjectId createFolder(String folderName, String parentObjectId) { ObjectId returnId = null; Session session = this.getSession(this.connectionParameters); if (session != null) { if (StringUtils.isEmpty(parentObjectId)) { parentObjectId = session.getRootFolder().getId(); } Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.NAME, folderName); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); try { returnId = session.createFolder(properties, session.getObject(session.createObjectId(parentObjectId))); } catch (CmisContentAlreadyExistsException e) { logger.debug("CMIS Content Already Exists ", e); CmisObject object = session.getObject(session.createObjectId(parentObjectId)); if (!(object instanceof Folder)) { throw new IllegalArgumentException(parentObjectId + " is not a folder"); } Folder folder = (Folder) object; for (CmisObject o : folder.getChildren()) { if (o.getName().equals(folderName)) { return session.createObjectId(o.getId()); } } } } return returnId; // End createFolder }
@Override public Map<String, org.alfresco.wcm.client.Rendition> getRenditions(String assetId) { Map<String, org.alfresco.wcm.client.Rendition> renditionMap = new TreeMap<String, org.alfresco.wcm.client.Rendition>(); if (assetId == null || assetId.length() == 0) { throw new IllegalArgumentException("assetId = " + assetId); } Session session = CmisSessionHelper.getSession(); OperationContext oc = session.createOperationContext(); oc.setRenditionFilterString("*"); List<Rendition> renditions = session.getObject(session.createObjectId(assetId), oc).getRenditions(); for (Rendition rendition : renditions) { renditionMap.put(rendition.getKind(), new ContentStreamCmisRenditionImpl(rendition)); } return renditionMap; }