/** * Helper method to check whether we should bother with reading the group for a given role in a given OU.<p> * * This is important because webuser OUs don't have most role groups, and their absence is not cached, so we want to avoid reading them. * * @param ou the OU * @param role the role * @return true if we should read the role in the OU */ private boolean canReadRoleInOu(CmsOrganizationalUnit ou, CmsRole role) { if (ou.hasFlagWebuser() && !role.getRoleName().equals(CmsRole.ACCOUNT_MANAGER.getRoleName())) { return false; } return true; }
/** * Applies the system role order to a list of roles.<p> * * @param roles the roles */ public static void applySystemRoleOrder(List<CmsRole> roles) { Map<String, CmsRole> ouRoles = new HashMap<String, CmsRole>(); for (CmsRole role : roles) { ouRoles.put(role.getRoleName(), role); } roles.clear(); for (CmsRole sysRole : CmsRole.getSystemRoles()) { if (ouRoles.containsKey(sysRole.getRoleName())) { roles.add(ouRoles.get(sysRole.getRoleName())); } } }
/** * Returns the fully qualified name of this role.<p> * * @return the fqn of this role */ public String getFqn() { if (getOuFqn() == null) { return getRoleName(); } return getOuFqn() + getRoleName(); }
/** * Returns the fully qualified name of this role.<p> * * @return the fqn of this role */ public String getFqn() { if (getOuFqn() == null) { return getRoleName(); } return getOuFqn() + getRoleName(); }
/** * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#getXPathsToUpdate() */ @Override protected List<String> getXPathsToUpdate() { if (m_xpaths == null) { StringBuffer xp = new StringBuffer(256); xp.append(getCommonPath()); xp.append("[@").append(I_CmsXmlConfiguration.A_NAME); xp.append("='jsp']"); xp.append("/").append(CmsWorkplaceConfiguration.N_ACCESSCONTROL); xp.append("/").append(CmsWorkplaceConfiguration.N_ACCESSENTRY); xp.append("[@").append(CmsWorkplaceConfiguration.A_PRINCIPAL); xp.append("='ROLE.").append(CmsRole.DEVELOPER.getRoleName()).append("']"); m_xpaths = Collections.singletonList(xp.toString()); } return m_xpaths; }
/** * @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 the role for the given role name.<p> * * @param roleName a role name to check for role representation * * @return the role for the given role name */ public static CmsRole valueOfRoleName(String roleName) { String roleOu = CmsOrganizationalUnit.getParentFqn(roleName); Iterator it = SYSTEM_ROLES.iterator(); while (it.hasNext()) { CmsRole role = (CmsRole)it.next(); // direct check if (roleName.equals(role.getRoleName())) { return role.forOrgUnit(roleOu); } if (!role.isOrganizationalUnitIndependent()) { // the role name does not start with "/", but the given role fqn does if (roleName.endsWith(CmsOrganizationalUnit.SEPARATOR + role.getRoleName())) { return role.forOrgUnit(roleOu); } } } return null; }
/** * Returns the role for the given role name.<p> * * @param roleName a role name to check for role representation * * @return the role for the given role name */ public static CmsRole valueOfRoleName(String roleName) { String roleOu = CmsOrganizationalUnit.getParentFqn(roleName); Iterator<CmsRole> it = SYSTEM_ROLES.iterator(); while (it.hasNext()) { CmsRole role = it.next(); // direct check if (roleName.equals(role.getRoleName())) { return role.forOrgUnit(roleOu); } if (!role.isOrganizationalUnitIndependent()) { // the role name does not start with "/", but the given role fqn does if (roleName.endsWith(CmsOrganizationalUnit.SEPARATOR + role.getRoleName())) { return role.forOrgUnit(roleOu); } } } return null; }
/** * @see org.opencms.setup.xml.A_CmsSetupXmlUpdate#executeUpdate(org.dom4j.Document, java.lang.String, boolean) */ @Override protected boolean executeUpdate(Document document, String xpath, boolean forReal) { Node node = document.selectSingleNode(xpath); if ((node != null) && getXPathsToUpdate().contains(xpath)) { CmsSetupXmlHelper.setAttribute( document, xpath, CmsWorkplaceConfiguration.A_PRINCIPAL, "ROLE." + CmsRole.VFS_MANAGER.getRoleName()); return true; } return false; }
/** * Returns a localized role name.<p> * * @param locale the locale * * @return the localized role name */ public String getName(Locale locale) { if (m_systemRole) { // localize role names for system roles return Messages.get().getBundle(locale).key("GUI_ROLENAME_" + m_roleName + "_0"); } else { return getRoleName(); } }
/** * Returns a localized role name.<p> * * @param locale the locale * * @return the localized role name */ public String getName(Locale locale) { if (m_systemRole) { // localize role names for system roles return Messages.get().getBundle(locale).key("GUI_ROLENAME_" + m_roleName + "_0"); } else { return getRoleName(); } }
/** * Returns the role select options.<p> * * @return the role select options */ private List<CmsSelectWidgetOption> getRoles() { List<CmsSelectWidgetOption> roleOptions = new ArrayList<CmsSelectWidgetOption>(); roleOptions.add( new CmsSelectWidgetOption( NO_ROLE, false, Messages.get().getBundle(getLocale()).key(Messages.GUI_USER_EDITOR_NO_ROLE_0))); try { List<CmsRole> roles = new ArrayList<CmsRole>( OpenCms.getRoleManager().getRoles(getCms(), m_paramOufqn, false)); // ensure the role sorting matches the system roles order CmsRole.applySystemRoleOrder(roles); for (CmsRole role : roles) { roleOptions.add( new CmsSelectWidgetOption( role.getRoleName(), role.getRoleName().equals(CmsRole.ELEMENT_AUTHOR.getRoleName()), role.getDisplayName(getCms(), getLocale()))); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } return roleOptions; }
for (CmsRole role : roles) { for (CmsRole child : role.getChildren(true)) { String deps = dependencies.get(child.getRoleName()); if (deps == null) { deps = ""; dependencies.put(child.getRoleName(), deps); String dependency = dependencies.get(role.getRoleName()); if (dependency == null) { dependency = "";
/** * Gets a user-readable name for a principal id read from an ACE.<p> * * @param cms the current CMS context * @param principalId the principal id from the ACE * @return the name of the principle */ public static String getAcePrincipalName(CmsObject cms, CmsUUID principalId) { if (CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID.equals(principalId)) { return CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME; } if (CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID.equals(principalId)) { return CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME; } CmsRole role = CmsRole.valueOfId(principalId); if (role != null) { return role.getRoleName(); } try { return CmsPrincipal.readPrincipalIncludingHistory(cms, principalId).getName(); } catch (CmsException e) { return "" + principalId; } }
/** * Gets a user-readable name for a principal id read from an ACE.<p> * * @param cms the current CMS context * @param principalId the principal id from the ACE * @return the name of the principle */ protected String getAcePrincipalName(CmsObject cms, CmsUUID principalId) { if (CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID.equals(principalId)) { return CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_NAME; } if (CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID.equals(principalId)) { return CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_NAME; } CmsRole role = CmsRole.valueOfId(principalId); if (role != null) { return role.getRoleName(); } try { return CmsPrincipal.readPrincipalIncludingHistory(cms, principalId).getName(); } catch (CmsException e) { return "" + principalId; } }
Messages.get().getBundle().key(Messages.LOG_DBG_UPDATE_ROLEGROUP_2, role.getRoleName(), groupName));
LOG.debug(Messages.get().getBundle().key(Messages.LOG_DBG_UPDATE_ROLEGROUP_2, role.getRoleName(), groupName));
Messages.get().getBundle().key(Messages.LOG_DBG_UPDATE_ROLEGROUP_2, groupName, role.getRoleName()));
/** * @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(); }