1

嗨,提前感谢您的帮助

我在露天插入和更新文档时遇到问题,因此当我设置“cmis:creationDate 或 cmis:lastModificationDate”之类的属性时,文档已成功创建,但具有 Updatability=ReadOnly 的属性未设置为新值鉴于它是由 alfresco 自动设置的。是否有任何解决方案可以将这些属性的可更新性设置为“ReadWrite”?我正在使用 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);
}
4

1 回答 1

4

更新只读字段需要在 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);

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

于 2016-02-10T13:52:49.010 回答