This document is outdated!
The former Chemistry library and OpenCMIS were merged into one Java library (OpenCMIS).
Chemistry is the name of the Apache CMIS implementation project, while OpenCMIS is the name of Chemistry's Java implementation.
RepositoryService and Repository
Because CMIS allows several repositories to live in the same server, the information about the remote server and how to talk to it is encapsulated in a RepositoryService. The RepositoryManager is the global registry of RepositoryServices, and from a RepositoryService you can get to several Repositories.
Your code can either instantiate a protocol-specific version of the Repository interface:
RepositoryService repositoryService = new APPRepositoryService(url, null);
Repository repository = repositoryService.getRepository("myrepo");
Or rely on it being already registered and look up the repository by name:
RepositoryManager.getInstance().registerService(repositoryService);
Repository repository = RepositoryManager.getInstance().getRepository("myrepo");
High-level, object-oriented API: Connection, Folder, Document
From a Repository you can get a new Connection, get the root folder, get the first of its children and change its description:
Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(Repository.PARAM_USERNAME, "username"); params.put(Repository.PARAM_PASSWORD, "password"); Connection conn = repository.getConnection(params); try { Folder root = conn.getRootFolder(); List<CMISObject> children = root.getChildren(); for (CMISObject child : children) { System.out.println(child.getName()); } Document doc = (Document) children.get(0); System.out.println("Child id: " + child.getId()); doc.setValue("description", "First child"); doc.save(); } finally { conn.close(); }
Low-level SPI: SPI, ObjectEntry
Here you access the DTO for the object itself. This example does the same thing as above:
Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(Repository.PARAM_USERNAME, "username"); params.put(Repository.PARAM_PASSWORD, "password"); SPI spi = repository.getSPI(params); try { ObjectId rootId = repository.getInfo().getRootFolderId(); ListPage<ObjectEntry> page = spi.getChildren(rootId, null, null, null); for (ObjectEntry entry : page) { System.out.println(entry.getValue(Property.NAME)); } ObjectId docId = page.get(0); // ObjectEntry implements ObjectId System.out.println("Child id: " + docId.getId()); Map<String, Serializable> props = new HashMap<String, Serializable>(); props.put("description", "First child"); spi.updateProperties(docId, null, props); } finally { spi.close(); }