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