ccc.services.ejb3
Class AliasesEJB

java.lang.Object
  extended by ccc.services.ejb3.AliasesEJB
All Implemented Interfaces:
Aliases

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

EJB implementation of the Aliases interface.

Author:
Civic Computing Ltd.

Field Summary
 
Fields inherited from interface ccc.api.core.Aliases
NAME
 
Constructor Summary
AliasesEJB()
           
 
Method Summary
 java.lang.String aliasTargetName(java.util.UUID aliasId)
          Retrieve the target name for a alias.
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.
 ResourceSummary create(Alias alias)
          Create a new alias in CCC.
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.
protected
<T> T
sudoExecute(Command<T> command, java.util.UUID actorId, java.util.Date happenedOn)
          Execute a command on behalf of another user.
 void update(java.util.UUID aliasId, Alias delta)
          Update an alias.
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

AliasesEJB

public AliasesEJB()
Method Detail

update

@RolesAllowed(value="ALIAS_UPDATE")
public void update(java.util.UUID aliasId,
                                Alias delta)
Update an alias.

Specified by:
update in interface Aliases
Parameters:
aliasId - The id of the alias to update.
delta - The changes to apply.

create

@RolesAllowed(value="ALIAS_CREATE")
public ResourceSummary create(Alias alias)
Create a new alias in CCC.

Specified by:
create in interface Aliases
Parameters:
alias - The alias to create.
Returns:
A resource summary describing the new alias.

aliasTargetName

@RolesAllowed(value="ALIAS_READ")
public java.lang.String aliasTargetName(java.util.UUID aliasId)
Retrieve the target name for a alias.

Specified by:
aliasTargetName in interface Aliases
Parameters:
aliasId - The alias' id.
Returns:
The corresponding target name.

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.