首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以更改属性"cmis:creationDate和cmis:lastModificationDate“?

我可以更改属性"cmis:creationDate和cmis:lastModificationDate“?
EN

Stack Overflow用户
提问于 2016-02-10 11:14:01
回答 1查看 1.8K关注 0票数 1

你好,谢谢您的帮助

我在al新鲜to中插入和更新文档时遇到了问题,所以当我设置一个属性"cmis:creationDate或cmis:lastModificationDate“时,文档将被成功创建,但是具有Updatability=ReadOnly的属性不会设置为新值,因为它是由al新鲜to自动设置的。是否有将这些属性的可更新性设置为"ReadWrite“的解决方案?我使用的是Aalfreco5.0和openCmis 0.13 --这是我的代码:

代码语言:javascript
复制
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);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-10 13:52:49

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

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

代码语言:javascript
复制
policyBehaviourFilter.disableBehaviour(node, ContentModel.ASPECT_AUDITABLE); 
// Update CreatedDate
nodeService.setProperty(node, ContentModel.PROP_CREATED, dateTime);
//Enable policy
policyBehaviourFilter.enableBehaviour(node, ContentModel.ASPECT_AUDITABLE);

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35313623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档