Class RepositoryDao
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.workspaces.repository.jcr.RepositoryDao
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
Component providing methods to access the repository.
-
Field Summary
Modifier and TypeFieldDescriptionprotected NodeStateTracker
The node state tracker.protected NodeTypeHierarchyComponent
The node type hierarchy component.protected RepositoryProvider
The repository provider. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
addLeadingSlash
(String path) Add a leading slash to the path.Add a node.void
checkoutNode
(String path, String workspaceName) Check-out a node.protected void
fillNodeInfo
(javax.jcr.Node node, Map<String, Object> nodeInfo) Fill the node info.getChildrenTypes
(String nodePath, String workspaceName) Get the possible children types of a node.getNodeByIdentifier
(String identifier, String workspaceName) Get node information by its identifier.getNodeByPath
(String path, String workspaceName) Get node information by path.getNodesByPath
(Collection<String> paths, String workspaceName) Get node information by path.Get information on the repository.Get the list of available workspaces in the repository.Change the name of a nodestatic String
removeLeadingSlash
(String path) Remove the leading slash from the path if needed.removeNode
(String path, String workspaceName) Remove a node from the repository.void
removeProperty
(String path, String workspaceName, String propertyName) Remove a property from a node.renameNode
(String path, String workspaceName, String newName) Change the name of a nodevoid
rollbackSession
(String workspaceName) Rollback a session.void
saveSession
(String workspaceName) Save a session.void
service
(ServiceManager serviceManager) void
unlockNode
(String path, String workspaceName) Unlock a node.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
_repositoryProvider
The repository provider. -
_nodeStateTracker
The node state tracker. -
_nodeTypeHierarchy
The node type hierarchy component.
-
-
Constructor Details
-
RepositoryDao
public RepositoryDao()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getRepositoryInfo
Get information on the repository.- Returns:
- information on the repository as a Map.
-
getWorkspaces
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
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
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
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
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
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.RepositoryExceptionFill the node info.- Parameters:
node
- The node to convertnodeInfo
- The map to fill- Throws:
javax.jcr.RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
addLeadingSlash
Add a leading slash to the path.- Parameters:
path
- the path.- Returns:
- the path with a leading slash.
-
removeLeadingSlash
Remove the leading slash from the path if needed.- Parameters:
path
- the path.- Returns:
- the path without leading slash.
-