Class RepositoryDao

java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.workspaces.repository.jcr.RepositoryDao
All Implemented Interfaces:
Component, LogEnabled, Serviceable

public class RepositoryDao extends AbstractLogEnabled implements Component, Serviceable
Component providing methods to access the repository.
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager serviceManager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • getRepositoryInfo

      Get information on the repository.
      Returns:
      information on the repository as a Map.
    • getWorkspaces

      public List<String> getWorkspaces() throws javax.jcr.RepositoryException
      Get the list of available workspaces in the repository.
      Returns:
      the list of available workspaces in the repository.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • getNodesByPath

      public Map<String,Object> getNodesByPath(Collection<String> paths, String workspaceName) throws javax.jcr.RepositoryException
      Get node information by path.
      Parameters:
      paths - the node paths, relative to the root node (without leading slash).
      workspaceName - the workspace name.
      Returns:
      information on the node as a Map.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • getNodeByPath

      public Map<String,Object> getNodeByPath(String path, String workspaceName) throws javax.jcr.RepositoryException
      Get node information by path.
      Parameters:
      path - the node path, relative to the root node (without leading slash).
      workspaceName - the workspace name.
      Returns:
      information on the node as a Map.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • getNodeByIdentifier

      public Map<String,Object> getNodeByIdentifier(String identifier, String workspaceName) throws javax.jcr.RepositoryException
      Get node information by its identifier.
      Parameters:
      identifier - the node identifier.
      workspaceName - the workspace name.
      Returns:
      information on the node as a Map.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • getChildrenTypes

      public Set<String> getChildrenTypes(String nodePath, String workspaceName) throws javax.jcr.RepositoryException
      Get the possible children types of a node.
      Parameters:
      nodePath - The node path.
      workspaceName - The workspace name.
      Returns:
      the possible children types of the node.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • addNode

      public Map<String,Object> addNode(String parentPath, String childName, String childType, String workspaceName) throws javax.jcr.RepositoryException
      Add a node.
      Parameters:
      parentPath - the parent node path.
      childName - the name of the node to create.
      childType - the type of the node to create.
      workspaceName - the workspace name.
      Returns:
      A Map with information on the created node.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • removeNode

      public String removeNode(String path, String workspaceName) throws javax.jcr.RepositoryException
      Remove a node from the repository.
      Parameters:
      path - The absolute node path, can start with a slash or not.
      workspaceName - The workspace name.
      Returns:
      The full parent path.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • removeProperty

      public void removeProperty(String path, String workspaceName, String propertyName) throws javax.jcr.RepositoryException
      Remove a property from a node.
      Parameters:
      path - The absolute node path, can start with a slash or not.
      workspaceName - The workspace name.
      propertyName - The name of the property to remove.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • unlockNode

      public void unlockNode(String path, String workspaceName) throws javax.jcr.RepositoryException
      Unlock a node.
      Parameters:
      path - The absolute node path.
      workspaceName - The workspace name.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • checkoutNode

      public void checkoutNode(String path, String workspaceName) throws javax.jcr.RepositoryException
      Check-out a node.
      Parameters:
      path - The absolute node path, must start with a slash.
      workspaceName - The workspace name.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • renameNode

      public Map<String,Object> renameNode(String path, String workspaceName, String newName) throws javax.jcr.RepositoryException
      Change the name of a node
      Parameters:
      path - The absolute node path, must start with a slash.
      workspaceName - The workspace name.
      newName - The new name of the node in the same parent
      Returns:
      A Map with information on the renamed node.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • moveNodes

      public Map<String,List<String>> moveNodes(List<String> paths, String workspaceName, String targetPath, int index) throws javax.jcr.RepositoryException
      Change the name of a node
      Parameters:
      paths - The absolute source node paths, must start with a slash.
      workspaceName - The workspace name.
      targetPath - The absolute target node paths, must start with a slash.
      index - The insert position in child nodes. -1 means as last child.
      Returns:
      A Map with information on the moved node.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • saveSession

      public void saveSession(String workspaceName) throws javax.jcr.RepositoryException
      Save a session.
      Parameters:
      workspaceName - The workspace name.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • rollbackSession

      public void rollbackSession(String workspaceName) throws javax.jcr.RepositoryException
      Rollback a session.
      Parameters:
      workspaceName - The workspace name.
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • fillNodeInfo

      protected void fillNodeInfo(javax.jcr.Node node, Map<String,Object> nodeInfo) throws javax.jcr.RepositoryException
      Fill the node info.
      Parameters:
      node - The node to convert
      nodeInfo - The map to fill
      Throws:
      javax.jcr.RepositoryException - if an error occurs getting or setting data from/in the repository.
    • addLeadingSlash

      public static String addLeadingSlash(String path)
      Add a leading slash to the path.
      Parameters:
      path - the path.
      Returns:
      the path with a leading slash.
    • removeLeadingSlash

      public static String removeLeadingSlash(String path)
      Remove the leading slash from the path if needed.
      Parameters:
      path - the path.
      Returns:
      the path without leading slash.