Package ch.tocco.nice2.dms.spi.tree
Class AbstractContentTreeNode
java.lang.Object
ch.tocco.nice2.dms.spi.tree.AbstractContentTreeNode
- All Implemented Interfaces:
ContentTreeNode
- Direct Known Subclasses:
BinaryContentImpl
,DomainNodeImpl
,FolderNodeImpl
,PageNodeImpl
,ResourceNodeImpl
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final com.google.common.base.Splitter
protected ContentTreeContext
protected final ContentTreeService
protected final Entity
protected static final com.google.common.hash.HashFunction
protected static final String
protected final org.slf4j.Logger
protected final Mode
<ContentException> A "default mode" that wrapsPersistException
s intoContentException
s.protected final ContentTreeNodeModel
protected static final String
protected final NodeServicePointHolder
protected static final String
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractContentTreeNode
(Entity delegate, ContentTreeService contentTreeService, NodeServicePointHolder nodeServicePointHolder) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an alias to the existing aliases.boolean
Is true, if an alias applies to the child nodes, else false.boolean
Determine if aliases have changed (in current transaction).copy
(CopyContentTreeNodeParams params) Copy the current ContentTreeNodeprotected void
copyChild
(ContentTreeNode child, CopyContentTreeNodeParams params) Copy the child node.protected void
copyChildren
(ContentTreeNode original, CopyContentTreeNodeParams params) Copy all child nodes.protected void
copyRelation
(String relationName, Entity originalDelegate) protected void
decorateCopy
(ContentTreeNode original) Post process this created copy of theoriginal
.protected EntityTreeNode
decorateTreeNode
(EntityTreeNode treeNode) void
delete()
recursively delete the current ContentTreeNodeboolean
Get the admin URL of this node.Same asContentTreeNode.getAliases()
, but aliases are split (not a multiline string).Get the checksum of this node.Returns child if the node has a child with the given name.protected CopyContentTreeNodeParams
getChildCopyParams
(CopyContentTreeNodeParams rootParams) Get the copy params for the child nodes.The iterable returned is a "lazy-loading" view that only creates ContentTreeNode objects upon iterating over the iterable.getChildren
(Pagination pagination, @Nullable String sort) Same asContentTreeNode.getChildren()
, but fetches only the requested subset.getChildren
(Predicate<ContentTreeNode> filter) long
Returns the over "relContent" related entity.@Nullable Entity
Does not check permission of content entity (privileged for performance reasons).Returns the over "relContent_published" related entity.protected String
Get the source node if this node is a copy.getLabel()
Returns the human readable label for this node.getModel()
Returns the model of this node.getName()
Returns this node's name.@Nullable Entity
getNodeRight
(String role, ContentNodePermission permission) get Node_right entity (if it esxists)The *old* full path of the current ContentTreeNode.Get the old path part of this node.Get the *old* full paths of this node (without aliases).getOptimalPathForRequest
(String requestUrl) @Nullable Entity
getOrCreateNodeRight
(String role, ContentNodePermission permission) add a new Node_right entity@Nullable ContentTreeNode
getPath()
Get the path part of this node.getPaths()
Get all full paths of this node (without aliases).Get thePublishStatus
or PUBLISHED if no publish status is available on node.getRoot()
<T extends ContentTreeNode>
Tboolean
boolean
Returns true if a child with the name (case-insensitive check) exist.boolean
boolean
hasContentReadPermission
(boolean checkPathOnly) Returns whether you can read this node's content, but assumes that the content entity is readable and that only additional paths need to be checked.int
hashCode()
boolean
Returns whether you are allowed to edit the permissions for this node.protected <V> V
invokePrivileged
(Callable<V> callable) boolean
isChildOf
(ContentTreeNode parentNode) boolean
Determine if at least one of the child relations has changed (in current transaction).boolean
protected abstract boolean
boolean
Determine if parent relation has changed (in current transaction).boolean
Determine if path part has changed (in current transaction).protected boolean
boolean
isRoot()
Determine if the node is a root node.boolean
System nodes are nodes in the content tree that are generated by the system.boolean
void
moveInto
(ContentTreeNode parentNode) move the currentContentTreeNode
intoparentNode
protected String
normalizeAliases
(String aliases) protected String
normalizeName
(String name) perform
(Mode<E> mode, PersistTask<Entity, V> task) protected String
readString
(Entity entity, String name) protected String
readStringPrivileged
(String name) void
removeNodeRight
(String role, ContentNodePermission permission) remove a Node_right entity from this nodeThe same asContentTreeNode.getParent()
, but the return value is not nullable and aIllegalStateException
is thrown if the parent is null.void
Should only be used internally.void
setAliases
(String aliases) void
setContentTreeContext
(ContentTreeContext context) void
Sets the human readable label for this node.void
Sets the name for this node.void
setParent
(ContentTreeNode parentNode) protected void
setPublishStatus
(PublishStatus status) void
setSorting
(Integer sorting) protected void
protected void
toString()
boolean
verifyChecksum
(String checksum) Checks if the given checksum matches the checksum of this node.boolean
verifyName
(String name) Checks if the given name matches the name of this node.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.dms.api.tree.ContentTreeNode
hasContentReadPermission, moveAbove, moveBelow
-
Field Details
-
log
protected final org.slf4j.Logger log -
HASH_FUNCTION
protected static final com.google.common.hash.HashFunction HASH_FUNCTION -
ALIAS_SPLITTER
protected static final com.google.common.base.Splitter ALIAS_SPLITTER -
URL_FIELD_NAME
- See Also:
-
ALIAS_FIELD_NAME
- See Also:
-
NAME_FIELD_NAME
- See Also:
-
LABEL_FIELD_NAME
- See Also:
-
mode
A "default mode" that wrapsPersistException
s intoContentException
s. -
delegate
-
model
-
nodeServicePointHolder
-
contentTreeService
-
contentTreeContext
-
-
Constructor Details
-
AbstractContentTreeNode
protected AbstractContentTreeNode(Entity delegate, ContentTreeService contentTreeService, NodeServicePointHolder nodeServicePointHolder)
-
-
Method Details
-
perform
protected <V,E extends Exception> Optional<V> perform(Mode<E> mode, PersistTask<Entity, V> task) throws E- Throws:
E
-
getModel
Description copied from interface:ContentTreeNode
Returns the model of this node.- Specified by:
getModel
in interfaceContentTreeNode
- Returns:
- the model of the node.
-
getName
Description copied from interface:ContentTreeNode
Returns this node's name. The name is a normalized string used in URLs to identify this node.- Specified by:
getName
in interfaceContentTreeNode
-
setName
Description copied from interface:ContentTreeNode
Sets the name for this node. The method takes care of properly normalizing the `name` argument.- Specified by:
setName
in interfaceContentTreeNode
-
setLabel
Description copied from interface:ContentTreeNode
Sets the human readable label for this node. If this node does not have a `name` set, a name value is generated from the given label and set for this node.- Specified by:
setLabel
in interfaceContentTreeNode
-
getLabel
Description copied from interface:ContentTreeNode
Returns the human readable label for this node.- Specified by:
getLabel
in interfaceContentTreeNode
-
setSorting
- Specified by:
setSorting
in interfaceContentTreeNode
-
getSorting
- Specified by:
getSorting
in interfaceContentTreeNode
-
hasAliases
public boolean hasAliases()- Specified by:
hasAliases
in interfaceContentTreeNode
-
areAliasesChanged
public boolean areAliasesChanged()Description copied from interface:ContentTreeNode
Determine if aliases have changed (in current transaction).- Specified by:
areAliasesChanged
in interfaceContentTreeNode
- Returns:
- true, if the aliases have changed, else false.
-
aliasesApplyRecursive
public boolean aliasesApplyRecursive()Description copied from interface:ContentTreeNode
Is true, if an alias applies to the child nodes, else false. This means: If aliases of this node apply recursive and this node has an alias "http://www.example.com" and there is a child node named "child", then "http://www.example.com/child" would resolve the child node.- Specified by:
aliasesApplyRecursive
in interfaceContentTreeNode
-
getAliases
- Specified by:
getAliases
in interfaceContentTreeNode
- Returns:
- all aliases of this ContentTreeNode as a string.
- Throws:
ContentException
- See Also:
-
getAliasesSet
Description copied from interface:ContentTreeNode
Same asContentTreeNode.getAliases()
, but aliases are split (not a multiline string).- Specified by:
getAliasesSet
in interfaceContentTreeNode
-
setAliases
- Specified by:
setAliases
in interfaceContentTreeNode
- See Also:
-
addAlias
Description copied from interface:ContentTreeNode
Add an alias to the existing aliases.- Specified by:
addAlias
in interfaceContentTreeNode
- Parameters:
alias
- The new alias to add.
-
getChildren
Description copied from interface:ContentTreeNode
The iterable returned is a "lazy-loading" view that only creates ContentTreeNode objects upon iterating over the iterable. It is recommended to callContentTreeNode.hasChildren()
in order to find out if this node has any children.- Specified by:
getChildren
in interfaceContentTreeNode
- Returns:
- child nodes of the current ContentTreeNode
- See Also:
-
getChildren
public Iterable<ContentTreeNode> getChildren(Pagination pagination, @Nullable @Nullable String sort) Description copied from interface:ContentTreeNode
Same asContentTreeNode.getChildren()
, but fetches only the requested subset.- Specified by:
getChildren
in interfaceContentTreeNode
- Parameters:
pagination
- the bounds of the requested subset with offset and limitsort
- comma separated string of fields to sort by- Returns:
- child nodes subset of the current ContentTreeNode
-
getChildrenCount
public long getChildrenCount()- Specified by:
getChildrenCount
in interfaceContentTreeNode
- Returns:
- the total number of children (that are readable by the current user).
-
hasChildren
- Specified by:
hasChildren
in interfaceContentTreeNode
- Throws:
ContentException
-
getChildren
public Iterable<ContentTreeNode> getChildren(Predicate<ContentTreeNode> filter) throws ContentException - Specified by:
getChildren
in interfaceContentTreeNode
- Parameters:
filter
- a filter to be applied to each child for filtering the result- Returns:
- filtered child nodes of the current ContentTreeNode
- Throws:
ContentException
-
isChildOf
- Specified by:
isChildOf
in interfaceContentTreeNode
- Returns:
- true if current node is a child of @param parentNode, otherwise false.
- Throws:
ContentException
-
hasChild
Returns true if a child with the name (case-insensitive check) exist.- Specified by:
hasChild
in interfaceContentTreeNode
- Parameters:
name
- The name of the child.- Returns:
- true, if the node has a child with the given name, else false.
-
getChild
Description copied from interface:ContentTreeNode
Returns child if the node has a child with the given name.- Specified by:
getChild
in interfaceContentTreeNode
- Parameters:
name
- The name of the child.
-
getParent
- Specified by:
getParent
in interfaceContentTreeNode
- Returns:
- the parent node of the current ContentTreeNode
- Throws:
ContentException
- See Also:
-
setParent
- Specified by:
setParent
in interfaceContentTreeNode
- Throws:
ContentException
-
requireParent
Description copied from interface:ContentTreeNode
The same asContentTreeNode.getParent()
, but the return value is not nullable and aIllegalStateException
is thrown if the parent is null.- Specified by:
requireParent
in interfaceContentTreeNode
- Returns:
- the parent node of the current ContentTreeNode
- Throws:
ContentException
-
getRoot
- Specified by:
getRoot
in interfaceContentTreeNode
- Returns:
- The root node of the tree this node pertains to. Absent value can be returned when required permissions are not available.
- Throws:
ContentException
-
isRoot
public boolean isRoot()Description copied from interface:ContentTreeNode
Determine if the node is a root node.- Specified by:
isRoot
in interfaceContentTreeNode
- Returns:
- true, if the node is a root node, else false.
-
getRoot
- Specified by:
getRoot
in interfaceContentTreeNode
- Throws:
ContentException
- See Also:
-
getPaths
Description copied from interface:ContentTreeNode
Get all full paths of this node (without aliases).- Specified by:
getPaths
in interfaceContentTreeNode
- Returns:
- all full paths of the node (without aliases).
-
getOldPaths
Description copied from interface:ContentTreeNode
Get the *old* full paths of this node (without aliases). This is different fromContentTreeNode.getPaths()
, if the path part of this node or of a parent node has changed in the current transaction.- Specified by:
getOldPaths
in interfaceContentTreeNode
- Returns:
- all old full paths of the node (without aliases).
-
getPath
- Specified by:
getPath
in interfaceContentTreeNode
- Returns:
- the full path of the current ContentTreeNode
- Throws:
ContentException
-
getOldPath
Description copied from interface:ContentTreeNode
The *old* full path of the current ContentTreeNode. This is different fromContentTreeNode.getPath()
, if the path part of this node or of a parent node has changed in the current transaction.- Specified by:
getOldPath
in interfaceContentTreeNode
- Returns:
- the old full path of the node.
- See Also:
-
getOptimalPath
- Specified by:
getOptimalPath
in interfaceContentTreeNode
- Returns:
- the optimal full path of the current ContentTreeNode
- Throws:
ContentException
-
getOptimalPathForRequest
- Specified by:
getOptimalPathForRequest
in interfaceContentTreeNode
- Returns:
- the optimal path of the current ContentTreeNode which does not contain authority if possible and uses same alias as request if possible
- Throws:
ContentException
-
getAdminUrl
Description copied from interface:ContentTreeNode
Get the admin URL of this node.- Specified by:
getAdminUrl
in interfaceContentTreeNode
- Returns:
- the admin URL.
-
getPathPart
Description copied from interface:ContentTreeNode
Get the path part of this node. The full path of a node is put together from the path parts of the node and of all parent nodes.- Specified by:
getPathPart
in interfaceContentTreeNode
- Returns:
- the path part of this node.
-
getOldPathPart
Description copied from interface:ContentTreeNode
Get the old path part of this node. This is different fromContentTreeNode.getPathPart()
if the path part of this node or of a parent node has changed in the current transaction.- Specified by:
getOldPathPart
in interfaceContentTreeNode
- Returns:
- the old path part.
- See Also:
-
getNodeRights
- Specified by:
getNodeRights
in interfaceContentTreeNode
- Returns:
- an
EntityList
of Node_rights of this node
-
getNodeRight
Description copied from interface:ContentTreeNode
get Node_right entity (if it esxists)- Specified by:
getNodeRight
in interfaceContentTreeNode
- Parameters:
role
- unique_id of the role entitypermission
- unique_id of the permission entity- Returns:
- the Node_right entity or null
-
getOrCreateNodeRight
@Nullable public @Nullable Entity getOrCreateNodeRight(String role, ContentNodePermission permission) Description copied from interface:ContentTreeNode
add a new Node_right entity- Specified by:
getOrCreateNodeRight
in interfaceContentTreeNode
- Parameters:
role
- unique_id of the role entitypermission
- unique_id of the permission entity- Returns:
- the loaded or created Node_right entity, null if it cannot be created because the requested permission is not available for this node type
-
removeNodeRight
Description copied from interface:ContentTreeNode
remove a Node_right entity from this node- Specified by:
removeNodeRight
in interfaceContentTreeNode
- Parameters:
role
- unique_id of the role entitypermission
- unique_id of the permission entity
-
getAvailablePermissions
- Specified by:
getAvailablePermissions
in interfaceContentTreeNode
- Returns:
- a set of available permissions for this node
-
getPermissionsForChildren
- Specified by:
getPermissionsForChildren
in interfaceContentTreeNode
- Returns:
- a set of permissions for this node's children
-
delete
Description copied from interface:ContentTreeNode
recursively delete the current ContentTreeNode- Specified by:
delete
in interfaceContentTreeNode
- Throws:
ContentException
-
isEntityDocsNode
protected abstract boolean isEntityDocsNode() -
copy
Description copied from interface:ContentTreeNode
Copy the current ContentTreeNode- Specified by:
copy
in interfaceContentTreeNode
- Returns:
- the copied ContentTreeNode
- Throws:
ContentException
-
decorateCopy
Post process this created copy of theoriginal
.- Parameters:
original
-ContentTreeNode
that was just copied
-
getChildCopyParams
Get the copy params for the child nodes.- Parameters:
rootParams
- The copy params for the root node to copy.- Returns:
- the copy params for the child nodes.
-
copyChildren
Copy all child nodes.- Parameters:
original
- The original root node.
-
copyChild
Copy the child node.- Parameters:
child
- The child to copy.params
- The copy params.
-
getTreeNode
- Specified by:
getTreeNode
in interfaceContentTreeNode
- Returns:
- TreeNode representation for the current ContentTreeNode for use in a DwrTreePanel
- Throws:
ContentException
-
getDelegate
- Specified by:
getDelegate
in interfaceContentTreeNode
-
setContentTreeContext
- Specified by:
setContentTreeContext
in interfaceContentTreeNode
-
getContentTreeContext
- Specified by:
getContentTreeContext
in interfaceContentTreeNode
-
getDefaultPublicContentTreeContext
- Specified by:
getDefaultPublicContentTreeContext
in interfaceContentTreeNode
-
isSystemNode
public boolean isSystemNode()Description copied from interface:ContentTreeNode
System nodes are nodes in the content tree that are generated by the system.- Specified by:
isSystemNode
in interfaceContentTreeNode
- Returns:
- true if this
ContentTreeNode
is a system node, false otherwise
-
getContent
Description copied from interface:ContentTreeNode
Returns the over "relContent" related entity.- Specified by:
getContent
in interfaceContentTreeNode
-
getContentPublished
Description copied from interface:ContentTreeNode
Returns the over "relContent_published" related entity.- Specified by:
getContentPublished
in interfaceContentTreeNode
-
isCurrentlyPublished
public boolean isCurrentlyPublished()- Specified by:
isCurrentlyPublished
in interfaceContentTreeNode
- Returns:
- true if this node has publish dates (published_from and published_until) which are valid for the current date
-
isPathPartChanged
public boolean isPathPartChanged()Description copied from interface:ContentTreeNode
Determine if path part has changed (in current transaction).- Specified by:
isPathPartChanged
in interfaceContentTreeNode
- Returns:
- true, if the path part has changed, else false.
- See Also:
-
isParentRelationChanged
public boolean isParentRelationChanged()Description copied from interface:ContentTreeNode
Determine if parent relation has changed (in current transaction).- Specified by:
isParentRelationChanged
in interfaceContentTreeNode
- Returns:
- true, if the parent relation has changed, else false.
-
isChildRelationChanged
public boolean isChildRelationChanged()Description copied from interface:ContentTreeNode
Determine if at least one of the child relations has changed (in current transaction).- Specified by:
isChildRelationChanged
in interfaceContentTreeNode
- Returns:
- true, if the child relation has changed, else false.
-
verifyChecksum
Description copied from interface:ContentTreeNode
Checks if the given checksum matches the checksum of this node.- Specified by:
verifyChecksum
in interfaceContentTreeNode
- Parameters:
checksum
- The checksum to check.- Returns:
- true, if the checksum matches, else false.
-
verifyName
Description copied from interface:ContentTreeNode
Checks if the given name matches the name of this node.- Specified by:
verifyName
in interfaceContentTreeNode
-
getChecksum
Description copied from interface:ContentTreeNode
Get the checksum of this node.- Specified by:
getChecksum
in interfaceContentTreeNode
- Returns:
- the checksum of this node.
- Throws:
ContentException
-
decorateTreeNode
- Throws:
ContentException
-
moveInto
Description copied from interface:ContentTreeNode
move the currentContentTreeNode
intoparentNode
- Specified by:
moveInto
in interfaceContentTreeNode
- Parameters:
parentNode
- becomes the new parent of thisContentTreeNode
- Throws:
ContentException
-
normalizeName
-
normalizeAliases
-
readStringPrivileged
-
readString
-
setValue
-
setValue
-
equals
-
hashCode
public int hashCode() -
toString
-
getContentRelation
- Throws:
ContentException
-
getContentEntity
Description copied from interface:ContentTreeNode
Does not check permission of content entity (privileged for performance reasons). It assumes that you have read permission when you can read the node itself (same acl).- Specified by:
getContentEntity
in interfaceContentTreeNode
- Throws:
ContentException
- See Also:
-
hasContentReadPermission
public boolean hasContentReadPermission(boolean checkPathOnly) Description copied from interface:ContentTreeNode
Returns whether you can read this node's content, but assumes that the content entity is readable and that only additional paths need to be checked. This can be used when it is *known* that the content node is readable to optimize performance.- Specified by:
hasContentReadPermission
in interfaceContentTreeNode
-
isPrivileged
protected boolean isPrivileged() -
hasPermissionEditPermission
public boolean hasPermissionEditPermission()Description copied from interface:ContentTreeNode
Returns whether you are allowed to edit the permissions for this node.- Specified by:
hasPermissionEditPermission
in interfaceContentTreeNode
-
getBusinessUnit
- Specified by:
getBusinessUnit
in interfaceContentTreeNode
- Returns:
- the business unit of the current node element
-
getBusinessUnitInvoker
- Specified by:
getBusinessUnitInvoker
in interfaceContentTreeNode
- Returns:
- an
Invoker
for the business unit of this node or an empty invoker if there is no associated business unit
-
getCopySource
Description copied from interface:ContentTreeNode
Get the source node if this node is a copy.- Specified by:
getCopySource
in interfaceContentTreeNode
- Returns:
- the source node if this node is a copy.
-
resetChildren
public void resetChildren()Description copied from interface:ContentTreeNode
Should only be used internally. Resets children cache.- Specified by:
resetChildren
in interfaceContentTreeNode
-
getPublishStatus
Description copied from interface:ContentTreeNode
Get thePublishStatus
or PUBLISHED if no publish status is available on node.- Specified by:
getPublishStatus
in interfaceContentTreeNode
-
setPublishStatus
-
invokePrivileged
-
copyRelation
-