AnsweredAssumed Answered

Adding a Category to a noderef

Question asked by mr_apples on May 3, 2010
Latest reply on Aug 3, 2010 by toze
Hi all,
I'm facing problems trying to add a category to a noderef.

My webscript downloads a file from an external source, then loads properties for an aspect, then applies the aspect to file, then stores the file at specified path.
Now the boss asked for a category. the following doesn't work:

//nds = nodeService;
ArrayList<NodeRef> categories = new ArrayList<NodeRef>();            
categories.add(categoryNode);
HashMap<QName, Serializable> categoriesProps = new HashMap<QName, Serializable>();
categoriesProps.put(ContentModel.PROP_CATEGORIES, categories);
if(nds.hasAspect(file_info.getNodeRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE) == false) {
    nds.addAspect(file_info.getNodeRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, categoriesProps);
} else {
    nds.setProperty(file_info.getNodeRef(), QName.createQName("{http://www.alfresco.org/model/content/1.0}subcategories"), "{http://www.alfresco.org/model/content/1.0}Tags");
}
setProperty doesn't work in any of my attempts:
nds.setProperty(file_info.getNodeRef(), QName.createQName("http://www.alfresco.org/model/content/1.0", "subcategories"), QName.createQName("http://www.alfresco.org/model/content/1.0", "Tags");
or any other combination of the above.

Any idea?

Outcomes