Package org.silverpeas.core.node.service
Class DefaultNodeService
- java.lang.Object
-
- org.silverpeas.core.node.service.DefaultNodeService
-
- All Implemented Interfaces:
ComponentInstanceDeletion
,NodeService
@Service @Singleton public class DefaultNodeService extends Object implements NodeService, ComponentInstanceDeletion
This is the default implementation of NodeService. A node is composed by some another nodes (children) and have got one and only one father. It describes a tree.- Author:
- Nicolas Eysseric
-
-
Constructor Summary
Constructors Constructor Description DefaultNodeService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createIndex(NodeDetail nodeDetail)
Indexes the specified node.NodePK
createNode(NodeDetail node)
Creates a new node in Silverpeas.NodePK
createNode(NodeDetail nd, NodeDetail fatherDetail)
Create a new Node objectvoid
delete(String componentInstanceId)
Deletes the resources belonging to the specified component instance.void
deleteIndex(NodePK pk)
Called on : - removeNode()Collection<NodeDetail>
getAllNodes(NodePK nodePK)
Method declarationCollection<NodeDetail>
getChildrenDetails(NodePK pk)
Get the header of each child of the nodeCollection<NodePK>
getChildrenPKs(NodePK nodePK)
Get children node PKs of a nodeList<NodeDetail>
getDescendantDetails(NodeDetail node)
Get descendant node details of a nodeList<NodeDetail>
getDescendantDetails(NodePK nodePK)
Get descendant node details of a nodeCollection<NodePK>
getDescendantPKs(NodePK nodePK)
Get descendant node PKs of a nodeNodeDetail
getDetail(NodePK pk)
Get the attributes of a node and of its childrenNodeDetail
getDetailByNameAndFatherId(NodePK pk, String name, int nodeFatherId)
Gets complete details about the specified node with the given name and with as father the specified one.NodeDetail
getHeader(NodePK pk)
Get the attributes of THIS nodeNodeDetail
getHeader(NodePK pk, boolean getTranslations)
Gets synthetic details about the specified node.List<NodeDetail>
getHeadersByLevel(NodePK pk, int level)
Method declarationList<NodeDetail>
getMinimalDataByInstances(Collection<String> instanceIds)
Selects massively simple data about nodes.NodePath
getPath(NodePK pk)
Get the path of this node from this node to rootList<NodeDetail>
getSubTree(NodePK pk)
Gets all the nodes that are part of the subtree from the specified node.List<NodeDetail>
getSubTree(NodePK pk, String sorting)
Gets all the nodes that are part of the subtree from the specified node and sorted according to the sorting argument.List<NodeDetail>
getSubTree(NodePK pk, String status, int level, String sorting)
Gets all the nodes that are part of the subtree from the specified node down to the given deep level of the subtree and having the given status.List<NodeDetail>
getSubTreeByLevel(NodePK pk, int level)
Gets all the nodes that are part of the subtree from the specified node down to the given deep level of the subtree.List<NodeDetail>
getSubTreeByLevel(NodePK pk, int level, String sorting)
Gets all the nodes that are part of the subtree from the specified node down to the given deep level of the subtree.List<NodeDetail>
getSubTreeByStatus(NodePK pk, String status)
Gets all the nodes that are part of the subtree from the specified node and having the given status.List<NodeDetail>
getSubTreeByStatus(NodePK pk, String status, String sorting)
Gets all the nodes that are part of the subtree from the specified node and having the given status.List<NodeDetail>
getTree(NodePK pk)
Gets all the nodes that are part of the tree rooted from the specified node.boolean
isSameNameSameLevelOnCreation(NodeDetail nd)
On node creation, check if another node have got the same name with same fatherboolean
isSameNameSameLevelOnUpdate(NodeDetail nd)
On node update, check if another node have got the same name with same fathervoid
moveNode(NodePK nodePK, NodePK toNode)
Moves the specified node to the given another one that then will become its new father.void
moveNode(NodePK nodePK, NodePK toNode, boolean preserveRights)
Moves the specified node to the given another one that then will become its new father.void
processWysiwyg(NodePK nodePK)
A wysiwyg's content has been added or modified to a node.void
removeNode(NodePK pk)
Remove a node and its descendantsvoid
setDetail(NodeDetail nd)
Update the attributes of the nodevoid
sortNodes(List<NodePK> nodePKs)
Sorts the specified nodes in Silverpeas.void
updateRightsDependency(NodeDetail nodeDetail)
Updates the dependency on the access rights of the specified node.
-
-
-
Method Detail
-
delete
public void delete(String componentInstanceId)
Description copied from interface:ComponentInstanceDeletion
Deletes the resources belonging to the specified component instance. This method is invoked by Silverpeas when a component instance is being deleted.- Specified by:
delete
in interfaceComponentInstanceDeletion
- Parameters:
componentInstanceId
- the unique identifier of a component instance.
-
getDetailByNameAndFatherId
public NodeDetail getDetailByNameAndFatherId(NodePK pk, String name, int nodeFatherId)
Description copied from interface:NodeService
Gets complete details about the specified node with the given name and with as father the specified one.- Specified by:
getDetailByNameAndFatherId
in interfaceNodeService
- Parameters:
pk
- the node primary key.name
- the name of the node.nodeFatherId
- the local unique identifier of the father of the asked node.- Returns:
- a
NodeDetail
instance.
-
getDetail
public NodeDetail getDetail(NodePK pk)
Get the attributes of a node and of its children- Specified by:
getDetail
in interfaceNodeService
- Parameters:
pk
- the node primary key.- Returns:
- a NodeDetail
- Since:
- 1.0
- See Also:
NodeDetail
-
getTree
public List<NodeDetail> getTree(NodePK pk)
Description copied from interface:NodeService
Gets all the nodes that are part of the tree rooted from the specified node.- Specified by:
getTree
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the root node of the tree.- Returns:
- a list of nodes.
-
getSubTree
public List<NodeDetail> getSubTree(NodePK pk)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node.- Specified by:
getSubTree
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.- Returns:
- a list of nodes.
-
getSubTree
public List<NodeDetail> getSubTree(NodePK pk, String sorting)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node and sorted according to the sorting argument.- Specified by:
getSubTree
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.sorting
- a coma-separated list of node's attributes from which the returned list should be sorted.- Returns:
- a list of nodes.
-
getSubTreeByStatus
public List<NodeDetail> getSubTreeByStatus(NodePK pk, String status)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node and having the given status.- Specified by:
getSubTreeByStatus
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.status
- the status of the nodes to return.- Returns:
- a list of nodes.
-
getSubTreeByStatus
public List<NodeDetail> getSubTreeByStatus(NodePK pk, String status, String sorting)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node and having the given status.- Specified by:
getSubTreeByStatus
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.status
- the status of the nodes to return.sorting
- a coma-separated list of node's attributes from which the returned list should be sorted.- Returns:
- a list of nodes.
-
getSubTreeByLevel
public List<NodeDetail> getSubTreeByLevel(NodePK pk, int level)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node down to the given deep level of the subtree.- Specified by:
getSubTreeByLevel
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.level
- the level of the subtree to get.- Returns:
- a list of nodes from the specified node down to the given level of the subtree.
-
getSubTreeByLevel
public List<NodeDetail> getSubTreeByLevel(NodePK pk, int level, String sorting)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node down to the given deep level of the subtree.- Specified by:
getSubTreeByLevel
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.level
- the level of the subtree to get.sorting
- a coma-separated list of node's attributes from which the returned list should be sorted.- Returns:
- a list of nodes from the specified node down to the given level of the subtree.
-
getSubTree
public List<NodeDetail> getSubTree(NodePK pk, String status, int level, String sorting)
Description copied from interface:NodeService
Gets all the nodes that are part of the subtree from the specified node down to the given deep level of the subtree and having the given status.- Specified by:
getSubTree
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node from which the subtree should be returned.status
- the status of the nodes to return.level
- the level of the subtree to get.sorting
- a coma-separated list of node's attributes from which the returned list should be sorted.- Returns:
- a list of nodes.
-
moveNode
public void moveNode(NodePK nodePK, NodePK toNode)
Description copied from interface:NodeService
Moves the specified node to the given another one that then will become its new father.- Specified by:
moveNode
in interfaceNodeService
- Parameters:
nodePK
- the unique identifier of the node to move.toNode
- the unique identifier of the new father of the node.
-
moveNode
public void moveNode(NodePK nodePK, NodePK toNode, boolean preserveRights)
Description copied from interface:NodeService
Moves the specified node to the given another one that then will become its new father.- Specified by:
moveNode
in interfaceNodeService
- Parameters:
nodePK
- the unique identifier of the node to move.toNode
- the unique identifier of the new father of the node.preserveRights
- indicates if specific rights must be maintained or not
-
getHeader
public NodeDetail getHeader(NodePK pk, boolean getTranslations)
Description copied from interface:NodeService
Gets synthetic details about the specified node.- Specified by:
getHeader
in interfaceNodeService
- Parameters:
pk
- the node primary key.getTranslations
- a flag indicating if the translation has to be retrieved.- Returns:
- a
NodeDetail
instance.
-
getHeader
public NodeDetail getHeader(NodePK pk)
Get the attributes of THIS node- Specified by:
getHeader
in interfaceNodeService
- Parameters:
pk
- the node primary key.- Returns:
- a NodeDetail
- Since:
- 1.0
- See Also:
NodeDetail
-
setDetail
public void setDetail(NodeDetail nd)
Update the attributes of the node- Specified by:
setDetail
in interfaceNodeService
- Parameters:
nd
- the NodeDetail which contains updated data- Since:
- 1.0
- See Also:
NodeDetail
-
removeNode
public void removeNode(NodePK pk)
Remove a node and its descendants- Specified by:
removeNode
in interfaceNodeService
- Parameters:
pk
- the node PK to delete- Since:
- 1.0
- See Also:
NodePK
-
getPath
public NodePath getPath(NodePK pk)
Get the path of this node from this node to root- Specified by:
getPath
in interfaceNodeService
- Parameters:
pk
- The PK of the node- Returns:
- a NodeDetail Collection (only header)
- Since:
- 1.0
- See Also:
NodeDetail
,Collection
-
getChildrenDetails
public Collection<NodeDetail> getChildrenDetails(NodePK pk)
Get the header of each child of the node- Specified by:
getChildrenDetails
in interfaceNodeService
- Parameters:
pk
- the node primary key.- Returns:
- a NodeDetail collection
- Since:
- 1.0
- See Also:
NodeDetail
-
getHeadersByLevel
public List<NodeDetail> getHeadersByLevel(NodePK pk, int level)
Method declaration- Specified by:
getHeadersByLevel
in interfaceNodeService
- Parameters:
pk
-level
-- Returns:
-
getAllNodes
public Collection<NodeDetail> getAllNodes(NodePK nodePK)
Method declaration- Specified by:
getAllNodes
in interfaceNodeService
- Parameters:
nodePK
-- Returns:
-
getMinimalDataByInstances
public List<NodeDetail> getMinimalDataByInstances(Collection<String> instanceIds)
Description copied from interface:NodeService
Selects massively simple data about nodes.For now, only the following data are retrieved:
- nodeId
- instanceId
- rightsDependsOn
- Specified by:
getMinimalDataByInstances
in interfaceNodeService
- Parameters:
instanceIds
- the instance ids aimed.- Returns:
- a list of
NodeDetail
instances.
-
createNode
public NodePK createNode(NodeDetail node)
Description copied from interface:NodeService
Creates a new node in Silverpeas.- Specified by:
createNode
in interfaceNodeService
- Parameters:
node
- the details of the node to save.- Returns:
- the unique identifier of the new node.
-
createNode
public NodePK createNode(NodeDetail nd, NodeDetail fatherDetail)
Create a new Node object- Specified by:
createNode
in interfaceNodeService
- Parameters:
nd
- the NodeDetail which contains datafatherDetail
- the PK of the user who have create this node- Returns:
- the NodePK of the new Node
- Since:
- 1.0
- See Also:
NodeDetail
-
isSameNameSameLevelOnCreation
public boolean isSameNameSameLevelOnCreation(NodeDetail nd)
On node creation, check if another node have got the same name with same father- Specified by:
isSameNameSameLevelOnCreation
in interfaceNodeService
- Parameters:
nd
- A NodeDetail contains new node data to compare- Returns:
- true if there is already a node with same name with same father false else
- Since:
- 1.0
- See Also:
NodeDetail
-
isSameNameSameLevelOnUpdate
public boolean isSameNameSameLevelOnUpdate(NodeDetail nd)
On node update, check if another node have got the same name with same father- Specified by:
isSameNameSameLevelOnUpdate
in interfaceNodeService
- Parameters:
nd
- A NodeDetail contains new node data to compare- Returns:
- true if there is already a node with same name with same father false else
- Since:
- 1.0
- See Also:
NodeDetail
-
getChildrenPKs
public Collection<NodePK> getChildrenPKs(NodePK nodePK)
Get children node PKs of a node- Specified by:
getChildrenPKs
in interfaceNodeService
- Parameters:
nodePK
- A NodePK- Returns:
- A collection of NodePK
- Since:
- 1.0
- See Also:
NodePK
-
getDescendantPKs
public Collection<NodePK> getDescendantPKs(NodePK nodePK)
Get descendant node PKs of a node- Specified by:
getDescendantPKs
in interfaceNodeService
- Parameters:
nodePK
- A NodePK- Returns:
- A collection of NodePK
- Since:
- 1.0
- See Also:
NodePK
-
getDescendantDetails
public List<NodeDetail> getDescendantDetails(NodePK nodePK)
Get descendant node details of a node- Specified by:
getDescendantDetails
in interfaceNodeService
- Parameters:
nodePK
- A NodePK- Returns:
- A List of NodeDetail
- Since:
- 1.0
- See Also:
NodePK
-
getDescendantDetails
public List<NodeDetail> getDescendantDetails(NodeDetail node)
Get descendant node details of a node- Specified by:
getDescendantDetails
in interfaceNodeService
- Parameters:
node
- A NodeDetail- Returns:
- A List of NodeDetail
- Since:
- 4.07
- See Also:
NodeDetail
-
processWysiwyg
public void processWysiwyg(NodePK nodePK)
Description copied from interface:NodeService
A wysiwyg's content has been added or modified to a node. Its content must be added to the indexed content of the node- Specified by:
processWysiwyg
in interfaceNodeService
- Parameters:
nodePK
- the identifier of the node associated to the wysiwyg
-
updateRightsDependency
public void updateRightsDependency(NodeDetail nodeDetail)
Description copied from interface:NodeService
Updates the dependency on the access rights of the specified node.- Specified by:
updateRightsDependency
in interfaceNodeService
- Parameters:
nodeDetail
- a node.
-
sortNodes
public void sortNodes(List<NodePK> nodePKs)
Description copied from interface:NodeService
Sorts the specified nodes in Silverpeas.- Specified by:
sortNodes
in interfaceNodeService
- Parameters:
nodePKs
- a list of the unique identifiers of the nodes to sort.
-
createIndex
public void createIndex(NodeDetail nodeDetail)
Description copied from interface:NodeService
Indexes the specified node.- Specified by:
createIndex
in interfaceNodeService
- Parameters:
nodeDetail
- a node.
-
deleteIndex
public void deleteIndex(NodePK pk)
Called on : - removeNode()- Specified by:
deleteIndex
in interfaceNodeService
- Parameters:
pk
- the unique identifier of the node.
-
-