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
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final com.google.common.base.Splitterprotected ContentTreeContextprotected final ContentTreeServiceprotected final Entityprotected static final com.google.common.hash.HashFunctionprotected static final Stringprotected final org.slf4j.Loggerprotected final Mode<ContentException> A "default mode" that wrapsPersistExceptions intoContentExceptions.protected final ContentTreeNodeModelprotected static final Stringprotected final NodeServicePointHolderprotected static final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractContentTreeNode(Entity delegate, ContentTreeService contentTreeService, NodeServicePointHolder nodeServicePointHolder) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd an alias to the existing aliases.booleanIs true, if an alias applies to the child nodes, else false.booleanDetermine if aliases have changed (in current transaction).copy(CopyContentTreeNodeParams params) Copy the current ContentTreeNodeprotected voidcopyChild(ContentTreeNode child, CopyContentTreeNodeParams params) Copy the child node.protected voidcopyChildren(ContentTreeNode original, CopyContentTreeNodeParams params) Copy all child nodes.protected voidcopyRelation(String relationName, Entity originalDelegate) protected voiddecorateCopy(ContentTreeNode original) Post process this created copy of theoriginal.protected EntityTreeNodedecorateTreeNode(EntityTreeNode treeNode) voiddelete()recursively delete the current ContentTreeNodebooleanGet 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 CopyContentTreeNodeParamsgetChildCopyParams(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) longReturns the over "relContent" related entity.@Nullable EntityDoes not check permission of content entity (privileged for performance reasons).Returns the over "relContent_published" related entity.protected StringGet 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 EntitygetNodeRight(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 EntitygetOrCreateNodeRight(String role, ContentNodePermission permission) add a new Node_right entity@Nullable ContentTreeNodegetPath()Get the path part of this node.getPaths()Get all full paths of this node (without aliases).Get thePublishStatusor PUBLISHED if no publish status is available on node.getRoot()<T extends ContentTreeNode>
TbooleanbooleanReturns true if a child with the name (case-insensitive check) exist.booleanbooleanhasContentReadPermission(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.inthashCode()booleanReturns whether you are allowed to edit the permissions for this node.protected <V> VinvokePrivileged(Callable<V> callable) booleanisChildOf(ContentTreeNode parentNode) booleanDetermine if at least one of the child relations has changed (in current transaction).booleanprotected abstract booleanbooleanDetermine if parent relation has changed (in current transaction).booleanDetermine if path part has changed (in current transaction).protected booleanbooleanisRoot()Determine if the node is a root node.booleanSystem nodes are nodes in the content tree that are generated by the system.booleanvoidmoveInto(ContentTreeNode parentNode) move the currentContentTreeNodeintoparentNodeprotected StringnormalizeAliases(String aliases) protected StringnormalizeName(String name) perform(Mode<E> mode, PersistTask<Entity, V> task) protected StringreadString(Entity entity, String name) protected StringreadStringPrivileged(String name) voidremoveNodeRight(String role, ContentNodePermission permission) remove a Node_right entity from this nodeThe same asContentTreeNode.getParent(), but the return value is not nullable and aIllegalStateExceptionis thrown if the parent is null.voidShould only be used internally.voidsetAliases(String aliases) voidsetContentTreeContext(ContentTreeContext context) voidSets the human readable label for this node.voidSets the name for this node.voidsetParent(ContentTreeNode parentNode) protected voidsetPublishStatus(PublishStatus status) voidsetSorting(Integer sorting) protected voidprotected voidtoString()booleanverifyChecksum(String checksum) Checks if the given checksum matches the checksum of this node.booleanverifyName(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, waitMethods 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 wrapsPersistExceptions intoContentExceptions. -
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:ContentTreeNodeReturns the model of this node.- Specified by:
getModelin interfaceContentTreeNode- Returns:
- the model of the node.
-
getName
Description copied from interface:ContentTreeNodeReturns this node's name. The name is a normalized string used in URLs to identify this node.- Specified by:
getNamein interfaceContentTreeNode
-
setName
Description copied from interface:ContentTreeNodeSets the name for this node. The method takes care of properly normalizing the `name` argument.- Specified by:
setNamein interfaceContentTreeNode
-
setLabel
Description copied from interface:ContentTreeNodeSets 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:
setLabelin interfaceContentTreeNode
-
getLabel
Description copied from interface:ContentTreeNodeReturns the human readable label for this node.- Specified by:
getLabelin interfaceContentTreeNode
-
setSorting
- Specified by:
setSortingin interfaceContentTreeNode
-
getSorting
- Specified by:
getSortingin interfaceContentTreeNode
-
hasAliases
public boolean hasAliases()- Specified by:
hasAliasesin interfaceContentTreeNode
-
areAliasesChanged
public boolean areAliasesChanged()Description copied from interface:ContentTreeNodeDetermine if aliases have changed (in current transaction).- Specified by:
areAliasesChangedin interfaceContentTreeNode- Returns:
- true, if the aliases have changed, else false.
-
aliasesApplyRecursive
public boolean aliasesApplyRecursive()Description copied from interface:ContentTreeNodeIs 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:
aliasesApplyRecursivein interfaceContentTreeNode
-
getAliases
- Specified by:
getAliasesin interfaceContentTreeNode- Returns:
- all aliases of this ContentTreeNode as a string.
- Throws:
ContentException- See Also:
-
getAliasesSet
Description copied from interface:ContentTreeNodeSame asContentTreeNode.getAliases(), but aliases are split (not a multiline string).- Specified by:
getAliasesSetin interfaceContentTreeNode
-
setAliases
- Specified by:
setAliasesin interfaceContentTreeNode- See Also:
-
addAlias
Description copied from interface:ContentTreeNodeAdd an alias to the existing aliases.- Specified by:
addAliasin interfaceContentTreeNode- Parameters:
alias- The new alias to add.
-
getChildren
Description copied from interface:ContentTreeNodeThe 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:
getChildrenin 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:ContentTreeNodeSame asContentTreeNode.getChildren(), but fetches only the requested subset.- Specified by:
getChildrenin 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:
getChildrenCountin interfaceContentTreeNode- Returns:
- the total number of children (that are readable by the current user).
-
hasChildren
- Specified by:
hasChildrenin interfaceContentTreeNode- Throws:
ContentException
-
getChildren
public Iterable<ContentTreeNode> getChildren(Predicate<ContentTreeNode> filter) throws ContentException - Specified by:
getChildrenin 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:
isChildOfin 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:
hasChildin 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:ContentTreeNodeReturns child if the node has a child with the given name.- Specified by:
getChildin interfaceContentTreeNode- Parameters:
name- The name of the child.
-
getParent
- Specified by:
getParentin interfaceContentTreeNode- Returns:
- the parent node of the current ContentTreeNode
- Throws:
ContentException- See Also:
-
setParent
- Specified by:
setParentin interfaceContentTreeNode- Throws:
ContentException
-
requireParent
Description copied from interface:ContentTreeNodeThe same asContentTreeNode.getParent(), but the return value is not nullable and aIllegalStateExceptionis thrown if the parent is null.- Specified by:
requireParentin interfaceContentTreeNode- Returns:
- the parent node of the current ContentTreeNode
- Throws:
ContentException
-
getRoot
- Specified by:
getRootin 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:ContentTreeNodeDetermine if the node is a root node.- Specified by:
isRootin interfaceContentTreeNode- Returns:
- true, if the node is a root node, else false.
-
getRoot
- Specified by:
getRootin interfaceContentTreeNode- Throws:
ContentException- See Also:
-
getPaths
Description copied from interface:ContentTreeNodeGet all full paths of this node (without aliases).- Specified by:
getPathsin interfaceContentTreeNode- Returns:
- all full paths of the node (without aliases).
-
getOldPaths
Description copied from interface:ContentTreeNodeGet 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:
getOldPathsin interfaceContentTreeNode- Returns:
- all old full paths of the node (without aliases).
-
getPath
- Specified by:
getPathin interfaceContentTreeNode- Returns:
- the full path of the current ContentTreeNode
- Throws:
ContentException
-
getOldPath
Description copied from interface:ContentTreeNodeThe *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:
getOldPathin interfaceContentTreeNode- Returns:
- the old full path of the node.
- See Also:
-
getOptimalPath
- Specified by:
getOptimalPathin interfaceContentTreeNode- Returns:
- the optimal full path of the current ContentTreeNode
- Throws:
ContentException
-
getOptimalPathForRequest
- Specified by:
getOptimalPathForRequestin 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:ContentTreeNodeGet the admin URL of this node.- Specified by:
getAdminUrlin interfaceContentTreeNode- Returns:
- the admin URL.
-
getPathPart
Description copied from interface:ContentTreeNodeGet 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:
getPathPartin interfaceContentTreeNode- Returns:
- the path part of this node.
-
getOldPathPart
Description copied from interface:ContentTreeNodeGet 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:
getOldPathPartin interfaceContentTreeNode- Returns:
- the old path part.
- See Also:
-
getNodeRights
- Specified by:
getNodeRightsin interfaceContentTreeNode- Returns:
- an
EntityListof Node_rights of this node
-
getNodeRight
Description copied from interface:ContentTreeNodeget Node_right entity (if it esxists)- Specified by:
getNodeRightin 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:ContentTreeNodeadd a new Node_right entity- Specified by:
getOrCreateNodeRightin 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:ContentTreeNoderemove a Node_right entity from this node- Specified by:
removeNodeRightin interfaceContentTreeNode- Parameters:
role- unique_id of the role entitypermission- unique_id of the permission entity
-
getAvailablePermissions
- Specified by:
getAvailablePermissionsin interfaceContentTreeNode- Returns:
- a set of available permissions for this node
-
getPermissionsForChildren
- Specified by:
getPermissionsForChildrenin interfaceContentTreeNode- Returns:
- a set of permissions for this node's children
-
delete
Description copied from interface:ContentTreeNoderecursively delete the current ContentTreeNode- Specified by:
deletein interfaceContentTreeNode- Throws:
ContentException
-
isEntityDocsNode
protected abstract boolean isEntityDocsNode() -
copy
Description copied from interface:ContentTreeNodeCopy the current ContentTreeNode- Specified by:
copyin interfaceContentTreeNode- Returns:
- the copied ContentTreeNode
- Throws:
ContentException
-
decorateCopy
Post process this created copy of theoriginal.- Parameters:
original-ContentTreeNodethat 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:
getTreeNodein interfaceContentTreeNode- Returns:
- TreeNode representation for the current ContentTreeNode for use in a DwrTreePanel
- Throws:
ContentException
-
getDelegate
- Specified by:
getDelegatein interfaceContentTreeNode
-
setContentTreeContext
- Specified by:
setContentTreeContextin interfaceContentTreeNode
-
getContentTreeContext
- Specified by:
getContentTreeContextin interfaceContentTreeNode
-
getDefaultPublicContentTreeContext
- Specified by:
getDefaultPublicContentTreeContextin interfaceContentTreeNode
-
isSystemNode
public boolean isSystemNode()Description copied from interface:ContentTreeNodeSystem nodes are nodes in the content tree that are generated by the system.- Specified by:
isSystemNodein interfaceContentTreeNode- Returns:
- true if this
ContentTreeNodeis a system node, false otherwise
-
getContent
Description copied from interface:ContentTreeNodeReturns the over "relContent" related entity.- Specified by:
getContentin interfaceContentTreeNode
-
getContentPublished
Description copied from interface:ContentTreeNodeReturns the over "relContent_published" related entity.- Specified by:
getContentPublishedin interfaceContentTreeNode
-
isCurrentlyPublished
public boolean isCurrentlyPublished()- Specified by:
isCurrentlyPublishedin 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:ContentTreeNodeDetermine if path part has changed (in current transaction).- Specified by:
isPathPartChangedin interfaceContentTreeNode- Returns:
- true, if the path part has changed, else false.
- See Also:
-
isParentRelationChanged
public boolean isParentRelationChanged()Description copied from interface:ContentTreeNodeDetermine if parent relation has changed (in current transaction).- Specified by:
isParentRelationChangedin interfaceContentTreeNode- Returns:
- true, if the parent relation has changed, else false.
-
isChildRelationChanged
public boolean isChildRelationChanged()Description copied from interface:ContentTreeNodeDetermine if at least one of the child relations has changed (in current transaction).- Specified by:
isChildRelationChangedin interfaceContentTreeNode- Returns:
- true, if the child relation has changed, else false.
-
verifyChecksum
Description copied from interface:ContentTreeNodeChecks if the given checksum matches the checksum of this node.- Specified by:
verifyChecksumin interfaceContentTreeNode- Parameters:
checksum- The checksum to check.- Returns:
- true, if the checksum matches, else false.
-
verifyName
Description copied from interface:ContentTreeNodeChecks if the given name matches the name of this node.- Specified by:
verifyNamein interfaceContentTreeNode
-
getChecksum
Description copied from interface:ContentTreeNodeGet the checksum of this node.- Specified by:
getChecksumin interfaceContentTreeNode- Returns:
- the checksum of this node.
- Throws:
ContentException
-
decorateTreeNode
- Throws:
ContentException
-
moveInto
Description copied from interface:ContentTreeNodemove the currentContentTreeNodeintoparentNode- Specified by:
moveIntoin 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:ContentTreeNodeDoes 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:
getContentEntityin interfaceContentTreeNode- Throws:
ContentException- See Also:
-
hasContentReadPermission
public boolean hasContentReadPermission(boolean checkPathOnly) Description copied from interface:ContentTreeNodeReturns 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:
hasContentReadPermissionin interfaceContentTreeNode
-
isPrivileged
protected boolean isPrivileged() -
hasPermissionEditPermission
public boolean hasPermissionEditPermission()Description copied from interface:ContentTreeNodeReturns whether you are allowed to edit the permissions for this node.- Specified by:
hasPermissionEditPermissionin interfaceContentTreeNode
-
getBusinessUnit
- Specified by:
getBusinessUnitin interfaceContentTreeNode- Returns:
- the business unit of the current node element
-
getBusinessUnitInvoker
- Specified by:
getBusinessUnitInvokerin interfaceContentTreeNode- Returns:
- an
Invokerfor the business unit of this node or an empty invoker if there is no associated business unit
-
getCopySource
Description copied from interface:ContentTreeNodeGet the source node if this node is a copy.- Specified by:
getCopySourcein interfaceContentTreeNode- Returns:
- the source node if this node is a copy.
-
resetChildren
public void resetChildren()Description copied from interface:ContentTreeNodeShould only be used internally. Resets children cache.- Specified by:
resetChildrenin interfaceContentTreeNode
-
getPublishStatus
Description copied from interface:ContentTreeNodeGet thePublishStatusor PUBLISHED if no publish status is available on node.- Specified by:
getPublishStatusin interfaceContentTreeNode
-
setPublishStatus
-
invokePrivileged
-
copyRelation
-