/** * 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; }
/** * Returns a list of those organizational units whose members can be managed by the current user.<p> * * @param cms the current CMS context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * @param includeWebusers if webuser organizational units should be included in the search * * @return a list of organizational units * * @throws CmsException if something goes wrong */ public List<CmsOrganizationalUnit> getManageableOrgUnits( CmsObject cms, String ouFqn, boolean includeSubOus, boolean includeWebusers) throws CmsException { List<CmsOrganizationalUnit> result = Lists.newArrayList(); List<CmsOrganizationalUnit> ous = getOrgUnitsForRole( cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(ouFqn), includeSubOus); for (CmsOrganizationalUnit ou : ous) { if (includeWebusers || !ou.hasFlagWebuser()) { result.add(ou); } } return result; }
/** * Adds a check for the web user condition to an SQL query.<p> * * @param select the query * @param orgUnit the organizational unit * @param users the user table alias */ protected void addWebuserCondition(CmsSelectQuery select, CmsOrganizationalUnit orgUnit, TableAlias users) { String webuserConditionTemplate; if (orgUnit.hasFlagWebuser()) { webuserConditionTemplate = "( %1$s >= 32768 AND %1$s < 65536 )"; } else { webuserConditionTemplate = "( %1$s < 32768 OR %1$s >= 65536 )"; } String webuserCondition = String.format(webuserConditionTemplate, users.column(colFlags())); select.addCondition(webuserCondition); }
/** * Gets the list of OUs which should be selectable in the login dialog.<p> * * @param cms the CMS context to use * @param predefOu the predefined OU * * @return the list of organizational units for the OU selector */ public static List<CmsOrganizationalUnit> getOrgUnitsForLoginDialog(CmsObject cms, String predefOu) { List<CmsOrganizationalUnit> result = new ArrayList<CmsOrganizationalUnit>(); try { if (predefOu == null) { result.add(OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, "")); result.addAll(OpenCms.getOrgUnitManager().getOrganizationalUnits(cms, "", true)); Iterator<CmsOrganizationalUnit> itOus = result.iterator(); while (itOus.hasNext()) { CmsOrganizationalUnit ou = itOus.next(); if (ou.hasFlagHideLogin() || ou.hasFlagWebuser()) { itOus.remove(); } } } else { result.add(OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, predefOu)); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } return result; }
/** * Returns all users of organizational units for which the current user has * the {@link CmsRole#ACCOUNT_MANAGER} role.<p> * * @param cms the current cms context * @param ouFqn the fully qualified name of the organizational unit * @param includeSubOus if sub organizational units should be included in the search * @param includeWebusers if webuser organizational units should be included in the search * * @return a list of {@link org.opencms.file.CmsUser} objects * * @throws CmsException if something goes wrong */ public List getManageableUsers(CmsObject cms, String ouFqn, boolean includeSubOus, boolean includeWebusers) throws CmsException { List users = new ArrayList(); Iterator it = getOrgUnitsForRole(cms, CmsRole.ACCOUNT_MANAGER.forOrgUnit(ouFqn), includeSubOus).iterator(); while (it.hasNext()) { CmsOrganizationalUnit orgUnit = (CmsOrganizationalUnit)it.next(); if (!includeWebusers && orgUnit.hasFlagWebuser()) { // webuser are never manageable continue; } users.addAll(OpenCms.getOrgUnitManager().getUsers(cms, orgUnit.getName(), false)); } return users; }
/** * Gets the list of OUs which should be selectable in the login dialog.<p> * * @param cms the CMS context to use * @param predefOu the predefined OU * * @return the list of organizational units for the OU selector */ public static List<CmsOrganizationalUnit> getOrgUnitsForLoginDialog(CmsObject cms, String predefOu) { List<CmsOrganizationalUnit> result = new ArrayList<CmsOrganizationalUnit>(); try { if (predefOu == null) { result.add(OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, "")); result.addAll(OpenCms.getOrgUnitManager().getOrganizationalUnits(cms, "", true)); Iterator<CmsOrganizationalUnit> itOus = result.iterator(); while (itOus.hasNext()) { CmsOrganizationalUnit ou = itOus.next(); if (ou.hasFlagHideLogin() || ou.hasFlagWebuser()) { itOus.remove(); } } } else { result.add(OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, predefOu)); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } return result; }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); // get content List<CmsUser> users = getUsers(); Iterator<CmsUser> itUsers = users.iterator(); while (itUsers.hasNext()) { CmsUser user = itUsers.next(); CmsListItem item = makeListItemForUser(user); ret.add(item); } CmsListColumnDefinition colDef = getList().getMetadata().getColumnDefinition(LIST_COLUMN_ROLE); if (colDef != null) { colDef.setVisible( !OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), getParamOufqn()).hasFlagWebuser()); } return ret; }
/** * Returns all organizational units in the system.<p> * * @return a list of {@link CmsOrganizationalUnit} objects */ protected List getOus() { if (m_ous == null) { m_ous = new ArrayList(); try { if (getPreDefOuFqn() == null) { m_ous.add(OpenCms.getOrgUnitManager().readOrganizationalUnit(getCmsObject(), "")); m_ous.addAll(OpenCms.getOrgUnitManager().getOrganizationalUnits(getCmsObject(), "", true)); Iterator itOus = m_ous.iterator(); while (itOus.hasNext()) { CmsOrganizationalUnit ou = (CmsOrganizationalUnit)itOus.next(); if (ou.hasFlagHideLogin() || ou.hasFlagWebuser()) { itOus.remove(); } } } else { m_ous.add(OpenCms.getOrgUnitManager().readOrganizationalUnit(getCmsObject(), m_oufqn)); } } catch (CmsException e) { LOG.error(e.getLocalizedMessage(), e); } } return m_ous; }
/** * @see org.opencms.db.I_CmsUserDriver#getUsers(org.opencms.db.CmsDbContext, org.opencms.security.CmsOrganizationalUnit, boolean) */ public List<CmsUser> getUsers(CmsDbContext dbc, CmsOrganizationalUnit orgUnit, boolean recursive) throws CmsDataAccessException { List<CmsUser> users = new ArrayList<CmsUser>(); try { Query q; // create statement if (orgUnit.hasFlagWebuser()) { q = m_sqlManager.createQuery(dbc, C_USERS_GET_WEBUSERS_FOR_ORGUNIT_1); } else { q = m_sqlManager.createQuery(dbc, C_USERS_GET_USERS_FOR_ORGUNIT_1); } String param = CmsOrganizationalUnit.SEPARATOR + orgUnit.getName(); if (recursive) { param += "%"; } q.setParameter(1, param); List<CmsDAOUsers> res = q.getResultList(); // create new Cms group objects for (CmsDAOUsers u : res) { users.add(internalCreateUser(dbc, u)); } } catch (PersistenceException e) { throw new CmsDataAccessException(Messages.get().container(Messages.ERR_JPA_PERSITENCE_1, e), e); } return users; }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); List<CmsOrganizationalUnit> orgUnits = getOrgUnits(); Iterator<CmsOrganizationalUnit> itOrgUnits = orgUnits.iterator(); while (itOrgUnits.hasNext()) { CmsOrganizationalUnit childOrgUnit = itOrgUnits.next(); CmsListItem item = getList().newItem(childOrgUnit.getName()); item.set(LIST_COLUMN_NAME, CmsOrganizationalUnit.SEPARATOR + childOrgUnit.getName()); item.set(LIST_COLUMN_DESCRIPTION, childOrgUnit.getDescription(getLocale())); item.set(LIST_COLUMN_ADMIN, Boolean.valueOf( OpenCms.getRoleManager().hasRole(getCms(), CmsRole.ADMINISTRATOR.forOrgUnit(childOrgUnit.getName())))); item.set(LIST_COLUMN_WEBUSER, Boolean.valueOf(childOrgUnit.hasFlagWebuser())); ret.add(item); } return ret; }
if (orgUnit.hasFlagWebuser()) { stmt = m_sqlManager.getPreparedStatement(conn, "C_USERS_GET_WEBUSERS_FOR_ORGUNIT_1"); } else {
webuserOu = OpenCms.getOrgUnitManager().readOrganizationalUnit( getCms(), getParamOufqn()).hasFlagWebuser(); } catch (CmsException e) {
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); List<CmsOrganizationalUnit> orgUnits = OpenCms.getOrgUnitManager().getOrganizationalUnits( getCms(), m_paramOufqn, true); Iterator<CmsOrganizationalUnit> itOrgUnits = orgUnits.iterator(); while (itOrgUnits.hasNext()) { CmsOrganizationalUnit childOrgUnit = itOrgUnits.next(); CmsListItem item = getList().newItem(childOrgUnit.getName()); item.set(LIST_COLUMN_NAME, CmsOrganizationalUnit.SEPARATOR + childOrgUnit.getName()); item.set(LIST_COLUMN_DESCRIPTION, childOrgUnit.getDescription(getLocale())); item.set(LIST_COLUMN_ADMIN, Boolean.valueOf( OpenCms.getRoleManager().hasRole(getCms(), CmsRole.ADMINISTRATOR.forOrgUnit(childOrgUnit.getName())))); item.set(LIST_COLUMN_WEBUSER, Boolean.valueOf(childOrgUnit.hasFlagWebuser())); ret.add(item); } return ret; }
/** * @see org.opencms.db.I_CmsUserDriver#fillDefaults(org.opencms.db.CmsDbContext) */ public void fillDefaults(CmsDbContext dbc) throws CmsInitException { try { CmsOrganizationalUnit ou = (CmsOrganizationalUnit)(dbc.getAttribute(CmsDriverManager.ATTR_INIT_OU)); if (ou == null) { internalCreateDefaultGroups(dbc, "", "", false); } else { internalCreateDefaultGroups(dbc, ou.getName(), ou.getDescription(), ou.hasFlagWebuser()); } } catch (CmsException e) { if (CmsLog.INIT.isErrorEnabled()) { CmsLog.INIT.error(Messages.get().getBundle().key(Messages.INIT_DEFAULT_USERS_CREATION_FAILED_0), e); } throw new CmsInitException(Messages.get().container(Messages.ERR_INITIALIZING_USER_DRIVER_0), e); } }
if (orgUnit.hasFlagWebuser()) { stmt = m_sqlManager.getPreparedStatement(conn, "C_USERS_GET_WEBUSERS_FOR_ORGUNIT_1"); } else {
/** * 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 } }
if (OpenCms.getOrgUnitManager().readOrganizationalUnit(m_wp.getCms(), id).hasFlagWebuser()) { return Messages.get().getBundle(m_wp.getLocale()).key(Messages.GUI_OU_TYPE_WEBUSER_0);
if (OpenCms.getOrgUnitManager().readOrganizationalUnit(m_wp.getCms(), id).hasFlagWebuser()) { return Messages.get().getBundle(m_wp.getLocale()).key(Messages.GUI_OU_TYPE_WEBUSER_0);
dbc.removeSiteRoot(resource.getRootPath()))); if ((vfsPaths.size() == 1) && !orgUnit.hasFlagWebuser()) {
m_orgUnitBean.setFqn(orgunit.getName()); m_orgUnitBean.setNologin(orgunit.hasFlagHideLogin()); m_orgUnitBean.setWebusers(orgunit.hasFlagWebuser()); if (orgunit.getParentFqn() != null) { m_orgUnitBean.setParentOuDesc(