Class RunAsUserCommand
- java.lang.Object
-
- com.atlassian.confluence.core.service.RunAsUserCommand
-
- All Implemented Interfaces:
ServiceCommand
public class RunAsUserCommand extends Object implements ServiceCommand
TODO : confluence-7.0 do we even want to keep this around ? currently not used An experimental command for running services as another user. NOT CURRENTLY UNIT-TESTED
-
-
Constructor Summary
Constructors Constructor Description RunAsUserCommand(ConfluenceUser userToRunAs, ServiceCommand delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexecute()Execute the command.CollectiongetValidationErrors()Gets the list of errors that are preventing the command from being executed.booleanisAuthorized()Determine if the current user is authorized to execute this command.booleanisValid()Determine if the command is in a valid state to be executed.
-
-
-
Constructor Detail
-
RunAsUserCommand
public RunAsUserCommand(ConfluenceUser userToRunAs, ServiceCommand delegate)
- Since:
- 5.2
-
-
Method Detail
-
isValid
public boolean isValid()
Description copied from interface:ServiceCommandDetermine if the command is in a valid state to be executed. If this method returns true, thenServiceCommand.execute()is be expected to perform successfully (unless prevented by some system error). If this method returns false,executewill fail with aNotValidException.This method should be called after checking
ServiceCommand.isAuthorized(). If the current user is not authorized to execute this command, this method must throw aNotAuthorizedException.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 bygetValidationErrors()must be empty.- Specified by:
isValidin interfaceServiceCommand- Returns:
- true if the command is in a valid state to be executed, false otherwise
-
getValidationErrors
public Collection getValidationErrors()
Description copied from interface:ServiceCommandGets the list of errors that are preventing the command from being executed. Calling this method before callingServiceCommand.isValid()will always return an empty collection.- Specified by:
getValidationErrorsin interfaceServiceCommand- Returns:
- a collection of
ValidationErrorobjects describing why command validation failed
-
isAuthorized
public boolean isAuthorized()
Description copied from interface:ServiceCommandDetermine if the current user is authorized to execute this command. The "current user" for a command is the user returned byAuthenticatedUserThreadLocal.get().- Specified by:
isAuthorizedin interfaceServiceCommand- Returns:
- true if the current user is authorized to execute this command, false otherwise.
-
execute
public void execute()
Description copied from interface:ServiceCommandExecute the command. After execution, the command should offer any indication of the results or products of the command as implementation-specific getter methods.- Specified by:
executein interfaceServiceCommand
-
-