ccc.services.ejb3
Class FoldersEJB

java.lang.Object
  extended by ccc.services.ejb3.FoldersEJB
All Implemented Interfaces:
Folders

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

EJB implementation of the FoldersExt interface.

Author:
Civic Computing Ltd.

Field Summary
 
Fields inherited from interface ccc.api.core.Folders
NAME
 
Constructor Summary
FoldersEJB()
           
 
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(Folder folder)
          Create a folder with the specified name.
 ResourceSummary createFolder(java.util.UUID parentId, java.lang.String name, java.lang.String title, boolean publish)
          Create a folder with the specified name and title.
 ResourceSummary createRoot(java.lang.String name)
          Create a root folder with the specified name.
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<ResourceSummary> getAccessibleChildren(java.util.UUID folderId)
          List all of the children of the specified folder which are accessible to current user.
protected  IRepositoryFactory getRepoFactory()
          Accessor.
protected  javax.ejb.TimerService getTimerService()
          Accessor.
 java.lang.Boolean nameExistsInFolder(java.util.UUID folderId, java.lang.String name)
          Query whether given folder has a resource with given name.
 PagedCollection<ResourceSummary> roots()
          List the root folders available.
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 folderId, Folder delta)
          Update the specified folder.
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

FoldersEJB

public FoldersEJB()
Method Detail

create

@PermitAll
public ResourceSummary create(Folder folder)
Create a folder with the specified name.

Specified by:
create in interface Folders
Parameters:
folder - Details of the new folder.
Returns:
A resource summary describing the new folder.

createFolder

@PermitAll
public ResourceSummary createFolder(java.util.UUID parentId,
                                              java.lang.String name,
                                              java.lang.String title,
                                              boolean publish)
Create a folder with the specified name and title.

Specified by:
createFolder in interface Folders
Parameters:
parentId - The folder in which the new folder should be created.
name - The name of the new folder.
title - The title of the folder.
publish - True if the title should be published, false otherwise.
Returns:
A resource summary describing the new folder.

createRoot

@RolesAllowed(value="ROOT_CREATE")
public ResourceSummary createRoot(java.lang.String name)
Create a root folder with the specified name.

Specified by:
createRoot in interface Folders
Parameters:
name - The name of the root folder.
Returns:
A resource summary describing the new root.

update

@RolesAllowed(value="FOLDER_UPDATE")
public void update(java.util.UUID folderId,
                                Folder delta)
Update the specified folder.

Specified by:
update in interface Folders
Parameters:
folderId - The id of the folder to update.
delta - The updated details of the folder.

nameExistsInFolder

@PermitAll
public java.lang.Boolean nameExistsInFolder(java.util.UUID folderId,
                                                      java.lang.String name)
Query whether given folder has a resource with given name.

Specified by:
nameExistsInFolder in interface Folders
Parameters:
folderId - The id of the folder to check.
name - The name of the resource.
Returns:
Returns true in case folder has a resource with given name, false otherwise.

roots

@RolesAllowed(value="FOLDER_READ")
public PagedCollection<ResourceSummary> roots()
List the root folders available.

Specified by:
roots in interface Folders
Returns:
A collection of resource summaries - one for each root folder.

getAccessibleChildren

@PermitAll
public PagedCollection<ResourceSummary> getAccessibleChildren(java.util.UUID folderId)
List all of the children of the specified folder which are accessible to current user.

Specified by:
getAccessibleChildren in interface Folders
Parameters:
folderId - The folder.
Returns:
The folder's of children.

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.