cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco CMIS 1.1 compliant?

mangar
Star Contributor
Star Contributor
I am getting some pushback at work for using the alfresco-opencmis-extension to get aspects to work, specifically "cm:titled"

My question is "Is Alfresco CMIS 1.1 compliant or not?" 

I am using 4.2.d community, and OpenCMIS 0.10.  Both the Alfresco documentation and the Apache site say they are 1.1 compliant, so why do I have to use the alfresco-opencmis-extension?  How long will I have to use it before a standard 1.1 client (like apache chemistry) will work?

14 REPLIES 14

jpotts
World-Class Innovator
World-Class Innovator
Yes, it is CMIS 1.1 compliant but you have to use the appropriate CMIS URLs:

http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom
http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom

Note that in 4.2.d I found some problems with secondary type (aspect) support. If you need to work with aspects you may want to upgrade to 4.2.e.

You can read more about CMIS 1.1 and 4.2.d at my blog post <a href="http://ecmarchitect.com/archives/2013/09/15/3554">here</a>.

Jeff

heisenberg
Champ in-the-making
Champ in-the-making
org.alfresco.cmis.CMISServices.getCMISVersion() returns String "1.0" in Alfresco 4.2.e CE. Typo then?

jpotts
World-Class Innovator
World-Class Innovator
Based on the Spring bean config for CMISService which references the CMISServicesImpl class, it sets the version to 1.0.

But when you use OpenCMIS, you can specify which server endpoint to use. And in Alfresco 4.2.e there are two for AtomPub. One is 1.0 and one is 1.1.

If you run this groovy script in the OpenCMIS Workbench:
println session.repositoryInfo.productName
println session.repositoryInfo.productVersion
println session.repositoryInfo.cmisVersion

When you connect to the 1.1 URL, you will get:
Alfresco Community
4.2.0 (r56674-b4848)
CMIS_1_1

When you connect to the 1.0 URL, you will get:
Alfresco Community
4.2.0 (r56674-b4848)
CMIS_1_0

So the answer to your question is, yes, 4.2.e is compliant with CMIS 1.1.

I'm curious as to why you are using that class instead of OpenCMIS?

Jeff

mangar
Star Contributor
Star Contributor
So I took your advice and switched from my old URL, (alfresco/cmisatom) And used the new ones.  I really like not having to use a repository ID that I have to go look up every time I re-install alfresco. (I do that alot)

But the aspects are killing me.  When I use the 1.0 URL adding a directory via CMIS with properties like this:

<java>
      Map<String, String> props = new HashMap<String, String>();
      props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder,P:cm:titled");
</java>

It works fine, but with the 1.1 url, it fails.

Is there a different way of doing it for 1.1?

jpotts
World-Class Innovator
World-Class Innovator
Yes, when using CMIS 1.1, first, make sure you are not using the OpenCMIS Extension. You should be dealing with Document and Folder objects not AlfrescoDocument and AlfrescoFolder objects.

Next, you will not use the old extension-based syntax for adding an aspect. Instead, you'll modify the multi-value secondary types property. Here's an example:


public void addAspect(Document doc) {
   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);
      
   System.out.println("Latitude: " + doc.getProperty("cm:latitude").getValueAsString());
   System.out.println("Longitude: " + doc.getProperty("cm:longitude").getValueAsString());

}


Jeff

mangar
Star Contributor
Star Contributor
Jeff, Hi have:

1. upgraded to 4.2.e
2. Removed the OpenCMIS Extension and I am using the plain org.apache.chemistry.opencmis.client.api
3. I am using the /public/cmis/versions/1.1/atom url

I am having problems adding a Folder to alfresco with a description.  Here is my list of properties when creating the CMIS object:

<java>
      Map<String, String> props = new HashMap<String, String>();
      props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
      props.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, "P:cm:titled");
      props.put("cm:description", description);
      props.put(PropertyIds.NAME, name);
</java>

it is saying the "cm:description" is not a property. I have tried all sorts of permutations with D, P, etc..  I cant seem to find the secret combo.


jpotts
World-Class Innovator
World-Class Innovator
The trick is that cmis:secondaryObjectTypeIds is a multi-value property. So you have to set it using an ArrayList, like this:


HashMap<String, Object> props = new HashMap<String, Object>();
props.put("cmis:objectTypeId", "cmis:folder");
ArrayList<String> secIds = new ArrayList<String>();
secIds.add("P:cm:titled");
props.put("cmis:secondaryObjectTypeIds", secIds);
props.put("cmis:name", "test");
props.put("cm:description", "test description");
folder = cmisSession.getRootFolder().createFolder(props);


Jeff

mangar
Star Contributor
Star Contributor
You are a god.  Thank you so much! 

mundi
Champ in-the-making
Champ in-the-making
I know the discussion is older, but the mentioned method is not working for me. I have the code:

<java>
Document document = (Document)getAlfrescoFacade().getObjectById("workspace://SpacesStore/e7af5c7c-226a-474d-abee-371bbb33eadb");
List<Object> aspects = document.getProperty("cmis:secondaryObjectTypeIds").getValues();
aspects.add("P:sigi:document");
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("cmis:secondaryObjectTypeIds", aspects);
document.updateProperties(properties);

aspects = document.getProperty("cmis:secondaryObjectTypeIds").getValues();
for (Object object: aspects)
    System.out.println(object);
</java>

but it does not add the aspect sigi:document. After exucting the code the aspects are still the same as before.
My version is Alfresco Enterprise 4.2.3.