aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-abstraction
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-abstraction')
-rw-r--r--aai-schema-abstraction/pom.xml13
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java17
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java22
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java14
-rw-r--r--aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java12
-rw-r--r--aai-schema-abstraction/src/main/resources/logging/SchemaProviderMsgs.properties16
6 files changed, 34 insertions, 60 deletions
diff --git a/aai-schema-abstraction/pom.xml b/aai-schema-abstraction/pom.xml
index 28413c4b..512fa0d9 100644
--- a/aai-schema-abstraction/pom.xml
+++ b/aai-schema-abstraction/pom.xml
@@ -51,14 +51,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>org.onap.aai.logging-service</groupId>
- <artifactId>common-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onap.aai.logging-service</groupId>
- <artifactId>logging-api</artifactId>
- </dependency>
- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
@@ -105,6 +97,11 @@
<version>5.14.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
index 637bbfe4..fba6e0fd 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/json/JsonSchemaProvider.java
@@ -34,8 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.schemaif.SchemaProvider;
import org.onap.aai.schemaif.SchemaProviderException;
import org.onap.aai.schemaif.SchemaProviderMsgs;
@@ -51,9 +49,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
public class JsonSchemaProvider implements SchemaProvider {
- // Logger logger = LoggerFactory.getInstance().getLogger(JsonSchemaProvider.class.getName());
- Logger logger = LoggerFactory.getInstance().getLogger(SchemaProvider.class);
private JsonSchemaProviderConfig config;
private Map<String, SchemaInstance> schemaCache = new ConcurrentHashMap<>();
@@ -152,11 +151,10 @@ public class JsonSchemaProvider implements SchemaProvider {
ResponseEntity<byte[]> response = restTemplate.exchange(url, HttpMethod.GET, entity, byte[].class);
if (response.getStatusCodeValue() == HttpStatus.NOT_FOUND.value()) {
- logger.warn(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "version " + version + " not found");
+ log.warn("PVD0500E | Unable to load schema: {}", "version " + version + " not found");
throw new SchemaProviderException("Schema version " + version + " not found");
} else if (response.getStatusCodeValue() != HttpStatus.OK.value()) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR,
- "failed to load version " + version + ": " + response.getBody());
+ log.error("PVD0500E | Unable to load schema: {}", "version " + version + " not found");
throw new SchemaProviderException("Error getting schema version " + version + ":" + response.getBody());
}
@@ -167,13 +165,12 @@ public class JsonSchemaProvider implements SchemaProvider {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
ex.printStackTrace(printWriter);
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR,
- "failed to load version " + version + ": " + response.getBody() + "\n" + writer.toString());
+ log.error("PVD0500E | Unable to load schema: {}", "failed to load version: " + version + ": "+ response.getBody() + "\n" + writer.toString());
throw new SchemaProviderException("Error loading schema version " + version + ":" + ex.getMessage());
}
- logger.info(SchemaProviderMsgs.LOADED_SCHEMA_FILE, version);
+ log.info("PVD0001I|Successfully loaded schema: {}", version);
}
static final int BUFFER = 512;
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java
index b404ccfe..11150f1f 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmEdgeRulesLoader.java
@@ -23,6 +23,8 @@ package org.onap.aai.schemaif.oxm;
import com.google.common.collect.Multimap;
+import lombok.extern.slf4j.Slf4j;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -36,18 +38,16 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
-import org.onap.aai.cl.api.Logger;
-import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.EdgeRule;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.schemaif.SchemaProviderException;
-import org.onap.aai.schemaif.SchemaProviderMsgs;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+@Slf4j
@Component
public class OxmEdgeRulesLoader {
@@ -64,8 +64,6 @@ public class OxmEdgeRulesLoader {
final static Pattern propsFilePattern = Pattern.compile(propsPrefix + "(.*)" + propsSuffix);
final static Pattern propsVersionPattern = Pattern.compile("(?i)v\\d*");
- private static Logger logger = LoggerFactory.getInstance().getLogger(OxmEdgeRulesLoader.class.getName());
-
private OxmEdgeRulesLoader() {
}
@@ -94,8 +92,8 @@ public class OxmEdgeRulesLoader {
public static synchronized void loadModels() throws SchemaProviderException {
Map<String, File> propFiles = edgePropertyFiles(edgePropsConfiguration);
- if (logger.isDebugEnabled()) {
- logger.debug("Loading DB Edge Rules");
+ if (log.isDebugEnabled()) {
+ log.debug("Loading DB Edge Rules");
}
for (String version : OxmSchemaLoader.getLoadedOXMVersions()) {
@@ -118,8 +116,8 @@ public class OxmEdgeRulesLoader {
public static synchronized void loadModels(String v) throws SchemaProviderException {
Map<String, File> propFiles = edgePropertyFiles(edgePropsConfiguration);
- if (logger.isDebugEnabled()) {
- logger.debug("Loading DB Edge Rules ");
+ if (log.isDebugEnabled()) {
+ log.debug("Loading DB Edge Rules ");
}
try {
@@ -145,7 +143,7 @@ public class OxmEdgeRulesLoader {
if (versionContextMap == null || versionContextMap.isEmpty()) {
loadModels();
} else if (!versionContextMap.containsKey(version)) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "Error loading DB Edge Rules for: " + version);
+ log.error("PVD0500E | Unable to load schema: {}", "Error loading DB Edge Rules for: " + version);
throw new SchemaProviderException("Error loading DB Edge Rules for: " + version);
}
@@ -182,7 +180,7 @@ public class OxmEdgeRulesLoader {
// If there are still no models available, then there's not much we can do...
if (versionContextMap.isEmpty()) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "No available DB Edge Rules to get latest version for.");
+ log.error("PVD0500E | Unable to load schema: {}", "No available DB Edge Rules to get latest version for.");
throw new SchemaProviderException("No available DB Edge Rules to get latest version for.");
}
@@ -228,7 +226,7 @@ public class OxmEdgeRulesLoader {
if (edges != null) {
RelationshipSchema rs = new RelationshipSchema(edges, edgeProps);
versionContextMap.put(version.toString().toLowerCase(), rs);
- logger.info(SchemaProviderMsgs.LOADED_DB_RULE_FILE, version.toString());
+ log.info("PVD0002I|Successfully loaded DB Edge Rule and Edge Properties for: {}", version);
}
}
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java
index 84bde101..71abdbc2 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/OxmSchemaLoader.java
@@ -43,10 +43,13 @@ import org.onap.aai.setup.Translator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
+import lombok.extern.slf4j.Slf4j;
+
/**
* This class contains all of the logic for importing OXM model schemas from the available OXM
* schema files.
*/
+@Slf4j
@Component
public class OxmSchemaLoader {
@@ -59,9 +62,6 @@ public class OxmSchemaLoader {
final static Pattern versionPattern = Pattern.compile("(?i)v(\\d*)");
- private static org.onap.aai.cl.api.Logger logger =
- LoggerFactory.getInstance().getLogger(OxmSchemaLoader.class.getName());
-
private OxmSchemaLoader() {
}
@@ -86,8 +86,8 @@ public class OxmSchemaLoader {
*
*/
public synchronized static void loadModels() throws SchemaProviderException {
- if (logger.isDebugEnabled()) {
- logger.debug("Loading OXM Models");
+ if (log.isDebugEnabled()) {
+ log.debug("Loading OXM Models");
}
for (SchemaVersion oxmVersion : translator.getSchemaVersions().getVersions()) {
@@ -102,7 +102,7 @@ public class OxmSchemaLoader {
versionContextMap.put(oxmVersion, jaxbContext);
loadXmlLookupMap(oxmVersion, jaxbContext);
loadVertexLookupMap(oxmVersion, jaxbContext);
- logger.info(SchemaProviderMsgs.LOADED_SCHEMA_FILE, oxmVersion);
+ log.info("PVD0001I|Successfully loaded schema: {}", oxmVersion);
}
/**
@@ -208,7 +208,7 @@ public class OxmSchemaLoader {
}
// If there are still no models available, then there's not much we can do...
if (versionContextMap.isEmpty()) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "No available OXM schemas to get versions for.");
+ log.error("PVD0500E|Unable to load schema: No available OXM schemas to get versions for.");
throw new SchemaProviderException("No available OXM schemas to get latest version for.");
}
List<String> versions = new ArrayList<String>();
diff --git a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java
index 32350779..63cec9da 100644
--- a/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java
+++ b/aai-schema-abstraction/src/main/java/org/onap/aai/schemaif/oxm/RelationshipSchema.java
@@ -26,6 +26,8 @@ package org.onap.aai.schemaif.oxm;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Multimap;
+import lombok.extern.slf4j.Slf4j;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -36,11 +38,10 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.edges.EdgeRule;
import org.onap.aai.schemaif.SchemaProviderException;
-import org.onap.aai.schemaif.SchemaProviderMsgs;
+@Slf4j
public class RelationshipSchema {
public static final String SCHEMA_SOURCE_NODE_TYPE = "from";
@@ -48,9 +49,6 @@ public class RelationshipSchema {
public static final String SCHEMA_RELATIONSHIP_TYPE = "label";
public static final String SCHEMA_RULES_ARRAY = "rules";
- private static org.onap.aai.cl.api.Logger logger =
- LoggerFactory.getInstance().getLogger(RelationshipSchema.class.getName());
-
private Map<String, Map<String, Class<?>>> relations = new HashMap<>();
/**
* Hashmap of valid relationship types along with properties.
@@ -85,7 +83,7 @@ public class RelationshipSchema {
try {
return resolveClass(p.getValue());
} catch (SchemaProviderException | ClassNotFoundException e) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "Error in RelationshipSchema: " + e);
+ log.error("PVD0500E|Unable to load schema: {}", "Error in RelationshipSchema: " + e);
}
return null;
}));
@@ -124,7 +122,7 @@ public class RelationshipSchema {
try {
return resolveClass(p.getValue());
} catch (SchemaProviderException | ClassNotFoundException e) {
- logger.error(SchemaProviderMsgs.SCHEMA_LOAD_ERROR, "Error in RelationshipSchema: " + e);
+ log.error("PVD0500E|Unable to load schema: {}", "Error in RelationshipSchema: " + e);
}
return null;
}));
diff --git a/aai-schema-abstraction/src/main/resources/logging/SchemaProviderMsgs.properties b/aai-schema-abstraction/src/main/resources/logging/SchemaProviderMsgs.properties
deleted file mode 100644
index 0feb2acd..00000000
--- a/aai-schema-abstraction/src/main/resources/logging/SchemaProviderMsgs.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-
-## Error Logs
-SCHEMA_LOAD_ERROR=\
- PVD0500E|\
- Unable to load schema: {0}
-
-## Info Logs
-LOADED_SCHEMA_FILE=\
- PVD0001I|\
- Successfully loaded schema: {0}
-
-LOADED_DB_RULE_FILE=\
- PVD0002I|\
- Successfully loaded DB Edge Rule and Edge Properties for: {0}
-
-