getting started with cmis

33
#SummitNow First Steps with CMIS & Alfresco Jeff Potts @jeffpotts01 http://ecmarchitect.com

Upload: jeff-potts

Post on 17-May-2015

1.244 views

Category:

Technology


0 download

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.

TRANSCRIPT

Page 1: Getting Started With CMIS

#SummitNow

First Steps with CMIS & AlfrescoJeff Potts@jeffpotts01http://ecmarchitect.com

Page 2: Getting Started With CMIS

#SummitNow

#SummitNow

You’ve been handed a project

Your Favorite Language/Framework

What Goes Here?

Page 3: Getting Started With CMIS

#SummitNow

#SummitNow

You’ve been handed a project

Your Favorite Language/Framework

Page 4: Getting Started With CMIS

#SummitNow

#SummitNow

CMIS gives developers a standard API for working with

content repositories like Alfresco

Page 5: Getting Started With CMIS

#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

Page 6: Getting Started With CMIS

#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

Page 7: Getting Started With CMIS

#SummitNow

#SummitNow

http://chemistry.apache.org

Page 8: Getting Started With CMIS

#SummitNow

#SummitNow

Start with the Workbench

Page 9: Getting Started With CMIS

#SummitNow

#SummitNow

Connect with CMIS Workbench

Page 10: Getting Started With CMIS

#SummitNow

#SummitNow

Explore the Alfresco repoCRUD objectsInspect/change propertiesRun queriesRun scripts using the Groovy consoleSee the content model

Page 11: Getting Started With CMIS

#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?

Page 12: Getting Started 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)

Page 13: Getting Started With CMIS

#SummitNow

#SummitNow

Set Up Your Dev Environment

Page 14: Getting Started With CMIS

#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

Page 15: Getting Started With CMIS

#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/

Page 16: Getting Started With CMIS

#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

Page 17: Getting Started With CMIS

#SummitNow

#SummitNow

Watch Out for Gotchas/Limitations

Page 18: Getting Started With CMIS

#SummitNow

#SummitNow

CMIS object IDs are opaque

Best not to even look at one!

Page 19: Getting Started With CMIS

#SummitNow

#SummitNow

QueriesCMIS queries are read-onlyDo you really need everything?• select * from cmis:documentDo you really need all rows?• Use OperationContext to limit

Page 20: Getting Started With CMIS

#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

Page 21: Getting Started With CMIS

#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");

Page 22: Getting Started With CMIS

#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);

Page 23: Getting Started With CMIS

#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

Page 24: Getting Started With CMIS

#SummitNow

#SummitNow

Working with RelationshipsPeer associations onlyBoth sides must be instances of cmis:folder or cmis:document or a descendant type

Page 25: Getting Started With CMIS

#SummitNow

#SummitNow

Working with ACLsCan manage ACLsCannot set or un-set ACL inheritance

Page 26: Getting Started With CMIS

#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

Page 27: Getting Started With CMIS

#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

Page 28: Getting Started With CMIS

#SummitNow

#SummitNow

Example Apps & Additional Learning Resources

Page 29: Getting Started With CMIS

#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

Page 30: Getting Started With CMIS

#SummitNow

#SummitNow

Quick Look at The Blend

Page 31: Getting Started With CMIS

#SummitNow

#SummitNow

Ask questions in the “Alfresco API” forum!

Page 32: Getting Started With CMIS

#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

Page 33: Getting Started With CMIS

#SummitNow