protected void addCategory(
Session session,
Document testDoc,
String categoryName
)
{
ItemIterable<QueryResult> rs = session.query(
"select * from cm:category where cmis:name = '" + categoryName + "'",false);
if (rs.getTotalNumItems() == 0) {
System.out.println("Couldn't find category with name: " + categoryName);
return;
}
int i=0;
String catId=null;;
for (QueryResult resultRow : rs)
{
if (i==0)
{
catId = resultRow.getPropertyValueById("cmis:objectId");
}
}
testDoc.refresh();
List<String> aspects = testDoc.getPropertyValue("cmis:secondaryObjectTypeIds");
//je contrôle l'existence de l'aspect 'categorisable' par une méthode adhoc
if (! CmisClientAspectUtil.readAspectsForExistingDocument(session,
testDoc, "P:cm:generalclassifiable"))
{
//et j'attribue l'aspect le cas échéant
CmisClientAspectUtil.addAspectToExistingDocument(
testDoc,"P:cm:generalclassifiable",debug);
}
if (!testDoc.isLatestVersion())
{
testDoc = testDoc.getObjectOfLatestVersion(false);
}
List<String> catIds = testDoc.getPropertyValue("cm:categories");
if (!catIds.contains(catId)) {
catIds.add(catId);
for (int k=0; k<catIds.size(); k++)
{
catIds.set(k,"workspace://SpacesStore/"+catIds.get(k));
}
HashMap<String, List<String>> props = new HashMap<String, List<String>>();
props.put("cm:categories",catIds);
testDoc.updateProperties(props, false);
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.