我可以在露天更改属性“cmis:creationDate 和 cmis:lastModificationDate”可更新性吗?

Sfa*_*ayn 1 alfresco cmis opencmis cmis-workbench

您好,提前感谢您的帮助

我在露天插入和更新文档时遇到问题,因此当我设置“cmis:creationDate 或 cmis:lastModificationDate”等属性时,文档已成功创建,但具有 Updatability=ReadOnly 的属性未设置为新值鉴于它是由 alfresco 自动设置的。有什么解决方案可以将这些属性的可更新性设置为“读写”吗?我正在使用 Aalfresco 5.0 和 openCmis 0.13 这是我的代码:

public void createDocument(Folder folder) throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Date d = sdf.parse("21/12/2012");
    String name = "myNewDocument.txt";
    Map<String, Object> properties = new HashMap<String, Object>();
    Calendar cal = new GregorianCalendar();
    cal.setTime(d);
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:cm:titled,P:cm:author");
    properties.put(PropertyIds.NAME, name);
    properties.put(PropertyIds.CREATION_DATE, cal);
    properties.put(PropertyIds.LAST_MODIFICATION_DATE, cal);
    properties.put("cm:title", "Title");
    properties.put("cm:description", "Description");
    properties.put("cm:author", "author");
    properties.put("cmis:creationDate ", cal);
    byte[] content = "Hello World!".getBytes();
    InputStream stream = new ByteArrayInputStream(content);
    ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(content.length), "text/plain", stream);
    Document newDoc = folder.createDocument(properties, contentStream, VersioningState.MAJOR);
}
Run Code Online (Sandbox Code Playgroud)

Doc*_*son 5

更新只读字段需要在 Alfresco 端进行工作。有一些策略可以防止方面的属性cm:auditable被更改。

禁用该策略行为后,您可以使用 NodeService API 更新 Alfresco 中的字段。这是一个例子:

policyBehaviourFilter.disableBehaviour(node, ContentModel.ASPECT_AUDITABLE); 
// Update CreatedDate
nodeService.setProperty(node, ContentModel.PROP_CREATED, dateTime);
//Enable policy
policyBehaviourFilter.enableBehaviour(node, ContentModel.ASPECT_AUDITABLE);
Run Code Online (Sandbox Code Playgroud)

您可以将其打包到自定义网页脚本中,以允许远程更改属性。

  • 这个问题有点超出了单线程的范围。您将需要查看一些有关扩展 Alfresco 的教程。以下是一些可以帮助您入门的资源:https://wiki.alfresco.com/wiki/Developer_Guide 和 http://ecmarchitect.com/alfresco-developer-series-tutorials/ (2认同)