/** * Returns {@code true} if the given {@code tree} is of type * {@code mix:versionable}; {@code false} otherwise. * * @param tree the tree to check. * @return whether the {@code tree} is versionable. */ protected boolean isVersionable(@NotNull Tree tree) { return getNodeTypeManager().isNodeType( checkNotNull(tree), VersionConstants.MIX_VERSIONABLE); }
/** * Returns {@code true} if the given {@code tree} is of type * {@code mix:versionable}; {@code false} otherwise. * * @param tree the tree to check. * @return whether the {@code tree} is versionable. */ protected boolean isVersionable(@NotNull Tree tree) { return getNodeTypeManager().isNodeType( checkNotNull(tree), VersionConstants.MIX_VERSIONABLE); }
/** * Returns {@code true} if the given {@code tree} is of type * {@code mix:versionable}; {@code false} otherwise. * * @param tree the tree to check. * @return whether the {@code tree} is versionable. */ protected boolean isVersionable(@Nonnull Tree tree) { return getNodeTypeManager().isNodeType( checkNotNull(tree), VersionConstants.MIX_VERSIONABLE); }
static boolean isAccessControlled(@Nullable String oakPath, @NotNull Tree tree, @NotNull ReadOnlyNodeTypeManager ntMgr) { String mixinName = getMixinName(oakPath); return ntMgr.isNodeType(tree, mixinName); }
public static boolean isAccessControlled(@Nullable String oakPath, @Nonnull Tree tree, @Nonnull ReadOnlyNodeTypeManager ntMgr) { String mixinName = getMixinName(oakPath); return ntMgr.isNodeType(tree, mixinName); }
static boolean isAccessControlled(@Nullable String oakPath, @NotNull Tree tree, @NotNull ReadOnlyNodeTypeManager ntMgr) { String mixinName = getMixinName(oakPath); return ntMgr.isNodeType(tree, mixinName); }
static boolean isACE(@NotNull Tree tree, @NotNull ReadOnlyNodeTypeManager ntMgr) { return tree.exists() && ntMgr.isNodeType(tree, NT_REP_ACE); }
static boolean isACE(@NotNull Tree tree, @NotNull ReadOnlyNodeTypeManager ntMgr) { return tree.exists() && ntMgr.isNodeType(tree, NT_REP_ACE); }
public static boolean isACE(@Nonnull Tree tree, @Nonnull ReadOnlyNodeTypeManager ntMgr) { return tree.exists() && ntMgr.isNodeType(tree, NT_REP_ACE); }
private boolean isVersionable(ReadOnlyNodeTypeManager ntMgr) { // this is not 100% correct, because t.getPath() will // not return the correct path for node after, but is // sufficient to check if it is versionable Tree tree = providerCtx.getTreeProvider().createReadOnlyTree(builder.getNodeState()); return ntMgr.isNodeType(tree, VersionConstants.MIX_VERSIONABLE); } }
private boolean isExcluded(MountedNodeStore mountedStore, Tree tree, Context context) { for ( String excludedNodeType : excludedNodeTypes ) { if ( context.getTypeManager().isNodeType(tree, excludedNodeType ) ) { log.warn("Not failing check for tree at path {}, mount {} due to matching excluded node type {}", tree.getPath(), mountedStore.getMount().getName(), excludedNodeType); return true; } } return false; }
private boolean isVersionable(ReadOnlyNodeTypeManager ntMgr) { // this is not 100% correct, because t.getPath() will // not return the correct path for node after, but is // sufficient to check if it is versionable Tree tree = providerCtx.getTreeProvider().createReadOnlyTree(builder.getNodeState()); return ntMgr.isNodeType(tree, VersionConstants.MIX_VERSIONABLE); } }
@Override public boolean check(MountedNodeStore mountedStore, Tree tree, ErrorHolder errorHolder, Context context) { if ( context.getTypeManager().isNodeType(tree, invalidNodeType) && !isExcluded(mountedStore, tree, context) ) { errorHolder.report(mountedStore, tree.getPath(), errorLabel); } return true; }
@CheckForNull private JackrabbitAccessControlList getACL(Tree tree) throws RepositoryException { String nodeName = tree.getName(); JackrabbitAccessControlList acList = null; if (!tree.isRoot()) { Tree parent = tree.getParent(); if (AccessControlConstants.REP_POLICY.equals(nodeName) && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)) { String path = parent.getPath(); acList = getACL(path); } else if (AccessControlConstants.REP_REPO_POLICY.equals(nodeName) && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL) && parent.isRoot()) { acList = getACL((String) null); } } if (acList != null) { // clear all existing entries for (AccessControlEntry ace: acList.getAccessControlEntries()) { acList.removeAccessControlEntry(ace); } } return acList; }
@Nullable private JackrabbitAccessControlList getACL(Tree tree) throws RepositoryException { String nodeName = tree.getName(); JackrabbitAccessControlList acList = null; if (!tree.isRoot()) { Tree parent = tree.getParent(); if (AccessControlConstants.REP_POLICY.equals(nodeName) && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)) { String path = parent.getPath(); acList = getACL(path); } else if (AccessControlConstants.REP_REPO_POLICY.equals(nodeName) && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL) && parent.isRoot()) { acList = getACL((String) null); } } if (acList != null) { // clear all existing entries for (AccessControlEntry ace: acList.getAccessControlEntries()) { acList.removeAccessControlEntry(ace); } } return acList; }
@Nullable private JackrabbitAccessControlList getACL(Tree tree) throws RepositoryException { String nodeName = tree.getName(); JackrabbitAccessControlList acList = null; if (!tree.isRoot()) { Tree parent = tree.getParent(); if (AccessControlConstants.REP_POLICY.equals(nodeName) && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL)) { String path = parent.getPath(); acList = getACL(path); } else if (AccessControlConstants.REP_REPO_POLICY.equals(nodeName) && ntMgr.isNodeType(tree, AccessControlConstants.NT_REP_ACL) && parent.isRoot()) { acList = getACL((String) null); } } if (acList != null) { // clear all existing entries for (AccessControlEntry ace: acList.getAccessControlEntries()) { acList.removeAccessControlEntry(ace); } } return acList; }
@NotNull @Override public AccessControlPolicyIterator getApplicablePolicies(@Nullable String absPath) throws RepositoryException { String oakPath = getOakPath(absPath); Tree tree = getTree(oakPath, Permissions.READ_ACCESS_CONTROL, true); AccessControlPolicy policy = null; Tree aclTree = getAclTree(oakPath, tree); if (aclTree == null) { if (tree.hasChild(Util.getAclName(oakPath))) { // policy child node without tree being access controlled log.warn("Colliding policy child without node being access controllable ({}).", absPath); } else { // create an empty acl unless the node is protected or cannot have // mixin set (e.g. due to a lock) String mixinName = Util.getMixinName(oakPath); if (ntMgr.isNodeType(tree, mixinName) || ntMgr.getEffectiveNodeType(tree).supportsMixin(mixinName)) { policy = new NodeACL(oakPath); } else { log.warn("Node {} cannot be made access controllable.", absPath); } } } // else: acl already present -> getPolicies must be used. if (policy == null) { return AccessControlPolicyIteratorAdapter.EMPTY; } else { return new AccessControlPolicyIteratorAdapter(Collections.singleton(policy)); } }
@NotNull @Override public AccessControlPolicyIterator getApplicablePolicies(@Nullable String absPath) throws RepositoryException { String oakPath = getOakPath(absPath); Tree tree = getTree(oakPath, Permissions.READ_ACCESS_CONTROL, true); AccessControlPolicy policy = null; Tree aclTree = getAclTree(oakPath, tree); if (aclTree == null) { if (tree.hasChild(Util.getAclName(oakPath))) { // policy child node without tree being access controlled log.warn("Colliding policy child without node being access controllable ({}).", absPath); } else { // create an empty acl unless the node is protected or cannot have // mixin set (e.g. due to a lock) String mixinName = Util.getMixinName(oakPath); if (ntMgr.isNodeType(tree, mixinName) || ntMgr.getEffectiveNodeType(tree).supportsMixin(mixinName)) { policy = new NodeACL(oakPath); } else { log.warn("Node {} cannot be made access controllable.", absPath); } } } // else: acl already present -> getPolicies must be used. if (policy == null) { return AccessControlPolicyIteratorAdapter.EMPTY; } else { return new AccessControlPolicyIteratorAdapter(Collections.singleton(policy)); } }
@Nonnull @Override public AccessControlPolicyIterator getApplicablePolicies(@Nullable String absPath) throws RepositoryException { String oakPath = getOakPath(absPath); Tree tree = getTree(oakPath, Permissions.READ_ACCESS_CONTROL, true); AccessControlPolicy policy = null; Tree aclTree = getAclTree(oakPath, tree); if (aclTree == null) { if (tree.hasChild(Util.getAclName(oakPath))) { // policy child node without tree being access controlled log.warn("Colliding policy child without node being access controllable ({}).", absPath); } else { // create an empty acl unless the node is protected or cannot have // mixin set (e.g. due to a lock) String mixinName = Util.getMixinName(oakPath); if (ntMgr.isNodeType(tree, mixinName) || ntMgr.getEffectiveNodeType(tree).supportsMixin(mixinName)) { policy = new NodeACL(oakPath); } else { log.warn("Node {} cannot be made access controllable.", absPath); } } } // else: acl already present -> getPolicies must be used. if (policy == null) { return AccessControlPolicyIteratorAdapter.EMPTY; } else { return new AccessControlPolicyIteratorAdapter(Collections.singleton(policy)); } }
@Test public void testRemovePolicyRemovesMixin() throws Exception { ReadOnlyNodeTypeManager ntMgr = ReadOnlyNodeTypeManager.getInstance(root, NamePathMapper.DEFAULT); CugPolicy cug = getApplicableCug(SUPPORTED_PATH); cugAccessControlManager.setPolicy(SUPPORTED_PATH, cug); root.commit(); assertTrue(ntMgr.isNodeType(root.getTree(SUPPORTED_PATH), MIX_REP_CUG_MIXIN)); cugAccessControlManager.removePolicy(SUPPORTED_PATH, cugAccessControlManager.getPolicies(SUPPORTED_PATH)[0]); root.commit(); assertFalse(ntMgr.isNodeType(root.getTree(SUPPORTED_PATH), MIX_REP_CUG_MIXIN)); }