2

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.

4

2 回答 2

4

对象的类型一旦通过 CMIS 创建就无法更改。如果您查看 cmis:objectTypeId 属性定义,您会注意到它的可更新性设置为“ONCREATE”而不是“READWRITE”。

杰夫

于 2013-05-14T21:25:20.843 回答
0

试图在这里做类似的事情。

我有一些文档最初以 .doc 文件的形式上传到户外共享,其 mimetype 为 Microsoft Word (application/msword)。

现在我已经能够成功更改扩展名并将 mime 类型属性更新为 Microsoft Word 2007。但是,当下载文件并使用 microsoft word 打开时,它会抛出一个错误,指出文件格式与扩展名不匹配.

我以为我做得对,但显然不是。这是应该处理 mime 类型转换的代码部分。

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);
于 2018-01-10T15:30:31.810 回答