alfresco - 如何更改 alfresco 可审计的方面(创建者、修改者等)
问题描述
我一直在使用 Alfresco 4.2。我想复制带有从原始文件复制的所有可审计属性的文件。问题是,即使我禁用了可审计方面并将我的代码放在属性无法复制的单独事务中。甚至可以复制属性(修改、修改、创建、创建者)。在我的java代码下面:
result = copy(sourceNodeRef, targetParentNodeRef, assocTypeQName, assocQName, copyChildren);
UserTransaction userTransaction = transactionService.getUserTransaction();
try {
userTransaction.begin();
this.behaviourFilter.disableBehaviour(result, ContentModel.ASPECT_AUDITABLE);
this.behaviourFilter.disableBehaviour(QName.createQName("cm:auditable"));
boolean disableAuditable = this.behaviourFilter.isEnabled(result, ContentModel.ASPECT_AUDITABLE);
boolean disableCmAuditable = this.behaviourFilter.isEnabled(result, QName.createQName("cm:auditable"));
copyFileMetadata(sourceNodeRef, result);
userTransaction.commit();
} catch (NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) {
logger.error("Error in disabling AUDITABLE ASPECT: " + e);
} finally {
this.behaviourFilter.enableBehaviour(result, ContentModel.ASPECT_AUDITABLE);
this.behaviourFilter.enableBehaviour(QName.createQName("cm:auditable"));
}
我希望将属性设置为 copyFileMetadata() 中的属性,但值保持不变。
解决方案
我找到了解决方案,这是完整的代码:
UserTransaction userTransaction = transactionService.getUserTransaction();
Map<QName, Serializable> propertiesCopy = nodeService.getProperties(destinationNode);
try {
userTransaction.begin();
boolean disableAuditable = !this.behaviourFilter.isEnabled(destinationNode, ContentModel.ASPECT_AUDITABLE);
boolean disableCmAuditable = !this.behaviourFilter.isEnabled(destinationNode, QName.createQName("cm:auditable"));
if (disableAuditable && disableCmAuditable) {
//copied node props
String creator = (String) nodeService.getProperty(sourceNodeRef, ContentModel.PROP_CREATOR);
Date created = (Date) nodeService.getProperty(sourceNodeRef, ContentModel.PROP_CREATED);
String modifier = (String) nodeService.getProperty(sourceNodeRef, ContentModel.PROP_MODIFIER);
Date modified = (Date) nodeService.getProperty(sourceNodeRef, ContentModel.PROP_MODIFIED);
//copy of node props
Map<QName, Serializable> auditableProps = new HashMap<>();
auditableProps.put(ContentModel.PROP_CREATOR, creator);
auditableProps.put(ContentModel.PROP_CREATED, created);
auditableProps.put(ContentModel.PROP_MODIFIER, modifier);
auditableProps.put(ContentModel.PROP_MODIFIED, modified);
internalNodeService.setProperties(destinationNode, auditableProps);
}
userTransaction.commit();
} catch (NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) {
logger.error("Error in disabling AUDITABLE ASPECT: " + e);
} finally {
this.behaviourFilter.enableBehaviour(destinationNode, ContentModel.ASPECT_AUDITABLE);
this.behaviourFilter.enableBehaviour(destinationNode, QName.createQName("cm:auditable"));
propertiesCopy.remove(ContentModel.PROP_MODIFIED);
propertiesCopy.remove(ContentModel.PROP_MODIFIER);
propertiesCopy.remove(ContentModel.PROP_CREATED);
propertiesCopy.remove(ContentModel.PROP_CREATOR);
internalNodeService.setProperties(destinationNode, propertiesCopy);
this.copyAspects(sourceNodeRef, destinationNode);
}
上面的问题是我认为给出了错误的 targetNode。这里的destinationNode是以下结果:
NodeRef copyRef = this.services.getCopyService().copyAndRenameAndKeepMeta(this.nodeRef, destination.getNodeRef(),
ContentModel.ASSOC_CONTAINS, null, false);
copy = newInstance(copyRef, this.services, this.scope);
推荐阅读
- javascript - folder.getOwner 没有返回正确的值/谷歌脚本
- r - 固定效应模型:chol.default(mat[ok, ok]) 中的错误:# 阶的前导次要不是正定的
- python - 在python中绘制分布的分数
- python - 从元组列表中替换元组的元素 - Python
- go - 在 net.DialTCP 中指定本地 IP 地址抛出错误绑定:地址已在使用中
- c++ - MacOS gcc dylib 和 clang 应用程序 - 异常处理问题
- devops - 秘密服务器 - 我无法访问 superdev 秘密
- html - 在 html 和 docx 中的 Caption 中具有不同样式的几行 - flextable
- assembly - 电路解码所需的最小输入位数
- angular - 如何在 Angular Material 中拥有“简单”的可替换占位符文本?