diff options
Diffstat (limited to 'aai-schema-ingest')
5 files changed, 21 insertions, 18 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java index 27148a44..680bdd12 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java @@ -23,6 +23,7 @@ package org.onap.aai.setup; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,15 +49,12 @@ public class SchemaServiceTranslator extends Translator { private static final Logger LOGGER = LoggerFactory.getLogger(SchemaServiceTranslator.class); - private static final String SchemaServiceClientType = "schema.service"; - @Value("${schema.service.nodes.endpoint}") private String nodeSchemaUri; @Value("${schema.service.edges.endpoint}") private String edgeSchemaUri; - @Qualifier("restClient") @Autowired private RestClient restClient; @@ -73,21 +71,20 @@ public class SchemaServiceTranslator extends Translator { @Override public List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException { - List<InputStream> inputStreams = new ArrayList<>(); - String content = ""; - String uri = nodeSchemaUri + version.toString(); - Map<String, String> headersMap = new HashMap<>(); - + final Map<String, String> headersMap = new HashMap<>(); headersMap.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML.toString()); headersMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML.toString()); + final String content = ""; + final String uri = nodeSchemaUri + version.toString(); ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri, headersMap); + verifySchemaServiceResponse(schemaResponse.getStatusCode()); LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode()); + Resource resultBody = schemaResponse.getBody(); - if (resultBody != null) { - inputStreams.add(resultBody.getInputStream()); - } - return inputStreams; + return resultBody != null + ? Collections.singletonList(resultBody.getInputStream()) + : Collections.emptyList(); } @Override @@ -95,16 +92,14 @@ public class SchemaServiceTranslator extends Translator { /* * Call Schema MS to get versions using RestTemplate */ - List<String> inputStreams = new ArrayList<>(); - String content = ""; - String uri = edgeSchemaUri + version.toString(); - Map<String, String> headersMap = new HashMap<>(); + final String content = ""; + final String uri = edgeSchemaUri + version.toString(); + final Map<String, String> headersMap = new HashMap<>(); ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, uri, headersMap); verifySchemaServiceResponse(schemaResponse.getStatusCode()); LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode()); - inputStreams.add(schemaResponse.getBody()); - return inputStreams; + return Collections.singletonList(schemaResponse.getBody()); } diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java index 73337a49..688a6b96 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/CousinDefaultingValidationModule.java @@ -28,11 +28,13 @@ import org.onap.aai.edges.EdgeRuleQuery; import org.onap.aai.edges.EdgeRuleQuery.Builder; import org.onap.aai.edges.enums.EdgeField; import org.onap.aai.edges.enums.EdgeType; +import org.springframework.stereotype.Component; /** * Validates that in the collection of cousin rules between a given node type pair, * there is exactly 1 set default=true. */ +@Component public class CousinDefaultingValidationModule { /** diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java index 1229cf49..5d81c60e 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/DefaultEdgeFieldsValidationModule.java @@ -29,12 +29,14 @@ import java.util.Map; import java.util.Map.Entry; import org.onap.aai.edges.enums.EdgeField; +import org.springframework.stereotype.Component; /** * Default core A&AI edge field validation * All fields in EdgeField enum are required EXCEPT description * */ +@Component public class DefaultEdgeFieldsValidationModule implements EdgeFieldsValidationModule { /* diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java index 5f6a9646..1f18eb67 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/SingleContainmentValidationModule.java @@ -28,12 +28,14 @@ import java.util.Map; import org.onap.aai.edges.EdgeRuleQuery; import org.onap.aai.edges.enums.EdgeType; +import org.springframework.stereotype.Component; /** * Validates that the given node type pair has at most one containment relationship * in their edge rules. * */ +@Component public class SingleContainmentValidationModule { /** diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java index 82dc1694..162a11cf 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/edges/UniqueLabelValidationModule.java @@ -27,11 +27,13 @@ import java.util.*; import org.onap.aai.edges.EdgeRuleQuery; import org.onap.aai.edges.EdgeRuleQuery.Builder; import org.onap.aai.edges.enums.EdgeField; +import org.springframework.stereotype.Component; /** * Applies label validation rules * */ +@Component public class UniqueLabelValidationModule { /** |