/** * Returns the HTML code for selecting an organizational unit.<p> * * @return the HTML code for selecting an organizational unit */ public String buildOrgUnitSelector() { StringBuffer html = new StringBuffer(); html.append("<select style='width: 100%;' size='1' "); appendId(html, PARAM_OUFQN); html.append(">\n"); for (CmsOrganizationalUnit ou : getOus()) { String selected = ""; if (ou.getName().equals(m_oufqn) || (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_oufqn) && ou.getName().equals(m_oufqn.substring(1)))) { selected = " selected='selected'"; } html.append("<option value='").append(ou.getName()).append("'").append(selected).append(">"); html.append(ou.getDisplayName(m_locale)); html.append("</option>\n"); } html.append("</select>\n"); return html.toString(); }
/** * Returns the display name for this organizational unit.<p> * * @param locale the locale * * @return the display name for this organizational unit */ public String getDisplayName(Locale locale) { if (getParentFqn() == null) { // for the root ou return getDescription(locale); } return Messages.get().getBundle(locale).key( Messages.GUI_ORGUNIT_DISPLAY_NAME_2, getDescription(locale), CmsOrganizationalUnit.SEPARATOR + getName()); }
/** * Returns the simple name if the ou is the same as the current user's ou.<p> * * @param name the fully qualified name to check * * @return the simple name if the ou is the same as the current user's ou */ private String getCurrentOuRelativeName(String name) { if (m_request == null) { return CmsOrganizationalUnit.SEPARATOR + name; } String ou = CmsOrganizationalUnit.getParentFqn(name); if (ou.equals(m_request.getCurrentUser().getOuFqn())) { return CmsOrganizationalUnit.getSimpleName(name); } return CmsOrganizationalUnit.SEPARATOR + name; }
/** * Returns the organizational unit for the parent of the given fully qualified name.<p> * * @param fqn the fully qualified name to get the parent organizational unit for * * @return the parent organizational unit for the fully qualified name */ protected String getParentOrganizationalUnit(String fqn) { String ouFqn = CmsOrganizationalUnit.getParentFqn(CmsOrganizationalUnit.removeLeadingSeparator(fqn)); if (ouFqn == null) { ouFqn = ""; } return ouFqn; }
/** * Removes the given organizational unit from the cache.<p> * * The organizational unit is removed by name AND also by uuid.<p> * * @param orgUnit the organizational unit to remove from cache */ public void uncacheOrgUnit(CmsOrganizationalUnit orgUnit) { m_cacheOrgUnit.remove(orgUnit.getId().toString()); m_cacheOrgUnit.remove(orgUnit.getName()); }
if (orgUnit.getParentFqn() == null) { throw new CmsDataAccessException(org.opencms.security.Messages.get().container( org.opencms.security.Messages.ERR_ORGUNIT_ROOT_EDITION_0)); CmsResource ouResource = m_driverManager.readResource(dbc, orgUnit.getId(), CmsResourceFilter.ALL); throw new CmsDataAccessException(Messages.get().container( Messages.ERR_ORGUNIT_DOESNOT_CONTAINS_RESOURCE_2, orgUnit.getName(), dbc.removeSiteRoot(resource.getRootPath()))); if ((vfsPaths.size() == 1) && !orgUnit.hasFlagWebuser()) { orgUnit.getName(), dbc.removeSiteRoot(resource.getRootPath()))); CmsProject project = m_driverManager.readProject(dbc, orgUnit.getProjectId()); orgUnit.getProjectId(), resource.getRootPath());
m_orgUnitBean = new CmsOrgUnitBean(); if (!isNewOrgUnit()) { m_orgUnitBean.setName(orgunit.getName()); m_orgUnitBean.setDescription(orgunit.getDescription(getLocale())); m_orgUnitBean.setParentOu(orgunit.getParentFqn()); m_orgUnitBean.setFqn(orgunit.getName()); m_orgUnitBean.setNologin(orgunit.hasFlagHideLogin()); m_orgUnitBean.setWebusers(orgunit.hasFlagWebuser()); if (orgunit.getParentFqn() != null) { m_orgUnitBean.setParentOuDesc( OpenCms.getOrgUnitManager().readOrganizationalUnit( getCms(), orgunit.getParentFqn()).getDescription(getLocale()) + " (" + CmsOrganizationalUnit.SEPARATOR + orgunit.getParentFqn() + ")"); m_orgUnitBean.setParentOu(orgunit.getName()); m_orgUnitBean.setParentOuDesc( orgunit.getDescription(getLocale()) + " (" + CmsOrganizationalUnit.SEPARATOR + orgunit.getName() + ")"); orgunit.getName()); setResourcesInBean(m_orgUnitBean, resources); } else {
try { jsonObj.put("name", ou.getName()); jsonObj.put("displayname", ou.getDisplayName(m_locale)); jsonObj.put("simplename", ou.getSimpleName()); jsonObj.put("description", ou.getDescription(m_locale)); if (ou.getName().equals(m_oufqn) || (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_oufqn) && ou.getName().equals(m_oufqn.substring(1)))) { isSelected = true; jsonObj.put("level", CmsResource.getPathLevel(ou.getName()));
/** * Returns the description of the parent ou.<p> * * @return the description of the parent ou */ public String getAssignedOu() { try { return OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), m_group.getOuFqn()).getDisplayName( getLocale()); } catch (CmsException e) { return null; } }
/** * @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; }
/** * Initializes the select options.<p> * * @param orgUnits the selectable OUs */ public void initOrgUnits(List<CmsOrganizationalUnit> orgUnits) { if ((orgUnits.size() == 1) && (orgUnits.get(0).getParentFqn() == null)) { setVisible(false); m_alwaysHidden = true; } for (CmsOrganizationalUnit ou : orgUnits) { String key = normalizeOuName(ou.getName()); m_ouSelect.addItem(key); m_ouSelect.setItemCaption(key, ou.getDisplayName(A_CmsUI.get().getLocale())); } }
/** * 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; }
Messages.get().container( Messages.ERR_ORGUNIT_RESOURCE_IS_NOT_FOLDER_2, orgUnit.getName(), dbc.removeSiteRoot(resource.getRootPath()))); ORGUNIT_BASE_FOLDER + orgUnit.getName(), CmsResourceFilter.ALL); if (orgUnit.getParentFqn() != null) { CmsOrganizationalUnit parentOu = m_driverManager.readOrganizationalUnit(dbc, orgUnit.getParentFqn()); CmsProject project = m_driverManager.readProject(dbc, orgUnit.getProjectId()); orgUnit.getProjectId(), resource.getRootPath());
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() throws CmsException { List<CmsListItem> ret = new ArrayList<CmsListItem>(); Iterator<CmsOrganizationalUnit> itOrgUnits = getOrgUnits().iterator(); while (itOrgUnits.hasNext()) { CmsOrganizationalUnit orgUnit = itOrgUnits.next(); CmsListItem item = getList().newItem(orgUnit.getName()); item.set(LIST_COLUMN_DESCRIPTION, orgUnit.getDescription(getLocale())); item.set(LIST_COLUMN_PATH, CmsOrganizationalUnit.SEPARATOR + orgUnit.getName()); ret.add(item); } return ret; }
/** * 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; }
projectName = projectName + " - " + OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), project.getOuFqn()).getDisplayName( getLocale()); } catch (CmsException e) { if ((ou != null) && project.getUuid().equals(ou.getProjectId())) { ouDefaultProjIndex = i;
/** * @see org.opencms.workplace.list.A_CmsListDialog#fillDetails(java.lang.String) */ @Override protected void fillDetails(String detailId) { // get content List<CmsListItem> roles = getList().getAllContent(); Iterator<CmsListItem> itRoles = roles.iterator(); while (itRoles.hasNext()) { CmsListItem item = itRoles.next(); String roleName = item.get(LIST_COLUMN_GROUP_NAME).toString(); StringBuffer html = new StringBuffer(512); try { if (detailId.equals(LIST_DETAIL_PATH)) { html.append( OpenCms.getOrgUnitManager().readOrganizationalUnit( getCms(), CmsOrganizationalUnit.getParentFqn(roleName)).getDisplayName(getLocale())); } else if (detailId.equals(LIST_DETAIL_DESCRIPTION)) { CmsRole role = CmsRole.valueOf(getCms().readGroup(roleName)); html.append(role.getDescription(getCms().getRequestContext().getLocale())); } else { continue; } } catch (Exception e) { // noop } item.set(detailId, html.toString()); } }
/** * Returns the fully qualified name of the associated organizational unit.<p> * * @return the fully qualified name of the associated organizational unit */ public String getOuFqn() { return CmsOrganizationalUnit.getParentFqn(m_name); }
/** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer result = new StringBuffer(); result.append("[Organizational Unit]"); result.append(" fqn:"); result.append(getName()); result.append(" id:"); result.append(m_id); result.append(" description:"); result.append(m_description); return result.toString(); } }
CmsResource resource = m_driverManager.readResource( dbc, organizationalUnit.getId(), CmsResourceFilter.DEFAULT); dbc, resource, new CmsProperty(ORGUNIT_PROPERTY_DESCRIPTION, organizationalUnit.getDescription(), null)); : dbc.getProjectId(); resource.setFlags(organizationalUnit.getFlags() | CmsResource.FLAG_INTERNAL); m_driverManager.writeResource(dbc, resource); resource.setState(CmsResource.STATE_UNCHANGED);