cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to add a tag to a document

paulm
Champ in-the-making
Champ in-the-making
Hi, I'm trying to use the Alfresco OpenCMIS Extension to add a tag to an existing document. I tried the below code, but received an error when it called updateProperties(). I'm seriously confused. Can someone give me a pointer?


String path1 = "/Sites/IQ/documentLibrary/test";
CmisObject object = s.getObjectByPath(path1);
AlfrescoDocument alfDoc = (AlfrescoDocument) object;
…..
if(alfDoc.hasAspect("P:cm:titled")) {
          Map<String, Object> properties = new HashMap<String, Object>();
          properties.put("cm:taggable", "MyTag");
          alfDoc.updateProperties(properties);
  }   

regards,
Paul
5 REPLIES 5

fmui
Champ in-the-making
Champ in-the-making
Hi Paul,

Can you specify the error message?
Which Alfresco version and which binding are you using?

Thanks,

Florian

fmui
Champ in-the-making
Champ in-the-making
Two quick observations:

  • Is the Taggable aspect applied? You are only checking for the Titled aspect.

  • "cm:taggable" is a multi-value property. You should provide a List here.
- Florian

paulm
Champ in-the-making
Champ in-the-making
Hi Florian,

I'm using Alfresco Community v3.4.0 and I'm using ATOMPUB for BindType

The error is


Exception in thread "main" java.lang.NullPointerException
   at org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl.convertProperties(Unknown Source)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:314)
   at org.alfresco.cmis.client.impl.AlfrescoDocumentImpl.updateProperties(Unknown Source)
   at org.apache.chemistry.opencmis.client.runtime.AbstractCmisObject.updateProperties(AbstractCmisObject.java:277)
   at Migration.dds.com.App.main(App.java:134)

Paul

paulm
Champ in-the-making
Champ in-the-making
The taggable aspect has already been applied to that doc, but I've changed that line of code to check for P:cm:taggable anyhow. I'll see if providing a list works

something like below

properties.put("cm:taggable", list );


thanks alot,
Paul

fmui
Champ in-the-making
Champ in-the-making
Hi Paul,

I've tested the taggable aspect. You have to provide the node ref of the tag, not the tag name.
But node ref properties (= CMIS Id properties) were not supported. I have changed that. Please download the latest release.



List<String> tags = new ArrayList<String>();
tags.add("workspace://SpacesStore/a807b10e-6dea-403f-88f1-33e2383890dd");
tags.add("workspace://SpacesStore/a728d30f-0bbe-48cf-9557-2d6b7cb63b45");
       
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("cm:taggable", tags);
doc.updateProperties(properties);

- Florian