From f8c058b2be718ab825f88e10e43ed59d5ca75de2 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Thu, 10 Nov 2022 11:03:00 +0000 Subject: Reduce the number of problems in schema-service Issue-ID: AAI-3590 Signed-off-by: Fiete Ostkamp Change-Id: I7a5d3e5a4db75efb8a8fcc6c8598d6cab80dca4a --- .../onap/aai/schemaservice/SchemaServiceApp.java | 5 ----- .../config/PropertyPasswordConfiguration.java | 3 ++- .../interceptors/post/InvalidResponseStatus.java | 2 -- .../aai/schemaservice/nodeschema/NodeIngestor.java | 12 +++++----- .../aai/schemaservice/web/JerseyConfiguration.java | 2 +- .../onap/aai/schemaservice/SchemaServiceTest.java | 26 +++++++++++++--------- 6 files changed, 24 insertions(+), 26 deletions(-) (limited to 'aai-schema-service') 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 291e0a6..1cc7a36 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 @@ -20,9 +20,6 @@ package org.onap.aai.schemaservice; -import java.util.Map; -import java.util.UUID; - import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; @@ -31,7 +28,6 @@ import org.onap.aai.exceptions.AAIException; import org.onap.aai.schemaservice.config.PropertyPasswordConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -41,7 +37,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerA import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.context.annotation.ComponentScan; import org.springframework.core.env.Environment; -import org.springframework.web.context.request.RequestContextListener; @SpringBootApplication // Component Scan provides a way to look for spring beans diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java index 2292577..bd8ce6e 100644 --- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java +++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.Charset; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; @@ -61,7 +62,7 @@ public class PropertyPasswordConfiguration try (InputStream passwordStream = new FileInputStream(passwordFile)) { String keystorePassword = null; - keystorePassword = IOUtils.toString(passwordStream); + keystorePassword = IOUtils.toString(passwordStream, Charset.defaultCharset()); if (keystorePassword != null) { keystorePassword = keystorePassword.trim(); sslProps.put("server.ssl.key-store-password", keystorePassword); 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 5f80b2b..5a09615 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 @@ -25,12 +25,10 @@ import java.util.ArrayList; import java.util.List; 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 org.onap.aai.exceptions.AAIException; import org.onap.aai.logging.ErrorLogHelper; diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java index e7b9167..ad39e49 100644 --- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java +++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java @@ -20,6 +20,12 @@ package org.onap.aai.schemaservice.nodeschema; +import com.google.common.base.CaseFormat; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; + +import jakarta.xml.bind.JAXBException; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -58,12 +64,6 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import com.google.common.base.CaseFormat; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; - -import jakarta.xml.bind.JAXBException; - /** * NodeIngestor - ingests A&AI OXM files per given config, serves DynamicJAXBContext per version */ diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java index 8b3a936..ad7e546 100644 --- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java +++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java @@ -77,7 +77,7 @@ public class JerseyConfiguration extends ResourceConfig { // Check to ensure that each of the filter has the @Priority annotation and if not throw // exception - for (Class filterClass : filters) { + for (Class filterClass : filters) { if (filterClass.getAnnotation(Priority.class) == null) { throw new RuntimeException("Container filter " + filterClass.getName() + " does not have @Priority annotation"); diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java index c874038..c687a58 100644 --- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java @@ -38,7 +38,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.context.annotation.Import; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @@ -56,7 +60,7 @@ public class SchemaServiceTest { private HttpHeaders headers; - private HttpEntity httpEntity; + private HttpEntity httpEntity; private String baseUrl; @@ -89,7 +93,7 @@ public class SchemaServiceTest { headers.add("X-FromAppId", "JUNIT"); headers.add("X-TransactionId", "JUNIT"); headers.add("Authorization", "Basic " + authorization); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity(headers); baseUrl = "http://localhost:" + randomPort; } @@ -103,9 +107,9 @@ public class SchemaServiceTest { headers.add("X-FromAppId", "JUNIT"); headers.add("X-TransactionId", "JUNIT"); headers.add("Authorization", "Basic " + authorization); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity(headers); - ResponseEntity responseEntity; + ResponseEntity responseEntity; responseEntity = restTemplate.exchange(baseUrl + "/aai/schema-service/v1/nodes?version=v20", HttpMethod.GET, httpEntity, String.class); @@ -113,7 +117,7 @@ public class SchemaServiceTest { headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity(headers); responseEntity = restTemplate.exchange(baseUrl + "/aai/schema-service/v1/edgerules?version=v20", @@ -132,9 +136,9 @@ public class SchemaServiceTest { headers.add("X-FromAppId", "JUNIT"); headers.add("X-TransactionId", "JUNIT"); headers.add("Authorization", "Basic " + authorization); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity(headers); - ResponseEntity responseEntity; + ResponseEntity responseEntity; responseEntity = restTemplate.exchange(baseUrl + "/aai/schema-service/v1/nodes?version=blah", @@ -144,7 +148,7 @@ public class SchemaServiceTest { headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); headers.setContentType(MediaType.APPLICATION_JSON); - httpEntity = new HttpEntity(headers); + httpEntity = new HttpEntity(headers); responseEntity = restTemplate.exchange(baseUrl + "/aai/schema-service/v1/edgerules?version=blah", @@ -156,7 +160,7 @@ public class SchemaServiceTest { @Test public void testVersions() { - ResponseEntity responseEntity; + ResponseEntity responseEntity; responseEntity = restTemplate.exchange(baseUrl + "/aai/schema-service/v1/versions", HttpMethod.GET, httpEntity, String.class); @@ -167,7 +171,7 @@ public class SchemaServiceTest { @Test public void testGetStoredQueriesSuccess() { - ResponseEntity responseEntity; + ResponseEntity responseEntity; responseEntity = restTemplate.exchange(baseUrl + "/aai/schema-service/v1/stored-queries", HttpMethod.GET, httpEntity, String.class); -- cgit 1.2.3-korg