/** * Builds a {@link ParameterSet} from a {@link RequestEntity}. Currently only supports * JSON payload, and only basic JSON objects that are essentially key-value pairs, where the * values are primitives (String, numeric or boolean). * @param entity The RequestEntity payload, expected to be JSON. * @return a {@link ParameterSet} instance with key-value pairs from the JSON entity, or * and empty instance if there is no body in the entity. */ protected final ParameterSet getParamsFromEntity(RequestEntity<String> entity) { // attempt to build a parameter map from the request entity/payload if (entity != null && entity.hasBody()) { MediaType contentType = entity.getHeaders().getContentType(); String body = entity.getBody(); if (MediaType.APPLICATION_JSON.isCompatibleWith(contentType)) { // parse just a basic key-value styled JSON payload return handleJsonPayload(body); } else if (contentType.getSubtype().equals("xml")) { // handle XML payload return handleXmlPayload(body); } else { getLogger().error("RequestEntity does not have a JSON or XML payload. MediaType: " + contentType); } } return ParameterSetFactory.buildEmptyParameterSet(); }