001: package org.contineo.core.security.dao;
002:
003: import java.util.Collection;
004: import java.util.Set;
005:
006: import org.contineo.core.security.ExtMenu;
007: import org.contineo.core.security.Menu;
008:
009: /**
010: * Instances of this class is a DAO-service for menu objects.
011: *
012: * @author Michael Scholz
013: * @version 1.0
014: */
015: public interface MenuDAO {
016:
017: /**
018: * This method persists the menu object.
019: *
020: * @param menu Menu to be stored.
021: * @return True if successful stored in a database.
022: */
023: public boolean store(Menu menu);
024:
025: /**
026: * This method deletes a menu in database.
027: *
028: * @param menuId Menu to be deleted.
029: * @return True if successful deleted.
030: */
031: public boolean delete(int menuId);
032:
033: /**
034: * Finds a menu by primarykey.
035: *
036: * @param menuId Primarykey of wanted menu.
037: * @return Wanted menu or null.
038: */
039: public Menu findByPrimaryKey(int menuId);
040:
041: /**
042: * Finds all menus by menutext.
043: *
044: * @param menutext
045: * @return Collection of menus with given menutext.
046: */
047: public Collection<Menu> findByMenuText(String menutext);
048:
049: /**
050: * Finds authorized menus for a user.
051: *
052: * @param username Name of the user.
053: * @return Collection of found menus.
054: */
055: public Collection<Menu> findByUserName(String username);
056:
057: /**
058: * Finds authorized menus for a user having a specified keyword.
059: *
060: * @param username Name of the user.
061: * @param keyword Keyword of the document bind with the menu.
062: * @return Collection of found menus.
063: */
064: public Collection<Menu> findByUserNameAndKeyword(String username,
065: String keyword);
066:
067: /**
068: * Finds direct children of a menu.
069: *
070: * @param parentId MenuId of the menu which children are wanted.
071: * @return Collection of found menus.
072: */
073: public Collection<Menu> findByUserName(String username, int parentId);
074:
075: /**
076: * Finds all children(direct and indirect) by parentId
077: *
078: * @param parentId
079: * @return
080: */
081: public Collection<Menu> findByParentId(int parentId);
082:
083: /**
084: * Finds direct children of a menu.
085: *
086: * @param parentId MenuId of the menu which children are wanted.
087: * @return Collection of found menus.
088: */
089: public Collection<Menu> findChildren(int parentId);
090:
091: /**
092: * This method is looking up for writing rights for a menu and an user.
093: *
094: * @param menuId ID of the menu.
095: * @param username Name of the user.
096: */
097: public boolean isWriteEnable(int menuId, String username);
098:
099: public boolean isReadEnable(int menuId, String username);
100:
101: /**
102: * This method selects only the menutext from a menu.
103: *
104: * @param menuId Id of the menu.
105: * @return Selected menutext.
106: */
107: public String findMenuTextByMenuId(int menuId);
108:
109: /**
110: * This method selects only the menuId from the menus for which a user is
111: * authorized.
112: *
113: * @param username Name of the user.
114: * @return Collection of selected menuId's.
115: */
116: public Set<Integer> findMenuIdByUserName(String username);
117:
118: /**
119: * returns a collection with sub-menus contained in menu with the given id
120: *
121: * @param menuid return all menus in this menu
122: * @param userName only return those menus the user has at least read access
123: * to
124: * @return a collection containing elements of type {@link ExtMenu}
125: */
126: public Collection<ExtMenu> getContainedMenus(int menuId,
127: String userName);
128:
129: /**
130: * returns if a menu is writeable for a user
131: *
132: * @param menuid check this menu
133: * @param userName privileges for this should be checked
134: * @return a 0 if false, a 1 if true
135: */
136: public Integer isMenuWriteable(int menuId, String userName);
137:
138: /**
139: * checks that the user has access to the menu and all its sub-items
140: */
141: public boolean hasWriteAccess(Menu menu, String p_userName);
142:
143: /**
144: * Finds all menues associated to the passed group
145: *
146: * @param groupName The group name
147: * @return The collection of menues
148: */
149: public Collection<Menu> findByGroupName(String groupName);
150:
151: }
|