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 Summary
Fields Modifier and Type Field Description protected NodeStateTracker
_nodeStateTracker
The node state tracker.protected NodeTypeHierarchyComponent
_nodeTypeHierarchy
The node type hierarchy component.protected RepositoryProvider
_repositoryProvider
The repository provider.
-
Constructor Summary
Constructors Constructor Description RepositoryDao()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
addLeadingSlash(String path)
Add a leading slash to the path.Map<String,Object>
addNode(String parentPath, String childName, String childType, String workspaceName)
Add a node.void
checkoutNode(String path, String workspaceName)
Check-out a node.protected void
fillNodeInfo(Node node, Map<String,Object> nodeInfo)
Fill the node info.Set<String>
getChildrenTypes(String nodePath, String workspaceName)
Get the possible children types of a node.Map<String,Object>
getNodeByIdentifier(String identifier, String workspaceName)
Get node information by its identifier.Map<String,Object>
getNodeByPath(String path, String workspaceName)
Get node information by path.Map<String,Object>
getNodesByPath(Collection<String> paths, String workspaceName)
Get node information by path.Map<String,Object>
getRepositoryInfo()
Get information on the repository.List<String>
getWorkspaces()
Get the list of available workspaces in the repository.static String
removeLeadingSlash(String path)
Remove the leading slash from the path if needed.String
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.void
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 Detail
-
_repositoryProvider
protected RepositoryProvider _repositoryProvider
The repository provider.
-
_nodeStateTracker
protected NodeStateTracker _nodeStateTracker
The node state tracker.
-
_nodeTypeHierarchy
protected NodeTypeHierarchyComponent _nodeTypeHierarchy
The node type hierarchy component.
-
-
Constructor Detail
-
RepositoryDao
public RepositoryDao()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getRepositoryInfo
public Map<String,Object> getRepositoryInfo()
Get information on the repository.- Returns:
- information on the repository as a Map.
-
getWorkspaces
public List<String> getWorkspaces() throws RepositoryException
Get the list of available workspaces in the repository.- Returns:
- the list of available workspaces in the repository.
- Throws:
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 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:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
getNodeByPath
public Map<String,Object> getNodeByPath(String path, String workspaceName) throws 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:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
getNodeByIdentifier
public Map<String,Object> getNodeByIdentifier(String identifier, String workspaceName) throws 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:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
getChildrenTypes
public Set<String> getChildrenTypes(String nodePath, String workspaceName) throws 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:
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 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:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
removeNode
public String removeNode(String path, String workspaceName) throws 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:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
removeProperty
public void removeProperty(String path, String workspaceName, String propertyName) throws 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:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
unlockNode
public void unlockNode(String path, String workspaceName) throws RepositoryException
Unlock a node.- Parameters:
path
- The absolute node path.workspaceName
- The workspace name.- Throws:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
checkoutNode
public void checkoutNode(String path, String workspaceName) throws RepositoryException
Check-out a node.- Parameters:
path
- The absolute node path, must start with a slash.workspaceName
- The workspace name.- Throws:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
saveSession
public void saveSession(String workspaceName) throws RepositoryException
Save a session.- Parameters:
workspaceName
- The workspace name.- Throws:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
rollbackSession
public void rollbackSession(String workspaceName) throws RepositoryException
Rollback a session.- Parameters:
workspaceName
- The workspace name.- Throws:
RepositoryException
- if an error occurs getting or setting data from/in the repository.
-
fillNodeInfo
protected void fillNodeInfo(Node node, Map<String,Object> nodeInfo) throws RepositoryException
Fill the node info.- Parameters:
node
- The node to convertnodeInfo
- The map to fill- Throws:
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.
-
-