Search in sources :

Example 1 with METADATA

use of uk.gov.justice.services.messaging.JsonEnvelope.METADATA in project microservice_framework by CJSCommonPlatform.

the class RestEnvelopeBuilder method payload.

private JsonObject payload() {
    final JsonObjectBuilder payloadBuilder = initialPayload.map(jsonObject -> createObjectBuilderWithFilter(jsonObject, key -> !key.equals(METADATA))).orElse(Json.createObjectBuilder());
    params.ifPresent(parameters -> parameters.forEach(param -> {
        switch(param.getType()) {
            case NUMERIC:
                payloadBuilder.add(param.getName(), param.getNumericValue());
                break;
            case BOOLEAN:
                payloadBuilder.add(param.getName(), param.getBooleanValue());
                break;
            default:
                payloadBuilder.add(param.getName(), param.getStringValue());
        }
    }));
    return payloadBuilder.build();
}
Also used : CLIENT_CORRELATION_ID(uk.gov.justice.services.common.http.HeaderConstants.CLIENT_CORRELATION_ID) MetadataBuilder(uk.gov.justice.services.messaging.MetadataBuilder) JsonEnvelope.envelopeFrom(uk.gov.justice.services.messaging.JsonEnvelope.envelopeFrom) SESSION_ID(uk.gov.justice.services.common.http.HeaderConstants.SESSION_ID) METADATA(uk.gov.justice.services.messaging.JsonEnvelope.METADATA) Json(javax.json.Json) JsonEnvelope.metadataFrom(uk.gov.justice.services.messaging.JsonEnvelope.metadataFrom) JsonObject(javax.json.JsonObject) Parameter(uk.gov.justice.services.adapter.rest.parameter.Parameter) Collections.emptyList(java.util.Collections.emptyList) CAUSATION(uk.gov.justice.services.common.http.HeaderConstants.CAUSATION) Collection(java.util.Collection) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) USER_ID(uk.gov.justice.services.common.http.HeaderConstants.USER_ID) Consumer(java.util.function.Consumer) List(java.util.List) JsonObjects.getJsonObject(uk.gov.justice.services.messaging.JsonObjects.getJsonObject) HttpHeaders(javax.ws.rs.core.HttpHeaders) Optional(java.util.Optional) BadRequestException(uk.gov.justice.services.adapter.rest.exception.BadRequestException) Metadata(uk.gov.justice.services.messaging.Metadata) Arrays.stream(java.util.Arrays.stream) JsonObjects.createObjectBuilderWithFilter(uk.gov.justice.services.messaging.JsonObjects.createObjectBuilderWithFilter) JsonObjectBuilder(javax.json.JsonObjectBuilder) JsonEnvelope(uk.gov.justice.services.messaging.JsonEnvelope) JsonObjectBuilder(javax.json.JsonObjectBuilder)

Aggregations

String.format (java.lang.String.format)1 Arrays.stream (java.util.Arrays.stream)1 Collection (java.util.Collection)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Json (javax.json.Json)1 JsonObject (javax.json.JsonObject)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 HttpHeaders (javax.ws.rs.core.HttpHeaders)1 BadRequestException (uk.gov.justice.services.adapter.rest.exception.BadRequestException)1 Parameter (uk.gov.justice.services.adapter.rest.parameter.Parameter)1 CAUSATION (uk.gov.justice.services.common.http.HeaderConstants.CAUSATION)1 CLIENT_CORRELATION_ID (uk.gov.justice.services.common.http.HeaderConstants.CLIENT_CORRELATION_ID)1 SESSION_ID (uk.gov.justice.services.common.http.HeaderConstants.SESSION_ID)1 USER_ID (uk.gov.justice.services.common.http.HeaderConstants.USER_ID)1 JsonEnvelope (uk.gov.justice.services.messaging.JsonEnvelope)1