com.flexive.shared.interfaces
Interface UserGroupEngine

All Known Subinterfaces:
UserGroupEngineLocal

public interface UserGroupEngine

Interface to the user group engine.

Author:
Gregor Schober (gregor.schober@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Method Summary
 long create(java.lang.String name, java.lang.String color, long mandatorId)
          Creates a new group for a specific mandator.
 java.util.List<Role> getRoles(long groupId)
          Gets all roles that are assigned to a group.
 UserGroup load(long groupId)
          Loads a group defined by its unique id.
 java.util.List<UserGroup> loadAll(long mandatorId)
          Loads all groups belonging to a specific mandator, plus GROUP_EVERYONE and GROUP_OWNER.
 UserGroup loadMandatorGroup(long mandatorId)
          Load the user group that contains all users of a given mandator
 void rebuildMandatorGroups()
          Rebuild the mandator groups
 void remove(long groupId)
          Removes a group defined by its unique id.
 void setRoles(long groupId, java.util.List<Role> roles)
          Sets the roles a group is in.
 void setRoles(long groupId, long[] roles)
          Sets the roles a group is in.
 void update(long groupId, java.lang.String name, java.lang.String color)
          Updates a group defined by its unique id.
 

Method Detail

load

UserGroup load(long groupId)
               throws FxApplicationException
Loads a group defined by its unique id.

No permission checks are performed

Parameters:
groupId - the unique id of the group to load
Returns:
the requested user group
Throws:
FxApplicationException - TODO
FxNoAccessException - if the user may not access the group
FxNotFoundException - if the group does not exist
FxLoadException - if the load failed

loadMandatorGroup

UserGroup loadMandatorGroup(long mandatorId)
                            throws FxApplicationException
Load the user group that contains all users of a given mandator

Parameters:
mandatorId - mandator
Returns:
UserGroup containing all users of the mandator
Throws:
FxApplicationException - on errors

loadAll

java.util.List<UserGroup> loadAll(long mandatorId)
                                  throws FxApplicationException
Loads all groups belonging to a specific mandator, plus GROUP_EVERYONE and GROUP_OWNER.

Specify -1 t load all groups within the system (all mandators).

Parameters:
mandatorId - the mandator id to load the groups for, or -1 to load all groups
Returns:
all groups belonging to the mandator
Throws:
FxApplicationException - TODO
FxNoAccessException - If the calling user may not access the groups of the given mandator
FxLoadException - if the load failed

create

long create(java.lang.String name,
            java.lang.String color,
            long mandatorId)
            throws FxApplicationException
Creates a new group for a specific mandator.

A user may only create groups for the mandator he belongs to, and only if he is in the role ROLE_GROUP_MANAGEMENT. Global supervisors are a exception and may create groups for all mandators.

Parameters:
name - the unique name for the group
color - the color of the group as 7 digit string holding the RGB value, eg '#FF0000' for pure red, or the name of a CSS class
mandatorId - the mandator the group belongs to
Returns:
the created group's ID
Throws:
FxApplicationException - TODO
FxNoAccessException - if the calling user lacks the permissions to create the group
FxEntryExistsException - if a group with the given name exists
FxInvalidParameterException - if a parameter was invalid (name,color,mandator)
FxCreateException - if the create failed

update

void update(long groupId,
            java.lang.String name,
            java.lang.String color)
            throws FxApplicationException
Updates a group defined by its unique id.

Users may only update groups of the mandator they belong to if they are in role ROLE_GROUP_MANAGEMENT.
Global supervisors may update the groups of all mandators.

Parameters:
groupId - The group that should be updated
color - the color of the group as 6 digit RGB value (eg 'FF0000' for pure red), or null to keep the old value
name - the new name of the group, or null to keep the old value
Throws:
FxApplicationException - TODO
FxNotFoundException - if the group to update does not exist
FxNoAccessException - if the user lacks the permissions to update the group
FxUpdateException - if the update failed
FxEntryExistsException - if a group with the desired new name does already exist
FxInvalidParameterException - if a parameter was invalid (eg. the color format)

remove

void remove(long groupId)
            throws FxApplicationException
Removes a group defined by its unique id.

Users may only remove groups belonging to their mandator, and only if they are in ROLE_GROUP_MANAGEMENT.
Global supervisors may remove groups of all mandators. The groups GROUP_EVERYONE and GROUP_OWNER may not be removed in any case.

Parameters:
groupId - the unqiue id of the group to remove
Throws:
FxApplicationException - TODO
FxNoAccessException - if the user lacks the permissions to remove the group
FxNotFoundException - if the group does not exist
FxRemoveException - if the remove failed

setRoles

void setRoles(long groupId,
              long[] roles)
              throws FxApplicationException
Sets the roles a group is in.

To set roles the caller must be in role ROLE_ROLE_MANAGEMENT, and may only update groups belonging to his mandator.
GROUP_GLOBAL_SUPERVISOR may set the roles for groups of all users.

Parameters:
groupId - the group to set the roles for
roles - the roles to set
Throws:
FxApplicationException - TODO
FxNoAccessException - if the calling user lacks the permissions to set the roles for the given group
FxNotFoundException - if the group does not exist
FxUpdateException - if setting the roles failed

setRoles

void setRoles(long groupId,
              java.util.List<Role> roles)
              throws FxApplicationException
Sets the roles a group is in.

To set roles the caller must be in role ROLE_ROLE_MANAGEMENT, and may only update groups belonging to his mandator.
GROUP_GLOBAL_SUPERVISOR may set the roles for groups of all users.

Parameters:
groupId - the group to set the roles for
roles - the roles to set
Throws:
FxApplicationException - TODO
FxNoAccessException - if the calling user lacks the permissions to set the roles for the given group
FxNotFoundException - if the group does not exist
FxUpdateException - if setting the roles failed

getRoles

java.util.List<Role> getRoles(long groupId)
                              throws FxApplicationException
Gets all roles that are assigned to a group.

The caller may see the role assignments for all groups belonging to his mandator.
GLOBAL_SUPERVISOR may see the role assignments of all groups.

Parameters:
groupId - the group to get the assigned roles for
Returns:
a list of the roles that ate assigned to the group
Throws:
FxApplicationException - TODO
FxNoAccessException - if the caller lacks the permissions to get the roles
FxNotFoundException - if the group does not exist
FxLoadException - if the function failed to load the data

rebuildMandatorGroups

void rebuildMandatorGroups()
                           throws FxApplicationException
Rebuild the mandator groups

Throws:
FxApplicationException - on errors