diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java index 67bbc3db8e..b921f5beea 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java @@ -23,7 +23,6 @@ package org.onap.so.apihandler.common; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -31,31 +30,31 @@ import org.springframework.stereotype.Component; @Component public class ResponseBuilder { - - @Value("${mso.infra.default.versions.apiMinorVersion}") - private String apiMinorVersion; - @Value("${mso.infra.default.versions.apiPatchVersion}") - private String apiPatchVersion; - - public Response buildResponse(int status, String requestId, Object jsonResponse, String apiVersion) { - - if (apiVersion.matches("v[1-9]")) { - apiVersion = apiVersion.substring(1); - } - - String latestVersion = apiVersion + "." + apiMinorVersion + "." + apiPatchVersion; - - javax.ws.rs.core.Response.ResponseBuilder builder = Response.status(status) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .header(CommonConstants.X_MINOR_VERSION, apiMinorVersion) - .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion) - .header(CommonConstants.X_LATEST_VERSION, latestVersion); - - if(StringUtils.isNotBlank(requestId)) { - builder.header(CommonConstants.X_TRANSACTION_ID, requestId); - } - - return builder.entity(jsonResponse).build(); - } + + @Value("${mso.infra.default.versions.apiMinorVersion}") + private String apiMinorVersion; + @Value("${mso.infra.default.versions.apiPatchVersion}") + private String apiPatchVersion; + + public Response buildResponse(int status, String requestId, Object jsonResponse, String apiVersion) { + + if (apiVersion.matches("v[1-9]")) { + apiVersion = apiVersion.substring(1); + } + + String latestVersion = apiVersion + "." + apiMinorVersion + "." + apiPatchVersion; + + javax.ws.rs.core.Response.ResponseBuilder builder = + Response.status(status).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .header(CommonConstants.X_MINOR_VERSION, apiMinorVersion) + .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion) + .header(CommonConstants.X_LATEST_VERSION, latestVersion); + + if (StringUtils.isNotBlank(requestId)) { + builder.header(CommonConstants.X_TRANSACTION_ID, requestId); + } + + return builder.entity(jsonResponse).build(); + } } |