@Override public boolean includeReorder(String destName, String name, NodeState reordered) { return includeThis && predicate.apply(reordered); }
@Override public boolean includeMove(String sourcePath, String name, NodeState moved) { return includeThis && predicate.apply(moved); }
@Override public boolean includeAdd(String name, NodeState after) { return includeThis && predicate.apply(after); }
private void setChildOrder() { if (isOrderable.apply(this)) { properties.put(OAK_CHILD_ORDER, PropertyStates.createProperty( OAK_CHILD_ORDER, nodes.keySet(), Type.NAMES)); } }
private boolean isImmutableProperty(@NotNull String name, @NotNull Tree parent) { // NOTE: we cannot rely on autocreated/protected definition as this // doesn't reveal if a given property is expected to be never modified // after creation. NodeState parentNs = provider.getTreeProvider().asNodeState(parent); if (JcrConstants.JCR_UUID.equals(name) && isReferenceable.apply(parentNs)) { return true; } else { return (JCR_CREATED.equals(name) || JCR_CREATEDBY.equals(name)) && isCreated.apply(parentNs); } }
private void validateCugNode(@NotNull NodeState parent, @NotNull NodeState nodeState) throws CommitFailedException { if (!NT_REP_CUG_POLICY.equals(NodeStateUtils.getPrimaryTypeName(nodeState))) { throw accessViolation(21, "Reserved name 'rep:cugPolicy' must only be used for nodes of type 'rep:CugPolicy'."); } if (!isMixCug.apply(parent)) { throw accessViolation(22, "Parent node not of mixin type 'rep:CugMixin'."); } }
public IdentifierTracker(NodeState root) { this.referenceable = new TypePredicate(root, MIX_REFERENCEABLE); this.parent = null; this.name = null; String uuid = root.getString(JCR_UUID); if (uuid != null && referenceable.apply(root)) { this.identifier = uuid; } else { this.identifier = "/"; } }
public IdentifierTracker getChildTracker(String name, NodeState state) { String uuid = state.getString(JCR_UUID); if (uuid != null && !referenceable.apply(state)) { uuid = null; // discard jcr:uuid value of a non-referenceable node } return new IdentifierTracker(this, name, uuid); }
public IdentifierTracker(NodeState root) { this.referenceable = new TypePredicate(root, MIX_REFERENCEABLE); this.parent = null; this.name = null; String uuid = root.getString(JCR_UUID); if (uuid != null && referenceable.apply(root)) { this.identifier = uuid; } else { this.identifier = "/"; } }
public IdentifierTracker getChildTracker(String name, NodeState state) { String uuid = state.getString(JCR_UUID); if (uuid != null && !referenceable.apply(state)) { uuid = null; // discard jcr:uuid value of a non-referenceable node } return new IdentifierTracker(this, name, uuid); }
private static void checkValidAccessControlledNode(@NotNull Tree accessControlledTree, @NotNull TypePredicate requiredMixin, @NotNull TreeProvider treeProvider) throws CommitFailedException { if (AC_NODETYPE_NAMES.contains(TreeUtil.getPrimaryTypeName(accessControlledTree))) { throw accessViolation(5, "Access control policy within access control content (" + accessControlledTree.getPath() + ')'); } if (!requiredMixin.apply(treeProvider.asNodeState(accessControlledTree))) { String msg = "Isolated policy node (" + accessControlledTree.getPath() + "). Parent is not of type " + requiredMixin; throw accessViolation(6, msg); } }
@Override public void leave(NodeState before, NodeState after) { if (glob != null && isACE.apply(after) && !builder.hasChildNode(REP_RESTRICTIONS)) { NodeBuilder restrictions = builder.setChildNode(REP_RESTRICTIONS); restrictions.setProperty(JCR_PRIMARYTYPE, NT_REP_RESTRICTIONS, NAME); restrictions.setProperty(glob); builder.removeProperty(REP_GLOB); } }
@Override public void leave(NodeState before, NodeState after) { if (glob != null && isACE.apply(after) && !builder.hasChildNode(REP_RESTRICTIONS)) { NodeBuilder restrictions = builder.setChildNode(REP_RESTRICTIONS); restrictions.setProperty(JCR_PRIMARYTYPE, NT_REP_RESTRICTIONS, NAME); restrictions.setProperty(glob); builder.removeProperty(REP_GLOB); } }
public static void removeVersionProperties(NodeBuilder versionableBuilder, TypePredicate isReferenceable) { assert versionableBuilder.exists(); removeMixin(versionableBuilder, MIX_VERSIONABLE); // we don't know if the UUID is otherwise referenced, // so make sure the node remains referencable if (!isReferenceable.apply(versionableBuilder.getNodeState())) { addMixin(versionableBuilder, MIX_REFERENCEABLE); } versionableBuilder.removeProperty(JCR_VERSIONHISTORY); versionableBuilder.removeProperty(JCR_PREDECESSORS); versionableBuilder.removeProperty(JCR_BASEVERSION); versionableBuilder.removeProperty(JCR_ISCHECKEDOUT); }
@Test public void singleNodeTypeMatch() { NodeState node = createNodeOfType(NT_BASE); TypePredicate p = new TypePredicate(node, new String[] {NT_BASE}); assertTrue(p.apply(node)); }
@Test public void singleNodeTypeMiss() { NodeState node = createNodeOfType(NT_BASE); TypePredicate p = new TypePredicate(node, new String[] {NT_FILE}); assertFalse(p.apply(node)); }
@Test public void multipleNodeTypesMatch() { NodeState node = createNodeOfType(NT_FILE); TypePredicate p = new TypePredicate(node, new String[] { NT_FOLDER, NT_RESOURCE, NT_FILE }); assertTrue(p.apply(node)); }
@Test public void multipleNodeTypesMiss() { NodeState node = createNodeOfType(NT_FILE); TypePredicate p = new TypePredicate(node, new String[] { NT_FOLDER, NT_RESOURCE, JCR_CONTENT }); assertFalse(p.apply(node)); }