Package com.logicaldoc.core.security.dao
Interface MenuDAO
- All Superinterfaces:
PersistentObjectDAO<Menu>
- All Known Implementing Classes:
HibernateMenuDAO
Instances of this class is a DAO-service for menu objects.
- Version:
- 1.0
- Author:
- Michael Scholz
-
Field Summary
Fields inherited from interface com.logicaldoc.core.PersistentObjectDAO
ENTITY
-
Method Summary
Modifier and TypeMethodDescriptionboolean
applyRightToTree
(long id) Propagates the security policies of a node to the whole subtreecomputePathExtended
(long id) Dynamically computes the path extended for the specified menu.createPath
(long parentId, long tenantId, int type, String path, boolean inheritSecurity) Creates the menu for the specified path.findByGroupId
(long groupId) Finds all menus accessible by the passed groupfindByName
(Menu parent, String name, boolean caseSensitive) Finds all menus by menu text, contained in the parent menufindByName
(String name) Finds all menus by menu text.findByNameAndParentId
(String name, long parentId) Finds that folder that lies under a specific parent (given by the id) an with a given text(like operator is used)findByParentId
(long parentId, boolean enabledOnly) Finds all children(direct and indirect) by parentIdfindByUserId
(long userId) Finds authorized menus for a user.findByUserId
(long userId, long parentId, boolean enabledOnly) Finds direct children of a menufindChildren
(long parentId, long userId) Finds direct children of a menu accessible by the given user.findChildren
(long parentId, Integer max) Finds direct children of a menu.findIdByUserId
(long userId, long parentId) This method selects only the menuId from the menus for which a user is authorized.findMenuIdByUserId
(long userId, boolean enabledOnly) This method selects only the menuId from the menus for which a user is authorizedfindMenuIdByUserIdAndPermission
(long userId, Permission permission, boolean enabledOnly) Finds all menus ids with a specific permission enabled on the specifies userfindNameById
(long id) This method selects only the menu text from a menufindParents
(long id) Returns a List of menus being a parent of the given menu.boolean
hasWriteAccess
(Menu menu, long userId) Checks that the user has access to the menu and all its sub-itemsint
isMenuWriteable
(long id, long userId) Returns if a menu is writeable for a userboolean
isReadEnable
(long id, long userId) This method is looking up for read rights for a menu and an userboolean
isWriteEnable
(long id, long userId) This method is looking up for writing rights for a menu and an uservoid
restore
(long id, boolean parents) Restores a previously deleted menuMethods inherited from interface com.logicaldoc.core.PersistentObjectDAO
bulkUpdate, delete, delete, deleteAll, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDatabaseMetadata, getDbms, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, query, queryForInt, queryForList, queryForList, queryForList, queryForLong, queryForLong, queryForObject, queryForRowSet, queryForRowSet, queryForString, store
-
Method Details
-
findByName
Finds all menus by menu text.- Parameters:
name
- name of the menu- Returns:
- List of menus with given menu text.
-
findByName
Finds all menus by menu text, contained in the parent menu- Parameters:
parent
- The parent menu(optional)name
- the name to searchcaseSensitive
- if we have to consider the search case sensitive- Returns:
- List of menus with given menu name.
-
findByUserId
Finds authorized menus for a user.- Parameters:
userId
- ID of the user.- Returns:
- List of found menus.
-
findMenuIdByUserIdAndPermission
Finds all menus ids with a specific permission enabled on the specifies user- Parameters:
userId
- The user identifierpermission
- The permission to checkenabledOnly
- if the menus must also be enabled- Returns:
- list of folder IDs
-
findByUserId
Finds direct children of a menu- Parameters:
userId
- identifier of the userparentId
- MenuId of the menu which children are wantedenabledOnly
- if the menus must also be enabled- Returns:
- List of found menus sorted by name
-
findByParentId
Finds all children(direct and indirect) by parentId- Parameters:
parentId
- identifier of the parent menuenabledOnly
- if the menus must also be enabled- Returns:
- list of children menus
-
findChildren
Finds direct children of a menu.- Parameters:
parentId
- MenuId of the menu which children are wantedmax
- Optional, maximum number of children- Returns:
- List of found menus
-
findChildren
Finds direct children of a menu accessible by the given user.- Parameters:
parentId
- MenuId of the menu which children are wanteduserId
- Identifier of the user that mush have read access- Returns:
- List of found menus.
-
isWriteEnable
boolean isWriteEnable(long id, long userId) This method is looking up for writing rights for a menu and an user- Parameters:
id
- ID of the menuuserId
- ID of the user- Returns:
- id the user has write permission
-
isReadEnable
boolean isReadEnable(long id, long userId) This method is looking up for read rights for a menu and an user- Parameters:
id
- ID of the menuuserId
- ID of the user- Returns:
- if the user can access the menu
-
findNameById
This method selects only the menu text from a menu- Parameters:
id
- Id of the menu- Returns:
- Selected menu text
-
findMenuIdByUserId
This method selects only the menuId from the menus for which a user is authorized- Parameters:
userId
- ID of the userenabledOnly
- if the menus must also be enabled- Returns:
- List of selected menuId's
-
findIdByUserId
This method selects only the menuId from the menus for which a user is authorized. Only menus direct child of the specified parent are returned.- Parameters:
userId
- ID of the user.parentId
- Parent menu- Returns:
- List of selected menuId's.
-
isMenuWriteable
int isMenuWriteable(long id, long userId) Returns if a menu is writeable for a user- Parameters:
id
- check this menuuserId
- privileges for this should be checked- Returns:
- a 0 if false, a 1 if true
-
hasWriteAccess
Checks that the user has access to the menu and all its sub-items- Parameters:
menu
- the menuuserId
- identifier of the menu- Returns:
- if the user has write permission
-
findByGroupId
Finds all menus accessible by the passed group- Parameters:
groupId
- The group id- Returns:
- The List of menus
-
findParents
Returns a List of menus being a parent of the given menu. The list is ordered starting from the root of menus.- Parameters:
id
- identifier of the group- Returns:
- hierarchy of parents
-
restore
Restores a previously deleted menu- Parameters:
id
- The menu identifierparents
- true if parents must be restored also- Throws:
PersistenceException
- is happened a database error
-
findByNameAndParentId
Finds that folder that lies under a specific parent (given by the id) an with a given text(like operator is used)- Parameters:
name
- name of the menuparentId
- identifier of the parent menu- Returns:
- list of manues
-
computePathExtended
Dynamically computes the path extended for the specified menu. The path extended is a human readable path in the form: /menu1/menu2/menu3- Parameters:
id
- identifier of the menu- Returns:
- full path of the menu
-
createPath
Menu createPath(long parentId, long tenantId, int type, String path, boolean inheritSecurity) throws PersistenceException Creates the menu for the specified path. All unexisting nodes specified in the path will be created.- Parameters:
parentId
- Identifier of the parent menutenantId
- Identifier of the tenant that will own the new menutype
- The type of the created menuspath
- The folder path(for example /dog/cat/mouse)inheritSecurity
- If true the new menus will 'point' to the parent for the security policies.- Returns:
- The created folder
- Throws:
PersistenceException
- error at data layer
-
applyRightToTree
boolean applyRightToTree(long id) Propagates the security policies of a node to the whole subtree- Parameters:
id
- identifier of a folder- Returns:
- true if all went correctly
-