Alfresco我可以更改属性" cmis:creationDate和cmis:lastModificationDate" Updatablity?

时间:2016-02-10 11:14:02

标签: alfresco cmis opencmis cmis-workbench

您好,并提前感谢您的帮助

我在alfresco中插入和更新文档时遇到问题,所以当我设置像" cmis:creationDate或cmis:lastModificationDate"这样的属性时,文档会成功创建,但属性具有Updatability = ReadOnly在露天自动设置的情况下,它不会设置为新值。 是否有任何解决方案可以将这些属性的可更新性设置为" 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);
}

1 个答案:

答案 0 :(得分: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,以允许远程更改属性。