OpenCMIS, an Apache Chemistry sub-project, is an open source library which provides a simple Java API for accessing any CMIS compliant content repository. Think of it as the JDBC of content repositories. In this session, you'll learn about the architecture of OpenCMIS and walkthrough many code samples showing how easy it is to build CMIS-based applications.
2. OpenCMIS 3 OpenCMIS is a sub-project of Apache Chemistry is an umbrella project for CMIS implementations Java Python PHP Server and client implementation of the CMIS specification
3. OpenCMIS goals 4 OpenCMIS hides the bindings and provides binding agnostic APIs and SPIs OpenCMIS adds a lot of convenience Developers should focus on the domain model!
4. Current state 5 OpenCMIS has contributors from Alfresco, Open Text, SAP and Nuxeo OpenCMIS 0.1.0 has been released in September The code is pretty mature and stable and has been tested against all major ECM vendors The some areas of client API will be refactored and simplified within the next month OpenCMIS is an active Open Source project
6. OpenCMIS Server 7 One Servlet per binding that map the requests to an SPI Repository vendors have to implement two interfaces Not our focus today… … for CMIS connector developers SOAP AtomPub CMIS Service Factory CMIS Service CMIS Service CMIS Service
7. OpenCMIS client 8 Client API OO API Easy to use Build-in caching Client Binding API Low-level Very close to the CMIS specification More control, less comfort … for CMIS application developers
8. Let’s start 9 Download it! http://incubator.apache.org/chemistry/opencmis.html Use Maven! Build the latest and greatest! http://incubator.apache.org/chemistry/opencmis-how-to-build.html Get hold of the OpenCMIS Jars <dependency> <groupId>org.apache.chemistry.opencmis</groupId> <artifactId>chemistry-opencmis-client-impl</artifactId> <version>0.1.0-incubating</version> </dependency>
9. Connect to a repository – Variant 1 10 Map<String, String> parameter = new HashMap<String, String>(); parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameter.put(SessionParameter.ATOMPUB_URL, "http://cmis.alfresco.com/service/cmis"); parameter.put(SessionParameter.REPOSITORY_ID, "84ccfe80-b325-4d79-ab4d-080a4bdd045b"); parameter.put(SessionParameter.USER, "admin"); parameter.put(SessionParameter.PASSWORD, "admin"); SessionFactory factory = SessionFactoryImpl.newInstance(); Session session = factory.createSession(parameter); CMIS is stateless! OpenCMIS introduces a session concept to support caching.
10. Connect to a repository – Variant 2 11 Map<String, String> parameter = new HashMap<String, String>(); parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value()); parameter.put(SessionParameter.ATOMPUB_URL, "http://cmis.alfresco.com/service/cmis"); parameter.put(SessionParameter.REPOSITORY_ID, "84ccfe80-b325-4d79-ab4d-080a4bdd045b"); parameter.put(SessionParameter.USER, "admin"); parameter.put(SessionParameter.PASSWORD, "admin"); SessionFactory factory = SessionFactoryImpl.newInstance(); List<Repository> repositories = factory.getRepositories(parameter); Session session = repositories.get(0).createSession(); Alfresco only exposes one repository! This is the simplest way to create a session.
11. Walking around 12 RepositoryInfori = session.getRepositoryInfo(); String id = ri.getId(); String name = ri.getName(); Folder rootFolder = session.getRootFolder(); String rootFolderId = rootFolder.getId(); for(CmisObject object: rootFolder.getChildren()) { String name = object.getName(); if(objectinstanceof Document) { Document doc = (Document) object; long size = doc.getContentStreamLength(); } }
13. Caching 14 Repository Info Retrieved and cached during session creation Will not be updated during the lifetime of a session Type Definitions Cached whenever a type definition is retrieved –explicitly or implicitly Will not be updated during the lifetime of a session (OpenCMIS can be forced to forget Repository Infos and Type Definitions. That is similar to creating a new session.) What is cached and when?
14. Caching 15 CMIS Objects Object caching is turned on by default LRU cache with 1000 objects getObject() might return stale objectsif an old copy is found in the cache Refresh objects manually CmisObject object = session.getObject(id); object.refresh(); object.refreshIfOld(60 * 1000); What is cached and when?
15. Caching 16 Turn caching offsession.getDefaultContext().setCacheEnabled(false); Turn caching off for one requestOperationContextoc = session.createOperationContext(); oc.setCacheEnabled(false);CmisObject object = session.getObject(id, oc); Control the cache!
25. CMIS Extensions 26 CMIS specifies extension points Arbitrary data can be attached to CMIS structures Clients and servers either understand the extension or ignore them Alfresco sends aspect data as CMIS extension Alfresco will accept aspect data through CMIS extensions There will be an Alfresco addition to OpenCMISthat handles aspects How to get and set of aspect properties?
26. Learn More 27 wiki.alfresco.com forums.alfresco.com twitter: @AlfrescoECM