public static String getName(Node node) { try { return node.getName(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Unable to get name of Node " + node, e); } }
public static Node createNode(Node parentNode, String name, String nodeType) { try { return parentNode.addNode(name, nodeType); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to create the Node named " + name, e); } }
public void testMoveNode() throws Exception { Node n = (Node) readOnlySession.getItem(testNodePath); String destPath = testRootNode.getPath() + "/" + nodeName2; try { readOnlySession.move(n.getPath(), destPath); readOnlySession.save(); fail("A read only session must not be allowed to move a node"); } catch (AccessDeniedException e) { // expected log.debug(e.getMessage()); } }
public void testWorkspaceMoveNode() throws Exception { Node n = (Node) readOnlySession.getItem(testNodePath); String destPath = testRootNode.getPath() + "/" + nodeName2; try { readOnlySession.getWorkspace().move(n.getPath(), destPath); fail("A read only session must not be allowed to move a node"); } catch (AccessDeniedException e) { // expected log.debug(e.getMessage()); } }
public void testCopyNode() throws Exception { Node n = (Node) readOnlySession.getItem(testNodePath); String destPath = testRootNode.getPath() + "/" + nodeName2; try { readOnlySession.getWorkspace().copy(n.getPath(), destPath); fail("A read only session must not be allowed to copy a node"); } catch (AccessDeniedException e) { // expected log.debug(e.getMessage()); } } }
public static Node copy(Node srcNode, Node destNode) { try { Session sess = srcNode.getSession(); return copy(sess, srcNode.getPath(), destNode.getPath()); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to copy source node: " + srcNode + " to destination node: " + destNode, e); } }
public static boolean hasAnyPermission(Node node, Principal principal, Privilege... privileges) { try { return hasAnyPermission(node.getSession(), node.getPath(), principal, privileges); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to check permission(s) of node " + node + ": " + Arrays.toString(privileges), e); } }
public static boolean removePermissions(Node node, Principal principal, String... privilegeNames) { try { return removePermissions(node.getSession(), node.getPath(), principal, privilegeNames); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to remove permission(s) from node " + node + ": " + Arrays.toString(privilegeNames), e); } }
public static boolean removePermissions(Node node, Principal principal, Privilege... privileges) { try { return removePermissions(node.getSession(), node.getPath(), principal, privileges); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to remove permission(s) from node " + node + ": " + Arrays.toString(privileges), e); } }
public static boolean addPermissions(Node node, Principal principal, Collection<String> privilegeNames) { try { return addPermissions(node.getSession(), node.getPath(), principal, privilegeNames); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to add permission(s) to node " + node + ": " + privilegeNames, e); } }
public static <T extends Serializable> T getGenericJson(Node parent, String nodeName, boolean allowClassNotFound) { try { Node jsonNode = parent.getNode(nodeName); return getGenericJson(jsonNode, allowClassNotFound); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to deserialize generic JSON node", e); } }
public static boolean setPermissions(Node node, Principal principal, Collection<String> privilegeNames) { try { return setPermissions(node.getSession(), node.getPath(), principal, privilegeNames); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to set permission(s) on node " + node + ": " + privilegeNames, e); } }
public static boolean hasAnyPermission(Node node, Principal principal, String... privileges) { try { return hasAnyPermission(node.getSession(), node.getPath(), principal, privileges); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to check permission(s) for node: " + node); } }
public static boolean clearPermissions(Node node) { try { return clearPermissions(node.getSession(), node.getPath()); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to remove all permission(s) from node " + node, e); } }
public static Node getParent(Property prop) { try { return prop.getParent(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to get the parent node of the property: " + prop, e); } }
public static void removeNode(Node node) { try { node.remove(); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to remove the node " + node, e); } }
public static boolean removePermissions(Session session, String path, Principal principal, String... privilegeNames) { try { return removePermissions(session, path, principal, asPrivileges(session, privilegeNames)); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to remove permission(s) from node " + path + ": " + Arrays.toString(privilegeNames), e); } }
public static NodeType getNodeType(Session session, String typeName) { try { return session.getWorkspace().getNodeTypeManager().getNodeType(typeName); } catch (NoSuchNodeTypeException e) { throw new MetadataRepositoryException("No node type exits named: " + typeName, e); } catch (AccessDeniedException e) { log.debug("Access denied", e); throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to retrieve node type named: " + typeName, e); } }
public static boolean hasAnyPermission(Session session, String path, Principal principal, String... privilegeNames) { try { return hasAnyPermission(session, path, principal, asPrivileges(session, privilegeNames)); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to check permission(s) for node: " + path); } }
public static boolean setPermissions(Session session, String path, Principal principal, Collection<String> privilegeNames) { try { return setPermissions(session, path, principal, asPrivileges(session, privilegeNames)); } catch (AccessDeniedException e) { throw new AccessControlException(e.getMessage()); } catch (RepositoryException e) { throw new MetadataRepositoryException("Failed to set permission(s) on node " + path + ": " + privilegeNames, e); } }