Package org.opencms.security
Class CmsOrgUnitManager
java.lang.Object
org.opencms.security.CmsOrgUnitManager
This manager provide access to the organizational unit related operations.
- Since:
- 6.5.6
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addResourceToOrgUnit
(CmsObject cms, String ouFqn, String resourceName) Adds a resource to the given organizational unit.long
countUsers
(CmsObject cms, CmsUserSearchParameters params) Counts the users which fit the given search criteria.createOrganizationalUnit
(CmsObject cms, String ouFqn, String description, int flags, String resourceName) Creates a new organizational unit.void
deleteOrganizationalUnit
(CmsObject cms, String ouFqn) Deletes an organizational unit.getAllAccessibleProjects
(CmsObject cms, String ouFqn, boolean includeSubOus) Returns all accessible projects of the given organizational unit.getAllManageableProjects
(CmsObject cms, String ouFqn, boolean includeSubOus) Returns all manageable projects of the given organizational unit.Returns all groups of the given organizational unit.getOrganizationalUnits
(CmsObject cms, String ouFqn, boolean includeChildren) Returns all child organizational units of the given parent organizational unit including hierarchical deeper organization units if needed.getOrgUnitsForResource
(CmsObject cms, String rootPath) Gets all organizational units x such that x and all of its ancestor org.getResourcesForOrganizationalUnit
(CmsObject cms, String ouFqn) Returns all resources of the given organizational unit.Returns all users of the given organizational unit.getUsersWithoutAdditionalInfo
(CmsObject cms, String ouFqn, boolean recursive) Returns all users of the given organizational unit, without their additional info.void
initialize
(CmsObject cms) Initializes the organizational units.readOrganizationalUnit
(CmsObject cms, String ouFqn) Reads an organizational Unit based on its fully qualified name.void
removeResourceFromOrgUnit
(CmsObject cms, String ouFqn, String resourceName) Removes a resource from the given organizational unit.searchUsers
(CmsObject cms, CmsUserSearchParameters params) Searches users which fit the given search parameters.void
setUsersOrganizationalUnit
(CmsObject cms, String ouFqn, String userName) Moves an user to the given organizational unit.void
writeOrganizationalUnit
(CmsObject cms, CmsOrganizationalUnit organizationalUnit) Writes an already existing organizational unit.
-
Constructor Details
-
CmsOrgUnitManager
Default constructor.- Parameters:
securityManager
- the security manager
-
-
Method Details
-
addResourceToOrgUnit
public void addResourceToOrgUnit(CmsObject cms, String ouFqn, String resourceName) throws CmsException Adds a resource to the given organizational unit.- Parameters:
cms
- the opencms contextouFqn
- the full qualified name of the organizational unit to add the resource toresourceName
- the name of the resource that is to be added to the organizational unit- Throws:
CmsException
- if something goes wrong
-
countUsers
Counts the users which fit the given search criteria.- Parameters:
cms
- the current CMS contextparams
- 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, String ouFqn, String description, int flags, String resourceName) throws CmsException Creates a new organizational unit.The parent structure must exist.
- Parameters:
cms
- the opencms contextouFqn
- the fully qualified name of the new organizational unitdescription
- the description of the new organizational unitflags
- the flags for the new organizational unitresourceName
- the first associated resource- Returns:
- a
object representing the newly created organizational unitCmsOrganizationalUnit
- Throws:
CmsException
- if operation was not successful
-
deleteOrganizationalUnit
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 contextouFqn
- the fully qualified name of the organizational unit to delete- Throws:
CmsException
- if operation was not successful
-
getAllAccessibleProjects
public List<CmsProject> getAllAccessibleProjects(CmsObject cms, 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 contextouFqn
- the fully qualified name of the organizational unit to get projects forincludeSubOus
- if all projects of sub-organizational units should be retrieved too- Returns:
- all
objects in the organizational unitCmsProject
- Throws:
CmsException
- if operation was not successful
-
getAllManageableProjects
public List<CmsProject> getAllManageableProjects(CmsObject cms, 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 contextouFqn
- the fully qualified name of the organizational unit to get projects forincludeSubOus
- if all projects of sub-organizational units should be retrieved too- Returns:
- all
objects in the organizational unitCmsProject
- Throws:
CmsException
- if operation was not successful
-
getGroups
public List<CmsGroup> getGroups(CmsObject cms, String ouFqn, boolean includeSubOus) throws CmsException Returns all groups of the given organizational unit.- Parameters:
cms
- the opencms contextouFqn
- the fully qualified name of the organizational unit to get all principals forincludeSubOus
- if all groups of sub-organizational units should be retrieved too- Returns:
- all
objects in the organizational unitCmsGroup
- Throws:
CmsException
- if operation was not successful
-
getOrganizationalUnits
public List<CmsOrganizationalUnit> getOrganizationalUnits(CmsObject cms, 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 contextouFqn
- the fully qualified name of the parent organizational unitincludeChildren
- if hierarchical deeper organization units should also be returned- Returns:
- a list of
objectsCmsOrganizationalUnit
- Throws:
CmsException
- if operation was not successful
-
getOrgUnitsForResource
public List<CmsOrganizationalUnit> getOrgUnitsForResource(CmsObject cms, 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 contextrootPath
- the root path of a resource- Returns:
- the list of organizational units containing the path
- Throws:
CmsException
- if something goes wrong
-
getResourcesForOrganizationalUnit
public List<CmsResource> getResourcesForOrganizationalUnit(CmsObject cms, String ouFqn) throws CmsException Returns all resources of the given organizational unit.- Parameters:
cms
- the opencms contextouFqn
- the fully qualified name of the organizational unit to get all resources for- Returns:
- all
objects in the organizational unitCmsResource
- Throws:
CmsException
- if operation was not successful
-
getUsers
Returns all users of the given organizational unit.- Parameters:
cms
- the opencms contextouFqn
- the fully qualified name of the organizational unit to get all principals forrecursive
- if all users of sub-organizational units should be retrieved too- Returns:
- all
objects in the organizational unitCmsUser
- Throws:
CmsException
- if operation was not successful
-
getUsersWithoutAdditionalInfo
public List<CmsUser> getUsersWithoutAdditionalInfo(CmsObject cms, String ouFqn, boolean recursive) throws CmsException Returns all users of the given organizational unit, without their additional info.- Parameters:
cms
- the opencms contextouFqn
- the fully qualified name of the organizational unit to get all principals forrecursive
- if all users of sub-organizational units should be retrieved too- Returns:
- all
objects in the organizational unitCmsUser
- Throws:
CmsException
- if operation was not successful
-
initialize
Initializes the organizational units.- Parameters:
cms
- the admin CMS context- Throws:
CmsException
- if something goes wrong
-
readOrganizationalUnit
public CmsOrganizationalUnit readOrganizationalUnit(CmsObject cms, String ouFqn) throws CmsException Reads an organizational Unit based on its fully qualified name.- Parameters:
cms
- the opencms contextouFqn
- 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, String ouFqn, String resourceName) throws CmsException Removes a resource from the given organizational unit.- Parameters:
cms
- the opencms contextouFqn
- the fully qualified name of the organizational unit to remove the resource fromresourceName
- the name of the resource that is to be removed from the organizational unit- Throws:
CmsException
- if something goes wrong
-
searchUsers
Searches users which fit the given search parameters.- Parameters:
cms
- the current CMS contextparams
- the user search parameters- Returns:
- the users which fit the given search criteria
- Throws:
CmsException
- if something goes wrong
-
setUsersOrganizationalUnit
public void setUsersOrganizationalUnit(CmsObject cms, String ouFqn, String userName) throws CmsException Moves an user to the given organizational unit.- Parameters:
cms
- the opencms contextouFqn
- the full qualified name of the organizational unit to add the user touserName
- 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 contextorganizationalUnit
- the organizational unit that should be written- Throws:
CmsException
- if operation was not successful
-