|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.confluence.core.service.AbstractServiceCommand
public abstract class AbstractServiceCommand
Base implementation of ServiceCommand
that takes care of the internal logic related to the order in which
the various operations must be performed.
To enforce the contract of ServiceCommand
, the non-abstract methods of this class are declared as
final, and template methods are provided for implementors to provide custom authorization, validation and
execution code.
Constructor Summary | |
---|---|
AbstractServiceCommand()
|
Method Summary | |
---|---|
void |
execute()
Execute the command. |
protected abstract void |
executeInternal()
Template method for implementations to perform command execution. |
protected com.atlassian.user.User |
getCurrentUser()
Gets the user responsible for executing this command |
java.util.Collection<ValidationError> |
getValidationErrors()
Gets the list of errors that are preventing the command from being executed. |
boolean |
isAuthorized()
Determine if the current user is authorized to execute this command. |
protected abstract boolean |
isAuthorizedInternal()
Template method for implementations to perform authorization. |
boolean |
isValid()
Determine if the command is in a valid state to be executed. |
protected abstract void |
validateInternal(ServiceCommandValidator validator)
Template method for implementations to perform validation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractServiceCommand()
Method Detail |
---|
public final boolean isValid()
ServiceCommand
ServiceCommand.execute()
is be expected to perform successfully (unless prevented by some system
error). If this method returns false, execute
will fail with a
NotValidException
.
This method should be called after checking ServiceCommand.isAuthorized()
. If the current user is not
authorized to execute this command, this method must throw a NotAuthorizedException
.
If this method returns false, then ServiceCommand.getValidationErrors()
must return a non-empty list of
errors explaining why the command was not valid. If this method returns true, the collection returned by
getValidationErrors()
must be empty.
isValid
in interface ServiceCommand
public java.util.Collection<ValidationError> getValidationErrors()
ServiceCommand
ServiceCommand.isValid()
will always return an empty collection.
getValidationErrors
in interface ServiceCommand
ValidationError
objects describing why command validation failedpublic final boolean isAuthorized()
ServiceCommand
AuthenticatedUserThreadLocal.get()
.
isAuthorized
in interface ServiceCommand
public final void execute()
ServiceCommand
execute
in interface ServiceCommand
protected final com.atlassian.user.User getCurrentUser()
protected abstract void validateInternal(ServiceCommandValidator validator)
Implementations can assume that if this method is called, authorization was already successful.
protected abstract boolean isAuthorizedInternal()
protected abstract void executeInternal()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |