Package com.logicaldoc.core.security.dao
Class HibernateMenuDAO
- java.lang.Object
-
- com.logicaldoc.core.HibernatePersistentObjectDAO<Menu>
-
- com.logicaldoc.core.security.dao.HibernateMenuDAO
-
- All Implemented Interfaces:
PersistentObjectDAO<Menu>,MenuDAO
public class HibernateMenuDAO extends HibernatePersistentObjectDAO<Menu> implements MenuDAO
Hibernate implementation ofMenuDAO- Since:
- 3.0
- Author:
- Marco Meschieri - LogicalDOC
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplyRightToTree(long id)Propagates the security policies of a node to the whole subtreeStringcomputePathExtended(long menuId)Dynamically computes the path extended for the specified menu.MenucreatePath(long parentId, long tenantId, int type, String path, boolean inheritSecurity)Creates the menu for the specified path.booleandelete(long menuId, int code)This method deletes an entity and you can give a deletion codevoiddeleteAll(Collection<Menu> menus)Deletes all entries form the databaseList<Menu>findByGroupId(long groupId)Finds all menus accessible by the passed groupList<Menu>findByName(Menu parent, String name, boolean caseSensitive)Finds all menus by menu text, contained in the parent menuList<Menu>findByName(String name)Finds all menus by menu text.List<Menu>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)List<Menu>findByParentId(long parentId, boolean enaledOnly)Finds all children(direct and indirect) by parentIdList<Menu>findByUserId(long userId)Finds authorized menus for a user.List<Menu>findByUserId(long userId, long parentId, boolean enabledOnly)Finds direct children of a menuList<Menu>findByUserId(long userId, long parentId, Integer type, boolean enabledOnly)List<Menu>findChildren(long parentId, long userId)Finds direct children of a menu accessible by the given user.List<Menu>findChildren(long parentId, Integer max)Finds direct children of a menu.List<Long>findIdByUserId(long userId, long parentId)This method selects only the menuId from the menus for which a user is authorized.List<Long>findIdByUserId(long userId, long parentId, Integer type)List<Long>findMenuIdByUserId(long userId, boolean enabledOnly)This method selects only the menuId from the menus for which a user is authorizedList<Long>findMenuIdByUserIdAndPermission(long userId, Permission permission, boolean enabledOnly)Finds all menus ids with a specific permission enabled on the specifies userStringfindNameById(long menuId)This method selects only the menu text from a menuList<Menu>findParents(long menuId)Returns a List of menus being a parent of the given menu.UserDAOgetUserDAO()booleanhasWriteAccess(Menu menu, long userId)Checks that the user has access to the menu and all its sub-itemsintisMenuWriteable(long menuId, long userId)Returns if a menu is writeable for a userbooleanisReadEnable(long menuId, long userId)This method is looking up for read rights for a menu and an userbooleanisWriteEnable(long menuId, long userId)This method is looking up for writing rights for a menu and an uservoidrestore(long menuId, boolean parents)Restores a previously deleted menuvoidsetUserDAO(UserDAO userDAO)booleanstore(Menu menu)This method persists the entity object-
Methods inherited from class com.logicaldoc.core.HibernatePersistentObjectDAO
bulkUpdate, delete, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, getSessionFactory, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString, setSessionFactory
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.logicaldoc.core.PersistentObjectDAO
bulkUpdate, delete, deleteAll, findAll, findAll, findAllIds, findAllIds, findById, findById, findByObjectQuery, findByQuery, findByWhere, findByWhere, findIdsByWhere, findIdsByWhere, getDbms, initialize, isOracle, jdbcUpdate, jdbcUpdate, query, queryForInt, queryForList, queryForList, queryForLong, queryForObject, queryForRowSet, queryForString
-
-
-
-
Method Detail
-
getUserDAO
public UserDAO getUserDAO()
-
setUserDAO
public void setUserDAO(UserDAO userDAO)
-
store
public boolean store(Menu menu) throws PersistenceException
Description copied from interface:PersistentObjectDAOThis method persists the entity object- Specified by:
storein interfacePersistentObjectDAO<Menu>- Overrides:
storein classHibernatePersistentObjectDAO<Menu>- Parameters:
menu- entity to be stored- Returns:
- True if successfully stored in a database
- Throws:
PersistenceException- raised in case of errors in the database
-
findByUserId
public List<Menu> findByUserId(long userId)
Description copied from interface:MenuDAOFinds authorized menus for a user.- Specified by:
findByUserIdin interfaceMenuDAO- Parameters:
userId- ID of the user.- Returns:
- List of found menus.
-
findByUserId
public List<Menu> findByUserId(long userId, long parentId, boolean enabledOnly)
Description copied from interface:MenuDAOFinds direct children of a menu- Specified by:
findByUserIdin interfaceMenuDAO- 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
-
findByUserId
public List<Menu> findByUserId(long userId, long parentId, Integer type, boolean enabledOnly)
-
findChildren
public List<Menu> findChildren(long parentId, Integer max)
Description copied from interface:MenuDAOFinds direct children of a menu.- Specified by:
findChildrenin interfaceMenuDAO- Parameters:
parentId- MenuId of the menu which children are wantedmax- Optional, maximum number of children- Returns:
- List of found menus
-
findChildren
public List<Menu> findChildren(long parentId, long userId)
Description copied from interface:MenuDAOFinds direct children of a menu accessible by the given user.- Specified by:
findChildrenin interfaceMenuDAO- Parameters:
parentId- MenuId of the menu which children are wanteduserId- Identifier of the user that mush have read access- Returns:
- List of found menus.
-
findByParentId
public List<Menu> findByParentId(long parentId, boolean enaledOnly)
Description copied from interface:MenuDAOFinds all children(direct and indirect) by parentId- Specified by:
findByParentIdin interfaceMenuDAO- Parameters:
parentId- identifier of the parent menuenaledOnly- if the menus must also be enabled- Returns:
- list of children menus
-
isWriteEnable
public boolean isWriteEnable(long menuId, long userId)Description copied from interface:MenuDAOThis method is looking up for writing rights for a menu and an user- Specified by:
isWriteEnablein interfaceMenuDAO- Parameters:
menuId- ID of the menuuserId- ID of the user- Returns:
- id the user has write permission
-
isReadEnable
public boolean isReadEnable(long menuId, long userId)Description copied from interface:MenuDAOThis method is looking up for read rights for a menu and an user- Specified by:
isReadEnablein interfaceMenuDAO- Parameters:
menuId- ID of the menuuserId- ID of the user- Returns:
- id the user can access the menu
-
findNameById
public String findNameById(long menuId)
Description copied from interface:MenuDAOThis method selects only the menu text from a menu- Specified by:
findNameByIdin interfaceMenuDAO- Parameters:
menuId- Id of the menu- Returns:
- Selected menu text
-
findMenuIdByUserId
public List<Long> findMenuIdByUserId(long userId, boolean enabledOnly)
Description copied from interface:MenuDAOThis method selects only the menuId from the menus for which a user is authorized- Specified by:
findMenuIdByUserIdin interfaceMenuDAO- Parameters:
userId- ID of the userenabledOnly- if the menus must also be enabled- Returns:
- List of selected menuId's
-
isMenuWriteable
public int isMenuWriteable(long menuId, long userId)Description copied from interface:MenuDAOReturns if a menu is writeable for a user- Specified by:
isMenuWriteablein interfaceMenuDAO- Parameters:
menuId- check this menuuserId- privileges for this should be checked- Returns:
- a 0 if false, a 1 if true
- See Also:
MenuDAO.isMenuWriteable(long, long)
-
hasWriteAccess
public boolean hasWriteAccess(Menu menu, long userId)
Description copied from interface:MenuDAOChecks that the user has access to the menu and all its sub-items- Specified by:
hasWriteAccessin interfaceMenuDAO- Parameters:
menu- the menuuserId- identifier of the menu- Returns:
- if the user has write permission
-
findByGroupId
public List<Menu> findByGroupId(long groupId)
Description copied from interface:MenuDAOFinds all menus accessible by the passed group- Specified by:
findByGroupIdin interfaceMenuDAO- Parameters:
groupId- The group id- Returns:
- The List of menus
-
findByName
public List<Menu> findByName(String name)
Description copied from interface:MenuDAOFinds all menus by menu text.- Specified by:
findByNamein interfaceMenuDAO- Parameters:
name- name of the menu- Returns:
- List of menus with given menu text.
-
findByName
public List<Menu> findByName(Menu parent, String name, boolean caseSensitive)
Description copied from interface:MenuDAOFinds all menus by menu text, contained in the parent menu- Specified by:
findByNamein interfaceMenuDAO- 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.
-
computePathExtended
public String computePathExtended(long menuId)
Description copied from interface:MenuDAODynamically computes the path extended for the specified menu. The path extended is a human readable path in the form: /menu1/menu2/menu3- Specified by:
computePathExtendedin interfaceMenuDAO- Parameters:
menuId- identifier of the menu- Returns:
- full path of the menu
-
findByNameAndParentId
public List<Menu> findByNameAndParentId(String name, long parentId)
Description copied from interface:MenuDAOFinds that folder that lies under a specific parent (given by the id) an with a given text(like operator is used)- Specified by:
findByNameAndParentIdin interfaceMenuDAO- Parameters:
name- name of the menuparentId- identifier of the parent menu- Returns:
- list of manues
-
findParents
public List<Menu> findParents(long menuId)
Description copied from interface:MenuDAOReturns a List of menus being a parent of the given menu. The list is ordered starting from the root of menus.- Specified by:
findParentsin interfaceMenuDAO- Parameters:
menuId- identifier of the group- Returns:
- hierarchy of parents
-
restore
public void restore(long menuId, boolean parents) throws PersistenceExceptionDescription copied from interface:MenuDAORestores a previously deleted menu- Specified by:
restorein interfaceMenuDAO- Parameters:
menuId- The menu identifierparents- true if parents must be restored also- Throws:
PersistenceException- is happened a database error
-
findMenuIdByUserIdAndPermission
public List<Long> findMenuIdByUserIdAndPermission(long userId, Permission permission, boolean enabledOnly)
Description copied from interface:MenuDAOFinds all menus ids with a specific permission enabled on the specifies user- Specified by:
findMenuIdByUserIdAndPermissionin interfaceMenuDAO- Parameters:
userId- The user identifierpermission- The permission to checkenabledOnly- if the menus must also be enabled- Returns:
- list of folder IDs
-
deleteAll
public void deleteAll(Collection<Menu> menus) throws PersistenceException
Description copied from interface:PersistentObjectDAODeletes all entries form the database- Specified by:
deleteAllin interfacePersistentObjectDAO<Menu>- Overrides:
deleteAllin classHibernatePersistentObjectDAO<Menu>- Parameters:
menus- The entities to be deleted- Throws:
PersistenceException- raised in case of errors in the database
-
delete
public boolean delete(long menuId, int code) throws PersistenceExceptionDescription copied from interface:PersistentObjectDAOThis method deletes an entity and you can give a deletion code- Specified by:
deletein interfacePersistentObjectDAO<Menu>- Overrides:
deletein classHibernatePersistentObjectDAO<Menu>- Parameters:
menuId- ID of the entity which should be deletedcode- Deletion code- Returns:
- if the record has been successfully deleted
- Throws:
PersistenceException- raised in case of errors in the database
-
applyRightToTree
public boolean applyRightToTree(long id)
Description copied from interface:MenuDAOPropagates the security policies of a node to the whole subtree- Specified by:
applyRightToTreein interfaceMenuDAO- Parameters:
id- identifier of a folder- Returns:
- true if all went correctly
-
findIdByUserId
public List<Long> findIdByUserId(long userId, long parentId)
Description copied from interface:MenuDAOThis method selects only the menuId from the menus for which a user is authorized. Only menus direct child of the specified parent are returned.- Specified by:
findIdByUserIdin interfaceMenuDAO- Parameters:
userId- ID of the user.parentId- Parent menu- Returns:
- List of selected menuId's.
-
createPath
public Menu createPath(long parentId, long tenantId, int type, String path, boolean inheritSecurity) throws PersistenceException
Description copied from interface:MenuDAOCreates the menu for the specified path. All unexisting nodes specified in the path will be created.- Specified by:
createPathin interfaceMenuDAO- 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- in case of database error
-
-