protected String messageJson(String message) { return MessageJson.create(message); }
public static String create(String message, Consumer<OutputWriter> json) { return new MessageJson(message, json).toString(); }
public static HaltException haltBecauseForbidden() { return halt(HttpStatus.FORBIDDEN.value(), MessageJson.create(forbiddenMessage())); }
private void haltIfRequestBodyDoesNotContainPropertyJobs(Request req) { JsonReader requestBody = GsonTransformer.getInstance().jsonReaderFrom(req.body()); if (!requestBody.hasJsonObject(JOB_NAMES_PROPERTY)) { throw HaltApiResponses.haltBecauseOfReason("Could not read property '%s' in request body", JOB_NAMES_PROPERTY); } requestBody.readStringArrayIfPresent(JOB_NAMES_PROPERTY); } }
static TriState toTriState(String agentConfigState) { if (StringUtils.isBlank(agentConfigState)) { return TriState.UNSET; } else if (StringUtils.equalsIgnoreCase(agentConfigState, "enabled")) { return TriState.TRUE; } else if (StringUtils.equalsIgnoreCase(agentConfigState, "disabled")) { return TriState.FALSE; } else { throw HaltApiResponses.haltBecauseOfReason("The value of `agent_config_state` can be one of `Enabled`, `Disabled` or null."); } } }
public static HaltException haltBecauseNotFound() { return halt(HttpStatus.NOT_FOUND.value(), MessageJson.create(notFoundMessage())); }
public static HaltException haltBecauseEtagDoesNotMatch(String entityType, CaseInsensitiveString name) { return halt(HttpStatus.PRECONDITION_FAILED.value(), MessageJson.create(etagDoesNotMatch(entityType, name))); }
public static HaltException haltBecauseRateLimitExceeded() { return halt(HttpStatus.TOO_MANY_REQUESTS.value(), MessageJson.create(rateLimitExceeded())); }
public static HaltException haltBecauseJsonContentTypeExpected() { return halt(HttpStatus.UNSUPPORTED_MEDIA_TYPE.value(), MessageJson.create(jsonContentTypeExpected())); }
public static HaltException haltBecausePropertyIsNotAJsonArray(String property, JsonObject jsonObject) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonArray(property, jsonObject))); }
public static HaltException haltBecauseEntityAlreadyExists(Consumer<OutputWriter> jsonInRequestBody, String entityType, Object existingName) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(entityAlreadyExistsMessage(entityType, existingName), jsonInRequestBody)); }
public static HaltException haltBecausePropertyIsNotAJsonObject(String property, JsonObject jsonObject) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonObject(property, jsonObject))); }
public static HaltException haltBecauseMissingJsonProperty(String property, JsonObject jsonObject) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(missingJsonProperty(property, jsonObject))); }
public static HaltException haltBecauseRenameOfEntityIsNotSupported(String entityType) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(renameOfEntityIsNotSupportedMessage(entityType))); }
public static HaltException haltBecauseConfirmHeaderMissing() { return halt(HttpStatus.BAD_REQUEST.value(), MessageJson.create(confirmHeaderMissing())); }
public static HaltException haltBecausePropertyIsNotAJsonBoolean(String property, JsonObject jsonObject) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonBoolean(property, jsonObject))); }
public static HaltException haltBecausePropertyIsNotAJsonStringArray(String property, JsonObject jsonObject) { return halt(HttpStatus.UNPROCESSABLE_ENTITY.value(), MessageJson.create(propertyIsNotAJsonStringArray(property, jsonObject))); }
default void notFound(Exception ex, Request req, Response res) { res.status(HttpStatus.NOT_FOUND.value()); res.body(MessageJson.create(notFoundMessage())); }
public static HaltException haltBecauseEtagDoesNotMatch(String entityType, String name) { return halt(HttpStatus.PRECONDITION_FAILED.value(), MessageJson.create(etagDoesNotMatch(entityType, name))); }
public static String create(String message) { return create(message, null); }