@Override public Future<CmisObject> getObject(ObjectId objectId) { return getObject(objectId, session.getDefaultContext()); }
@Override public Document getRenditionDocument() { return getRenditionDocument(session.getDefaultContext()); }
@Override public Future<CmisObject> getObjectByPath(String parentPath, String name) { return getObjectByPath(parentPath, name, session.getDefaultContext()); }
@Override public Future<Document> getLatestDocumentVersion(String objectId) { return getLatestDocumentVersion(objectId, session.getDefaultContext()); }
@Override public Future<CmisObject> getObject(String objectId) { return getObject(objectId, session.getDefaultContext()); }
@Override public Future<CmisObject> getObjectByPath(String parentPath, String name) { return getObjectByPath(parentPath, name, session.getDefaultContext()); }
@Override public Future<Document> getLatestDocumentVersion(String objectId) { return getLatestDocumentVersion(objectId, session.getDefaultContext()); }
@Override public Future<CmisObject> getObject(String objectId) { return getObject(objectId, session.getDefaultContext()); }
@Override public Future<CmisObject> getObjectByPath(String path) { return getObjectByPath(path, session.getDefaultContext()); }
@Override public Future<CmisObject> getObjectByPath(String path) { return getObjectByPath(path, session.getDefaultContext()); }
@Override public Future<Document> getLatestDocumentVersion(ObjectId objectId) { return getLatestDocumentVersion(objectId, session.getDefaultContext()); }
@Override public Future<CmisObject> getObject(ObjectId objectId) { return getObject(objectId, session.getDefaultContext()); }
@Override public Future<Document> getLatestDocumentVersion(ObjectId objectId) { return getLatestDocumentVersion(objectId, session.getDefaultContext()); }
@Override public Document getRenditionDocument() { return getRenditionDocument(session.getDefaultContext()); }
@Override public void deleteFolder(String path, Session session) throws Exception { // Disable cache session.getDefaultContext().setCacheEnabled(false); if (path.endsWith("/")) path = path.substring(0, path.length()-1); Folder folder = (Folder)FileUtils.getObject(path, session); folder.deleteTree(true, UnfileObject.DELETE, true); // Enable cache session.getDefaultContext().setCacheEnabled(true); }
@Override public void delete(String path, String documentName, Session session) throws Exception { // Disable cache session.getDefaultContext().setCacheEnabled(false); Document document = (Document)FileUtils.getObject(path + "/" + documentName, session); document.delete(); // Enable cache session.getDefaultContext().setCacheEnabled(true); }
public static void main(String args[]) { String serverUrl = args[0]; String username = args[1]; String password = args[2]; Session session = getSession(serverUrl, username, password); Folder root = session.getRootFolder(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_ DOCUMENT.value()); String name = "New Document (" + System.currentTimeMillis() + ").txt"; properties.put(PropertyIds.NAME, name); List<Ace> addAces = new LinkedList<Ace>(); List<Ace> removeAces = new LinkedList<Ace>(); List<Policy> policies = new LinkedList<Policy>(); String content = "The quick brown fox jumps over the lazy dog."; ContentStream contentStream = new ContentStreamImpl("text.txt", BigInteger.valueOf(content.length()), "text/plain", new ByteArrayInputStream(content. getBytes())); Document newDocument = root.createDocument(properties, contentStream, VersioningState.MAJOR, policies, addAces, removeAces, session.getDefaultContext()); System.out.println(newDocument.getId());}
@Override public void move(String pathOrigin, String documentNameOrigin, String pathDestination, String documentNameDestination, Session session) throws Exception { // Disable cache session.getDefaultContext().setCacheEnabled(false); // Fetch the object FileableCmisObject fileableCmisObject = (FileableCmisObject) FileUtils.getObject(pathOrigin + documentNameOrigin, session); // ECM folder paths does not end with "/" if (pathOrigin.endsWith("/")) pathOrigin = pathOrigin.substring(0, pathOrigin.length()-1); if (pathDestination.endsWith("/")) pathDestination = pathDestination.substring(0, pathDestination.length()-1); // Fetch source folder CmisObject sourceObject = FileUtils.getObject(pathOrigin, session); // Fetch the destination folder // We need to make sure the target folder exists createFolder(pathDestination); CmisObject targetObject = FileUtils.getObject(pathDestination, session); if (documentNameDestination != documentNameOrigin){ fileableCmisObject.rename(documentNameDestination, true); } // Move the object fileableCmisObject.move(sourceObject, targetObject); // Enable cache session.getDefaultContext().setCacheEnabled(true); }
@Override public T retrieve(String path, String documentName, Session session) throws Exception { // Disable cache session.getDefaultContext().setCacheEnabled(false); Document object = (Document)FileUtils.getObject(path + documentName, session); ContentStream contentStream = object.getContentStream(); Class<T> classP = getClassP(); T document = classP.newInstance(); document.setContentStream(IOUtils.toByteArray(contentStream.getStream())); document.setContentStreamFilename(documentName); document.setContentStreamLenght(contentStream.getLength()); document.setContentStreamMimeType(contentStream.getMimeType()); // Enable cache session.getDefaultContext().setCacheEnabled(true); return document; }
public void DISABLED_testBasicFileOps() { Repository repository = getRepository("admin", "admin"); Session session = repository.createSession(); Folder rootFolder = session.getRootFolder(); // create folder Map<String,String> folderProps = new HashMap<String, String>(); { folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate()); } Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext()); Map<String, String> fileProps = new HashMap<String, String>(); { fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt"); } ContentStreamImpl fileContent = new ContentStreamImpl(); { ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt")); writer.putContent("Ipsum and so on"); ContentReader reader = writer.getReader(); fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN); fileContent.setStream(reader.getContentInputStream()); } folder.createDocument(fileProps, fileContent, VersioningState.MAJOR); }