Class CmsOrgUnitManager


  • public class CmsOrgUnitManager
    extends java.lang.Object
    This manager provide access to the organizational unit related operations.

    Since:
    6.5.6
    • Method Detail

      • addResourceToOrgUnit

        public void addResourceToOrgUnit​(CmsObject cms,
                                         java.lang.String ouFqn,
                                         java.lang.String resourceName)
                                  throws CmsException
        Adds a resource to the given organizational unit.

        Parameters:
        cms - the opencms context
        ouFqn - the full qualified name of the organizational unit to add the resource to
        resourceName - the name of the resource that is to be added to the organizational unit
        Throws:
        CmsException - if something goes wrong
      • countUsers

        public long countUsers​(CmsObject cms,
                               CmsUserSearchParameters params)
                        throws CmsException
        Counts the users which fit the given search criteria.

        Parameters:
        cms - the current CMS context
        params - the user search parameters
        Returns:
        the total number of users which fit the given search parameters
        Throws:
        CmsException - if something goes wrong
      • createOrganizationalUnit

        public CmsOrganizationalUnit createOrganizationalUnit​(CmsObject cms,
                                                              java.lang.String ouFqn,
                                                              java.lang.String description,
                                                              int flags,
                                                              java.lang.String resourceName)
                                                       throws CmsException
        Creates a new organizational unit.

        The parent structure must exist.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the new organizational unit
        description - the description of the new organizational unit
        flags - the flags for the new organizational unit
        resourceName - the first associated resource
        Returns:
        a CmsOrganizationalUnit object representing the newly created organizational unit
        Throws:
        CmsException - if operation was not successful
      • deleteOrganizationalUnit

        public void deleteOrganizationalUnit​(CmsObject cms,
                                             java.lang.String ouFqn)
                                      throws CmsException
        Deletes an organizational unit.

        Only organizational units that contain no sub units can be deleted.

        The organizational unit can not be delete if it is used in the request context, or if the current user belongs to it.

        All users and groups in the given organizational unit will be deleted.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to delete
        Throws:
        CmsException - if operation was not successful
      • getAllAccessibleProjects

        public java.util.List<CmsProjectgetAllAccessibleProjects​(CmsObject cms,
                                                                   java.lang.String ouFqn,
                                                                   boolean includeSubOus)
                                                            throws CmsException
        Returns all accessible projects of the given organizational unit. That is all projects which are owned by the current user or which are accessible for the group of the user.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to get projects for
        includeSubOus - if all projects of sub-organizational units should be retrieved too
        Returns:
        all CmsProject objects in the organizational unit
        Throws:
        CmsException - if operation was not successful
      • getAllManageableProjects

        public java.util.List<CmsProjectgetAllManageableProjects​(CmsObject cms,
                                                                   java.lang.String ouFqn,
                                                                   boolean includeSubOus)
                                                            throws CmsException
        Returns all manageable projects of the given organizational unit.

        That is all projects which are owned by the current user or which are manageable for the group of the user.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to get projects for
        includeSubOus - if all projects of sub-organizational units should be retrieved too
        Returns:
        all CmsProject objects in the organizational unit
        Throws:
        CmsException - if operation was not successful
      • getGroups

        public java.util.List<CmsGroupgetGroups​(CmsObject cms,
                                                  java.lang.String ouFqn,
                                                  boolean includeSubOus)
                                           throws CmsException
        Returns all groups of the given organizational unit.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to get all principals for
        includeSubOus - if all groups of sub-organizational units should be retrieved too
        Returns:
        all CmsGroup objects in the organizational unit
        Throws:
        CmsException - if operation was not successful
      • getOrganizationalUnits

        public java.util.List<CmsOrganizationalUnitgetOrganizationalUnits​(CmsObject cms,
                                                                            java.lang.String ouFqn,
                                                                            boolean includeChildren)
                                                                     throws CmsException
        Returns all child organizational units of the given parent organizational unit including hierarchical deeper organization units if needed.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the parent organizational unit
        includeChildren - if hierarchical deeper organization units should also be returned
        Returns:
        a list of CmsOrganizationalUnit objects
        Throws:
        CmsException - if operation was not successful
      • getOrgUnitsForResource

        public java.util.List<CmsOrganizationalUnitgetOrgUnitsForResource​(CmsObject cms,
                                                                            java.lang.String rootPath)
                                                                     throws CmsException
        Gets all organizational units x such that x and all of its ancestor org. units, up to the root organizational unit contain a given path.
        Parameters:
        cms - the CMS context
        rootPath - the root path of a resource
        Returns:
        the list of organizational units containing the path
        Throws:
        CmsException - if something goes wrong
      • getResourcesForOrganizationalUnit

        public java.util.List<CmsResourcegetResourcesForOrganizationalUnit​(CmsObject cms,
                                                                             java.lang.String ouFqn)
                                                                      throws CmsException
        Returns all resources of the given organizational unit.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to get all resources for
        Returns:
        all CmsResource objects in the organizational unit
        Throws:
        CmsException - if operation was not successful
      • getUsers

        public java.util.List<CmsUsergetUsers​(CmsObject cms,
                                                java.lang.String ouFqn,
                                                boolean recursive)
                                         throws CmsException
        Returns all users of the given organizational unit.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to get all principals for
        recursive - if all users of sub-organizational units should be retrieved too
        Returns:
        all CmsUser objects in the organizational unit
        Throws:
        CmsException - if operation was not successful
      • getUsersWithoutAdditionalInfo

        public java.util.List<CmsUsergetUsersWithoutAdditionalInfo​(CmsObject cms,
                                                                     java.lang.String ouFqn,
                                                                     boolean recursive)
                                                              throws CmsException
        Returns all users of the given organizational unit, without their additional info.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to get all principals for
        recursive - if all users of sub-organizational units should be retrieved too
        Returns:
        all CmsUser objects in the organizational unit
        Throws:
        CmsException - if operation was not successful
      • readOrganizationalUnit

        public CmsOrganizationalUnit readOrganizationalUnit​(CmsObject cms,
                                                            java.lang.String ouFqn)
                                                     throws CmsException
        Reads an organizational Unit based on its fully qualified name.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational Unit to be read
        Returns:
        the organizational Unit with the provided fully qualified name
        Throws:
        CmsException - if something goes wrong
      • removeResourceFromOrgUnit

        public void removeResourceFromOrgUnit​(CmsObject cms,
                                              java.lang.String ouFqn,
                                              java.lang.String resourceName)
                                       throws CmsException
        Removes a resource from the given organizational unit.

        Parameters:
        cms - the opencms context
        ouFqn - the fully qualified name of the organizational unit to remove the resource from
        resourceName - the name of the resource that is to be removed from the organizational unit
        Throws:
        CmsException - if something goes wrong
      • setUsersOrganizationalUnit

        public void setUsersOrganizationalUnit​(CmsObject cms,
                                               java.lang.String ouFqn,
                                               java.lang.String userName)
                                        throws CmsException
        Moves an user to the given organizational unit.

        Parameters:
        cms - the opencms context
        ouFqn - the full qualified name of the organizational unit to add the user to
        userName - the name of the user that is to be added to the organizational unit
        Throws:
        CmsException - if something goes wrong
      • writeOrganizationalUnit

        public void writeOrganizationalUnit​(CmsObject cms,
                                            CmsOrganizationalUnit organizationalUnit)
                                     throws CmsException
        Writes an already existing organizational unit.

        The organizational unit has to be a valid OpenCms organizational unit.
        The organizational unit will be completely overridden by the given data.

        Parameters:
        cms - the opencms context
        organizationalUnit - the organizational unit that should be written
        Throws:
        CmsException - if operation was not successful