/** * Returns the translated display name of this principal if it is a group and the display name otherwise.<p> * * @param cms the current CMS context * @param locale the locale * @param translation the group name translation to use * * @return the translated display name * * @throws CmsException if something goes wrong */ public String getDisplayName(CmsObject cms, Locale locale, I_CmsGroupNameTranslation translation) throws CmsException { if (!isGroup() || (translation == null)) { return getDisplayName(cms, locale); } return Messages.get().getBundle(locale).key( Messages.GUI_PRINCIPAL_DISPLAY_NAME_2, translation.translateGroupName(getName(), false), OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, getOuFqn()).getDisplayName(locale)); }
/** * @see org.opencms.security.I_CmsPrincipal#setName(java.lang.String) */ public void setName(String name) { checkName(CmsOrganizationalUnit.getSimpleName(name)); m_name = name; } }
/** * @see org.opencms.security.I_CmsPrincipal#getPrefixedName() */ public String getPrefixedName() { if (isUser()) { return getPrefixedUser(getName()); } else if (isGroup()) { return getPrefixedGroup(getName()); } return getName(); }
/** * Returns the name of the user who created the given resource.<p> * * @return the name of the user who created the given resource */ public String getUserCreated() { String user = m_resource.getUserCreated().toString(); try { user = getCurrentOuRelativeName( CmsPrincipal.readPrincipalIncludingHistory(getCms(), m_resource.getUserCreated()).getName()); } catch (Throwable e) { LOG.info(e.getLocalizedMessage()); } return user; }
/** * Returns the display name of this principal including the organizational unit.<p> * * @param cms the cms context * @param locale the locale * * @return the display name of this principal 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, getSimpleName(), OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, getOuFqn()).getDisplayName(locale)); }
/** * Returns if the list of principals has principals of other organizational units.<p> * * @return if the list of principals has principals of other organizational units */ public boolean hasPrincipalsInOtherOus() { if (m_hasPrincipalsInOtherOus == null) { // lazzy initialization m_hasPrincipalsInOtherOus = Boolean.FALSE; try { Iterator itPrincipals = getPrincipals(true).iterator(); while (itPrincipals.hasNext()) { CmsPrincipal principal = (CmsPrincipal)itPrincipals.next(); if (!principal.getOuFqn().equals(getCms().getRequestContext().currentUser().getOuFqn())) { m_hasPrincipalsInOtherOus = Boolean.TRUE; break; } } } catch (Exception e) { // ignore } } return m_hasPrincipalsInOtherOus.booleanValue(); }
/** * @see org.opencms.security.I_CmsPrincipal#isEnabled() */ public boolean isEnabled() { return (getFlags() & I_CmsPrincipal.FLAG_DISABLED) == 0; }
/** * Returns the list of users for selection.<p> * * @return a list of users * * @throws CmsException if womething goes wrong */ protected List<CmsPrincipal> getUsers() throws CmsException { List<CmsPrincipal> ret = new ArrayList<CmsPrincipal>(); if (getParamGroup() != null) { ret.addAll(getCms().getUsersOfGroup(getParamGroup())); } else { ret.addAll(OpenCms.getRoleManager().getManageableUsers(getCms(), "", true)); } if (getParamFlags() != null) { int flags = Integer.parseInt(getParamFlags()); return new ArrayList<CmsPrincipal>(CmsPrincipal.filterFlag(ret, flags)); } return ret; }
/** * Unsubscribes the user or group from all resources.<p> * * @param context the request context * @param poolName the name of the database pool to use * @param principal the principal that unsubscribes from all resources * * @throws CmsException if something goes wrong */ public void unsubscribeAllResourcesFor(CmsRequestContext context, String poolName, CmsPrincipal principal) throws CmsException { CmsDbContext dbc = m_dbContextFactory.getDbContext(context); try { m_driverManager.unsubscribeAllResourcesFor(dbc, poolName, principal); } catch (Exception e) { if (principal instanceof CmsUser) { dbc.report( null, Messages.get().container(Messages.ERR_UNSUBSCRIBE_ALL_RESOURCES_USER_1, principal.getName()), e); } else { dbc.report( null, Messages.get().container(Messages.ERR_UNSUBSCRIBE_ALL_RESOURCES_GROUP_1, principal.getName()), e); } } finally { dbc.clear(); } }
/** * Returns the name of the user who last modified the given resource.<p> * * @return the name of the user who last modified the given resource */ public String getUserLastModified() { String user = m_resource.getUserLastModified().toString(); try { user = getCurrentOuRelativeName( CmsPrincipal.readPrincipalIncludingHistory(getCms(), m_resource.getUserLastModified()).getName()); } catch (Throwable e) { LOG.info(e.getLocalizedMessage()); } return user; }
/** * @see org.opencms.security.I_CmsPrincipal#getPrefixedName() */ public String getPrefixedName() { if (isUser()) { return getPrefixedUser(getName()); } else if (isGroup()) { return getPrefixedGroup(getName()); } return getName(); }
/** * Returns the display name of this principal including the organizational unit.<p> * * @param cms the cms context * @param locale the locale * * @return the display name of this principal 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, getSimpleName(), OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, getOuFqn()).getDisplayName(locale)); }
/** * Returns if the list of principals has principals of other organizational units.<p> * * @return if the list of principals has principals of other organizational units */ public boolean hasPrincipalsInOtherOus() { if (m_hasPrincipalsInOtherOus == null) { // lazzy initialization m_hasPrincipalsInOtherOus = Boolean.FALSE; try { Iterator<CmsPrincipal> itPrincipals = getPrincipals(true).iterator(); while (itPrincipals.hasNext()) { CmsPrincipal principal = itPrincipals.next(); if (!principal.getOuFqn().equals(getCms().getRequestContext().getCurrentUser().getOuFqn())) { m_hasPrincipalsInOtherOus = Boolean.TRUE; break; } } } catch (Exception e) { // ignore } } return m_hasPrincipalsInOtherOus.booleanValue(); }
/** * @see org.opencms.security.I_CmsPrincipal#isEnabled() */ public boolean isEnabled() { return (getFlags() & I_CmsPrincipal.FLAG_DISABLED) == 0; }
/** * Returns the groups to show for selection.<p> * * @return A list of group objects * * @throws CmsException if womething goes wrong */ protected List getGroups() throws CmsException { List ret = new ArrayList(); if (getParamUser() != null) { ret.addAll(getCms().getGroupsOfUser(getParamUser(), false)); } else { ret.addAll(OpenCms.getRoleManager().getManageableGroups(getCms(), "", true)); } if (getParamFlags() != null) { int flags = Integer.parseInt(getParamFlags()); ret = CmsPrincipal.filterFlag(ret, flags); } if ((getParamOufqn() != null) && !getParamOufqn().equals("null")) { Iterator itTempRet = ret.iterator(); while (itTempRet.hasNext()) { CmsGroup group = (CmsGroup)itTempRet.next(); if (!group.getOuFqn().startsWith(getParamOufqn())) { itTempRet.remove(); } } } return ret; }
/** * Returns the name of the user who created the given resource.<p> * * @return the name of the user who created the given resource */ public String getUserCreated() { String user = m_resource.getUserCreated().toString(); try { user = getCurrentOuRelativeName(CmsPrincipal.readPrincipalIncludingHistory( getCms(), m_resource.getUserCreated()).getName()); } catch (Throwable e) { LOG.error(e.getLocalizedMessage()); } return user; }