summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-core/pom.xml6
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java33
-rw-r--r--aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java75
-rw-r--r--aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java6
-rw-r--r--aai-els-onap-logging/pom.xml6
-rw-r--r--aai-rest/pom.xml6
6 files changed, 72 insertions, 60 deletions
diff --git a/aai-core/pom.xml b/aai-core/pom.xml
index b9814e8e..955f62bb 100644
--- a/aai-core/pom.xml
+++ b/aai-core/pom.xml
@@ -365,6 +365,12 @@ limitations under the License.
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.vaadin.external.google</groupId>
+ <artifactId>android-json</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
diff --git a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
index 28d66dd0..7ecdd6d5 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java
@@ -155,49 +155,22 @@ public class HttpEntry {
}
public HttpEntry setHttpEntryProperties(SchemaVersion version, String serverBase) {
- this.version = version;
- this.loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- this.dbEngine = new JanusGraphDBEngine(queryStyle, loader);
-
- getDbEngine().startTransaction();
- this.notification = new UEBNotification(loader, loaderFactory, schemaVersions);
- if ("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))) {
- this.notificationDepth = AAIProperties.MAXIMUM_DEPTH;
- } else {
- this.notificationDepth = AAIProperties.MINIMUM_DEPTH;
- }
-
+ setHttpEntryProperties(version);
this.serverBase = serverBase;
return this;
}
public HttpEntry setHttpEntryProperties(SchemaVersion version, UEBNotification notification) {
- this.version = version;
- this.loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- this.dbEngine = new JanusGraphDBEngine(queryStyle, loader);
-
+ setHttpEntryProperties(version);
this.notification = notification;
-
- if ("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))) {
- this.notificationDepth = AAIProperties.MAXIMUM_DEPTH;
- } else {
- this.notificationDepth = AAIProperties.MINIMUM_DEPTH;
- }
- // start transaction on creation
- getDbEngine().startTransaction();
return this;
}
public HttpEntry setHttpEntryProperties(SchemaVersion version, UEBNotification notification,
int notificationDepth) {
- this.version = version;
- this.loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, version);
- this.dbEngine = new JanusGraphDBEngine(queryStyle, loader);
-
+ setHttpEntryProperties(version);
this.notification = notification;
this.notificationDepth = notificationDepth;
- // start transaction on creation
- getDbEngine().startTransaction();
return this;
}
diff --git a/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java b/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
index be30c468..0c8fde62 100644
--- a/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
+++ b/aai-core/src/main/java/org/onap/aai/rest/ueb/UEBNotification.java
@@ -98,42 +98,15 @@ public class UEBNotification {
Introspector obj, HashMap<String, Introspector> relatedObjects, String basePath)
throws AAIException, UnsupportedEncodingException {
- String action = "UPDATE";
-
- if (status.equals(Status.CREATED)) {
- action = "CREATE";
- } else if (status.equals(Status.OK)) {
- action = "UPDATE";
- } else if (status.equals(Status.NO_CONTENT)) {
- action = "DELETE";
- }
+ String action = getAction(status);
try {
Introspector eventHeader = currentVersionLoader.introspectorFromName("notification-event-header");
URIToObject parser = new URIToObject(currentVersionLoader, uri, relatedObjects);
- if ((basePath != null) && (!basePath.isEmpty())) {
- if (!(basePath.startsWith("/"))) {
- basePath = "/" + basePath;
- }
- if (!(basePath.endsWith("/"))) {
- basePath = basePath + "/";
- }
- } else {
- // default
- basePath = "/aai/";
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Please check the schema.uri.base.path as it didn't seem to be set");
- }
- }
+ basePath = formatBasePath(basePath);
- String uriStr = getUri(uri.toString(), basePath);
- String entityLink;
- if (uriStr.startsWith("/")) {
- entityLink = basePath + notificationVersion + uriStr;
- } else {
- entityLink = basePath + notificationVersion + "/" + uriStr;
- }
+ String entityLink = formatEntityLink(uri, basePath);
eventHeader.setValue("entity-link", entityLink);
eventHeader.setValue("action", action);
@@ -191,6 +164,48 @@ public class UEBNotification {
}
}
+ private String formatEntityLink(URI uri, String basePath) {
+ String uriStr = getUri(uri.toString(), basePath);
+ String entityLink;
+ if (uriStr.startsWith("/")) {
+ entityLink = basePath + notificationVersion + uriStr;
+ } else {
+ entityLink = basePath + notificationVersion + "/" + uriStr;
+ }
+ return entityLink;
+ }
+
+ private String formatBasePath(String basePath) {
+ if ((basePath != null) && (!basePath.isEmpty())) {
+ if (!(basePath.startsWith("/"))) {
+ basePath = "/" + basePath;
+ }
+ if (!(basePath.endsWith("/"))) {
+ basePath = basePath + "/";
+ }
+ } else {
+ // default
+ basePath = "/aai/";
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug("Please check the schema.uri.base.path as it didn't seem to be set");
+ }
+ }
+ return basePath;
+ }
+
+ private String getAction(Status status) {
+ String action = "UPDATE";
+
+ if (status.equals(Status.CREATED)) {
+ action = "CREATE";
+ } else if (status.equals(Status.OK)) {
+ action = "UPDATE";
+ } else if (status.equals(Status.NO_CONTENT)) {
+ action = "DELETE";
+ }
+ return action;
+ }
+
/**
* Trigger events.
*
diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
index 371c07a5..8d703d3b 100644
--- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
+++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java
@@ -196,7 +196,13 @@ public class HttpEntryTest extends AAISetup {
.put("equip-type", "theEquipType")
.toString();
+ JSONObject expectedResponseBody = new JSONObject()
+ .put("hostname", "theHostname")
+ .put("equip-type", "theEquipType");
Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, requestBody);
+ JSONObject actualResponseBody = new JSONObject(response.getEntity().toString());
+
+ JSONAssert.assertEquals(expectedResponseBody, actualResponseBody, JSONCompareMode.NON_EXTENSIBLE);
assertEquals("Expected the pserver to be returned", 200, response.getStatus());
}
diff --git a/aai-els-onap-logging/pom.xml b/aai-els-onap-logging/pom.xml
index aa0782b7..2180f6e7 100644
--- a/aai-els-onap-logging/pom.xml
+++ b/aai-els-onap-logging/pom.xml
@@ -140,6 +140,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.vaadin.external.google</groupId>
+ <artifactId>android-json</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/aai-rest/pom.xml b/aai-rest/pom.xml
index 9e8697e6..0ff4dadd 100644
--- a/aai-rest/pom.xml
+++ b/aai-rest/pom.xml
@@ -103,6 +103,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.vaadin.external.google</groupId>
+ <artifactId>android-json</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>