As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
@Override public void onCreateNode(ChildAssociationRef childAssocRef) { if (applicable(childAssocRef.getChildRef())) { onCreateNodeImpl(childAssocRef); } } protected boolean applicable(NodeRef nodeRef) { return getNodeService().exists(nodeRef) && !getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_HIDDEN_RENDITION) && !getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN) && !getNodeService().getType(nodeRef).equals(ForumModel.TYPE_FORUM) && !getNodeService().getType(nodeRef).equals(ForumModel.TYPE_POST) && !getNodeService().getType(nodeRef).equals(ForumModel.TYPE_FORUMS) && !getNodeService().getType(nodeRef).equals(ForumModel.TYPE_TOPIC) }
@Service @BehaviourBean public class ApplyConfidentiality implements NodeServicePolicies.OnCreateNodePolicy { @Autowired @Qualifier("NodeService") private NodeService nodeService; /** * Called when a new node has been created. * * @param childAssocRef the created child association reference */ @Behaviour( kind = BehaviourKind.CLASS, type = "cm:content") @Override public void onCreateNode(ChildAssociationRef childAssocRef) { if (ContentModel.TYPE_CONTENT.equals(nodeService.getType(childAssocRef.getChildRef()))) { System.out.println("CM:CONTENT"); }else { System.out.println("CM:CONTENT subType"); } for (QName qName : nodeService.getAspects(childAssocRef.getChildRef())) { System.out.println(qName.getLocalName()); } if (nodeService.hasAspect(childAssocRef.getChildRef(), RenditionModel.ASPECT_HIDDEN_RENDITION)) { System.out.println("REDITION HIDDEN"); } if (nodeService.hasAspect(childAssocRef.getChildRef(), ContentModel.ASPECT_HIDDEN)) { System.out.println("ASPECT HIDDEN"); } } }
/** the types (hardcoded) to ignore generally */ private static final Set<QName> IGNORE_TYPES; /** the aspects (hardcoded) to ignore generally */ private static final Set<QName> IGNORE_ASPECTS; static { IGNORE_TYPES = new HashSet<QName>(13); IGNORE_TYPES.add(RuleModel.TYPE_RULE); IGNORE_TYPES.add(ActionModel.TYPE_ACTION); IGNORE_TYPES.add(ContentModel.TYPE_THUMBNAIL); // Workaround to prevent rules running on cm:rating nodes (which happened for 'liked' folders ALF-8308 & ALF-8382) IGNORE_TYPES.add(ContentModel.TYPE_RATING); IGNORE_TYPES.add(ContentModel.TYPE_SYSTEM_FOLDER); IGNORE_ASPECTS = new HashSet<QName>(13); IGNORE_ASPECTS.add(ContentModel.ASPECT_TEMPORARY); } protected void triggerRules(NodeRef nodeRef, NodeRef actionedUponNodeRef) { // Break out early if rules are off if (!areRulesEnabled()) { return; } // Do not trigger rules for rule and action type nodes if (ignoreTrigger(actionedUponNodeRef) == false) { for (RuleType ruleType : this.ruleTypes) { ruleType.triggerRuleType(nodeRef, actionedUponNodeRef, this.executeRuleImmediately); } } } /** * Indicate whether the trigger should be ignored or not * @param actionedUponNodeRef actioned upon node reference * @return boolean true if the trigger should be ignored, false otherwise */ private boolean ignoreTrigger(NodeRef actionedUponNodeRef) { boolean result = false; QName typeQName = nodeService.getType(actionedUponNodeRef); if (IGNORE_TYPES.contains(typeQName)) { result = true; } for (QName aspectToIgnore : IGNORE_ASPECTS) { if (nodeService.hasAspect(actionedUponNodeRef, aspectToIgnore)) { return true; } } return result; }
/** * the types to ignore generally (see RuleTriggerAbstractBase) */ private static ImmutableSet<QName> IGNORE_TYPES = ImmutableSet.<QName>builder() .add(RuleModel.TYPE_RULE) .add(ActionModel.TYPE_ACTION) .add(ContentModel.TYPE_THUMBNAIL) .add(ContentModel.TYPE_RATING) .add(ContentModel.TYPE_SYSTEM_FOLDER) .build(); /** * the aspects to ignoreForBehaviour generally (see RuleTriggerAbstractBase) */ public static ImmutableSet<QName> IGNORE_ASPECTS = ImmutableSet.<QName>builder().add(ContentModel.ASPECT_TEMPORARY).build(); /** * (see RuleTriggerAbstractBase) * determine if the node has to be ignored for a behaviour* * * @param nodeRef ref of the node * @return true if the node should be ignored, false otherwise */ public boolean ignoreForBehaviour(NodeRef nodeRef) { if (IGNORE_TYPES.contains(nodeService.getType(nodeRef))) { return true; } for (QName aspectToIgnore : IGNORE_ASPECTS) { if (nodeService.hasAspect(nodeRef, aspectToIgnore)) { return true; } } return isSurfConfig(nodeRef); } /** * Check if the node is inside a surf-config folder (E.g. of files in the surf-config folder dashboard.xml)* * @param nodeRef ref of the node to check * @return true if it's surf-config file otherwise false */ private boolean isSurfConfig(NodeRef nodeRef) { if(nodeRef != null && nodeService.exists(nodeRef)) { if ("surf-config".equals(nodeService.getProperty(nodeRef, ContentModel.PROP_NAME))) { return true; } return isSurfConfig(nodeService.getPrimaryParent(nodeRef).getParentRef()); } return false; }