diff options
author | Kajur, Harish (vk250x) <vk250x@att.com> | 2020-02-21 14:34:10 -0500 |
---|---|---|
committer | Harish Venkata Kajur <vk250x@att.com> | 2020-02-25 23:59:33 -0500 |
commit | 98749c47bbb5f5ddcc1c4f0690b79c7288f6bdd6 (patch) | |
tree | a472ce2edabd497b643917f44785b775fa16e15e /aai-schema-ingest/src/main/java/org | |
parent | e654645a50a0d028d8e67ea997f84efe8d28a6a0 (diff) |
Enhancements for the aai-common library
Issue-ID: AAI-2806
Change-Id: I2dbb46b897b35136ac1bb802978d3f974af1b307
Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-schema-ingest/src/main/java/org')
14 files changed, 62 insertions, 97 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java index a6675d43..0bb36a2d 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/NodesConfiguration.java @@ -22,8 +22,8 @@ package org.onap.aai.config; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.Arrays; import java.util.HashSet; @@ -49,7 +49,7 @@ public class NodesConfiguration { private static final String CONFIG_TRANSLATOR = "config"; private static final String SCHEMA_SERVICE_TRANSLATOR = "schema-service"; - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(NodesConfiguration.class); + private static final Logger LOGGER = LoggerFactory.getLogger(NodesConfiguration.class); @Autowired(required = false) SchemaServiceConfiguration schemaConfiguration; diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java index 4074b425..529c0684 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/RestConfiguration.java @@ -44,21 +44,6 @@ public class RestConfiguration { @Value("${schema.service.client:one-way-ssl}") private String schemaServiceClient; - @Autowired - private RestClient restClient; - - @Bean - public RestClientFactory restClientFactory() { - - return new RestClientFactory() { - @Override - public RestClient getRestClient(String clientType) { - return restClient; - - } - }; - } - /* * In the below cases bean name and method names are different because all of them qualify as restClient */ diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java index 245dce97..cdd87492 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java @@ -44,7 +44,7 @@ public class SchemaServiceConfiguration { return schemaVersionsBean().getSchemaVersions(); } - @Bean(name = "schemaVersions2") + @Bean(name = "schemaVersions") public SchemaVersions schemaVersions() { return schemaServiceVersions(); } diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java index 3cf67052..002ec1ee 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeIngestor.java @@ -23,8 +23,8 @@ package org.onap.aai.edges; import static com.jayway.jsonpath.Criteria.where; import static com.jayway.jsonpath.Filter.filter; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -60,7 +60,7 @@ import org.springframework.stereotype.Component; */ @Component public class EdgeIngestor { - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(EdgeIngestor.class); + private static final Logger LOGGER = LoggerFactory.getLogger(EdgeIngestor.class); private Map<SchemaVersion, List<DocumentContext>> versionJsonFilesMap = new TreeMap<>(); private static final String READ_START = "$.rules.[?]"; private static final String READ_ALL_START = "$.rules.*"; diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java index d3c9a599..68def753 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/EdgeRule.java @@ -20,13 +20,13 @@ package org.onap.aai.edges; +import org.apache.tinkerpop.gremlin.structure.Direction; +import org.onap.aai.edges.enums.*; + import java.util.EnumMap; import java.util.HashMap; import java.util.Map; -import org.apache.tinkerpop.gremlin.structure.Direction; -import org.onap.aai.edges.enums.*; - /** * Container for A&AI edge rule information */ @@ -43,7 +43,7 @@ public class EdgeRule { /** * Instantiates a new edge rule. - * + * * @param fieldVals - Map<String, String> where first string is * an EdgeField value and second string is the * value of that field @@ -56,14 +56,14 @@ public class EdgeRule { label = fieldVals.get(EdgeField.LABEL.toString()); direction = Direction.valueOf(fieldVals.get(EdgeField.DIRECTION.toString())); multiplicityRule = MultiplicityRule.getValue(fieldVals.get(EdgeField.MULTIPLICITY.toString())); - isPrivateEdge = Boolean.valueOf(fieldVals.getOrDefault(EdgeField.PRIVATE.toString(), "false")); + isPrivateEdge = Boolean.parseBoolean(fieldVals.getOrDefault(EdgeField.PRIVATE.toString(), "false")); for (EdgeProperty prop : EdgeProperty.values()) { String rawVal = fieldVals.get(prop.toString()); edgeFields.put(prop, convertNotation(direction, rawVal)); } - isDefaultEdge = Boolean.valueOf(fieldVals.get(EdgeField.DEFAULT.toString())); + isDefaultEdge = Boolean.parseBoolean(fieldVals.get(EdgeField.DEFAULT.toString())); description = fieldVals.get(EdgeField.DESCRIPTION.toString()); if (description == null) { // bc description is optional and not in v12 and earlier description = ""; @@ -86,7 +86,7 @@ public class EdgeRule { /** * Converts whatever string was in the json for an edge property value into * the appropriate AAIDirection - * + * * @param Direction dir - the edge direction * @param String rawVal - property value from the json, may be * IN, OUT, BOTH, NONE, ${direction}, or !${direction} @@ -114,7 +114,7 @@ public class EdgeRule { /** * Gets the name of the node type in the "from" field - * + * * @return String nodetype */ public String getFrom() { @@ -123,7 +123,7 @@ public class EdgeRule { /** * Gets the name of the node type in the "to" field - * + * * @return String nodetype */ public String getTo() { @@ -177,7 +177,7 @@ public class EdgeRule { /** * Gets the value of the prevent-delete property - * + * * @return String prevent-delete property value */ public String getPreventDelete() { @@ -186,7 +186,7 @@ public class EdgeRule { /** * Returns if this rule is a default or not - * + * * @return boolean */ public boolean isDefault() { @@ -195,7 +195,7 @@ public class EdgeRule { /** * Gets the description on the edge rule (if there is one) - * + * * @return String description */ public String getDescription() { diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java index b686b3a6..9b1f0bd9 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/edges/JsonIngestor.java @@ -20,8 +20,8 @@ package org.onap.aai.edges; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; @@ -40,7 +40,7 @@ import org.onap.aai.setup.SchemaVersion; * JsonIngestor produces DocumentContexts from json files */ public class JsonIngestor { - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(JsonIngestor.class); + private static final Logger LOGGER = LoggerFactory.getLogger(JsonIngestor.class); /** * Reads in given json files to queryable DocumentContexts. diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java index 6016fcca..139eb625 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/nodes/NodeIngestor.java @@ -22,8 +22,8 @@ package org.onap.aai.nodes; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.CaseFormat; import java.io.*; @@ -62,7 +62,7 @@ import org.xml.sax.SAXException; @PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) public class NodeIngestor { - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(NodeIngestor.class); + private static final Logger LOGGER = LoggerFactory.getLogger(NodeIngestor.class); private static final Pattern classNamePattern = Pattern.compile("\\.(v\\d+)\\."); private Map<SchemaVersion, DynamicJAXBContext> versionContextMap = new HashMap<>(); private Map<SchemaVersion, Set<String>> typesPerVersion = new HashMap<>(); diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java index cc88edef..a92005ea 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceNoAuthClient.java @@ -20,34 +20,24 @@ package org.onap.aai.restclient; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.Collections; -import java.util.Map; -import java.util.UUID; - -import javax.annotation.PostConstruct; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; import org.springframework.util.MultiValueMap; -@Component(value = "no-auth-service-rest-client") +import java.util.Collections; +import java.util.Map; +import java.util.UUID; + public class SchemaServiceNoAuthClient extends NoAuthRestClient { - private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceNoAuthClient.class); + private static Logger logger = LoggerFactory.getLogger(SchemaServiceNoAuthClient.class); @Value("${schema.service.base.url}") private String baseUrl; - @PostConstruct - public void init() throws Exception { - super.init(); - } - @Override public String getBaseUrl() { return baseUrl; diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java index 6b107285..1ab0999e 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceOneWayClient.java @@ -20,25 +20,20 @@ package org.onap.aai.restclient; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.Collections; -import java.util.Map; -import java.util.UUID; - -import javax.annotation.PostConstruct; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; import org.springframework.util.MultiValueMap; -@Component(value = "schema-service-one-way-rest-client") +import java.util.Collections; +import java.util.Map; +import java.util.UUID; + public class SchemaServiceOneWayClient extends OneWaySSLRestClient { - private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceOneWayClient.class); + private static Logger logger = LoggerFactory.getLogger(SchemaServiceOneWayClient.class); @Value("${schema.service.base.url}") private String baseUrl; diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java index 56ddd744..62f4b68b 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/restclient/SchemaServiceRestClient.java @@ -22,22 +22,19 @@ package org.onap.aai.restclient; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -import java.util.Collections; -import java.util.Map; -import java.util.UUID; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; import org.springframework.util.MultiValueMap; -@Component(value = "schema-service-rest-client") +import java.util.Collections; +import java.util.Map; +import java.util.UUID; + public class SchemaServiceRestClient extends TwoWaySSLRestClient { - private static EELFLogger logger = EELFManager.getInstance().getLogger(SchemaServiceRestClient.class); + private static Logger logger = LoggerFactory.getLogger(SchemaServiceRestClient.class); @Value("${schema.service.base.url}") private String baseUrl; diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java index 1c49e1de..a62dd17b 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java @@ -20,8 +20,8 @@ package org.onap.aai.setup; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.*; import java.nio.charset.Charset; @@ -40,7 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired; * */ public abstract class ConfigTranslator extends Translator { - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ConfigTranslator.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigTranslator.class); protected SchemaLocationsBean bean; 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 8c29f96d..4ee93fad 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 @@ -20,8 +20,8 @@ package org.onap.aai.setup; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.*; import java.util.*; @@ -29,8 +29,8 @@ import java.util.*; import javax.ws.rs.HttpMethod; import org.onap.aai.restclient.RestClient; -import org.onap.aai.restclient.RestClientFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.http.HttpHeaders; @@ -45,7 +45,7 @@ import org.springframework.http.ResponseEntity; */ public class SchemaServiceTranslator extends Translator { - private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(SchemaServiceTranslator.class); + private static final Logger LOGGER = LoggerFactory.getLogger(SchemaServiceTranslator.class); private static final String SchemaServiceClientType = "schema.service"; @@ -55,8 +55,9 @@ public class SchemaServiceTranslator extends Translator { @Value("${schema.service.edges.endpoint}") private String edgeSchemaUri; + @Qualifier("restClient") @Autowired - private RestClientFactory restClientFactory; + private RestClient restClient; public SchemaServiceTranslator(SchemaVersions schemaVersions) { super(schemaVersions); @@ -64,7 +65,7 @@ public class SchemaServiceTranslator extends Translator { /* * (non-Javadoc) - * + * * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles() */ @@ -78,7 +79,6 @@ public class SchemaServiceTranslator extends Translator { headersMap.put(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML.toString()); headersMap.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML.toString()); - RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType); ResponseEntity<Resource> schemaResponse = restClient.getGetResource(content, uri, headersMap); verifySchemaServiceResponse(schemaResponse.getStatusCode()); LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode()); @@ -96,8 +96,6 @@ public class SchemaServiceTranslator extends Translator { String uri = edgeSchemaUri + version.toString(); Map<String, String> headersMap = new HashMap<>(); - RestClient restClient = restClientFactory.getRestClient(SchemaServiceClientType); - ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, uri, headersMap); verifySchemaServiceResponse(schemaResponse.getStatusCode()); LOGGER.debug("SchemaResponse Status code" + schemaResponse.getStatusCode()); diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java index 68678b83..90b05e38 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaVersionsBean.java @@ -31,8 +31,8 @@ import java.util.Map; import javax.annotation.PostConstruct; import org.onap.aai.restclient.RestClient; -import org.onap.aai.restclient.RestClientFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; @@ -47,12 +47,13 @@ public class SchemaVersionsBean { @Value("${schema.service.versions.override:false}") private String overrideSchemaService; - @Autowired - private RestClientFactory restClientFactory; - @Autowired(required = false) private SchemaConfigVersions schemaConfigVersions; + @Qualifier("restClient") + @Autowired + private RestClient restClient; + @PostConstruct public void initialize() { // Call SchemaService to get versions @@ -65,7 +66,6 @@ public class SchemaVersionsBean { */ String content = ""; Map<String, String> headersMap = new HashMap<>(); - RestClient restClient = restClientFactory.getRestClient(SCHEMA_SERVICE); ResponseEntity<String> schemaResponse = restClient.getGetRequest(content, versionsUri, headersMap); Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create(); diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java b/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java index 3f0ee41f..d16e3cc7 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/validation/CheckEverythingStrategy.java @@ -59,7 +59,7 @@ public class CheckEverythingStrategy implements SchemaErrorStrategy { if (errorMsgs.isEmpty()) { return "No errors found."; } else { - return StringUtils.join(errorMsgs, "\n"); + return StringUtils.join(errorMsgs.iterator(), "\n"); } } |