Good Chemistry: Alfresco, JBoss and CMIS

3,390 views

Published on

These are the slides presented at Red Hat Summit/JBoss World on 5/5/2011. The session was mostly a panel discussion but the slides include a brief CMIS introduction and some code samples at the end.

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,390
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
81
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Good Chemistry: Alfresco, JBoss and CMIS

  1. 1. Good Chemistry: Alfresco, JBoss and CMIS<br />JBoss World 2011<br />
  2. 2. <ul><li>Let’s Meet our Panel
  3. 3. Quick CMIS Intro</li></ul>Discussion<br />Q & A <br />Agenda <br />Usehashtag#cmispanelto tweet questions during the talk<br />
  4. 4. Let’s Meet Our Panel<br />
  5. 5. Florian Müller<br />Apache Chemistry Chair<br />Alfresco Architect<br />OASIS CMIS Technical Committee member<br />CMIS specification editor<br />@florian_mueller<br />florian.mueller@alfresco.com<br />
  6. 6. Mike Vertal<br />Rivet Logic CEO<br />Alfresco Platinum Partner<br />Alfresco Community Committer Program Chair<br />http://www.rivetlogic.com<br />@mvertal<br />
  7. 7. Jason Andersen<br />Director, JBoss Middleware<br />janderse@redhat.com<br />
  8. 8. Jeff Potts<br />Apache Chemistry cmislib lead<br />Alfresco Chief Community Officer<br />http://ecmarchitect.com<br />jpotts@alfresco.com<br />@jeffpotts01<br />
  9. 9. Quick CMIS Intro<br />
  10. 10. What is CMIS?<br />Vendor independent API for working with content repositories<br />Specification managed by OASIS<br />Web Services Binding<br />ATOM Pub Binding<br />CMIS Query Language<br />
  11. 11. Client<br />consumer<br />read<br />write<br />Services<br />Domain Model<br />Content<br />Management<br />Interoperability<br />Services<br />Vendor Mapping<br />provider<br />Content Repository<br />CMIS lets you read, search, write, update, delete, version, control, … content and metadata!<br />Meet CMIS<br />
  12. 12. Client<br />Content Repository<br />Client<br />Content Repository<br />Content Repository<br />Content Repository<br />Content Repository<br />Content Repository<br /><ul><li>Workflow & BPM
  13. 13. Archival
  14. 14. Virtual Documents
  15. 15. DAM / WCM
  16. 16. Collaborative Content Creation
  17. 17. Portals
  18. 18. Client Application Integration
  19. 19. Mashup</li></ul>Use Cases<br />
  20. 20. Document<br /><ul><li> Content
  21. 21. Renditions
  22. 22. Version History</li></ul>Folder<br /><ul><li> Container
  23. 23. Hierarchy
  24. 24. Filing</li></ul>Described by<br />Type Definitions<br />Relationship<br /><ul><li> Source Object
  25. 25. Target Object</li></ul>Policy<br /><ul><li> Target Object</li></ul>Types<br />
  26. 26. Object<br /><ul><li> Type Id
  27. 27. Parent
  28. 28. Display Name
  29. 29. Queryable
  30. 30. Controllable</li></ul>Property<br /><ul><li> Property Id
  31. 31. Display Name
  32. 32. Type
  33. 33. Required
  34. 34. Default Value
  35. 35. …</li></ul>*<br />Document<br /><ul><li>Versionable
  36. 36. Allow Content</li></ul>Folder<br />Relationship<br /><ul><li> Source Types
  37. 37. Target Types</li></ul>Policy<br />Custom Type<br />Type Definitions<br />
  38. 38. Implementations Already Available…<br />Providers<br />Consumers<br />Developed by 30+ ECM Vendors<br />
  39. 39. Open Source implementations of CMIS<br />Apache Chemistry is the umbrella project for all CMIS related projects within the ASF<br />OpenCMIS (Java, client and server)<br />cmislib (Python, client)<br />phpclient (PHP, client)<br />DotCMIS (.NET, client)<br />
  40. 40. Apache Chemistry started as an incubator project in May 2009<br />Graduated to a top level project in February 2011.<br />Backed by Adobe, Alfresco, Nuxeo, OpenText, and SAP<br />OpenCMIS is a de-facto reference for CMIS and is also used by the CMIS TC to test new CMIS 1.1 features<br />
  41. 41.
  42. 42. Wrap-up<br />Download OpenCMIShttp://chemistry.apache.org<br />Need a full-featured CMIS repository?http://www.alfresco.org<br />Stop by the Alfresco booth to see CMIS in action<br />
  43. 43. CMIS Code Examples<br />
  44. 44. // set up session parameters<br />Map<String, String> parameter = new HashMap<String, String>();<br />parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());<br />parameter.put(SessionParameter.ATOMPUB_URL, "http://cmis.alfresco.com/service/cmis");<br />parameter.put(SessionParameter.USER, "admin");<br />parameter.put(SessionParameter.PASSWORD, "admin");<br />// get a list of repositories and choose the first one<br />SessionFactory factory = SessionFactoryImpl.newInstance();<br />List<Repository> repositories = factory.getRepositories(parameter);<br />Session session = repositories.get(0).createSession();<br />Example: Getting a Session<br />
  45. 45. Example: Using the Session<br />Information about the repository:<br />RepositoryInfo ri = session.getRepositoryInfo();<br />String id = ri.getId();<br />String name = ri.getName();<br />Access objects by id or path:<br />CmisObject object1 = session.getObject("1234567890");<br />CmisObject object2 = session.getObjectByPath("/my/path/doc");<br />Iterate through a folder:<br />Folder rootFolder = session.getRootFolder();<br />String rootFolderId = rootFolder.getId();<br />for(CmisObject object: rootFolder.getChildren()) {<br /> String name = object.getName();<br />if(objectinstanceof Document) {<br /> Document doc = (Document) object;<br /> long size = doc.getContentStreamLength(); <br /> }<br />}<br />
  46. 46. Navigation<br />// get root folder<br />Folder root = session.getRootFolder();<br />String rootFolderName = root.getName();<br />println "Root folder: ${rootFolderName}n"<br />// print root folder children<br />for(CmisObject object: root.getChildren()) {<br /> String name = object.getName();<br /> String typeId = object.getType().getId();<br /> String path = object.getPaths().get(0);<br />println "${name} t${typeId} t(${path})"<br /> // get parents<br /> /*<br />for(CmisObject parent: object.getParents()) {<br /> String parentName = parent.getName();<br />println " Parent: ${parentName}"<br /> }<br /> */<br />}<br />
  47. 47. Paging<br />Folder root = session.getRootFolder();<br />printList( root.getChildren() )<br />//printList( root.getChildren().getPage(3) )<br />//printList( root.getChildren().skipTo(2) )<br />//printList( root.getChildren().skipTo(2).getPage(3) )<br />void printList(ItemIterable<CmisObject> list) {<br />list.each { println "${it.name} t${it.type.id}" }<br /> long numItems = list.getTotalNumItems();<br />booleanhasMore = list.getHasMoreItems();<br />println "--------------------------------------"<br />println "Total number: ${numItems}"<br />println "Has more: ${hasMore}" <br />println "--------------------------------------"<br />}<br />
  48. 48. Properties<br />CmisObject object = session.getObjectByPath("/User Homes/florian/Test Folder/MyText");<br />for(Property<?> property: object.getProperties()) {<br /> String propId = property.getId();<br /> String displayName = property.getDefinition().getDisplayName();<br /> String queryName = property.getDefinition().getQueryName();<br />PropertyTypedatatype = property.getType();<br /> Object value = property.getFirstValue();<br />println "${displayName}: ${value}"<br />println " Data type: ${datatype}"<br />println " Id: ${propId}"<br />println " Query name: ${queryName}"<br />println ""<br />}<br />
  49. 49. Content<br />CmisObject object = session.getObjectByPath("/User Homes/florian/Test Folder/MyText");<br />if(!(object instanceof Document)) {<br /> throw new Exception("Not a document!");<br />}<br />Document doc = (Document) object;<br />ContentStream content = doc.getContentStream();<br />if(content == null) {<br /> throw new Exception("Document has no content!");<br />}<br />String filename = content.getFileName();<br />String mimeType = content.getMimeType();<br />long length = content.getLength();<br />InputStream stream = content.getStream();<br />println "File: ${filename}"<br />println "MIME Type: ${mimeType}"<br />println "Size: ${length} bytes"<br />println "Has stream: " + (stream != null)<br />
  50. 50. Query<br />String cql = "SELECT cmis:objectId, cmis:name, cmis:contentStreamLength FROM cmis:document";<br />ItemIterable<QueryResult> results = session.query(cql, false);<br />//ItemIterable<QueryResult> results = session.query(cql, false).getPage(10);<br />//ItemIterable<QueryResult> results = session.query(cql, false).skipTo(10).getPage(10);<br />for(QueryResult hit: results) { <br /> for(PropertyData<?> property: hit.getProperties()) {<br /> String queryName = property.getQueryName();<br /> Object value = property.getFirstValue();<br /> println "${queryName}: ${value}" <br /> }<br /> println "--------------------------------------"<br />}<br />
  51. 51. Folders<br />Folder root = session.getRootFolder();<br />// create a new folder<br />Map<String, Object> properties = new HashMap<String, Object>();<br />properties.put("cmis:objectTypeId", "cmis:folder");<br />properties.put("cmis:name", "a new folder");<br />Folder newFolder = root.createFolder(properties);<br />printProperties(newFolder);<br />// update properties<br />Map<String, Object> updateproperties = new HashMap<String, Object>();<br />updateproperties.put("cmis:name", "renamed folder");<br />newFolder.updateProperties(updateproperties);<br />newFolder.refresh();<br />printProperties(newFolder);<br />// delete folder<br />newFolder.deleteTree(true, UnfileObject.DELETE, true);<br />
  52. 52. Documents<br />Folder root = session.getRootFolder();<br />// create a new document<br />String name = "myNewDocument.txt";<br />Map<String, Object> properties = new HashMap<String, Object>();<br />properties.put("cmis:objectTypeId", "cmis:document");<br />properties.put("cmis:name", name);<br />byte[] content = "Hello World!".getBytes();<br />InputStream stream = new ByteArrayInputStream(content);<br />ContentStreamcontentStream = new ContentStreamImpl(name, content.length, "text/plain", stream);<br />Document newDoc = root.createDocument(properties, contentStream, VersioningState.MAJOR);<br />printProperties(newDoc);<br />// delete document<br />newDoc.delete(true);<br />

×