04-17-2017 09:51 AM
I'd like to remove some properties or some aspects when user make upload a new version.
04-17-2017 02:21 PM
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.
04-17-2017 02:26 PM
What event should I use for java version? onCreateVersion? beforeCreateVersion?
04-17-2017 02:48 PM
04-17-2017 03:02 PM
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));
}
04-17-2017 03:28 PM
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.
04-18-2017 03:01 AM
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));
}
}
04-18-2017 12:01 PM
Can I change properties when I upload a new version?
Explore our Alfresco products with the links below. Use labels to filter content by product module.