I’ve written a new tutorial on the proposed Content Management Interoperability Services (CMIS) standard called, “Getting Started with CMIS“. The tutorial first takes you through an overview of the specification. Then, I do several examples. The examples start out using curl to make GET, PUT, POST, and DELETE calls against Alfresco to perform CRUD functions on folders, documents, and relationships in the repository. If you’ve been dabbling with CMIS and you’ve struggled to find examples, particularly of POSTs, here you go.
I used Alfresco Community built from head, but yesterday, Alfresco pushed a new Community release that supports CMIS 1.0 Committee Draft 04 so you can download that, use the hosted Alfresco CMIS repository, or spin up an EC2 image (once Luis gets it updated with the new Community release). If you don’t want to use Alfresco you should be able to use any CMIS repository that supports 1.0cd04. I tried some, but not all, of the command-line examples against the Apache Chemistry test server.
Once you’ve felt both the joy and the pain of talking directly to the CMIS AtomPub Binding, I take you through some very short examples using JavaScript and Java. For Java I show Apache Abdera, Apache Chemistry, and the Apache Chemistry TCK.
For the Chemistry TCK stuff, I’m using Alfresco’s CMIS Maven Toolkit which Gabriele Columbro and Richard McKnight put together. That inspired me to do my examples with Maven as well (plus, it’s practical–the Abdera and Chemistry clients have a lot of dependencies, and using Maven meant I didn’t have to chase any of those down).
So take a look at the tutorial, try out the examples with your favorite CMIS 1.0 repo, and let me know what you think. If you like it, pass it along to a friend. As with past tutorials, I’ve released it under Creative Commons Attribution-Share Alike.
[Updated to correct typo with Gabriele’s name. Sorry, Gab!]
Couple of things I forgot to mention:
Check out http://cmisdev.org for useful CMIS-related links
Richard and Gab are doing a free, interactive CMIS training session tomorrow, 24 November. See http://www.alfresco.com/about/events/2009/11/cmis_training/ for more details.
Jeff
Thanks for the tutorial. I’m in the process of going through the CMIS spec and it’s nice to see it in practice.
Nice tutorial but are there any known examples or at least clients using the web service binding?
I haven’t seen any clients choose to use the web services binding yet, but it is still early. I’m sure there will be cases where it makes sense.
Jeff
I was trying to get into CMIS and I noticed that there are only XML bindings – is that right? Or is there the option (at least for Alfresco) to get the response in a different format (e.g. JSON)?
Martin,
CMIS compliant servers must implement two bindings. One is the Restful AtomPub Binding. The other is the Web Services binding. The current spec doesn’t provide for any other bindings (such as JSON).
Jeff
Thanks for the Tutorial Jeff. One aspect i am struggling to get working is querying against categories. How do I do this?
From page 475 of the Alfresco Developer Guide…
A handy little hack to get the Lucene full-text search query syntax is to use the web client to build your search, then save the search, then use the Node Browser to go look at the search string Alfresco saved.
[UPDATE: I just realized you posted this comment regarding the CMIS tutorial so this answer isn’t going to help you at all. CMIS queries don’t support categories, so, unfortunately, if you’re using CMIS, you’re out-of-luck for now].
Hope that helps,
Jeff
Hi Jeff,
I have created Axis2 client and able to access different CMIS services (Alfresco).
I want execute different features like createDocument, createFolder etc.
Can you guide me how to set properties using web service client?
I have generated stub classes using Axis2 ADB option.
Jeff, thanks very much for (another) great tutorial.
Please correct the namespace errata in page 25. CMIS namespace is missing and ending /. I lost 2 days until I did find the error.
Definitively copy&paste is the worst enemy of the programmer.
Totally agree on the copy and paste comment. Yes, screwing up those namespaces can really foul things up. The snippet on page 25 is missing a trailing slash. Instead of:
"http://docs.oasis-open.org/ns/cmis/core/200908"
It should read:
"http://docs.oasis-open.org/ns/cmis/core/200908/"
The actual downloadable source code does not have this problem.
Jeff
This CMIS has been good stuff to have found. Is there a trick to passing the Drupal user name to Alfresco to limit access to spaces?
In a nutshell, you need to do single sign-on between Drupal and Alfresco to make this happen. So, instead of configuring CMIS to use a “system” ID to connect (like “admin” for Alfresco) you can configure it to get a session using the creds already in the Drupal header. Unfortunately, this isn’t a simple checkbox config. We may show this working at DrupalCon (no promises). Maybe we can post more details on it for those that can’t attend.
I’m trying to follow our tutorial but, when trying to create a document, with testCreateSampleA.atom.xml I get an error
Invalid typeId D:sc:whitepaper.
However, if I use cmis:document
then it works.
Can you explain that?
That type, D:sc:whitepaper, is a custom type that does not come with Alfresco out-of-the-box. You have to deploy it as part of a custom content model. You can use your own custom types instead or use the “SomeCo” examples from my blog and/or book. Does your custom content model include a custom content type called sc:whitepaper?
Jeff
No, I don’t have that type. I’ll get your blog code and give it a try. Thanks
hiiiii,I want to migrate from twiki to alfresco(migrate twiki format documents to alfresco)…can u please help?
Hello jeff!
I am trying yo create a folder with aspect.But i got the error like ‘Prefix can not be null or empty’.I have added all properties specified by you.I am using alfresco community edition 4.0d.
Can you have any idea why i getting this kind of error.
Rutaveej,
I cannot really provide any advice unless you include the code you are using to create the folder.
Jeff
Hello jeff!
I have raise the question like prefix can not be null or empty error while creating a folder with aspects.
My code for that is:
private Session getSession(String serverUrl, String username, String password)
{
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map params = new HashMap();
params.put(SessionParameter.USER, username);
params.put(SessionParameter.PASSWORD, password);
params.put(SessionParameter.ATOMPUB_URL, serverUrl);
params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
params.put(SessionParameter.OBJECT_FACTORY_CLASS, “org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl”);
List repos = sessionFactory.getRepositories(params);
if (repos.isEmpty()) {
throw new RuntimeException(“Server has no repositories!”);
}
return repos.get(0).createSession();
}
public void createFolder()
{
String servalUrl=”http://localhost:8080/alfresco/cmisatom”;
String userName=”admin”;
String password=”admin”;
Session session=getSession(servalUrl, userName, password);
Map properties = new HashMap();
properties.put(PropertyIds.OBJECT_TYPE_ID, “cmis:folder,P:cm:titled”);
properties.put(PropertyIds.NAME,”TESTFOLDER2″);
properties.put(PropertyIds.CREATED_BY, “admin”);
properties.put(“cm:title”, “Title”);
properties.put(“cm:description”, “Desc”);
AlfrescoFolder root=(AlfrescoFolder) session.getRootFolder();
System.out.println(“The Name:”+root.getId()+root.getName());
AlfrescoFolder newFolder=(AlfrescoFolder) root.createFolder(properties);
System.out.println(newFolder.getName());
}
I have not used alfresco SDK.
I just used the jar of alfresco open cmis and create code for creating a folder with aspects.
Please provide me any suggestion on this.
Thanks
I posted an answer to this in the forums. This is probably due to an XML parser class collision. See http://code.google.com/a/apache-extras.org/p/alfresco-opencmis-extension/issues/detail?id=2