Alfresco 我可以更改属性 "cmis:creationDate and cmis:lastModificationDate" 可更新性吗?
Alfresco can I Change properties "cmis:creationDate and cmis:lastModificationDate" Updatablity?
您好,在此先感谢您的帮助
我在户外插入和更新文档时遇到问题,所以当我设置 属性 像 "cmis:creationDate or 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);
}
更新只读字段需要在 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);
您可以将其打包到自定义网络脚本中以允许远程更改属性。
您好,在此先感谢您的帮助
我在户外插入和更新文档时遇到问题,所以当我设置 属性 像 "cmis:creationDate or 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);
}
更新只读字段需要在 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);
您可以将其打包到自定义网络脚本中以允许远程更改属性。