Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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

...

Code Block
titleObject-oriented API
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();
}

...

Code Block
titleObject-oriented API
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();
}

...