【问题标题】:Update alfresco content type through chemistry OpenCMIS通过化学 OpenCMIS 更新露天内容类型
【发布时间】:2013-05-08 18:58:01
【问题描述】:

我正在尝试通过 OpenCMIS 更新 alfresco 中文件的内容类型。

CMIS 工作台在类型窗口中显示类型,仅禁用开关“策略可控”。其本地名称为document,查询名称为prefix:document,基本类型为cmis:document

在 groovy 控制台中,我尝试了以下操作:

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);

名字更新好了,但是内容类型还是cmis:document

这段代码是写给波茨先生本人的以下示例:

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);

但是,他使用这个示例 sn-p 来创建一个节点,而不是更新它。

我还在链接到 alfresco 的 java 应用程序中尝试了此代码,但无济于事。

【问题讨论】:

    标签: java alfresco cmis opencmis apache-chemistry


    【解决方案1】:

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

    杰夫

    【讨论】:

    • 我一直在期待。非常感谢您的澄清!
    【解决方案2】:

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

    我有一些文档最初以 .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);
    

    【讨论】:

    • 你真的应该为此开始你自己的问题。话虽如此,您可以在运行此更新代码后使用节点浏览器查看 mimetype 是什么。您还可以检查 MimeTypes.getMIMEType("docx") 的评估结果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    • 2012-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多