ccc.services.ejb3
Class FilesEJB

java.lang.Object
  extended by ccc.services.ejb3.FilesEJB
All Implemented Interfaces:
Files

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

EJB implementation of the Files interface.

Author:
Civic Computing Ltd.

Field Summary
 
Fields inherited from interface ccc.api.core.Files
NAME
 
Constructor Summary
FilesEJB()
           
 
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(File file)
          Create a new CCC file.
 ResourceSummary createTextFile(File file)
          Create a new text file 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.
 PagedCollection<File> getPagedImages(java.util.UUID folderId, int pageNo, int pageSize)
          List all images of the given folder id.
protected  IRepositoryFactory getRepoFactory()
          Accessor.
protected  javax.ejb.TimerService getTimerService()
          Accessor.
 File retrieve(java.util.UUID fileId)
          Get the representation of an existing CCC file.
 void retrieve(java.util.UUID file, StreamAction action)
          Process the contents of a file with an action.
 void retrieveRevision(java.util.UUID file, int revision, StreamAction action)
          Process the contents of a file revision with an action.
 void retrieveWorkingCopy(java.util.UUID file, StreamAction action)
          Process the contents of a file's working copy with an action.
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 id, File file)
          Update an existing CCC file.
 ResourceSummary updateFile(java.util.UUID fileId, File file)
          Update an existing CCC file.
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

FilesEJB

public FilesEJB()
Method Detail

getPagedImages

@RolesAllowed(value="FILE_READ")
public PagedCollection<File> getPagedImages(java.util.UUID folderId,
                                                         int pageNo,
                                                         int pageSize)
List all images of the given folder id.

Specified by:
getPagedImages in interface Files
Parameters:
folderId - The id of the folder.
pageNo - The page to display.
pageSize - The number of results per page.
Returns:
The list of images.

create

@PermitAll
public ResourceSummary create(File file)
Create a new CCC file.

Specified by:
create in interface Files
Parameters:
file - The file to create.
Returns:
A summary of the newly created file.

updateFile

@RolesAllowed(value="FILE_UPDATE")
public ResourceSummary updateFile(java.util.UUID fileId,
                                               File file)
Update an existing CCC file.

Specified by:
updateFile in interface Files
Parameters:
fileId - The id of the file to update.
file - The changes to apply.
Returns:
A summary of the updated file.

update

@RolesAllowed(value="FILE_UPDATE")
public void update(java.util.UUID id,
                                File file)
Update an existing CCC file.

Specified by:
update in interface Files
Parameters:
id - The ID of the file to update.
file - The new file representation.

createTextFile

@RolesAllowed(value="FILE_CREATE")
public ResourceSummary createTextFile(File file)
Create a new text file in CCC.

Specified by:
createTextFile in interface Files
Parameters:
file - The textFile details.
Returns:
A resource summary describing the new text file.

retrieve

@PermitAll
public File retrieve(java.util.UUID fileId)
Get the representation of an existing CCC file.

Specified by:
retrieve in interface Files
Parameters:
fileId - The ID of the file to get.
Returns:
The file for the specified ID.

retrieve

@PermitAll
public void retrieve(java.util.UUID file,
                               StreamAction action)
Process the contents of a file with an action.

Specified by:
retrieve in interface Files
Parameters:
file - The file's ID.
action - The action to perform.

retrieveRevision

@PermitAll
public void retrieveRevision(java.util.UUID file,
                                       int revision,
                                       StreamAction action)
Process the contents of a file revision with an action.

Specified by:
retrieveRevision in interface Files
Parameters:
file - The file's ID.
revision - The file revision to retrieve.
action - The action to perform.

retrieveWorkingCopy

@PermitAll
public void retrieveWorkingCopy(java.util.UUID file,
                                          StreamAction action)
Process the contents of a file's working copy with an action.

Specified by:
retrieveWorkingCopy in interface Files
Parameters:
file - The file's ID.
action - The action to perform.

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.