/** * Initializes the group object.<p> */ protected void initRoleObject() { try { m_role = CmsRole.valueOf(getCms().readGroup(m_paramRole)); } catch (CmsException e) { // noop } }
/** * Returns all roles, in the given organizational unit.<p> * * @param cms the opencms context * @param ouFqn the fully qualified name of the organizational unit of the role * @param includeSubOus include roles of child organizational units * * @return a list of all <code>{@link org.opencms.file.CmsGroup}</code> objects * * @throws CmsException if operation was not successful */ public List getRoles(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException { CmsOrganizationalUnit ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, ouFqn); List groups = m_securityManager.getGroups(cms.getRequestContext(), ou, includeSubOus, true); List roles = new ArrayList(groups.size()); Iterator itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = (CmsGroup)itGroups.next(); roles.add(CmsRole.valueOf(group)); } return roles; }
/** * Returns all roles, in the given organizational unit.<p> * * @param cms the opencms context * @param ouFqn the fully qualified name of the organizational unit of the role * @param includeSubOus include roles of child organizational units * * @return a list of all <code>{@link CmsRole}</code> objects * * @throws CmsException if operation was not successful */ public List<CmsRole> getRoles(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException { CmsOrganizationalUnit ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, ouFqn); List<CmsGroup> groups = m_securityManager.getGroups(cms.getRequestContext(), ou, includeSubOus, true); List<CmsRole> roles = new ArrayList<CmsRole>(groups.size()); Iterator<CmsGroup> itGroups = groups.iterator(); while (itGroups.hasNext()) { CmsGroup group = itGroups.next(); roles.add(CmsRole.valueOf(group)); } return roles; }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRoleUsersList#getUsers(boolean) */ @Override protected List<CmsUser> getUsers(boolean withOtherOus) throws CmsException { return OpenCms.getRoleManager().getUsersOfRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), withOtherOus, true); }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRoleUsersList#getUsers(boolean) */ @Override protected List<CmsUser> getUsers(boolean withOtherOus) throws CmsException { return OpenCms.getRoleManager().getUsersOfRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), withOtherOus, false); }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRoleUsersList#validateParamaters() */ @Override protected void validateParamaters() throws Exception { super.validateParamaters(); OpenCms.getRoleManager().checkRole(getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole()))); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListMultiActions() */ @Override public void executeListMultiActions() throws CmsRuntimeException { if (getParamListAction().equals(LIST_MACTION_ADD)) { // execute the remove multiaction try { Iterator<CmsListItem> itItems = getSelectedItems().iterator(); while (itItems.hasNext()) { CmsListItem listItem = itItems.next(); OpenCms.getRoleManager().addUserToRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), (String)listItem.get(LIST_COLUMN_LOGIN)); } } catch (CmsException e) { // refresh the list throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ADD_SELECTED_USERS_0), e); } } else { throwListUnsupportedActionException(); } listSave(); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws IOException, ServletException, CmsRuntimeException { String roleName = getSelectedItem().get(LIST_COLUMN_GROUP_NAME).toString(); Map<String, String[]> params = new HashMap<String, String[]>(); params.put(A_CmsOrgUnitDialog.PARAM_OUFQN, new String[] {getParamOufqn()}); params.put(PARAM_ROLE, new String[] {roleName}); params.put(CmsDialog.PARAM_ACTION, new String[] {CmsDialog.DIALOG_INITIAL}); if (getParamListAction().equals(LIST_ACTION_ICON)) { try { if (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.valueOf(getCms().readGroup(roleName)))) { // forward to the edit user screen getToolManager().jspForwardTool(this, getCurrentToolPath() + "/overview/edit", params); } else { getToolManager().jspForwardTool(this, getCurrentToolPath() + "/overview", params); } } catch (CmsException e) { // noop } } else if (getParamListAction().equals(LIST_DEFACTION_OVERVIEW)) { // forward to the overview screen getToolManager().jspForwardTool(this, getCurrentToolPath() + "/overview", params); } else { throwListUnsupportedActionException(); } listSave(); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#validateParamaters() */ @Override protected void validateParamaters() throws Exception { // test the needed parameters OpenCms.getRoleManager().checkRole(getCms(), CmsRole.ACCOUNT_MANAGER.forOrgUnit(getParamOufqn())); CmsRole.valueOf(getCms().readGroup(getParamRole())).getRoleName(); }
/** * @see org.opencms.workplace.CmsWidgetDialog#validateParamaters() */ @Override protected void validateParamaters() throws Exception { // test the needed parameters OpenCms.getRoleManager().checkRole(getCms(), CmsRole.ACCOUNT_MANAGER.forOrgUnit(getParamOufqn())); CmsRole.valueOf(getCms().readGroup(getParamRole())).getGroupName(); } }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRoleUsersList#getUsers(boolean) */ @Override protected List<CmsUser> getUsers(boolean withOtherOus) throws CmsException { List<CmsUser> roleUsers = OpenCms.getRoleManager().getUsersOfRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), withOtherOus, false); List<CmsUser> users; if (withOtherOus) { users = OpenCms.getRoleManager().getManageableUsers(getCms(), "", true); } else { users = OpenCms.getRoleManager().getManageableUsers(getCms(), getParamOufqn(), false); } users.removeAll(roleUsers); return users; }
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws CmsRuntimeException { if (m_addActionIds.contains(getParamListAction())) { CmsListItem listItem = getSelectedItem(); try { OpenCms.getRoleManager().addUserToRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), (String)listItem.get(LIST_COLUMN_LOGIN)); } catch (CmsException e) { // should never happen throw new CmsRuntimeException(Messages.get().container(Messages.ERR_ADD_SELECTED_USER_0), e); } } else { throwListUnsupportedActionException(); } listSave(); }
/** * @see org.opencms.workplace.list.A_CmsListDialog#executeListSingleActions() */ @Override public void executeListSingleActions() throws CmsRuntimeException { if (m_removeActionIds.contains(getParamListAction())) { CmsListItem listItem = getSelectedItem(); try { OpenCms.getRoleManager().removeUserFromRole( getCms(), CmsRole.valueOf(getCms().readGroup(getParamRole())), (String)listItem.get(LIST_COLUMN_LOGIN)); } catch (CmsException e) { // should never happen throw new CmsRuntimeException(Messages.get().container(Messages.ERR_REMOVE_SELECTED_GROUP_0), e); } } else { throwListUnsupportedActionException(); } listSave(); }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRolesList#getIconPath(CmsListItem) */ @Override public String getIconPath(CmsListItem item) { try { CmsRole role = CmsRole.valueOf(getCms().readGroup((String)item.get(LIST_COLUMN_GROUP_NAME))); if (OpenCms.getRoleManager().hasRole( getCms(), getCms().readUser(new CmsUUID(getParamUserid())).getName(), role)) { return PATH_BUTTONS + "role.png"; } } catch (Exception e) { // ignore } return PATH_BUTTONS + "role_inactive.png"; }
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible() */ @Override public boolean isVisible() { if (getItem() != null) { String roleName = getItem().getId(); try { CmsRole role = CmsRole.valueOf(getCms().readGroup(roleName)); if (OpenCms.getRoleManager().hasRole( getCms(), getCms().readUser(new CmsUUID(((CmsRoleEditList)getWp()).getParamUserid())).getName(), role)) { return false; } return true; } catch (CmsException e) { return false; } } return super.isVisible(); } };
/** * @see org.opencms.workplace.tools.A_CmsHtmlIconButton#isVisible() */ @Override public boolean isVisible() { if (getItem() != null) { String roleName = getItem().getId(); try { CmsRole role = CmsRole.valueOf(getCms().readGroup(roleName)); if (OpenCms.getRoleManager().hasRole( getCms(), getCms().readUser(new CmsUUID(((CmsRoleEditList)getWp()).getParamUserid())).getName(), role)) { return true; } return false; } catch (CmsException e) { return false; } } return super.isVisible(); } };
/** * Gets the search parameters.<p> * * @return the search parameters * * @throws CmsException if something goes wrong */ protected CmsUserSearchParameters getSearchParams() throws CmsException { CmsListState state = getListState(); CmsUserSearchParameters params = new CmsUserSearchParameters(); String searchFilter = state.getFilter(); params.setSearchFilter(searchFilter); if (!otherOrgUnitsVisible()) { CmsOrganizationalUnit ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), getParamOufqn()); params.setOrganizationalUnit(ou); } params.setPaging(getList().getMaxItemsPerPage(), state.getPage()); CmsRole role = CmsRole.valueOf(getCms().readGroup(getParamRole())); Set<CmsGroup> roleGroups = OpenCms.getRoleManager().getRoleGroups(getCms(), role, false); params.setAnyGroups(roleGroups); params.setSorting(getSortKey(state.getColumn()), state.getOrder().equals(CmsListOrderEnum.ORDER_ASCENDING)); params.setFilterByGroupOu(false); return params; }
/** * Gets the search parameters.<p> * * @return the search parameters * * @throws CmsException if something goes wrong */ protected CmsUserSearchParameters getSearchParams() throws CmsException { CmsListState state = getListState(); CmsUserSearchParameters params = new CmsUserSearchParameters(); String searchFilter = state.getFilter(); params.setSearchFilter(searchFilter); if (!otherOrgUnitsVisible()) { CmsOrganizationalUnit ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), getParamOufqn()); params.setOrganizationalUnit(ou); } params.setPaging(getList().getMaxItemsPerPage(), state.getPage()); CmsRole role = CmsRole.valueOf(getCms().readGroup(getParamRole())); Set<CmsGroup> roleGroups = OpenCms.getRoleManager().getRoleGroups(getCms(), role, false); params.setNotAnyGroups(roleGroups); params.setSorting(getSortKey(state.getColumn()), state.getOrder().equals(CmsListOrderEnum.ORDER_ASCENDING)); params.setFilterByGroupOu(false); return params; }