cancel
Showing results for 
Search instead for 
Did you mean: 

add a category to a document with Alfresco openCMIS extensio

hatonis
Champ in-the-making
Champ in-the-making
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.
8 REPLIES 8

ifeldman
Champ in-the-making
Champ in-the-making
Hi, were you able to get it resolved? I'm having the same issue… would be great if you could share your solution

piotrp
Champ in-the-making
Champ in-the-making
Do you have any solution? I have the same problem.

kaynezhang
World-Class Innovator
World-Class Innovator
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

piotrp
Champ in-the-making
Champ in-the-making
Thank you for the reply. Did you try to work with Alfresco openCMIS extension particularly with cm:categories property?

kaynezhang
World-Class Innovator
World-Class Innovator
I didn't get your point.
A document's categories are saved in cm:categories property ,so you can modify  cm:categories directly.

piotrp
Champ in-the-making
Champ in-the-making
This code works for me:

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?

kaynezhang
World-Class Innovator
World-Class Innovator
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.

piotrp
Champ in-the-making
Champ in-the-making
Thank you for your help, I will try the webscript api.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.