문제

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

다른 팁

Trying to do something similar here.

I have a few documents that were originally uploaded as .doc files with the mimetype of Microsoft Word (application/msword) to alfresco share.

Now I've been able to successfully change the extension and update the mime type property to Microsoft Word 2007. But, when the file is downloaded and opened with microsoft word, it throws an error saying that the file format doesn't match the extension.

I thought I was doing it correctly but apparently not. Here is the part of the code that's supposed to handle the mime type conversion.

Map<String, Object> updateProperties = new HashMap<String, Object>();

updateProperties.put("cmis:name", changeName);
updateProperties.put("cmis:contentStreamFileName", changeName);
document.updateProperties(updateProperties);

ContentStream contentStream = document.getContentStream();
InputStream stream = contentStream.getStream();
ContentStream cs1 = session.getObjectFactory().createContentStream(changeName, docLength, MimeTypes.getMIMEType("docx"), stream);

document.setContentStream(cs1, true);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top