#SummitNow First Steps with CMIS & Alfresco Jeff
#SummitNow You’ve been handed a project Your Favorite Language/Framework What Goes Here?
#SummitNow You’ve been handed a project Your Favorite Language/Framework
#SummitNow CMIS gives developers a standard API for working with content repositories like Alfresco
#SummitNow Why CMIS? Preferred API for working with Alfresco Open standard, managed by OASIS Many vendors support it Plenty of examples Client libraries for many languages Java, Python,.NET, PHP, Objective-C, Android
#SummitNow
#SummitNow Start with the Workbench
#SummitNow Connect with CMIS Workbench
#SummitNow Explore the Alfresco repo CRUD objects Inspect/change properties Run queries Run scripts using the Groovy console See the content model
#SummitNow The Workbench is great for… Testing queries Inspecting the data dictionary Including whether or not a property is read/write or queryable Can I do _____________ with CMIS?
#SummitNow Alfresco CMIS Service URLs by Version Alfresco Version CMIS Service URL 3.2r http://localhost:8080/alfresco/service/cmishttp://localhost:8080/alfresco/service/cmis (ATOM) (SOAP) 4.0http://localhost:8080/alfresco/cmisatom (SOAP) 4.2.d/4.2 Enterprise (SOAP)
#SummitNow Set Up Your Dev Environment
#SummitNow Let’s set up your environment Could use curl or any other HTTP client, but why? Grab OpenCMIS from Apache Chemistry Maven makes it easy Group: org.apache.chemistry.opencmis Artifact: chemistry-opencmis-client-impl Version:
#SummitNow File Loader Example Let’s load some images into Alfresco on- premise Get a session Create a folder Check-in some documents Set some properties
#SummitNow CMIS Works in the Cloud Too! Let’s load some images into Alfresco in the cloud Same CMIS calls, different authentication Register for an API key
#SummitNow Watch Out for Gotchas/Limitations
#SummitNow CMIS object IDs are opaque Best not to even look at one!
#SummitNow Queries CMIS queries are read-only Do you really need everything? select * from cmis:document Do you really need all rows? Use OperationContext to limit
#SummitNow Working with Aspects CMIS 1.0 doesn’t know what an aspect is Must use OpenCMIS Extension CMIS 1.1 calls aspects secondary types Add/remove aspects by setting cmis:secondaryObjectTypeIds For queries, use a join
#SummitNow Adding an aspect (CMIS 1.0) if (!doc.hasAspect("P:cm:geographic")) { doc.addAspect("P:cm:geographic"); System.out.println("Added aspect"); } else { System.out.println("Doc already had aspect"); } HashMap props = new HashMap (); props.put("cm:latitude", ); props.put("cm:longitude", ); doc.updateProperties(props); parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
#SummitNow Adding an aspect (CMIS 1.1) List aspects = doc.getProperty("cmis:secondaryObjectTypeIds").getValues(); if (!aspects.contains("P:cm:geographic")) { aspects.add("P:cm:geographic"); HashMap props = new HashMap (); props.put("cmis:secondaryObjectTypeIds", aspects); doc.updateProperties(props); System.out.println("Added aspect"); } else { System.out.println("Doc already had aspect"); } HashMap props = new HashMap (); props.put("cm:latitude", ); props.put("cm:longitude", ); doc.updateProperties(props);
#SummitNow Query for aspect-based props SELECT D.cmis:name, G.cm:latitude, G.cm:longitude FROM cmis:document as D JOIN cm:geographic as G ON D.cmis:objectId = G.cmis:objectId
#SummitNow Working with Relationships Peer associations only Both sides must be instances of cmis:folder or cmis:document or a descendant type
#SummitNow Working with ACLs Can manage ACLs Cannot set or un-set ACL inheritance
#SummitNow Other Limitations Can only access objects that are descendants of cm:content or cm:folder Cannot create users/groups Cannot create or change types through the API (yet) Cannot work with categories or tags
#SummitNow A Word About Interoperability Pay attention to RepositoryInfo Multifiling, search, ACL, etc. may differ between repository vendors Inspect getAllowableActions Look at the type definitions Not all repositories name types the same way
#SummitNow Example Apps & Additional Learning Resources
#SummitNow Read the Book Everything you need to know about CMIS 1.0 & 1.1 Lots of Groovy and Java examples Also covers Python,.NET, PHP, Android, & iOS 37%-off: 12cmisal
#SummitNow Quick Look at The Blend
#SummitNow Ask questions in the “Alfresco API” forum!
#SummitNow First Steps with CMIS 1.Choose CMIS as your preferred API 2.Use the OpenCMIS Workbench as a learning tool 3.Set up your development environment 4.Watch out for gotchas/limitations 5.Take advantage of additional learning resources
#SummitNow