@Test(expected = CommitFailedException.class) public void testUnknownAggregate() throws Exception { try { NodeState newDef = new MemoryNodeBuilder(EmptyNodeState.EMPTY_NODE) .setProperty(JCR_PRIMARYTYPE, NT_REP_PRIVILEGE) .setProperty(REP_BITS, 8) .setProperty(REP_AGGREGATES, ImmutableList.of("unknown", JCR_READ), Type.NAMES) .getNodeState(); PrivilegeValidator validator = createPrivilegeValidator(); validator.childNodeAdded("test", newDef); } catch (CommitFailedException e) { throw assertCommitFailed(e, 51); } }
@Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { Tree parent = getPrivilegesTree(rootBefore); if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } return null; }
PrivilegeValidator extends DefaultValidator implements PrivilegeConstants { @Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { Tree parent = getPrivilegesTree(rootBefore); if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } return null; } }
PrivilegeValidator extends DefaultValidator implements PrivilegeConstants { @Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { Tree parent = getPrivilegesTree(rootBefore); if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } return null; } PrivilegeValidator(@NotNull Root before, @NotNull Root after, @NotNull TreeProvider treeProvider); }
PrivilegeValidator extends DefaultValidator implements PrivilegeConstants { @Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { Tree parent = getPrivilegesTree(rootBefore); if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } return null; } PrivilegeValidator(@NotNull Root before, @NotNull Root after, @NotNull TreeProvider treeProvider); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override Validator childNodeAdded(String name, NodeState after); @Override Validator childNodeChanged(String name, NodeState before, NodeState after); @Override Validator childNodeDeleted(String name, NodeState before); }
PrivilegeValidator extends DefaultValidator implements PrivilegeConstants { @Override public Validator childNodeAdded(String name, NodeState after) throws CommitFailedException { if (isPrivilegeDefinition(after)) { Tree parent = getPrivilegesTree(rootBefore); if (NamespaceConstants.RESERVED_PREFIXES.contains(Text.getNamespacePrefix(name))) { String msg = "Failed to register custom privilege: Definition uses reserved namespace: " + name; throw new CommitFailedException("Privilege", 1, msg); } Tree tree = treeProvider.createReadOnlyTree(parent, name, after); validateDefinition(tree); } return null; } PrivilegeValidator(@NotNull Root before, @NotNull Root after, @NotNull TreeProvider treeProvider); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override Validator childNodeAdded(String name, NodeState after); @Override Validator childNodeChanged(String name, NodeState before, NodeState after); @Override Validator childNodeDeleted(String name, NodeState before);  }