Interface ServiceCommand

    • Method Detail

      • isValid

        @Transactional(readOnly=true,
                       noRollbackFor={NotValidException.class,NotAuthorizedException.class})
        boolean isValid()
        Determine if the command is in a valid state to be executed. If this method returns true, then 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 isAuthorized(). If the current user is not authorized to execute this command, this method must throw a NotAuthorizedException.

        If this method returns false, then 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.

        Returns:
        true if the command is in a valid state to be executed, false otherwise
        Throws:
        NotAuthorizedException - if calling isValid() on the command would return false.
      • getValidationErrors

        Collection<ValidationError> getValidationErrors()
        Gets the list of errors that are preventing the command from being executed. Calling this method before calling isValid() will always return an empty collection.
        Returns:
        a collection of ValidationError objects describing why command validation failed
      • execute

        void execute()
        Execute the command. After execution, the command should offer any indication of the results or products of the command as implementation-specific getter methods.
        Throws:
        NotAuthorizedException - if calling isAuthorized() on this command would return false
        NotValidException - if calling isValid() on this command would return false
        IllegalStateException - if the command has already been executed