05-03-2010 11:36 AM
//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.05-04-2010 06:11 AM
// reference to a category node. The reference is by its id.
NodeRef categoryNode = new NodeRef("workspace://SpacesStore/170ca17e-5625-4285-bd2f-898efae39128");
if (nds.hasAspect(file_info.getNodeRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE) == false) {
// List of categories. At first step only categoryNode will be added
ArrayList<NodeRef> categories = new ArrayList<NodeRef>();
categories.add(categoryNode);
HashMap<QName, Serializable> categoriesProps = new HashMap<QName, Serializable>();
categoriesProps.put(ContentModel.PROP_CATEGORIES, categories);
// Adds the generalclassifiable aspect to the file, so it can be classifiable via categories
nds.addAspect(file_info.getNodeRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, categoriesProps);
} else {
// The file is already classifiable, so we simply add the category
nds.setProperty(file_info.getNodeRef(), ContentModel.PROP_CATEGORIES, categoryNode);
}
The problem is that categoryNode is referred by an id that can be changed at any time. It will probably change in production environment, so now the question is: how can I get a category node without using a search?
08-03-2010 05:50 AM
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.