/** * Creates a successful response with the specified message. * * @param message the message to return, which is optional and will be truncated to * {@link com.atlassian.scheduler.status.RunDetails#MAXIMUM_MESSAGE_LENGTH} if necessary * @return the response */ public static JobRunnerResponse success(@Nullable final String message) { return new JobRunnerResponse(SUCCESS, message); }
/** * Creates a response that indicates the request has failed. * * @param message the message to return, which will be truncated to {@link com.atlassian.scheduler.status.RunDetails#MAXIMUM_MESSAGE_LENGTH} if * necessary. The message is <strong>required</strong> when reporting that the job has failed. * @return the response */ public static JobRunnerResponse failed(final String message) { checkArgument(isNotBlank(message), "The message must be specified when reporting a job as failed!"); return new JobRunnerResponse(FAILED, message); }
/** * Creates a response that indicates the request was aborted. In most cases, it will make * more sense to report the job as either having {@link #success() succeeded} with nothing to * do or {@link #failed(String) failed}, instead. * * @param message the message to return, which will be truncated to {@link com.atlassian.scheduler.status.RunDetails#MAXIMUM_MESSAGE_LENGTH} if * necessary. The message is <strong>required</strong> when reporting that the job was aborted. * @return the response */ public static JobRunnerResponse aborted(final String message) { checkArgument(isNotBlank(message), "The message must be specified when reporting a job as aborted!"); return new JobRunnerResponse(ABORTED, message); }
/** * Creates a response that indicates the request has failed. The {@link #getMessage() message} is set to * to an abbreviated representation of the exception and its causes, but the * {@link com.atlassian.scheduler.status.RunDetails#MAXIMUM_MESSAGE_LENGTH} still applies, so this information may be incomplete. * When possible, the {@link JobRunner} is encouraged to trap its exceptions and report more specific * diagnostic messages with {@link #failed(String)}, instead. * * @param cause the exception that caused this failure * @return the response */ public static JobRunnerResponse failed(final Throwable cause) { return new JobRunnerResponse(FAILED, toMessage(requireNonNull(cause, "cause"))); }