- minor refactorings in SchemaServiceTranslator
- annotate the other classes with @Component to make them available for dependency injection
Issue-ID: AAI-3780
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: Ia48743b81de36e1da3e71eee8821baa526c86885
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
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;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaServiceTranslator.class);
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;
@Value("${schema.service.nodes.endpoint}")
private String nodeSchemaUri;
@Value("${schema.service.edges.endpoint}")
private String edgeSchemaUri;
- @Qualifier("restClient")
@Autowired
private RestClient restClient;
@Autowired
private RestClient restClient;
@Override
public List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException {
@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());
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);
ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri, headersMap);
verifySchemaServiceResponse(schemaResponse.getStatusCode());
LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode());
verifySchemaServiceResponse(schemaResponse.getStatusCode());
LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode());
Resource resultBody = schemaResponse.getBody();
Resource resultBody = schemaResponse.getBody();
- if (resultBody != null) {
- inputStreams.add(resultBody.getInputStream());
- }
- return inputStreams;
+ return resultBody != null
+ ? Collections.singletonList(resultBody.getInputStream())
+ : Collections.emptyList();
/*
* Call Schema MS to get versions using RestTemplate
*/
/*
* 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());
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());
import org.onap.aai.edges.EdgeRuleQuery.Builder;
import org.onap.aai.edges.enums.EdgeField;
import org.onap.aai.edges.enums.EdgeType;
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.
*/
/**
* Validates that in the collection of cousin rules between a given node type pair,
* there is exactly 1 set default=true.
*/
public class CousinDefaultingValidationModule {
/**
public class CousinDefaultingValidationModule {
/**
import java.util.Map.Entry;
import org.onap.aai.edges.enums.EdgeField;
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
*
*/
/**
* Default core A&AI edge field validation
* All fields in EdgeField enum are required EXCEPT description
*
*/
public class DefaultEdgeFieldsValidationModule implements EdgeFieldsValidationModule {
/*
public class DefaultEdgeFieldsValidationModule implements EdgeFieldsValidationModule {
/*
import org.onap.aai.edges.EdgeRuleQuery;
import org.onap.aai.edges.enums.EdgeType;
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.
*
*/
/**
* Validates that the given node type pair has at most one containment relationship
* in their edge rules.
*
*/
public class SingleContainmentValidationModule {
/**
public class SingleContainmentValidationModule {
/**
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.EdgeRuleQuery;
import org.onap.aai.edges.EdgeRuleQuery.Builder;
import org.onap.aai.edges.enums.EdgeField;
+import org.springframework.stereotype.Component;
/**
* Applies label validation rules
*
*/
/**
* Applies label validation rules
*
*/
public class UniqueLabelValidationModule {
/**
public class UniqueLabelValidationModule {
/**