/** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer result = new StringBuffer(); result.append("["); result.append(this.getClass().getName()); result.append(", role: "); result.append(getRoleName()); result.append(", org unit: "); result.append(getOuFqn()); result.append(", group: "); result.append(getGroupName()); result.append("]"); return result.toString(); }
/** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer result = new StringBuffer(); result.append("["); result.append(this.getClass().getName()); result.append(", role: "); result.append(getRoleName()); result.append(", org unit: "); result.append(getOuFqn()); result.append(", group: "); result.append(getGroupName()); result.append("]"); return result.toString(); }
/** * Returns true if the list of users has users of other organizational units.<p> * * @return <code>true</code> if the list of users has users of other organizational units */ protected boolean hasRolesInOtherOus() { if (m_hasRolesInOtherOus == null) { m_hasRolesInOtherOus = Boolean.FALSE; try { Iterator<CmsRole> itRoles = getRoles().iterator(); while (itRoles.hasNext()) { CmsRole role = itRoles.next(); if (!role.getOuFqn().equals(getParamOufqn())) { m_hasRolesInOtherOus = Boolean.TRUE; break; } } } catch (Exception e) { // ignore } } return m_hasRolesInOtherOus.booleanValue(); }
Iterator<CmsGroup> it = getGroups(dbc, readOrganizationalUnit(dbc, role.getOuFqn()), false, false).iterator(); while (it.hasNext()) { CmsGroup group = it.next();
/** * 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 } }
Iterator it = getGroups(dbc, readOrganizationalUnit(dbc, role.getOuFqn()), false, false).iterator(); while (it.hasNext()) { CmsGroup group = (CmsGroup)it.next();
/** * Checks if the user of the current database context has permissions to impersonate the given role * in the given organizational unit.<p> * * If the organizational unit is <code>null</code>, this method will check if the * given user has the given role for at least one organizational unit.<p> * * @param dbc the current OpenCms users database context * @param role the role to check * * @throws CmsRoleViolationException if the user does not have the required role permissions * * @see org.opencms.security.CmsRoleManager#checkRole(CmsObject, CmsRole) */ public void checkRole(CmsDbContext dbc, CmsRole role) throws CmsRoleViolationException { if (!hasRole(dbc, dbc.currentUser(), role)) { if (role.getOuFqn() != null) { throw role.createRoleViolationExceptionForOrgUnit(dbc.getRequestContext(), role.getOuFqn()); } else { throw role.createRoleViolationException(dbc.getRequestContext()); } } }
/** * Returns all resources of organizational units for which the current user has * the given role role.<p> * * @param dbc the current database context * @param role the role to check * * @return a list of {@link org.opencms.file.CmsResource} objects * * @throws CmsException if something goes wrong */ protected List<CmsResource> getManageableResources(CmsDbContext dbc, CmsRole role) throws CmsException { CmsOrganizationalUnit ou = m_driverManager.readOrganizationalUnit(dbc, role.getOuFqn()); if (hasRole(dbc, dbc.currentUser(), role)) { return m_driverManager.getResourcesForOrganizationalUnit(dbc, ou); } List<CmsResource> resources = new ArrayList<CmsResource>(); Iterator<CmsOrganizationalUnit> it = m_driverManager.getOrganizationalUnits(dbc, ou, false).iterator(); while (it.hasNext()) { CmsOrganizationalUnit orgUnit = it.next(); resources.addAll(getManageableResources(dbc, role.forOrgUnit(orgUnit.getName()))); } return resources; }
/** * Checks if the user of the current database context has permissions to impersonate the given role * in the given organizational unit.<p> * * If the organizational unit is <code>null</code>, this method will check if the * given user has the given role for at least one organizational unit.<p> * * @param dbc the current OpenCms users database context * @param role the role to check * * @throws CmsRoleViolationException if the user does not have the required role permissions * * @see org.opencms.security.CmsRoleManager#checkRole(CmsObject, CmsRole) */ public void checkRole(CmsDbContext dbc, CmsRole role) throws CmsRoleViolationException { if (!hasRole(dbc, dbc.currentUser(), role)) { if (role.getOuFqn() != null) { throw role.createRoleViolationExceptionForOrgUnit(dbc.getRequestContext(), role.getOuFqn()); } else { throw role.createRoleViolationException(dbc.getRequestContext()); } } }
/** * Returns all resources of organizational units for which the current user has * the given role role.<p> * * @param dbc the current database context * @param role the role to check * * @return a list of {@link org.opencms.file.CmsResource} objects * * @throws CmsException if something goes wrong */ protected List getManageableResources(CmsDbContext dbc, CmsRole role) throws CmsException { CmsOrganizationalUnit ou = m_driverManager.readOrganizationalUnit(dbc, role.getOuFqn()); if (hasRole(dbc, dbc.currentUser(), role)) { return m_driverManager.getResourcesForOrganizationalUnit(dbc, ou); } List resources = new ArrayList(); Iterator it = m_driverManager.getOrganizationalUnits(dbc, ou, false).iterator(); while (it.hasNext()) { CmsOrganizationalUnit orgUnit = (CmsOrganizationalUnit)it.next(); resources.addAll(getManageableResources(dbc, role.forOrgUnit(orgUnit.getName()))); } return resources; }
/** * @see org.opencms.workplace.tools.accounts.A_CmsRolesList#getIconPath(CmsListItem) */ @Override public String getIconPath(CmsListItem item) { List<CmsListItem> roles = getList().getAllContent(); Iterator<CmsListItem> itRoles = roles.iterator(); List<CmsRole> roleObjects = new ArrayList<CmsRole>(); try { while (itRoles.hasNext()) { CmsListItem listItem = itRoles.next(); roleObjects.add(CmsRole.valueOf(getCms().readGroup((String)listItem.get(LIST_COLUMN_GROUP_NAME)))); } CmsRole role = CmsRole.valueOf(getCms().readGroup((String)item.get(LIST_COLUMN_GROUP_NAME))); if ((role.getParentRole() != null) && roleObjects.contains(role.getParentRole())) { if (role.getOuFqn().equals(getParamOufqn())) { return PATH_BUTTONS + "role_child.png"; } else { return PATH_BUTTONS + "role_other_ou_inherit.png"; } } if (role.getOuFqn().equals(getParamOufqn())) { return PATH_BUTTONS + "role.png"; } else { return PATH_BUTTONS + "role_other_ou.png"; } } catch (CmsException e) { return PATH_BUTTONS + "role.png"; } }
throws CmsException { String ouFqn = role.getOuFqn(); if (ouFqn == null) { ouFqn = "";
String ouFqn = role.getOuFqn(); if (ouFqn == null) { ouFqn = "";
String key = user.getName().toString() + role.getGroupName() + role.getOuFqn(); Boolean result = OpenCms.getMemoryMonitor().getCachedRole(key); if (result != null) {
/** * Returns the display name of this role including the organizational unit.<p> * * @param cms the cms context * @param locale the locale * * @return the display name of this role including the organizational unit * * @throws CmsException if the organizational unit could not be read */ public String getDisplayName(CmsObject cms, Locale locale) throws CmsException { return Messages.get().getBundle(locale).key( Messages.GUI_PRINCIPAL_DISPLAY_NAME_2, getName(locale), OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, getOuFqn()).getDisplayName(locale)); }
/** * Returns the display name of this role including the organizational unit.<p> * * @param cms the cms context * @param locale the locale * * @return the display name of this role including the organizational unit * * @throws CmsException if the organizational unit could not be read */ public String getDisplayName(CmsObject cms, Locale locale) throws CmsException { return Messages.get().getBundle(locale).key( Messages.GUI_PRINCIPAL_DISPLAY_NAME_2, getName(locale), OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, getOuFqn()).getDisplayName(locale)); }
/** * 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 } }