Class AbstractDataDistributionType
- java.lang.Object
-
- org.exoplatform.services.jcr.ext.distribution.impl.AbstractDataDistributionType
-
- All Implemented Interfaces:
DataDistributionType
- Direct Known Subclasses:
DataDistributionByHash,DataDistributionByName,DataDistributionByPath
public abstract class AbstractDataDistributionType extends Object implements DataDistributionType
- Version:
- $Id$
- Author:
- Nicolas Filotto
-
-
Constructor Summary
Constructors Constructor Description AbstractDataDistributionType()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected javax.jcr.NodecreateNode(javax.jcr.Node parentNode, String nodeName, String nodeType, List<String> mixinTypes, Map<String,String[]> permissions, boolean isLeaf, boolean callSave)Creates the node of the given node type with the given node name directly under the given parent node, using the given mixin types and permissionsprotected abstract List<String>getAncestors(String dataId)Gives the list of all the name of the ancestorsjavax.jcr.NodegetDataNode(javax.jcr.Node rootNode, String dataId)Retrieves the node from the JCR under the given root node and corresponding to the given data id.javax.jcr.NodegetOrCreateDataNode(javax.jcr.Node rootNode, String dataId)Tries to get the node from the JCR and if it cannot be found, it will create it automatically.javax.jcr.NodegetOrCreateDataNode(javax.jcr.Node rootNode, String dataId, String nodeType)Tries to get the node from the JCR and if it cannot be found, it will create it automatically.javax.jcr.NodegetOrCreateDataNode(javax.jcr.Node rootNode, String dataId, String nodeType, List<String> mixinTypes)Tries to get the node from the JCR and if it cannot be found, it will create it automatically.javax.jcr.NodegetOrCreateDataNode(javax.jcr.Node rootNode, String dataId, String nodeType, List<String> mixinTypes, Map<String,String[]> permissions)Tries to get the node from the JCR and if it cannot be found, it will create it automatically.protected StringgetRelativePath(String dataId)Gives the relative path corresponding to the given id of the data to find/createvoidmigrate(javax.jcr.Node rootNode)Migrate from old structure to new one.voidmigrate(javax.jcr.Node rootNode, String nodeType, List<String> mixinTypes, Map<String,String[]> permissions)Migrate from old structure to new one.voidremoveDataNode(javax.jcr.Node rootNode, String dataId)Remove the node from the JCR if it existsprotected abstract booleanuseParametersOnLeafOnly()Indicates whether or not the node type, the mixin types and the permissions have to be used on leaf node only.
-
-
-
Method Detail
-
getDataNode
public javax.jcr.Node getDataNode(javax.jcr.Node rootNode, String dataId) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryExceptionRetrieves the node from the JCR under the given root node and corresponding to the given data id.- Specified by:
getDataNodein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to find is storeddataId- the id of the data to find- Returns:
- the Node corresponding to the data to find
- Throws:
javax.jcr.PathNotFoundException- if the data cannot be findjavax.jcr.RepositoryException- if an error occurred while trying to get the expected data
-
getOrCreateDataNode
public javax.jcr.Node getOrCreateDataNode(javax.jcr.Node rootNode, String dataId) throws javax.jcr.RepositoryExceptionTries to get the node from the JCR and if it cannot be found, it will create it automatically.- Specified by:
getOrCreateDataNodein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to find is storeddataId- the id of the data to find/create- Returns:
- the Node corresponding to the data to find
- Throws:
javax.jcr.RepositoryException- if an error occurred while trying to get or create the expected data
-
getOrCreateDataNode
public javax.jcr.Node getOrCreateDataNode(javax.jcr.Node rootNode, String dataId, String nodeType) throws javax.jcr.RepositoryExceptionTries to get the node from the JCR and if it cannot be found, it will create it automatically. If the node has to be created, the node will be created with the given node type.- Specified by:
getOrCreateDataNodein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to find is storeddataId- the id of the data to find/createnodeType- the node type to use in case we need to create the node- Returns:
- the Node corresponding to the data to find
- Throws:
javax.jcr.RepositoryException- if an error occurred while trying to get or create the expected data
-
getOrCreateDataNode
public javax.jcr.Node getOrCreateDataNode(javax.jcr.Node rootNode, String dataId, String nodeType, List<String> mixinTypes) throws javax.jcr.RepositoryExceptionTries to get the node from the JCR and if it cannot be found, it will create it automatically. If the node has to be created, the node will be created with the given node type and given mixin types.- Specified by:
getOrCreateDataNodein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to find is storeddataId- the id of the data to find/createnodeType- the node type to use in case we need to create the nodemixinTypes- the mixin types to use in case we need to create the node- Returns:
- the Node corresponding to the data to find
- Throws:
javax.jcr.RepositoryException- if an error occurred while trying to get or create the expected data
-
getOrCreateDataNode
public javax.jcr.Node getOrCreateDataNode(javax.jcr.Node rootNode, String dataId, String nodeType, List<String> mixinTypes, Map<String,String[]> permissions) throws javax.jcr.RepositoryExceptionTries to get the node from the JCR and if it cannot be found, it will create it automatically. If the node has to be created, the node will be created with the given node type, given mixin types and given permissions.- Specified by:
getOrCreateDataNodein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to find is storeddataId- the id of the data to find/createnodeType- the node type to use in case we need to create the nodemixinTypes- the mixin types to use in case we need to create the nodepermissions- the permissions to use in case we need to create the node- Returns:
- the Node corresponding to the data to find
- Throws:
javax.jcr.RepositoryException- if an error occurred while trying to get or create the expected data
-
removeDataNode
public void removeDataNode(javax.jcr.Node rootNode, String dataId) throws javax.jcr.RepositoryExceptionRemove the node from the JCR if it exists- Specified by:
removeDataNodein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to remove is storeddataId- the id of the data to remove- Throws:
javax.jcr.RepositoryException- if an error occurred while trying to remove the expected data
-
migrate
public void migrate(javax.jcr.Node rootNode) throws javax.jcr.RepositoryExceptionMigrate from old structure to new one.- Specified by:
migratein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to migrate is stored- Throws:
javax.jcr.RepositoryException- if an error occurred during migration
-
migrate
public void migrate(javax.jcr.Node rootNode, String nodeType, List<String> mixinTypes, Map<String,String[]> permissions) throws javax.jcr.RepositoryExceptionMigrate from old structure to new one.- Specified by:
migratein interfaceDataDistributionType- Parameters:
rootNode- the root node under which the data to migrate is storednodeType- the node type to use in case we need to create the nodemixinTypes- the mixin types to use in case we need to create the nodepermissions- the permissions to use in case we need to create the node- Throws:
javax.jcr.RepositoryException- if an error occurred during migration
-
createNode
protected javax.jcr.Node createNode(javax.jcr.Node parentNode, String nodeName, String nodeType, List<String> mixinTypes, Map<String,String[]> permissions, boolean isLeaf, boolean callSave) throws javax.jcr.RepositoryExceptionCreates the node of the given node type with the given node name directly under the given parent node, using the given mixin types and permissions- Parameters:
parentNode- the parent nodenodeName- the name of the node to createnodeType- the node type to usemixinTypes- the list of mixin types to usepermissions- the map of permissions to useisLeaf- indicates whether or not the current node to create is the leaf node- Returns:
- the created node
- Throws:
javax.jcr.RepositoryException- if any exception occurs while creating the node
-
getRelativePath
protected String getRelativePath(String dataId)
Gives the relative path corresponding to the given id of the data to find/create- Parameters:
dataId- the id of the data to find/create- Returns:
- the relative path of the data to find/create
-
getAncestors
protected abstract List<String> getAncestors(String dataId)
Gives the list of all the name of the ancestors- Parameters:
dataId- the id of the data to find/create- Returns:
- the list of the ancestor names
-
useParametersOnLeafOnly
protected abstract boolean useParametersOnLeafOnly()
Indicates whether or not the node type, the mixin types and the permissions have to be used on leaf node only.- Returns:
trueif only the leaf node has to be created with the parametersfalseotherwise.
-
-