add a category to a document with Alfresco openCMIS extensio

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2011 04:34 PM
Hello,
I have to add a category to a document. I tried it with the Alfresco openCMIS extension but i didn't succeed.
Could you please tell me how to do that with this extension?
Thanks.
I have to add a category to a document. I tried it with the Alfresco openCMIS extension but i didn't succeed.
Could you please tell me how to do that with this extension?
Thanks.
Labels:
- Labels:
-
Archive
8 REPLIES 8
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2012 01:35 PM
Hi, were you able to get it resolved? I'm having the same issue… would be great if you could share your solution

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013 06:28 AM
Do you have any solution? I have the same problem.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013 07:44 AM
In alfresco category is implemented by and an aspect cm:generalclassifiable(this aspect has an property named cm:categories).
So you can
1. add cm:generalclassifiable aspect to the node;
2.obtain the node ref values for the category or categories to be applied to the node;
3.set these values for the appropriate property on the aspect.
You can refer to http://docs.alfresco.com/4.2/topic/com.alfresco.enterprise.doc/concepts/opencmis-ext-adding.html
on how to add aspect with Alfresco openCMIS extension
So you can
1. add cm:generalclassifiable aspect to the node;
2.obtain the node ref values for the category or categories to be applied to the node;
3.set these values for the appropriate property on the aspect.
You can refer to http://docs.alfresco.com/4.2/topic/com.alfresco.enterprise.doc/concepts/opencmis-ext-adding.html
on how to add aspect with Alfresco openCMIS extension

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013 08:01 AM
Thank you for the reply. Did you try to work with Alfresco openCMIS extension particularly with cm:categories property?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013 08:35 AM
I didn't get your point.
A document's categories are saved in cm:categories property ,so you can modify cm:categories directly.
A document's categories are saved in cm:categories property ,so you can modify cm:categories directly.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013 09:21 AM
This code works for me:
But now I add alfDoc.addAspect("P:cm:generalclassifiable");
When I list all the property definitions of this aspect I have many properties. Some of them I can add without problems like in the example above (for example I can use without problems cmis:name, cmis:lastModifiedBy and others).
There is a property with id cm:categories. I don't know how to add a property with such id. I would like to add new categories. Is this possible?
This code will not work:
I suspect that the xml structure of categories is different. But anyway I would like to see a simple OpenCMIS extension code to achieve this:
1. create a category
2. add the created category to the document
Is this possible with OpenCMIS extension?
if(alfDoc.hasAspect("P:cm:titled")) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("cm:description", "My taggable document"); alfDoc.updateProperties(properties);}
But now I add alfDoc.addAspect("P:cm:generalclassifiable");
When I list all the property definitions of this aspect I have many properties. Some of them I can add without problems like in the example above (for example I can use without problems cmis:name, cmis:lastModifiedBy and others).
There is a property with id cm:categories. I don't know how to add a property with such id. I would like to add new categories. Is this possible?
This code will not work:
if(alfDoc.hasAspect("P:cm:generalclassifiable")) { Map<String, Object> properties = new HashMap<String, Object>(); properties.put("cm:categories", "my new category"); alfDoc.updateProperties(properties);}
I suspect that the xml structure of categories is different. But anyway I would like to see a simple OpenCMIS extension code to achieve this:
1. create a category
2. add the created category to the document
Is this possible with OpenCMIS extension?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2013 10:47 AM
I have just checked it ,There are 2 reasons why it didn't work.
First,you can't just set arbitrary value to cm:categories property ,you should obtain the node ref values of a category and set it to cm:categories property.
Second,there is an constraint on Alfresco openCMIS extension ,Because cmis root is mapped to workspace://SpacesStore/company_home,but category root is workspace://SpacesStore/categoryRoot.So you can't obtain category node using Alfresco openCMIS extension api.
That is to say you can't add default classification category to a document with Alfresco openCMIS extension.,you can use webscipt api instead.
First,you can't just set arbitrary value to cm:categories property ,you should obtain the node ref values of a category and set it to cm:categories property.
Second,there is an constraint on Alfresco openCMIS extension ,Because cmis root is mapped to workspace://SpacesStore/company_home,but category root is workspace://SpacesStore/categoryRoot.So you can't obtain category node using Alfresco openCMIS extension api.
That is to say you can't add default classification category to a document with Alfresco openCMIS extension.,you can use webscipt api instead.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2013 03:54 AM
Thank you for your help, I will try the webscript api.
