ccc.services.ejb3
Class GroupsEJB

java.lang.Object
  extended by ccc.services.ejb3.GroupsEJB
All Implemented Interfaces:
Groups

@RolesAllowed(value={})
public class GroupsEJB
extends java.lang.Object
implements Groups

EJB implementation of the Groups interface.

Author:
Civic Computing Ltd.

Field Summary
 
Fields inherited from interface ccc.api.core.Groups
NAME
 
Constructor Summary
GroupsEJB()
           
 
Method Summary
protected  void checkPermission(java.lang.String... permissions)
          Check that the current user has ONE OF the specified permissions.
protected  void checkRead(ResourceEntity r)
          Check that a resource is readable by a user.
protected  void checkWrite(ResourceEntity r)
          Check that a resource is write-able by a user.
 CommandFactory commands()
          Accessor.
 Group create(Group comment)
          Create a new group in the system.
protected  UserEntity currentUser()
          Accessor.
protected  java.util.UUID currentUserId()
          Accessor.
protected
<T> T
execute(Command<T> command)
          Execute a command on behalf of the current user.
protected  java.util.Collection<? extends ResourceEntity> filterAccessibleTo(UserEntity u, java.util.List<? extends ResourceEntity> resources)
          Filter a collection of resources based on accessibility.
protected  IRepositoryFactory getRepoFactory()
          Accessor.
protected  javax.ejb.TimerService getTimerService()
          Accessor.
 PagedCollection<Group> query(java.lang.String name, int pageNo, int pageSize)
          List available groups.
 Group retrieve(java.util.UUID id)
          Find the group for a given ID.
protected
<T> T
sudoExecute(Command<T> command, java.util.UUID actorId, java.util.Date happenedOn)
          Execute a command on behalf of another user.
 Group update(java.util.UUID id, Group group)
          Update an existing group in the system.
protected  UserEntity userForId(java.util.UUID userId)
          Look up the user for the specified ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupsEJB

public GroupsEJB()
Method Detail

create

@RolesAllowed(value="GROUP_CREATE")
public Group create(Group comment)
Create a new group in the system.

Specified by:
create in interface Groups
Parameters:
comment - The new group details.
Returns:
A DTO describing the new group.

retrieve

@RolesAllowed(value="GROUP_READ")
public Group retrieve(java.util.UUID id)
Find the group for a given ID.

Specified by:
retrieve in interface Groups
Parameters:
id - The group ID.
Returns:
Returns the corresponding group.

query

@RolesAllowed(value="GROUP_READ")
public PagedCollection<Group> query(java.lang.String name,
                                                 int pageNo,
                                                 int pageSize)
List available groups.

Specified by:
query in interface Groups
Parameters:
name - Filter based on group name. NULL disables filter.
pageNo - The page to display.
pageSize - The number of results per page.
Returns:
Returns paged list of groups.

update

@RolesAllowed(value="GROUP_UPDATE")
public Group update(java.util.UUID id,
                                 Group group)
Update an existing group in the system.

Specified by:
update in interface Groups
Parameters:
id - The ID of the group to update.
group - The updated group details.
Returns:
A DTO describing the updated group.

getRepoFactory

protected IRepositoryFactory getRepoFactory()
Accessor.

Returns:
Returns the repository factory.

commands

public CommandFactory commands()
Accessor.

Returns:
Returns the command factory.

getTimerService

protected final javax.ejb.TimerService getTimerService()
Accessor.

Returns:
The timer service for this EJB.

sudoExecute

protected final <T> T sudoExecute(Command<T> command,
                                  java.util.UUID actorId,
                                  java.util.Date happenedOn)
Execute a command on behalf of another user.

Type Parameters:
T - The command's return type.
Parameters:
command - The command to execute.
actorId - The actor executing the command.
happenedOn - When the command was executed.
Returns:
The command's return value.

execute

protected final <T> T execute(Command<T> command)
Execute a command on behalf of the current user.

Type Parameters:
T - The command's return type.
Parameters:
command - The command to execute.
Returns:
The command's return value.

userForId

protected UserEntity userForId(java.util.UUID userId)
Look up the user for the specified ID.

Parameters:
userId - The user's ID.
Returns:
The corresponding user.

currentUser

protected UserEntity currentUser()
Accessor. TODO: Throw 'invalid session exception instead.

Returns:
The currently logged in user.

currentUserId

protected java.util.UUID currentUserId()
Accessor.

Returns:
The currently logged in user's ID.

checkRead

protected void checkRead(ResourceEntity r)
Check that a resource is readable by a user.

Parameters:
r - The resource to check.

checkWrite

protected void checkWrite(ResourceEntity r)
Check that a resource is write-able by a user.

Parameters:
r - The resource to check.

checkPermission

protected void checkPermission(java.lang.String... permissions)
Check that the current user has ONE OF the specified permissions.

Parameters:
permissions - The permissions to check.

filterAccessibleTo

protected java.util.Collection<? extends ResourceEntity> filterAccessibleTo(UserEntity u,
                                                                            java.util.List<? extends ResourceEntity> resources)
Filter a collection of resources based on accessibility.

Parameters:
u - The user reading the collection.
resources - The un-filtered collection.
Returns:
Subset of the input collection, accessible to the specified user.


Copyright © 2010. All Rights Reserved.