// User credentials. parameters.put(SessionParameter.USER, "admin"); parameters.put(SessionParameter.PASSWORD, "admin"); // Connection settings. parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameters.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/service/cmis"); // URL to your CMIS server. parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true" ); parameters.put(SessionParameter.COOKIES, "true" ); // Create session. // Alfresco only provides one repository. Repository repository = sessionFactory.getRepositories(parameters).get(0); Session session = repository.createSession();
@Override public String getDocumentId( String path ) { // establish relation between path and object identifier return session.getObjectByPath(path).getId(); }
private void doQuery(Session session, String stmt) { for (QueryResult qr : session.query(stmt, false)) { qr.getPropertyByQueryName("cmis:name"); } }
// For how to get a Session see: // http://chemistry.apache.org/java/opencmis-client-api.html#sessions Session session = getSession(); CmisObject object = session.getObjectByPath("/path/to/object"); ObjectType type = object.getType(); Boolean isVersionable = type instanceOf DocumentType && ((DocumentType)type).isVersionable();
@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 List<Tree<ObjectType>> getDescendants(int depth) { return session.getTypeDescendants(objectType.getId(), depth, true); } }
@Override public ContentStream call() throws Exception { return session.getContentStream(docId, streamId, offset, length); } }
@Override public Object call() throws Exception { session.delete(objectId, allVersions); return null; } }
@Override public Acl call() throws Exception { return session.setAcl(objectId, aces); } }
@Override public ObjectType call() throws Exception { return session.createType(type); } }
@Override public ObjectId call() throws Exception { return session.createFolder(properties, folderId, policies, addAces, removeAces); } }
@Override public ObjectId call() throws Exception { return session.createDocumentFromSource(source, properties, folderId, versioningState, policies, addAces, removeAces); } }
@Override public ObjectId call() throws Exception { return session.createItem(properties, folderId, policies, addAces, removeAces); } }
@Override public List<String> call() throws Exception { return session.deleteTree(folderId, allVersions, unfile, continueOnFailure); } }
public List<Tree<ObjectType>> getDescendants(int depth) { return session.getTypeDescendants(objectType.getId(), depth, true); } }
@Override public ContentStream call() throws Exception { return session.getContentStream(docId, streamId, offset, length); } }
@Override public Object call() throws Exception { session.delete(objectId, allVersions); return null; } }
@Override public Acl call() throws Exception { return session.setAcl(objectId, aces); } }