Upload
jeff-potts
View
1.245
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Content Management Interoperability Services (CMIS) is the preferred API for writing code against Alfresco. This presentation explains how to get started using CMIS and covers some of the gotchas and limitations you should be aware of before you commit to CMIS for your project. This presentation was originally delivered at Alfresco Summit 2013 in Barcelona and Boston.
Citation preview
#SummitNow
First Steps with CMIS & AlfrescoJeff Potts@jeffpotts01http://ecmarchitect.com
#SummitNow
#SummitNow
You’ve been handed a project
Your Favorite Language/Framework
What Goes Here?
#SummitNow
#SummitNow
You’ve been handed a project
Your Favorite Language/Framework
#SummitNow
#SummitNow
CMIS gives developers a standard API for working with
content repositories like Alfresco
#SummitNow
#SummitNow
First Steps with CMIS1. Choose CMIS as your preferred API2. Use the OpenCMIS Workbench as a
learning tool3. Set up your development
environment4. Watch out for gotchas/limitations5. Take advantage of additional
learning resources
#SummitNow
#SummitNow
Why CMIS?Preferred API for working with AlfrescoOpen standard, managed by OASISMany vendors support itPlenty of examplesClient libraries for many languages• Java, Python, .NET, PHP, Objective-C,
Android
#SummitNow
#SummitNow
http://chemistry.apache.org
#SummitNow
#SummitNow
Start with the Workbench
#SummitNow
#SummitNow
Connect with CMIS Workbench
#SummitNow
#SummitNow
Explore the Alfresco repoCRUD objectsInspect/change propertiesRun queriesRun scripts using the Groovy consoleSee the content model
#SummitNow
#SummitNow
The Workbench is great for…Testing queriesInspecting the data dictionary• Including whether or not a property
is read/write or queryableCan I do _____________ with CMIS?
#SummitNow
#SummitNow
Alfresco CMIS Service URLs by Version
Alfresco Version
CMIS Service URL
3.2r2 - 3.4 http://localhost:8080/alfresco/service/cmis (ATOM)http://localhost:8080/alfresco/cmis (SOAP)
4.0 http://localhost:8080/alfresco/cmisatomhttp://localhost:8080/alfresco/cmis (SOAP)
4.2.d/4.2 Enterprise
http://localhost:8080/alfresco/api/-default-/cmis/versions/1.0/atomhttp://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/atomhttp://localhost:8080/alfresco/api/-default-/cmis/versions/1.1/browserhttp://localhost:8080/alfresco/cmis (SOAP)
#SummitNow
#SummitNow
Set Up Your Dev Environment
#SummitNow
#SummitNow
Let’s set up your environmentCould use curl or any other HTTP client, but why?Grab OpenCMIS from Apache ChemistryMaven makes it easyGroup: org.apache.chemistry.opencmis
Artifact: chemistry-opencmis-client-implVersion: 0.10.0
#SummitNow
#SummitNow
File Loader ExampleLet’s load some images into Alfresco on-premise• Get a session• Create a folder• Check-in some documents• Set some properties
https://code.google.com/p/alfresco-api-java-examples/
#SummitNow
#SummitNow
CMIS Works in the Cloud Too!Let’s load some images into Alfresco in the cloudSame CMIS calls, different authenticationRegister for an API key• http://www.alfresco.com/develop
#SummitNow
#SummitNow
Watch Out for Gotchas/Limitations
#SummitNow
#SummitNow
CMIS object IDs are opaque
Best not to even look at one!
#SummitNow
#SummitNow
QueriesCMIS queries are read-onlyDo you really need everything?• select * from cmis:documentDo you really need all rows?• Use OperationContext to limit
#SummitNow
#SummitNow
Working with AspectsCMIS 1.0 doesn’t know what an aspect is• Must use OpenCMIS ExtensionCMIS 1.1 calls aspects secondary types• Add/remove aspects by setting
cmis:secondaryObjectTypeIdsFor queries, use a join
#SummitNow
#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<String, Object> props = new HashMap<String, Object>();
props.put("cm:latitude", 52.513871);props.put("cm:longitude", 13.391106);doc.updateProperties(props);
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
#SummitNow
#SummitNow
Adding an aspect (CMIS 1.1)List<Object> aspects =
doc.getProperty("cmis:secondaryObjectTypeIds").getValues();if (!aspects.contains("P:cm:geographic")) {
aspects.add("P:cm:geographic");HashMap<String, Object> props = new
HashMap<String, Object>();props.put("cmis:secondaryObjectTypeIds",
aspects);doc.updateProperties(props);System.out.println("Added aspect");
} else {System.out.println("Doc already had
aspect");}
HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cm:latitude", 52.513871);props.put("cm:longitude", 13.391106);doc.updateProperties(props);
#SummitNow
#SummitNow
Query for aspect-based props
SELECT D.cmis:name, G.cm:latitude, G.cm:longitudeFROM cmis:document as DJOIN cm:geographic as GON D.cmis:objectId = G.cmis:objectId
#SummitNow
#SummitNow
Working with RelationshipsPeer associations onlyBoth sides must be instances of cmis:folder or cmis:document or a descendant type
#SummitNow
#SummitNow
Working with ACLsCan manage ACLsCannot set or un-set ACL inheritance
#SummitNow
#SummitNow
Other LimitationsCan only access objects that are descendants of cm:content or cm:folderCannot create users/groupsCannot create or change types through the API (yet)Cannot work with categories or tags
#SummitNow
#SummitNow
A Word About InteroperabilityPay attention to RepositoryInfo• Multifiling, search, ACL, etc. may
differ between repository vendorsInspect getAllowableActionsLook at the type definitions• Not all repositories name types the
same way
#SummitNow
#SummitNow
Example Apps & Additional Learning Resources
#SummitNow
#SummitNow
Read the BookEverything you need to know about CMIS 1.0 & 1.1Lots of Groovy and Java examplesAlso covers Python, .NET, PHP, Android, & iOS37%-off: 12cmisal
#SummitNow
#SummitNow
Quick Look at The Blend
#SummitNow
#SummitNow
Ask questions in the “Alfresco API” forum!
#SummitNow
#SummitNow
First Steps with CMIS1. Choose CMIS as your preferred API2. Use the OpenCMIS Workbench as a
learning tool3. Set up your development
environment4. Watch out for gotchas/limitations5. Take advantage of additional
learning resources
#SummitNow