Issues in setting secondary properties to a document using cmis 1.1

cancel
Showing results for 
Search instead for 
Did you mean: 
azarfaiz
Member II

Issues in setting secondary properties to a document using cmis 1.1

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.

2 Replies
angelborroy
Alfresco Employee

Re: Issues in setting secondary properties to a document using cmis 1.1

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");
Hyland Developer Evangelist
azarfaiz
Member II

Re: Issues in setting secondary properties to a document using cmis 1.1

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

‌