public abstract class AbstractAction extends RoleBasedObject
| Constructor and Description |
|---|
AbstractAction()
Constructor
Creates an action without any required role for its execution
|
AbstractAction(Role... requiredRoles)
Constructor.
|
AbstractAction(String... requiredRoleNames)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRequiredRole(Role... roles)
Adds required roles to this action.
|
void |
addRequiredRole(String... roleNames)
Adds required roles to this action.
|
void |
clearRequiredRoles()
Remove all required roles associations.
|
void |
execute(User user,
Object... params)
Execute this action.
|
Set<Role> |
getRequiredRoles() |
protected void |
postRun(User user,
Object... params)
Called after action execution.
|
protected void |
preRun(User user,
Object... params)
Called before action execution.
|
void |
removeRequiredRole(Role... roles)
Removes a required role.
|
void |
removeRequiredRole(String... roleNames)
Removes a required role.
|
protected abstract void |
run(User user,
Object... params)
Actual action code.
|
addRole, addRole, clearRoles, getRoles, removeRole, removeRolepublic AbstractAction()
RoleBasedObject.RoleBasedObject()public AbstractAction(Role... requiredRoles) throws IllegalArgumentException, DuplicateException
requiredRoles - required roles for execution.IllegalArgumentException - if any of given roles is nullDuplicateException - if there is an attempt to register the same role more than once (either directly of as a child of any associated role).RoleBasedObject.RoleBasedObject(Role...),
run(User, Object...)public AbstractAction(String... requiredRoleNames) throws IllegalArgumentException, DuplicateException, RoleNotFoundException
requiredRoleNames - required roles for execution.IllegalArgumentException - if any of given roles is nullRoleNotFoundException - if any of given roleNames is not registered in RoleRepositoryDuplicateException - if there is an attempt to register the same role more than once (either directly of as a child of any associated role).RoleBasedObject.RoleBasedObject(String...),
run(User, Object...)protected void preRun(User user, Object... params)
user - user running this actionparams - parameters passed to action on execute(User, Object...)protected abstract void run(User user, Object... params)
user - user running actionparams - parameters passed to action on execute(User, Object...)protected void postRun(User user, Object... params)
user - user running actionparams - parameters passed to action on execute(User, Object...)public final Set<Role> getRequiredRoles()
public final void addRequiredRole(Role... roles) throws DuplicateException, IllegalArgumentException
roles - required roles. User running this action must have all required roles in order to proceed.IllegalArgumentException - if roles.length == 0 or any given role is nullDuplicateException - if given role was already associated to this object (either directly or as child of any associated role)public final void addRequiredRole(String... roleNames) throws DuplicateException, IllegalArgumentException, RoleNotFoundException
roleNames - roles to be added. Role instances will be obtained through RoleRepositoryIllegalArgumentException - if roleNames.length == 0 or any of given roleNames is null/emptyDuplicateException - if given role was already associated to this object (either directly or as child of any associated role)RoleNotFoundException - if any of given roleNames is not registered in RoleRepositorypublic final void removeRequiredRole(Role... roles) throws IllegalArgumentException
roles - role to be removed from association set. If given role is not associated to this instance, nothing happens.IllegalArgumentException - if roles.length == 0 or any of given roles is nullpublic final void removeRequiredRole(String... roleNames) throws IllegalArgumentException, RoleNotFoundException
roleNames - role to be removed from association set. If given role is not associated to this instance, nothing happens. Role instances will be obtained through RoleRepositoryIllegalArgumentException - if roleNames.length == 0 or any given role is null/emptyRoleNotFoundException - if any given role is not registered in RoleRepositorypublic final void clearRequiredRoles()
public final void execute(User user, Object... params) throws SecurityException
user - user calling this action. Given user must fulfill (via see User.getRoles()) all required roles (see getRequiredRoles()) in order to execute this actionparams - extra parameters passed to action execution.SecurityException - If user does not fulfill required roles.Copyright © 2015 Agapsys Tecnologia Ltda-ME. All rights reserved.