I am trying to update the content type of files in alfresco through OpenCMIS.
The CMIS workbench shows the type in the types windows, with as only disabled switch 'Policy controlable'. Its local name is document
, queryname is prefix:document
and Base type is cmis:document
.
In the groovy console, I tried the following:
Folder folder = (Folder) session.getObjectByPath("/Sites/mySite");
CmisObject o = session.getObject(aNodeRef);
cmis.printObjectSummary(o);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:prefix:document");
properties.put(PropertyIds.NAME, "itsanewname!");
println("\n\nFrom "+PropertyIds.OBJECT_TYPE_ID+" cmis:document to " + " D:prefix:document:\n\n\n");
o.updateProperties(properties);
cmis.printObjectSummary(o);
The name is updated alright, but the content type remains cmis:document
.
This code was written to the following example of mister Potts himself:
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:sc:whitepaper,P:sc:webable,P:sc:productRelated");
properties.put(PropertyIds.NAME, filename);
properties.put("sc:isActive", true);
GregorianCalendar publishDate = new GregorianCalendar(2007,4,1,5,0);
properties.put("sc:published", publishDate);
However, he uses this example snippet to create a node, not update it.
I also tried this code in a java application that is linked to alfresco, to no avail.
You cannot change an object's type once it is created through CMIS. If you look at the cmis:objectTypeId property definition, you'll notice that its updatability is set to "ONCREATE" and not "READWRITE".
Jeff