ccc.services.ejb3
Class PagesEJB

java.lang.Object
  extended by ccc.services.ejb3.PagesEJB
All Implemented Interfaces:
Pages

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

EJB implementation of the PagesExt interface.

Author:
Civic Computing Ltd.

Field Summary
 
Fields inherited from interface ccc.api.core.Pages
NAME
 
Constructor Summary
PagesEJB()
           
 
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.
 ResourceSummary create(Page page)
          Creates a new page.
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<ResourceSummary> list(PageCriteria criteria, int pageNo, int pageSize)
          List existing pages.
 Page retrieve(java.util.UUID pageId)
          Retrieve the page.
 Page retrieveWorkingCopy(java.util.UUID pageId)
          Retrieve the working copy for a page.
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 pageId, Page delta)
          Update the specified page on the server.
 void updateWorkingCopy(java.util.UUID pageId, Page delta)
          Update the working copy of the specified page.
protected  UserEntity userForId(java.util.UUID userId)
          Look up the user for the specified ID.
 java.lang.String validate(Page page)
          Validate a set of paragraphs against a given definition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PagesEJB

public PagesEJB()
Method Detail

create

@PermitAll
public ResourceSummary create(Page page)
Creates a new page.

Specified by:
create in interface Pages
Parameters:
page - Details of the new page to create.
Returns:
A resource summary describing the new page.

update

@RolesAllowed(value="PAGE_UPDATE")
public void update(java.util.UUID pageId,
                                Page delta)
Update the specified page on the server.

Specified by:
update in interface Pages
Parameters:
pageId - The id of the page to update.
delta - The changes to apply.

updateWorkingCopy

@RolesAllowed(value="PAGE_UPDATE")
public void updateWorkingCopy(java.util.UUID pageId,
                                           Page delta)
Update the working copy of the specified page.

Specified by:
updateWorkingCopy in interface Pages
Parameters:
pageId - The id of the page to update.
delta - The changes to apply.

validate

@RolesAllowed(value="PAGE_UPDATE")
public java.lang.String validate(Page page)
Validate a set of paragraphs against a given definition.

Specified by:
validate in interface Pages
Parameters:
page - The page to test.
Returns:
A list of errors, as strings.

retrieve

@PermitAll
public Page retrieve(java.util.UUID pageId)
Retrieve the page.

Specified by:
retrieve in interface Pages
Parameters:
pageId - The page's id.
Returns:
The corresponding page.

retrieveWorkingCopy

@RolesAllowed(value="PAGE_UPDATE")
public Page retrieveWorkingCopy(java.util.UUID pageId)
Retrieve the working copy for a page.

Specified by:
retrieveWorkingCopy in interface Pages
Parameters:
pageId - The page's id.
Returns:
The corresponding working copy.

list

@PermitAll
public PagedCollection<ResourceSummary> list(PageCriteria criteria,
                                                       int pageNo,
                                                       int pageSize)
List existing pages.

Specified by:
list in interface Pages
Parameters:
criteria - The criteria by which to filter pages.
pageNo - The page of results to return.
pageSize - The number of results in a page.
Returns:
A list of pages.

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.