aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-service/src/main/java')
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java9
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatus.java39
2 files changed, 40 insertions, 8 deletions
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
index 8f36ac5..f2e0bd1 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
@@ -148,6 +148,15 @@ public class SchemaServiceApp {
@PreDestroy
public void cleanup() {
+
+ LoggingContext.save();
+ LoggingContext.component("Stopped");
+ LoggingContext.partnerName("NA");
+ LoggingContext.targetEntity(APP_NAME);
+ LoggingContext.requestId(UUID.randomUUID().toString());
+ LoggingContext.serviceName(APP_NAME);
+ LoggingContext.targetServiceName("Stopped");
+ LoggingContext.statusCode(StatusCode.COMPLETE);
logger.info("SchemaService shutting down");
}
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatus.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatus.java
index 4fd3220..8b03ac2 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatus.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatus.java
@@ -24,10 +24,12 @@ import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.schemaservice.interceptors.AAIContainerFilter;
import javax.annotation.Priority;
+import javax.print.attribute.standard.Media;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -39,15 +41,18 @@ public class InvalidResponseStatus extends AAIContainerFilter implements Contain
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
throws IOException {
- if (responseContext.getStatus() == 405) {
+ String contentType = responseContext.getHeaderString("Content-Type");
+ ArrayList<String> templateVars = new ArrayList<>();
+ List<MediaType> mediaTypeList = new ArrayList<>();
+ AAIException e;
+ String message = "";
- responseContext.setStatus(400);
- AAIException e = new AAIException("AAI_3012");
- ArrayList<String> templateVars = new ArrayList<>();
+ if (responseContext.getStatus() == 405) {
- List<MediaType> mediaTypeList = new ArrayList<>();
+ // add the accept type error msg here as well.
- String contentType = responseContext.getHeaderString("Content-Type");
+ responseContext.setStatus(400);
+ e = new AAIException("AAI_3012");
if (contentType == null) {
mediaTypeList.add(MediaType.APPLICATION_XML_TYPE);
@@ -55,11 +60,29 @@ public class InvalidResponseStatus extends AAIContainerFilter implements Contain
mediaTypeList.add(MediaType.valueOf(contentType));
}
- String message = ErrorLogHelper.getRESTAPIErrorResponse(mediaTypeList, e, templateVars);
+ message = ErrorLogHelper.getRESTAPIErrorResponse(mediaTypeList, e, templateVars);
responseContext.setEntity(message);
}
+ else if (responseContext.getStatus() == 406) {
+ responseContext.setStatus(406);
+ mediaTypeList.add(MediaType.valueOf(contentType));
+ if (contentType.equals(MediaType.APPLICATION_XML)) {
+ e = new AAIException("AAI_3019", MediaType.APPLICATION_XML);
+ } else if (contentType.equals(MediaType.APPLICATION_JSON)) {
+ e = new AAIException("AAI_3019", MediaType.APPLICATION_JSON);
+ } else {
+ if (contentType == null) {
+ mediaTypeList.add(MediaType.APPLICATION_XML_TYPE);
+ e = new AAIException("AAI_3019", "null");
+ } else {
+ mediaTypeList.add(MediaType.valueOf(contentType));
+ e = new AAIException("AAI_3019", contentType);
+ }
+ }
+ message = ErrorLogHelper.getRESTAPIErrorResponse(mediaTypeList, e, templateVars);
+ responseContext.setEntity(message);
+ }
}
-
}