Hi
I am trying to add the secondary properties (title,description) programmatically to a document in Alfresco using CMIS 1.1.Below is the code snippet of the same.
properties.put(PropertyIds.NAME, fileName);
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled");
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, "P:cm:titled");
properties.put("cm:title", "test title");
properties.put("cm:description", "description of document");
The mentioned code results in successful upload of the document to the Alfresco site without any issues,but the title and description properties of the uploaded document were empty while checking in Alfresco UI.
Also I try setting the tags to a document as well.Tags were also empty while viewing the document in alfresco site.Below is the code snippet
document = parentFolder.createDocument(properties, contentStream, null);
AlfrescoDocument alfDoc = (AlfrescoDocument) document;
Map<String, Object> properties1 = new HashMap<String, Object>();
List<String> tags = new ArrayList<String>();
tags.add("cmisTag");
tags.add("testTag");
properties1.put("cm:taggable",tags);
alfDoc.updateProperties(properties1);
Kindly help me know what is wrong with the code.Thanks in advance.
Try this:
List<Object> aspects = new ArrayList<Object>();
aspects.add("P:cm:titled");
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects);
properties.put("cm:description", "description of document");
Hi Angel Borroy
I changed the code as you have mentioned, still my document is not listed in the search space when I search something like title:test title (or) test title (which means title property is not applied to my document)
I made another change in my code as mentioned below which works perfectly fine.
List<Object> aspects = new ArrayList<Object>();
aspects.add("P:cm:titled");
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, aspects);
//During document creation
document = parentFolder.createDocument(properties, contentStream, null);
AlfrescoDocument alfDoc = (AlfrescoDocument) document;
if(alfDoc.hasAspect("P:cm:titled")) {
Map<String, Object> properties1 = new HashMap<String, Object>();
properties1.put("cm:title", "test title ");
properties1.put("cmis:description", "test desc");
alfDoc.updateProperties(properties1);
}
But searching title:test title (or) test title in the search box lists the current uploaded file along with all other documents in the site in which I have uploaded the document.
I also made sure that updateProperties is updating only the currently created file by modifying the cmis:name property.I am confused why every files are listed there.
Anything wrong with my code?? Kindly anyone help me
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
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.