I'd like to remove some properties or some aspects when user make upload a new version.
Hi:
Try with a content rule that executes a Javascript API script, removing the corresponding aspects and modifying properties. If the trigger for the rule ("when the document is modified") is not enough or valid for you, you will need to program a behaviour component that runs some java or javascript code for doing it.
Regards.
--C.
What event should I use for java version? onCreateVersion? beforeCreateVersion?
When I use this code, my aspect don't removed
public void onCreateVersion(QName qName, NodeRef nodeRef, Map<String, Serializable> map, PolicyScope policyScope) {
policyScope.removeAspect(nodeRef, QName.createQName(PharmModel.NAMESPACE_PHARM_CONTENT_MODEL, PharmModel.ASPECT_SC_APPROVABLE));
}
Try both events and be sure that the events are triggered via log4j loggers. If the event is not reached, you will need to use another event.
Hope this helps.
Regards.
--C.
I use both events, but I was able to remove the aspect only from node, not version. The newly created version still has this aspect.
public void onCreateVersion(QName qName, NodeRef nodeRef, Map<String, Serializable> map, PolicyScope policyScope) {
if (logger.isDebugEnabled()) logger.debug("Inside onCreateVersion");
if (qName.equals(QName.createQName(PharmModel.NAMESPACE_PHARM_CONTENT_MODEL, PharmModel.ASPECT_SC_APPROVABLE))) {
policyScope.removeAspect(QName.createQName(PharmModel.NAMESPACE_PHARM_CONTENT_MODEL, PharmModel.ASPECT_SC_APPROVABLE));
}
}
public void beforeCreateVersion(NodeRef nodeRef) {
if (versionService.getVersionHistory(nodeRef).getHeadVersion().getVersionType() == VersionType.MAJOR &&
nodeService.hasAspect(nodeRef, QName.createQName(PharmModel.NAMESPACE_PHARM_CONTENT_MODEL, PharmModel.ASPECT_SC_APPROVABLE))) {
nodeService.removeAspect(nodeRef, QName.createQName(PharmModel.NAMESPACE_PHARM_CONTENT_MODEL, PharmModel.ASPECT_SC_APPROVABLE));
}
}
Can I change properties when I upload a new version?
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.