/** * 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 projects which are owned by the current user or which are * accessible for the group of the user.<p> * * @return a list of objects of type <code>{@link CmsProject}</code> * * @throws CmsException if operation was not successful * * @deprecated use {@link org.opencms.security.CmsOrgUnitManager#getAllAccessibleProjects(CmsObject, String, boolean) OpenCms.getOrgUnitManager().getAllAccessibleProjects(CmsObject, String, boolean)} instead */ public List getAllAccessibleProjects() throws CmsException { return OpenCms.getOrgUnitManager().getAllAccessibleProjects(this, "", true); }
/** * Returns all projects which are owned by the current user or which are manageable * for the group of the user.<p> * * @return a list of objects of type <code>{@link CmsProject}</code> * * @throws CmsException if operation was not successful * * @deprecated use {@link org.opencms.security.CmsOrgUnitManager#getAllManageableProjects(CmsObject, String, boolean) OpenCms.getOrgUnitManager().getAllManageableProjects(CmsObject, String, boolean)} instead */ public List getAllManageableProjects() throws CmsException { return OpenCms.getOrgUnitManager().getAllManageableProjects(this, "", true); }
try { if (detailId.equals(LIST_DETAIL_USERS)) { List<CmsUser> usersOrgUnit = OpenCms.getOrgUnitManager().getUsers(getCms(), ouFqn, false); Iterator<CmsUser> itUsersOrgUnit = usersOrgUnit.iterator(); while (itUsersOrgUnit.hasNext()) { List<CmsGroup> groupsOrgUnit = OpenCms.getOrgUnitManager().getGroups(getCms(), ouFqn, false); Iterator<CmsGroup> itGroupsOrgUnit = groupsOrgUnit.iterator(); while (itGroupsOrgUnit.hasNext()) { List<CmsResource> resourcesOrgUnit = OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit( getCms(), ouFqn);
CmsOrganizationalUnit newOrgUnit = OpenCms.getOrgUnitManager().createOrganizationalUnit( getCms(), m_orgUnitBean.getFqn(), Iterator<String> itResourceNames = CmsFileUtil.removeRedundancies(resourceNames).iterator(); while (itResourceNames.hasNext()) { OpenCms.getOrgUnitManager().addResourceToOrgUnit( getCms(), newOrgUnit.getName(), CmsOrganizationalUnit orgunit = OpenCms.getOrgUnitManager().readOrganizationalUnit( getCms(), m_orgUnitBean.getFqn()); orgunit.setFlags(m_orgUnitBean.getFlags()); List<String> resourceNamesNew = CmsFileUtil.removeRedundancies(m_orgUnitBean.getResources()); List<CmsResource> resourcesOld = OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit( getCms(), orgunit.getName()); String resourceNameNew = itResourceNamesNew.next(); if (!resourceNamesOld.contains(resourceNameNew)) { OpenCms.getOrgUnitManager().addResourceToOrgUnit(getCms(), orgunit.getName(), resourceNameNew); String resourceNameOld = itResourceNamesOld.next(); if (!resourceNamesNew.contains(resourceNameOld)) { OpenCms.getOrgUnitManager().removeResourceFromOrgUnit( getCms(), orgunit.getName(),
m_orgUnit = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), m_orgUnitName); resources.add(OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit( getCms(), CmsOrganizationalUnit.getParentFqn(m_orgUnitName)).get(0)); m_orgUnit = OpenCms.getOrgUnitManager().createOrganizationalUnit( getCms(), m_orgUnitName, ((CmsResource)resources.get(0)).getRootPath()); for (int i = 1; i < resources.size(); i++) { OpenCms.getOrgUnitManager().addResourceToOrgUnit( getCms(), m_orgUnitName,
ouFqn = cms.getRequestContext().getCurrentUser().getOuFqn(); allProjects = OpenCms.getOrgUnitManager().getAllAccessibleProjects( cms, ouFqn, projectName = projectName + " - " + OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, project.getOuFqn()).getDisplayName( locale); } catch (CmsException e) {
/** * Returns all resources of the given organizational unit.<p> * * @param cms the opencms context * @param ouFqn the fully qualified name of the organizational unit to get all resources for * * @return all <code>{@link CmsResource}</code> objects in the organizational unit * * @throws CmsException if operation was not successful */ public List getResourcesForOrganizationalUnit(CmsObject cms, String ouFqn) throws CmsException { CmsOrganizationalUnit orgUnit = readOrganizationalUnit(cms, ouFqn); return m_securityManager.getResourcesForOrganizationalUnit(cms.getRequestContext(), orgUnit); }
List<CmsProject> projects = OpenCms.getOrgUnitManager().getAllManageableProjects(getCms(), "", true); Iterator<CmsProject> itProjects = projects.iterator(); while (itProjects.hasNext()) { item.set( LIST_COLUMN_ORGUNIT, OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), project.getOuFqn()).getDisplayName( getLocale())); try { if (OpenCms.getOrgUnitManager().getOrganizationalUnits(getCms(), "", true).isEmpty()) { getList().getMetadata().getColumnDefinition(LIST_COLUMN_ORGUNIT).setVisible(false); } else {
try { OpenCms.getOrgUnitManager().addResourceToOrgUnit(getCms(), orgUnitName, resourceName); } catch (CmsException e) { getReport().addWarning(e); String resName = ((CmsResource)OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit( getCms(), CmsOrganizationalUnit.getParentFqn(orgUnitName)).get(0)).getRootPath(); if (!resources.contains(resName)) { OpenCms.getOrgUnitManager().removeResourceFromOrgUnit(getCms(), orgUnitName, resName);
/** * Checks if the user has more then one organizational unit to administrate.<p> * * @return true if the user has more then then one organizational unit to administrate * otherwise false * @throws CmsException if the organizational units can not be read */ public boolean hasSubOUs() throws CmsException { List<CmsOrganizationalUnit> orgUnits = OpenCms.getOrgUnitManager().getOrganizationalUnits( getCms(), m_paramOufqn, true); if (orgUnits == null) { return false; } if (orgUnits.size() < 1) { return false; } return true; }
if (OpenCms.getOrgUnitManager().getUsers(wp.getCms(), ouFqn, true).size() > 0) { return false; if (OpenCms.getOrgUnitManager().getGroups(wp.getCms(), ouFqn, true).size() > 0) { List<CmsGroup> groups = OpenCms.getOrgUnitManager().getGroups(wp.getCms(), ouFqn, true); Iterator<CmsGroup> itGroups = groups.iterator(); while (itGroups.hasNext()) { if (OpenCms.getOrgUnitManager().getOrganizationalUnits(wp.getCms(), ouFqn, true).size() > 0) { return false;
/** * Returns all users.<p> * * @return a list of all <code>{@link CmsUser}</code> objects * * @throws CmsException if operation was not successful * * @deprecated use {@link org.opencms.security.CmsOrgUnitManager#getUsers(CmsObject, String, boolean) OpenCms.getOrgUnitManager().getUsersForOrganizationalUnit(CmsObject, String, boolean)} instead */ public List getUsers() throws CmsException { return OpenCms.getOrgUnitManager().getUsers(this, "", true); }
/** * Initializes the organizational unit object to work with depending on the dialog state and request parameters.<p> * */ @Override protected void initOrgUnitObject() { try { CmsOrganizationalUnit orgunit = OpenCms.getOrgUnitManager().readOrganizationalUnit( getCms(), getParamOufqn()); m_orgUnitBean = new CmsOrgUnitBean(); m_orgUnitBean.setDescription(orgunit.getDescription(getLocale())); m_orgUnitBean.setName(orgunit.getName()); if (!orgunit.getName().equals("")) { m_orgUnitBean.setParentOu(orgunit.getParentFqn()); } m_orgUnitBean.setFqn(orgunit.getName()); setResourcesInBean( m_orgUnitBean, OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit(getCms(), orgunit.getName())); } catch (Exception e) { // noop } } }
/** * Returns all groups.<p> * * @return a list of all <code>{@link CmsGroup}</code> objects * * @throws CmsException if operation was not successful * * @deprecated use {@link org.opencms.security.CmsOrgUnitManager#getGroups(CmsObject, String, boolean) OpenCms.getOrgUnitManager().getGroups(CmsObject, String, boolean)} instead */ public List getGroups() throws CmsException { return OpenCms.getOrgUnitManager().getGroups(this, "", true); }
principals.addAll(OpenCms.getOrgUnitManager().getUsers(getCms(), ou, true)); } else { principals.addAll(OpenCms.getOrgUnitManager().getUsers(getCms(), ou, false)); principals.addAll(OpenCms.getOrgUnitManager().getGroups(getCms(), ou, true)); } else { principals.addAll(OpenCms.getOrgUnitManager().getGroups(getCms(), ou, false));
/** * Initializes the session object to work with depending on the dialog state and request parameters.<p> */ protected void initSessionObject() { try { if (!CmsStringUtil.isEmpty(getParamAction()) && !CmsDialog.DIALOG_INITIAL.equals(getParamAction())) { m_resources = (List)getDialogObject(); // test m_resources.size(); } } catch (Exception e) { // ignore } if (m_resources == null) { // create a new project object m_resources = new ArrayList(); try { Iterator it = OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit( getCms(), getCms().getRequestContext().getOuFqn()).iterator(); while (it.hasNext()) { CmsResource res = (CmsResource)it.next(); m_resources.add(getCms().getSitePath(res)); } } catch (CmsException e1) { // should never happen } } }
m_orgUnit = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), m_orgUnitName); OpenCms.getOrgUnitManager().getResourcesForOrganizationalUnit( getCms(), CmsOrganizationalUnit.getParentFqn(m_orgUnitName)).get(0)); m_orgUnit = OpenCms.getOrgUnitManager().createOrganizationalUnit( getCms(), m_orgUnitName, resources.get(0).getRootPath()); for (int i = 1; i < resources.size(); i++) { OpenCms.getOrgUnitManager().addResourceToOrgUnit( getCms(), m_orgUnitName,
ouFqn = cms.getRequestContext().getCurrentUser().getOuFqn(); allProjects = OpenCms.getOrgUnitManager().getAllAccessibleProjects( cms, ouFqn, projectName = projectName + " - " + OpenCms.getOrgUnitManager().readOrganizationalUnit(cms, project.getOuFqn()).getDisplayName( locale); } catch (CmsException e) {
/** * Removes a resource from the given organizational unit.<p> * * @param cms the opencms context * @param ouFqn the fully qualified name of the organizational unit to remove the resource from * @param resourceName the name of the resource that is to be removed from the organizational unit * * @throws CmsException if something goes wrong */ public void removeResourceFromOrgUnit(CmsObject cms, String ouFqn, String resourceName) throws CmsException { CmsOrganizationalUnit orgUnit = readOrganizationalUnit(cms, ouFqn); CmsResource resource = cms.readResource(resourceName, CmsResourceFilter.ALL); m_securityManager.removeResourceFromOrgUnit(cms.getRequestContext(), orgUnit, resource); }