aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src/main/java/org/onap/aai/rest
diff options
context:
space:
mode:
Diffstat (limited to 'aai-resources/src/main/java/org/onap/aai/rest')
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java20
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java2
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java9
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java176
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java27
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java23
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java188
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java178
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java414
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java260
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java64
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.java76
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Transaction.java (renamed from aai-resources/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java)20
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/TransactionResponse.java (renamed from aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java)20
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java141
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java410
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java (renamed from aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8Models.java)16
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java3
19 files changed, 1019 insertions, 1030 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
index 50e7634..0c316bf 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
@@ -23,7 +23,7 @@ import javax.ws.rs.Path;
import org.onap.aai.restcore.HttpMethod;
-@Path("{version: v[8-9]|v1[01234]}/bulkadd")
+@Path("{version: v[1-9][0-9]*|latest}/bulkadd")
public class BulkAddConsumer extends BulkConsumer {
@Override
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
index 1c40859..d6ec93a 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
@@ -43,12 +43,13 @@ import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
import org.javatuples.Pair;
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
import org.onap.aai.logging.ErrorObjectNotFoundException;
import org.onap.aai.logging.LoggingContext;
@@ -99,8 +100,8 @@ public abstract class BulkConsumer extends RESTAPI {
private ModelType introspectorFactoryType = ModelType.MOXY;
/** The query style. */
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
-
+ private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI;
+
/**
* Bulk add.
*
@@ -121,7 +122,7 @@ public abstract class BulkConsumer extends RESTAPI {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
Response response = null;
try {
@@ -145,9 +146,10 @@ public abstract class BulkConsumer extends RESTAPI {
JsonArray transactions = getTransactions(content, headers);
for (int i = 0; i < transactions.size(); i++){
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- Loader loader = httpEntry.getLoader();
- TransactionalGraphEngine dbEngine = httpEntry.getDbEngine();
+ HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+ Loader loader = resourceHttpEntry.getLoader();
+ TransactionalGraphEngine dbEngine = resourceHttpEntry.getDbEngine();
URI thisUri = null;
List<BulkOperation> bulkOperations = new ArrayList<>();
HttpMethod method = null;
@@ -175,7 +177,7 @@ public abstract class BulkConsumer extends RESTAPI {
requests.add(request);
}
- Pair<Boolean, List<Pair<URI, Response>>> results = httpEntry.process(requests, sourceOfTruth, this.enableResourceVersion());
+ Pair<Boolean, List<Pair<URI, Response>>> results = resourceHttpEntry.process(requests, sourceOfTruth, this.enableResourceVersion());
List<BulkOperationResponse> responses = BulkOperationResponse.processPairList(method, results.getValue1());
allResponses.add(responses);
if (results.getValue0()) { //everything was processed without error
@@ -364,7 +366,7 @@ public abstract class BulkConsumer extends RESTAPI {
* keep any errors with their corresponding uris for client feedback
*/
bulkOperation.setUri(uri);
-
+
bulkOperation.addUriInfoQueryParams(uriComponents.getQueryParams());
if (!ValidateEncoding.getInstance().validate(uri)) {
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
index 2cae668..aac2deb 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
@@ -23,7 +23,7 @@ import javax.ws.rs.Path;
import org.onap.aai.restcore.HttpMethod;
-@Path("{version: v[789]|v1[01234]}/bulkprocess")
+@Path("{version: v[1-9][0-9]*|latest}/bulkprocess")
public class BulkProcessConsumer extends BulkConsumer {
@Override
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java
index d52befd..74884e2 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/ExampleConsumer.java
@@ -31,13 +31,14 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.MarshallerProperties;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.introspection.generator.CreateExample;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
@@ -45,7 +46,7 @@ import org.onap.aai.restcore.RESTAPI;
/**
* The Class ExampleConsumer.
*/
-@Path("/{version: v[789]|v1[01234]}/examples")
+@Path("{version: v[1-9][0-9]*|latest}/examples")
public class ExampleConsumer extends RESTAPI {
@@ -71,8 +72,8 @@ public class ExampleConsumer extends RESTAPI {
String mediaType = getMediaType(headers.getAcceptableMediaTypes());
org.onap.aai.restcore.MediaType outputMediaType = org.onap.aai.restcore.MediaType.getEnum(mediaType);
- Version version = Version.valueOf(versionParam);
- Loader loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, version);
+ SchemaVersion version = new SchemaVersion(versionParam);
+ Loader loader = SpringContextAware.getBean( LoaderFactory.class).createLoaderForVersion(ModelType.MOXY, version);
CreateExample example = new CreateExample(loader, type);
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
index 61f0d88..3c2754d 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
@@ -25,10 +25,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
-import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
-import java.util.concurrent.Callable;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -52,13 +50,13 @@ import javax.ws.rs.core.UriInfo;
import io.swagger.jaxrs.PATCH;
import org.javatuples.Pair;
+import org.onap.aai.concurrent.AaiCallable;
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
-import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
@@ -66,50 +64,40 @@ import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace;
import org.onap.aai.rest.util.ValidateEncoding;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConstants;
-import org.onap.aai.workarounds.RemoveDME2QueryParams;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.common.base.Joiner;
-
/**
* The Class LegacyMoxyConsumer.
*/
-@Path("{version: v[789]|v1[01234]}")
+@Controller
+@Path("{version: v[1-9][0-9]*|latest}")
public class LegacyMoxyConsumer extends RESTAPI {
-
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName());
- protected static String authPolicyFunctionName = "REST";
- private ModelType introspectorFactoryType = ModelType.MOXY;
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- private final static String TARGET_ENTITY = "aai-resources";
- /**
- * Update.
- *
- * @param content the content
- * @param versionParam the version param
- * @param uri the uri
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LegacyMoxyConsumer.class.getName());
+
+// private HttpEntry traversalUriHttpEntry;
+
+// @Autowired
+// public LegacyMoxyConsumer(HttpEntry traversalUriHttpEntry){
+// this.traversalUriHttpEntry = traversalUriHttpEntry;
+// }
+
+ public LegacyMoxyConsumer(){
+
+ }
+
@PUT
@Path("/{uri: .+}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response update (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- String serviceName = "PUT " + uri.toString();
- String queryStr = req.getQueryString();
- if ( queryStr != null ) {
- serviceName = serviceName + "?" + queryStr;
- }
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetServiceName(serviceName);
MediaType mediaType = headers.getMediaType();
return this.handleWrites(mediaType, HttpMethod.PUT, content, versionParam, uri, headers, info);
}
@@ -140,25 +128,14 @@ public class LegacyMoxyConsumer extends RESTAPI {
TransactionalGraphEngine dbEngine = null;
boolean success = true;
- String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
- String queryStr = req.getQueryString();
- if ( queryStr != null ) {
- serviceName = serviceName + "?" + queryStr;
- }
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetEntity(TARGET_ENTITY);
- LoggingContext.targetServiceName(serviceName);
-
try {
validateRequest(info);
- Version version = Version.valueOf(versionParam);
- version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
+ HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ loader = traversalUriHttpEntry.getLoader();
+ dbEngine = traversalUriHttpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath(uri).build();
this.validateURI(uriObject);
@@ -170,7 +147,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
DBRequest request = new DBRequest.Builder(HttpMethod.PUT_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth);
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
@@ -214,13 +191,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
public Response patch (String content, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
MediaType mediaType = MediaType.APPLICATION_JSON_TYPE;
- String serviceName = "PATCH " + uri.toString();
- String queryStr = req.getQueryString();
- if ( queryStr != null ) {
- serviceName = serviceName + "?" + queryStr;
- }
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetServiceName(serviceName);
return this.handleWrites(mediaType, HttpMethod.MERGE_PATCH, content, versionParam, uri, headers, info);
}
@@ -249,9 +219,9 @@ public class LegacyMoxyConsumer extends RESTAPI {
headers,
info,
HttpMethod.GET,
- new Callable<Response>() {
+ new AaiCallable<Response>() {
@Override
- public Response call() {
+ public Response process() {
return getLegacy(content, versionParam, uri, depthParam, cleanUp, headers, info, req, new HashSet<String>(), resultIndex, resultSize);
}
}
@@ -279,25 +249,15 @@ public class LegacyMoxyConsumer extends RESTAPI {
Response response = null;
TransactionalGraphEngine dbEngine = null;
Loader loader = null;
-
- String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
- String queryStr = req.getQueryString();
- if ( queryStr != null ) {
- serviceName = serviceName + "?" + queryStr;
- }
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetEntity(TARGET_ENTITY);
- LoggingContext.targetServiceName(serviceName);
try {
validateRequest(info);
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- final HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- dbEngine = httpEntry.getDbEngine();
- loader = httpEntry.getLoader();
+ final HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = traversalUriHttpEntry.getDbEngine();
+ loader = traversalUriHttpEntry.getLoader();
MultivaluedMap<String, String> params = info.getQueryParameters();
params = removeNonFilterableParams(params);
@@ -319,7 +279,11 @@ public class LegacyMoxyConsumer extends RESTAPI {
new DBRequest.Builder(HttpMethod.GET, uriObject, uriQuery, obj, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
+ if (resultIndex != null && resultIndex != "-1" && resultSize != null && resultSize != "-1") {
+ traversalUriHttpEntry.setPaginationIndex(Integer.parseInt(resultIndex));
+ traversalUriHttpEntry.setPaginationBucket(Integer.parseInt(resultSize));
+ }
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth);
response = responsesTuple.getValue1().get(0).getValue1();
@@ -377,16 +341,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
- String queryStr = req.getQueryString();
- if ( queryStr != null ) {
- serviceName = serviceName + "?" + queryStr;
- }
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetEntity(TARGET_ENTITY);
- LoggingContext.targetServiceName(serviceName);
TransactionalGraphEngine dbEngine = null;
Response response = Response.status(404)
@@ -397,12 +351,12 @@ public class LegacyMoxyConsumer extends RESTAPI {
try {
validateRequest(info);
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
-
- dbEngine = httpEntry.getDbEngine();
- Loader loader = httpEntry.getLoader();
+ HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = traversalUriHttpEntry.getDbEngine();
+ Loader loader = traversalUriHttpEntry.getLoader();
URI uriObject = UriBuilder.fromPath(uri).build();
@@ -413,7 +367,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
DBRequest request = new DBRequest.Builder(HttpMethod.DELETE, uriObject, uriQuery, obj, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth);
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
@@ -462,17 +416,6 @@ public class LegacyMoxyConsumer extends RESTAPI {
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
- String queryStr = req.getQueryString();
- if ( queryStr != null ) {
- serviceName = serviceName + "?" + queryStr;
- }
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.serviceName(serviceName);
- LoggingContext.targetEntity(TARGET_ENTITY);
- LoggingContext.targetServiceName(serviceName);
-
Loader loader = null;
TransactionalGraphEngine dbEngine = null;
Response response = Response.status(404)
@@ -482,11 +425,12 @@ public class LegacyMoxyConsumer extends RESTAPI {
try {
this.validateRequest(info);
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
+ HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ loader = traversalUriHttpEntry.getLoader();
+ dbEngine = traversalUriHttpEntry.getDbEngine();
if (content.equals("")) {
throw new AAIException("AAI_3102", "You must supply a relationship");
@@ -501,7 +445,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
DBRequest request = new DBRequest.Builder(HttpMethod.DELETE_EDGE, uriObject, uriQuery, wrappedEntity, headers, info, transId).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth);
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
@@ -581,25 +525,21 @@ public class LegacyMoxyConsumer extends RESTAPI {
Response response = null;
TransactionalGraphEngine dbEngine = null;
Loader loader = null;
- Version version = null;
+ SchemaVersion version = null;
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
Boolean success = true;
-
- //LoggingContext service name and target service name set in calling method
- LoggingContext.requestId(transId);
- LoggingContext.partnerName(sourceOfTruth);
- LoggingContext.targetEntity(TARGET_ENTITY);
try {
validateRequest(info);
- version = Version.valueOf(versionParam);
+ version = new SchemaVersion(versionParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
+ HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ traversalUriHttpEntry.setHttpEntryProperties(version, type);
+ loader = traversalUriHttpEntry.getLoader();
+ dbEngine = traversalUriHttpEntry.getDbEngine();
URI uriObject = UriBuilder.fromPath(uri).build();
this.validateURI(uriObject);
QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject);
@@ -627,7 +567,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
.rawRequestContent(content).build();
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = traversalUriHttpEntry.process(requests, sourceOfTruth);
response = responsesTuple.getValue1().get(0).getValue1();
success = responsesTuple.getValue0();
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
index eb54194..b9e5aa8 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
@@ -20,7 +20,6 @@
package org.onap.aai.rest;
import java.net.URI;
-import java.net.URL;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
@@ -36,11 +35,11 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.rest.db.HttpEntry;
import org.onap.aai.restcore.HttpMethod;
import org.onap.aai.restcore.RESTAPI;
@@ -48,15 +47,14 @@ import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.util.AAIConfig;
-import org.onap.aai.workarounds.LegacyURITransformer;
/**
* The Class URLFromVertexIdConsumer.
*/
-@Path("{version: v[789]|v1[01234]}/generateurl")
+@Path("{version: v[1-9][0-9]*|latest}/generateurl")
public class URLFromVertexIdConsumer extends RESTAPI {
private ModelType introspectorFactoryType = ModelType.MOXY;
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI;
private final String ID_ENDPOINT = "/id/{vertexid: \\d+}";
@@ -73,20 +71,21 @@ public class URLFromVertexIdConsumer extends RESTAPI {
*/
@GET
@Path(ID_ENDPOINT)
- @Produces({ MediaType.TEXT_PLAIN })
+ @Produces({ MediaType.WILDCARD })
public Response generateUrlFromVertexId(String content, @PathParam("version")String versionParam, @PathParam("vertexid")long vertexid, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
StringBuilder result = new StringBuilder();
Response response = null;
TransactionalGraphEngine dbEngine = null;
try {
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- dbEngine = httpEntry.getDbEngine();
+ HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = resourceHttpEntry.getDbEngine();
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
@@ -100,14 +99,6 @@ public class URLFromVertexIdConsumer extends RESTAPI {
result.append(uri.getRawPath());
result.insert(0, version);
result.insert(0, AAIConfig.get("aai.server.url.base"));
- LegacyURITransformer urlTransformer = LegacyURITransformer.getInstance();
- URI output = new URI(result.toString());
- /*if (version.compareTo(Version.v2) == 0) {
- output = urlTransformer.getLegacyURI(output);
- result = new StringBuilder();
- result.append(output.toString());
- }*/
-
response = Response.ok().entity(result.toString()).status(Status.OK).type(MediaType.TEXT_PLAIN).build();
} catch (AAIException e) {
//TODO check that the details here are sensible
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
index 94a6a68..3451528 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/VertexIdConsumer.java
@@ -41,7 +41,7 @@ import javax.ws.rs.core.UriInfo;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
-
+import org.onap.aai.config.SpringContextAware;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.exceptions.AAIException;
@@ -49,7 +49,6 @@ import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.MarshallerProperties;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
import org.onap.aai.parsers.query.QueryParser;
import org.onap.aai.rest.db.DBRequest;
import org.onap.aai.rest.db.HttpEntry;
@@ -58,18 +57,21 @@ import org.onap.aai.restcore.RESTAPI;
import org.onap.aai.serialization.db.DBSerializer;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
/**
* The Class VertexIdConsumer.
*/
-@Path("{version: v[789]|v1[01234]}/resources")
+@Path("{version: v[1-9][0-9]*|latest}/resources")
public class VertexIdConsumer extends RESTAPI {
-
+
private ModelType introspectorFactoryType = ModelType.MOXY;
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
+ private QueryStyle queryStyle = QueryStyle.TRAVERSAL_URI;
private final String ID_ENDPOINT = "/id/{vertexid: \\d+}";
+ private HttpEntry resourceHttpEntry;
+
/**
* Gets the by vertex id.
*
@@ -91,7 +93,7 @@ public class VertexIdConsumer extends RESTAPI {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- Version version = Version.valueOf(versionParam);
+ SchemaVersion version = new SchemaVersion(versionParam);
Status status = Status.NOT_FOUND;
String result = "";
Response response = null;
@@ -99,9 +101,10 @@ public class VertexIdConsumer extends RESTAPI {
try {
int depth = setDepth(depthParam);
DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- dbEngine = httpEntry.getDbEngine();
- Loader loader = httpEntry.getLoader();
+ resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+ dbEngine = resourceHttpEntry.getDbEngine();
+ Loader loader = resourceHttpEntry.getLoader();
DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
@@ -127,7 +130,7 @@ public class VertexIdConsumer extends RESTAPI {
List<DBRequest> requests = new ArrayList<>();
requests.add(request);
- Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = httpEntry.process(requests, sourceOfTruth);
+ Pair<Boolean, List<Pair<URI, Response>>> responsesTuple = resourceHttpEntry.process(requests, sourceOfTruth);
response = responsesTuple.getValue1().get(0).getValue1();
} catch (AAIException e){
response = consumerExceptionResponseGenerator(headers, info, HttpMethod.GET, e);
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java
index dfd0f1d..82a706f 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperation.java
@@ -1,87 +1,101 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.rest.bulk;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.UriInfo;
-
-import org.onap.aai.introspection.Introspector;
-import org.onap.aai.restcore.HttpMethod;
-import org.springframework.util.MultiValueMap;
-
-public class BulkOperation {
-
- private URI uri = null;
- private Introspector introspector = null;
- private HttpMethod httpMethod = null;
- private String rawReq = "";
- private UriInfo uriInfo = new BulkUriInfo();
-
- public UriInfo getUriInfo() {
- return uriInfo;
- }
-
- public String getRawReq() {
- return rawReq;
- }
-
- public void setRawReq(String rawReq) {
- this.rawReq = rawReq;
- }
-
- public URI getUri() {
- return uri;
- }
-
- public void setUri(URI uri) {
- this.uri = uri;
- }
-
- public Introspector getIntrospector() {
- return introspector;
- }
-
- public void setIntrospector(Introspector introspector) {
- this.introspector = introspector;
- }
-
- public HttpMethod getHttpMethod() {
- return httpMethod;
- }
-
- public void setHttpMethod(HttpMethod httpMethod) {
- this.httpMethod = httpMethod;
- }
-
- public void addUriInfoQueryParams(MultiValueMap<String, String> queryParams) {
-
- BulkUriInfo bui = new BulkUriInfo();
-
- for (Entry<String, List<String>> entry : queryParams.entrySet()) {
- bui.addParams(entry.getKey(), entry.getValue());
- }
-
- this.uriInfo = bui;
- }
-
-}
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.bulk;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.ws.rs.core.UriInfo;
+
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.parsers.query.QueryParser;
+import org.onap.aai.restcore.HttpMethod;
+import org.springframework.util.MultiValueMap;
+
+public class BulkOperation {
+
+ private URI uri = null;
+ private QueryParser uriQuery = null;
+ private Introspector introspector = null;
+ private HttpMethod httpMethod = null;
+ private String rawReq = "";
+ private UriInfo uriInfo = new BulkUriInfo();
+
+ public UriInfo getUriInfo() {
+ return uriInfo;
+ }
+
+ public String getRawReq() {
+ return rawReq;
+ }
+
+ public void setRawReq(String rawReq) {
+ this.rawReq = rawReq;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public QueryParser getUriQuery() {
+ return uriQuery;
+ }
+
+ public void setUriQuery(QueryParser uriQuery) {
+ this.uriQuery = uriQuery;
+ }
+
+ public Introspector getIntrospector() {
+ return introspector;
+ }
+
+ public void setIntrospector(Introspector introspector) {
+ this.introspector = introspector;
+ }
+
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+
+ public void setHttpMethod(HttpMethod httpMethod) {
+ this.httpMethod = httpMethod;
+ }
+
+ public void addUriInfoQueryParams(MultiValueMap<String, String> queryParams) {
+
+ BulkUriInfo bui = new BulkUriInfo();
+
+ for (Entry<String, List<String>> entry : queryParams.entrySet()) {
+ bui.addParams(entry.getKey(), entry.getValue());
+ }
+
+ this.uriInfo = bui;
+ }
+
+ public void addUriInfo(UriInfo uriInfo){
+ this.uriInfo = uriInfo;
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java
index d5c53fd..130ab1c 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkOperationResponse.java
@@ -1,89 +1,89 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.rest.bulk;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.Response;
-
-import org.javatuples.Pair;
-import org.onap.aai.restcore.HttpMethod;
-
-public class BulkOperationResponse {
-
- private URI uri = null;
- private Response response = null;
- private HttpMethod httpMethod = null;
-
- private BulkOperationResponse() {
-
- }
-
- private BulkOperationResponse(HttpMethod httpMethod, Pair<URI, Response> pair) {
- this.httpMethod = httpMethod;
- this.response = pair.getValue1();
- this.uri = pair.getValue0();
- }
-
- public BulkOperationResponse(HttpMethod httpMethod, URI uri, Response response) {
- this.httpMethod = httpMethod;
- this.response = response;
- this.uri = uri;
- }
-
- public URI getUri() {
- return uri;
- }
-
- public void setUri(URI uri) {
- this.uri = uri;
- }
-
- public Response getResponse() {
- return response;
- }
-
- public void setResponse(Response response) {
- this.response = response;
- }
-
- public HttpMethod getHttpMethod() {
- return httpMethod;
- }
-
- public void setHttpMethod(HttpMethod httpMethod) {
- this.httpMethod = httpMethod;
- }
-
- public static List<BulkOperationResponse> processPairList(HttpMethod httpMethod, List<Pair<URI, Response>> pairList) {
-
- List<BulkOperationResponse> borList = new ArrayList<>();
- BulkOperationResponse bor;
-
- for (Pair<URI, Response> pair: pairList) {
- bor = new BulkOperationResponse(httpMethod, pair);
- borList.add(bor);
- }
-
- return borList;
- }
-}
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.bulk;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ws.rs.core.Response;
+
+import org.javatuples.Pair;
+import org.onap.aai.restcore.HttpMethod;
+
+public class BulkOperationResponse {
+
+ private URI uri = null;
+ private Response response = null;
+ private HttpMethod httpMethod = null;
+
+ private BulkOperationResponse() {
+
+ }
+
+ private BulkOperationResponse(HttpMethod httpMethod, Pair<URI, Response> pair) {
+ this.httpMethod = httpMethod;
+ this.response = pair.getValue1();
+ this.uri = pair.getValue0();
+ }
+
+ public BulkOperationResponse(HttpMethod httpMethod, URI uri, Response response) {
+ this.httpMethod = httpMethod;
+ this.response = response;
+ this.uri = uri;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public void setUri(URI uri) {
+ this.uri = uri;
+ }
+
+ public Response getResponse() {
+ return response;
+ }
+
+ public void setResponse(Response response) {
+ this.response = response;
+ }
+
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+
+ public void setHttpMethod(HttpMethod httpMethod) {
+ this.httpMethod = httpMethod;
+ }
+
+ public static List<BulkOperationResponse> processPairList(HttpMethod httpMethod, List<Pair<URI, Response>> pairList) {
+
+ List<BulkOperationResponse> borList = new ArrayList<>();
+ BulkOperationResponse bor;
+
+ for (Pair<URI, Response> pair: pairList) {
+ bor = new BulkOperationResponse(httpMethod, pair);
+ borList.add(bor);
+ }
+
+ return borList;
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java
new file mode 100644
index 0000000..1e6ab0c
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkSingleTransactionConsumer.java
@@ -0,0 +1,414 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.bulk;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.javatuples.Pair;
+import org.onap.aai.config.SpringContextAware;
+import org.onap.aai.dbmap.DBConnectionType;
+import org.onap.aai.exceptions.AAIException;
+import org.onap.aai.introspection.Introspector;
+import org.onap.aai.introspection.Loader;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.logging.LoggingContext;
+import org.onap.aai.rest.bulk.pojos.Operation;
+import org.onap.aai.rest.bulk.pojos.OperationResponse;
+import org.onap.aai.rest.bulk.pojos.Transaction;
+import org.onap.aai.rest.bulk.pojos.TransactionResponse;
+import org.onap.aai.rest.db.DBRequest;
+import org.onap.aai.rest.db.HttpEntry;
+import org.onap.aai.restcore.HttpMethod;
+import org.onap.aai.restcore.MediaType;
+import org.onap.aai.restcore.RESTAPI;
+import org.onap.aai.serialization.engines.TransactionalGraphEngine;
+import org.onap.aai.setup.SchemaVersion;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.AAIConstants;
+import org.springframework.web.util.UriComponents;
+import org.springframework.web.util.UriComponentsBuilder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.*;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.*;
+
+@Path(value = "{version: v[1-9][0-9]*|latest}/bulk/single-transaction")
+public class BulkSingleTransactionConsumer extends RESTAPI {
+
+ private static final String TARGET_ENTITY = "aai-resources";
+ private static final Set<String> validOperations = Collections.unmodifiableSet(new HashSet<>(Arrays.asList("put", "patch", "delete")));
+ private int allowedOperationCount = 30;
+ private TransactionalGraphEngine dbEngine = null;
+
+ @POST
+ @Consumes(value = javax.ws.rs.core.MediaType.APPLICATION_JSON)
+ @Produces(value = javax.ws.rs.core.MediaType.APPLICATION_JSON)
+ public Response process(String content, @PathParam(value = "version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req){
+
+ String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
+ String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
+ String realTime = headers.getRequestHeaders().getFirst("Real-Time");
+ SchemaVersion version = new SchemaVersion(versionParam);
+ DBConnectionType type;
+
+ initLogging(req, transId, sourceOfTruth);
+
+ try {
+ type = this.determineConnectionType(sourceOfTruth, realTime);
+
+ // unmarshall the payload.
+ Gson gson = new Gson();
+ Transaction transaction;
+ try {
+ transaction = gson.fromJson(content, Transaction.class);
+ } catch (Exception e) {
+ throw new AAIException("AAI_6111", "Input payload does not follow bulk/single-transaction interface");
+ }
+
+ //set the operation count limit
+ setOperationCount(headers);
+ //validate
+ validate(transaction);
+
+ //generate bulkoperations
+ List<BulkOperation> bulkOperations = generateBulkOperations(transaction);
+
+ //init http entry
+ HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
+ resourceHttpEntry.setHttpEntryProperties(version, type);
+ Loader loader = resourceHttpEntry.getLoader();
+ TransactionalGraphEngine dbEngine = resourceHttpEntry.getDbEngine();
+
+ //populate uri query
+ populateUriQuery(bulkOperations, dbEngine);
+
+ //populate introspector for operations
+ populateIntrospectors(bulkOperations, loader);
+
+ //generate db process from bulk operation
+ List<DBRequest> dbRequests = bulkOperationToDbRequests(headers, transId, bulkOperations);
+
+ //process db requests
+ Pair<Boolean, List<Pair<URI, Response>>> results = resourceHttpEntry.process(dbRequests, sourceOfTruth, this.enableResourceVersion());
+
+ //process result of db requests
+ TransactionResponse transactionResponse = buildTransactionResponse(transaction, results.getValue1());
+
+ //commit/rollback based on results
+ if (results.getValue0()) { //everything was processed without error
+ dbEngine.commit();
+ } else { //something failed
+ dbEngine.rollback();
+ }
+
+ return Response
+ .status(Response.Status.CREATED)
+ .entity(new GsonBuilder().serializeNulls().create().toJson(transactionResponse))
+ .build();
+
+ } catch (AAIException e) {
+ return consumerExceptionResponseGenerator(headers, info, javax.ws.rs.HttpMethod.POST, e);
+ } finally {
+ if (dbEngine != null) {
+ dbEngine.rollback();
+ }
+ }
+
+ }
+
+
+ /**
+ * Builds the response
+ * @param transaction the input transactions
+ * @param results the response of all of he operations
+ * @return TansactionResponse obj representing the result of the transaction
+ * @throws AAIException thrown if there is a failure in the result. Msg contains the details of the first failure.
+ */
+ private TransactionResponse buildTransactionResponse(Transaction transaction, List<Pair<URI, Response>> results) throws AAIException {
+ TransactionResponse transactionResponse = new TransactionResponse();
+ transactionResponse.setOperationResponses(new ArrayList<>(transaction.getOperations().size()));
+ final String failureInResponse = "Operation %s failed with status code (%s) and msg (%s)";
+ for (int i = 0; i < transaction.getOperations().size(); i++) {
+ if (!Response.Status.Family.familyOf(results.get(i).getValue1().getStatus())
+ .equals(Response.Status.Family.SUCCESSFUL)) {
+ throw new AAIException("AAI_3000",
+ String.format(
+ failureInResponse,
+ i,
+ results.get(i).getValue1().getStatus(),
+ results.get(i).getValue1().getEntity()));
+ }
+ OperationResponse operationResponse = new OperationResponse();
+ operationResponse.setResponseStatusCode(results.get(i).getValue1().getStatus());
+ operationResponse.setAction(transaction.getOperations().get(i).getAction());
+ operationResponse.setUri(transaction.getOperations().get(i).getUri());
+ operationResponse.setBody(results.get(i).getValue1().getEntity());
+ transactionResponse.getOperationResponsess().add(i, operationResponse);
+ }
+ return transactionResponse;
+ }
+
+ /**
+ * Generate one DBRequest per BulkOperation
+ * @param headers request headers
+ * @param transId transaction id
+ * @param bulkOperations operations to convert
+ * @return One DBRequest per BulkOperation
+ * @throws AAIException thrown if there are any issues with the transform
+ */
+ private List<DBRequest> bulkOperationToDbRequests(@Context HttpHeaders headers, String transId, List<BulkOperation> bulkOperations) throws AAIException {
+ List<DBRequest> requests = new ArrayList<>();
+ for (int i = 0; i < bulkOperations.size(); i++) {
+ try {
+ BulkOperation bulkOperation = bulkOperations.get(i);
+ DBRequest request = new DBRequest.Builder(
+ bulkOperation.getHttpMethod(),
+ bulkOperation.getUri(),
+ bulkOperation.getUriQuery(),
+ bulkOperation.getIntrospector(),
+ headers,
+ bulkOperation.getUriInfo(),
+ transId
+ ).rawRequestContent(bulkOperation.getRawReq()).build();
+ requests.add(request);
+ } catch (Exception e) {
+ throw new AAIException("AAI_3000", "Error with operation " + i + ": " +e.getMessage());
+ }
+ }
+ return requests;
+ }
+
+ /**
+ * Sets the uriquery for each bulk operation
+ * @param bulkOperations operations to generate queries for
+ * @param dbEngine engine for query builder generation
+ * @throws AAIException thrown for issues with generating uri query
+ */
+ private void populateUriQuery(List<BulkOperation> bulkOperations, TransactionalGraphEngine dbEngine) throws AAIException {
+ for (int i = 0; i < bulkOperations.size(); i++) {
+ try {
+ bulkOperations.get(i).setUriQuery(dbEngine.getQueryBuilder().createQueryFromURI(bulkOperations.get(i).getUri()));
+ } catch (AAIException e) {
+ throw new AAIException(e.getCode(), "Error with operation " + i + ": " +e.getMessage());
+ } catch (UnsupportedEncodingException e) {
+ throw new AAIException("AAI_3000", "Error with operation " + i + ": " +e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Sets the introspector for each bulk operation. requires that uriquery is set per operation
+ * @param bulkOperations operations to generate introspector for
+ * @param loader Loader for generating introspector
+ * @throws AAIException thrown for issues with generating introspector
+ */
+ private void populateIntrospectors(List<BulkOperation> bulkOperations, Loader loader) throws AAIException {
+
+ final String objectUnMarshallMsg = "Body of operation %s could not be unmarshalled: %s";
+ Introspector obj;
+ for (int i = 0; i < bulkOperations.size(); i++) {
+ BulkOperation bulkOperation = bulkOperations.get(i);
+ try {
+ if (bulkOperation.getHttpMethod().equals(HttpMethod.PUT_EDGE)
+ || bulkOperation.getHttpMethod().equals(HttpMethod.DELETE_EDGE)) {
+ obj = loader.unmarshal("relationship", bulkOperation.getRawReq(), MediaType.APPLICATION_JSON_TYPE);
+ bulkOperation.setIntrospector(obj);
+ } else {
+ String objName = bulkOperation.getUriQuery().getResultType();
+ if (bulkOperation.getHttpMethod().equals(HttpMethod.DELETE)) {
+ obj = loader.introspectorFromName(objName);
+ } else {
+ obj = loader.unmarshal(objName, bulkOperation.getRawReq(), MediaType.APPLICATION_JSON_TYPE);
+ this.validateIntrospector(obj, loader, bulkOperation.getUri(), bulkOperation.getHttpMethod());
+ }
+ bulkOperation.setIntrospector(obj);
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new AAIException("AAI_3000", String.format(objectUnMarshallMsg, i, bulkOperation.getRawReq()));
+ }
+ }
+
+ }
+
+ /**
+ * Sets the allowedOperationCount to one of the following
+ * - Integer.MAX_VALUE if override limit is configured
+ * - Property in aaiconfig
+ * - 30 by default
+ * @param headers request header
+ */
+ private void setOperationCount(HttpHeaders headers) {
+ try {
+ String overrideLimit = headers.getRequestHeaders().getFirst("X-OverrideLimit");
+ boolean isOverride = overrideLimit != null && !AAIConfig.get(AAIConstants.AAI_BULKCONSUMER_OVERRIDE_LIMIT).equals("false")
+ && overrideLimit.equals(AAIConfig.get(AAIConstants.AAI_BULKCONSUMER_OVERRIDE_LIMIT));
+ if (isOverride) {
+ allowedOperationCount = Integer.MAX_VALUE;
+ } else {
+ allowedOperationCount = AAIConfig.getInt(AAIConstants.AAI_BULKCONSUMER_LIMIT);
+ }
+ } catch (AAIException e) {
+ allowedOperationCount = 30;
+ }
+ }
+
+ /**
+ * Converts the request transaction into a list of bulk operations
+ * @param transaction transaction to extract bulk operations from
+ * @return list of bulk operations
+ */
+ private List<BulkOperation> generateBulkOperations(Transaction transaction) {
+ List<BulkOperation> bulkOperations = new ArrayList<>(transaction.getOperations().size());
+
+ BulkOperation bulkOperation;
+ for (int i = 0; i < transaction.getOperations().size(); i++) {
+ final Operation operation = transaction.getOperations().get(i);
+ bulkOperation = new BulkOperation();
+
+ UriComponents uriComponents = UriComponentsBuilder.fromUriString(operation.getUri()).build();
+ bulkOperation.setUri(UriBuilder.fromPath(uriComponents.getPath()).build());
+ bulkOperation.addUriInfoQueryParams(uriComponents.getQueryParams());
+ bulkOperation.setHttpMethod(getHttpMethod(operation.getAction(), bulkOperation.getUri()));
+ bulkOperation.setRawReq(operation.getBody().toString());
+ bulkOperations.add(bulkOperation);
+ }
+
+ return bulkOperations;
+ }
+
+ /**
+ * Map action to httpmethod
+ * @param action action to be mapped
+ * @param uri uri of the action
+ * @return HttpMethod thats action/uri maps to
+ */
+ private HttpMethod getHttpMethod(String action, URI uri) {
+ HttpMethod method = HttpMethod.GET;
+ switch (action) {
+ case "put":
+ method = HttpMethod.PUT;
+ break;
+ case "delete":
+ method = HttpMethod.DELETE;
+ break;
+ case "patch":
+ method = HttpMethod.MERGE_PATCH;
+ break;
+ }
+ if (uri.getPath().endsWith("/relationship-list/relationship")) {
+ if (method.equals(HttpMethod.PUT)) {
+ method = HttpMethod.PUT_EDGE;
+ } else if (method.equals(HttpMethod.DELETE)) {
+ method = HttpMethod.DELETE_EDGE;
+ }
+ }
+
+ return method;
+ }
+
+
+ /**
+ * For each operation validates:
+ * - action is provided and correct.
+ * - uri exists
+ * - body exists
+ * @param transaction parsed payload
+ * @throws AAIException with the violations in the msg
+ */
+ private void validate(Transaction transaction) throws AAIException {
+ if (transaction == null) {
+ throw new AAIException("AAI_6111", "input payload does not follow /bulk/single-transaction interface");
+ }
+
+ if (transaction.getOperations() == null
+ || transaction.getOperations().isEmpty()) {
+ throw new AAIException("AAI_6118", " Payload has no objects to operate on");
+ } else if (transaction.getOperations().size() > allowedOperationCount){
+ throw new AAIException("AAI_6147", " Allowed limit = " + allowedOperationCount);
+ }
+
+ final String missingFieldMsgFormat = "Operation %s missing '%s'";
+ final String invalidActionMsgFormat = "Operation %s has invalid action '%s'";
+ List<String> msgs = new ArrayList<>();
+ for (int i = 0; i < transaction.getOperations().size(); i++) {
+ final Operation operation = transaction.getOperations().get(i);
+ if (operation.getAction() == null || operation.getAction().isEmpty()) {
+ msgs.add(String.format(missingFieldMsgFormat, i, "action"));
+ } else if (!validOperations.contains(operation.getAction())) {
+ msgs.add(String.format(invalidActionMsgFormat, i, operation.getAction()));
+ }
+ if (operation.getUri() == null || operation.getUri().isEmpty()) {
+ msgs.add(String.format(missingFieldMsgFormat, i, "uri"));
+ }
+ if (operation.getBody() == null) {
+ msgs.add(String.format(missingFieldMsgFormat, i, "body"));
+ }
+ }
+ if (!msgs.isEmpty()) {
+ throw new AAIException("AAI_6111", "input payload missing required properties. [" + String.join(", ", msgs) + "]");
+ }
+
+ }
+
+ /**
+ * Initialize logging context
+ * @param req requestContext
+ * @param transId transaction id
+ * @param sourceOfTruth application source
+ */
+ private void initLogging(@Context HttpServletRequest req, String transId, String sourceOfTruth) {
+ String serviceName = req.getMethod() + " " + req.getRequestURI().toString();
+ LoggingContext.requestId(transId);
+ LoggingContext.partnerName(sourceOfTruth);
+ LoggingContext.serviceName(serviceName);
+ LoggingContext.targetEntity(TARGET_ENTITY);
+ LoggingContext.targetServiceName(serviceName);
+ }
+
+ protected boolean enableResourceVersion() {
+ return true;
+ }
+
+
+ /**
+ * Consumer exception response generator.
+ *
+ * @param headers the headers
+ * @param info the info
+ * @param action type of request
+ * @param e the e
+ * @return the response
+ */
+ protected Response consumerExceptionResponseGenerator(HttpHeaders headers, UriInfo info, String action, AAIException e) {
+ ArrayList<String> templateVars = new ArrayList<>();
+ templateVars.add(action); //GET, PUT, etc
+ templateVars.add(info.getPath());
+ templateVars.addAll(e.getTemplateVars());
+
+ ErrorLogHelper.logException(e);
+ return Response
+ .status(e.getErrorObject().getHTTPResponseCode())
+ .entity(ErrorLogHelper.getRESTAPIErrorResponseWithLogging(headers.getAcceptableMediaTypes(), e, templateVars))
+ .build();
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java
index 41cdd85..50b218f 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/BulkUriInfo.java
@@ -1,130 +1,130 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.rest.bulk;
-
-import java.net.URI;
-import java.util.List;
-
-import javax.ws.rs.core.*;
-
-
-public class BulkUriInfo implements UriInfo {
-
- private MultivaluedMap<String, String> queryParams= new MultivaluedHashMap<>();
-
- @Override
- public String getPath() {
- return null;
- }
-
- @Override
- public String getPath(boolean decode) {
- return null;
- }
-
- @Override
- public List<PathSegment> getPathSegments() {
- return null;
- }
-
- @Override
- public List<PathSegment> getPathSegments(boolean decode) {
- return null;
- }
-
- @Override
- public URI getRequestUri() {
- return null;
- }
-
- @Override
- public UriBuilder getRequestUriBuilder() {
- return null;
- }
-
- @Override
- public URI getAbsolutePath() {
- return null;
- }
-
- @Override
- public UriBuilder getAbsolutePathBuilder() {
- return null;
- }
-
- @Override
- public URI getBaseUri() {
- return null;
- }
-
- @Override
- public UriBuilder getBaseUriBuilder() {
- return null;
- }
-
- @Override
- public MultivaluedMap<String, String> getPathParameters() {
- return null;
- }
-
- @Override
- public MultivaluedMap<String, String> getPathParameters(boolean decode) {
- return null;
- }
-
- @Override
- public MultivaluedMap<String, String> getQueryParameters() {
- return this.queryParams;
- }
-
- @Override
- public MultivaluedMap<String, String> getQueryParameters(boolean decode) {
- return this.queryParams;
- }
-
- @Override
- public List<String> getMatchedURIs() {
- return null;
- }
-
- @Override
- public List<String> getMatchedURIs(boolean decode) {
- return null;
- }
-
- @Override
- public List<Object> getMatchedResources() {
- return null;
- }
-
- @Override
- public URI resolve(URI uri) {
- return null;
- }
-
- @Override
- public URI relativize(URI uri) {
- return null;
- }
-
- public void addParams(String key, List<String> list) {
- this.queryParams.put(key, list);
- }
-}
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.bulk;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.ws.rs.core.*;
+
+
+public class BulkUriInfo implements UriInfo {
+
+ private MultivaluedMap<String, String> queryParams= new MultivaluedHashMap<>();
+
+ @Override
+ public String getPath() {
+ return null;
+ }
+
+ @Override
+ public String getPath(boolean decode) {
+ return null;
+ }
+
+ @Override
+ public List<PathSegment> getPathSegments() {
+ return null;
+ }
+
+ @Override
+ public List<PathSegment> getPathSegments(boolean decode) {
+ return null;
+ }
+
+ @Override
+ public URI getRequestUri() {
+ return null;
+ }
+
+ @Override
+ public UriBuilder getRequestUriBuilder() {
+ return null;
+ }
+
+ @Override
+ public URI getAbsolutePath() {
+ return null;
+ }
+
+ @Override
+ public UriBuilder getAbsolutePathBuilder() {
+ return null;
+ }
+
+ @Override
+ public URI getBaseUri() {
+ return null;
+ }
+
+ @Override
+ public UriBuilder getBaseUriBuilder() {
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getPathParameters() {
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getPathParameters(boolean decode) {
+ return null;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getQueryParameters() {
+ return this.queryParams;
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getQueryParameters(boolean decode) {
+ return this.queryParams;
+ }
+
+ @Override
+ public List<String> getMatchedURIs() {
+ return null;
+ }
+
+ @Override
+ public List<String> getMatchedURIs(boolean decode) {
+ return null;
+ }
+
+ @Override
+ public List<Object> getMatchedResources() {
+ return null;
+ }
+
+ @Override
+ public URI resolve(URI uri) {
+ return null;
+ }
+
+ @Override
+ public URI relativize(URI uri) {
+ return null;
+ }
+
+ public void addParams(String key, List<String> list) {
+ this.queryParams.put(key, list);
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java
new file mode 100644
index 0000000..183f0ad
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Operation.java
@@ -0,0 +1,64 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.bulk.pojos;
+
+import com.google.gson.*;
+import com.google.gson.annotations.SerializedName;
+
+public class Operation {
+
+ @SerializedName("action")
+ private String action;
+ @SerializedName("uri")
+ private String uri;
+ @SerializedName("body")
+ private JsonObject body;
+
+ public Operation(String action, String uri, JsonObject body) {
+ this.action = action;
+ this.uri = uri;
+ this.body = body;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public JsonObject getBody() {
+ return body;
+ }
+
+ public void setBody(JsonObject body) {
+ this.body = body;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.java
new file mode 100644
index 0000000..007e434
--- /dev/null
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/OperationResponse.java
@@ -0,0 +1,76 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.rest.bulk.pojos;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.annotations.SerializedName;
+
+public class OperationResponse {
+
+ @SerializedName("action")
+ private String action;
+ @SerializedName("uri")
+ private String uri;
+ @SerializedName("response-status-code")
+ private int responseStatusCode;
+ @SerializedName("response-body")
+ private JsonObject body;
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public JsonObject getBody() {
+ return body;
+ }
+
+ public void setBody(JsonObject body) {
+ this.body = body;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public int getResponseStatusCode() {
+ return responseStatusCode;
+ }
+
+ public void setResponseStatusCode(int responseStatusCode) {
+ this.responseStatusCode = responseStatusCode;
+ }
+
+ public void setBody(Object s) {
+ if (s == null) {
+ this.body = null;
+ } else {
+ this.body = new JsonParser().parse(s.toString()).getAsJsonObject();
+ }
+ }
+}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Transaction.java
index 1a590bb..20329d7 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/retired/V3ThroughV7Consumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/Transaction.java
@@ -17,11 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.rest.retired;
+package org.onap.aai.rest.bulk.pojos;
-import javax.ws.rs.Path;
+import com.google.gson.annotations.SerializedName;
-@Path("{version: v[3-6]}") //TODO re-add v7 when we fix our env issues AAI-8567
-public class V3ThroughV7Consumer extends RetiredConsumer {
+import java.util.List;
+
+public class Transaction {
+
+ @SerializedName("operations")
+ private List<Operation> operations;
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ public void setOperations(List<Operation> operations) {
+ this.operations = operations;
+ }
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/TransactionResponse.java
index 9a9c183..ce5462c 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8NamedQueries.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/bulk/pojos/TransactionResponse.java
@@ -17,11 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.rest.retired;
+package org.onap.aai.rest.bulk.pojos;
-import javax.ws.rs.Path;
+import com.google.gson.annotations.SerializedName;
-@Path("{version: v[78]}/service-design-and-creation/named-queries")
-public class V7V8NamedQueries extends RetiredConsumer {
+import java.util.List;
+
+public class TransactionResponse {
+
+ @SerializedName("operation-responses")
+ private List<OperationResponse> operationResponses;
+
+ public List<OperationResponse> getOperationResponsess() {
+ return operationResponses;
+ }
+
+ public void setOperationResponses(List<OperationResponse> operationResponses) {
+ this.operationResponses = operationResponses;
+ }
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java
deleted file mode 100644
index 808b8bc..0000000
--- a/aai-resources/src/main/java/org/onap/aai/rest/retired/RetiredConsumer.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.rest.retired;
-
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-import io.swagger.jaxrs.PATCH;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.util.AAIConfig;
-
-/**
- * The Class RetiredConsumer.
- */
-public abstract class RetiredConsumer extends RESTAPI {
-
- /**
- * Creates the message get.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @GET
- @Path("/{uri:.*}")
- public Response createMessageGet(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
- /**
- * Creates the message delete.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @DELETE
- @Path("/{uri:.*}")
- public Response createMessageDelete(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
- /**
- * Creates the message post.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @POST
- @Path("/{uri:.*}")
- public Response createMessagePost(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
- @PATCH
- @Path("/{uri:.*}")
- public Response createMessagePatch(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
- /**
- * Creates the message put.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- @PUT
- @Path("/{uri:.*}")
- public Response createMessagePut(@PathParam("version")String versionParam, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) {
- return createMessage(versionParam, headers, info, req);
- }
-
-
- /**
- * Creates the message.
- *
- * @param versionParam the version param
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the response
- */
- private Response createMessage(String versionParam, HttpHeaders headers, UriInfo info, HttpServletRequest req) {
- AAIException e = new AAIException("AAI_3007");
-
- ArrayList<String> templateVars = new ArrayList<String>();
-
- if (templateVars.size() == 0) {
- templateVars.add("PUT");
- templateVars.add(info.getPath().toString());
- templateVars.add(versionParam);
- templateVars.add(AAIConfig.get("aai.default.api.version", ""));
- }
-
- Response response = Response
- .status(e.getErrorObject().getHTTPResponseCode())
- .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
- templateVars)).build();
-
- return response;
- }
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java b/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java
deleted file mode 100644
index 15596d0..0000000
--- a/aai-resources/src/main/java/org/onap/aai/rest/tools/ModelVersionTransformer.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.rest.tools;
-
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Encoded;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dbmap.DBConnectionType;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.introspection.Introspector;
-import org.onap.aai.introspection.Loader;
-import org.onap.aai.introspection.MarshallerProperties;
-import org.onap.aai.introspection.ModelType;
-import org.onap.aai.introspection.Version;
-import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.rest.db.HttpEntry;
-import org.onap.aai.rest.exceptions.AAIInvalidXMLNamespace;
-import org.onap.aai.rest.util.ValidateEncoding;
-import org.onap.aai.restcore.RESTAPI;
-import org.onap.aai.serialization.db.EdgeType;
-import org.onap.aai.serialization.db.exceptions.NoEdgeRuleFoundException;
-import org.onap.aai.serialization.engines.QueryStyle;
-import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.google.common.base.Joiner;
-
-
-/**
- * The Class ModelVersionTransformer.
- */
-@Path("tools")
-public class ModelVersionTransformer extends RESTAPI {
-
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ModelVersionTransformer.class.getName());
- protected static String authPolicyFunctionName = "REST";
- private ModelType introspectorFactoryType = ModelType.MOXY;
- private QueryStyle queryStyle = QueryStyle.TRAVERSAL;
- protected static String MODEL_ELEMENTS = "model-elements";
- private static final String RELATIONSHIP="relationship";
-
-
- /**
- * POST for model transformation.
- *
- * @param content the content
- * @param uri the uri
- * @param headers the headers
- * @param info the info
- * @param req the req
- * @return the transformed model
- * @Path("/{uri: modeltransform}")
- * @throws UnsupportedEncodingException
- */
- @POST
- @Path("/{uri: modeltransform}")
- @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
- @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
- public Response modelTransform (String content, @PathParam("uri") @Encoded String uri, @Context HttpHeaders headers, @Context UriInfo info, @Context HttpServletRequest req) throws UnsupportedEncodingException {
- Response response = null;
- TransactionalGraphEngine dbEngine = null;
- Loader loader = null;
- MediaType mediaType = headers.getMediaType();
- String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
- String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
- Boolean success = true;
- AAIException ex;
-
- try {
- validateRequest(info);
-
- DBConnectionType type = this.determineConnectionType(sourceOfTruth, realTime);
- HttpEntry httpEntry = new HttpEntry(Version.v8, introspectorFactoryType, queryStyle, type);
- loader = httpEntry.getLoader();
- dbEngine = httpEntry.getDbEngine();
- if (content.length() == 0) {
- if (mediaType.toString().contains(MediaType.APPLICATION_JSON)) {
- content = "{}";
- } else {
- content = "<empty/>";
- }
- }
-
- //Unmarshall the received model and store properties and values in a map.
- Introspector obj = loader.unmarshal("Model", content, org.onap.aai.restcore.MediaType.getEnum(this.getInputMediaType(mediaType)));
- if (obj == null) {
- throw new AAIException("AAI_3000", "object could not be unmarshalled:" + content);
- }
-
- if (mediaType.toString().contains(MediaType.APPLICATION_XML) && !content.equals("<empty/>") && isEmptyObject(obj)) {
- throw new AAIInvalidXMLNamespace(content);
- }
-
- Set<String> properties = obj.getProperties();
- java.util.Iterator<String> propItr = properties.iterator();
-
- Map<String, Object> v8PropMap = new HashMap<String, Object>();
- while (propItr.hasNext()){
- String property = propItr.next();
- Object propertyValue = obj.getValue(property);
- if (propertyValue != null) {
- v8PropMap.put(propItr.next(), propertyValue);
- }
- }
- // Get the current models and create a map of model-ver to model keys, this allows us
- // to easily figure out and construct the relationships on the supplied v8 model
- Map<String,String> modelVersionIdToModelInvariantIdMap = getCurrentModelsFromGraph(headers, transId, info);
-
- // Build the v10 - TODO
- HttpEntry newHttpEntry = new HttpEntry(Version.v10, introspectorFactoryType, queryStyle, type);
- Loader newLoader = newHttpEntry.getLoader();
- Introspector newModelObj = newLoader.introspectorFromName("Model");
-
- // pull the attributes we need to apply to the model + model-ver objects
- // model specific attrs
- String oldModelInvariantId = obj.getValue("model-id");
- String oldModelType = obj.getValue("model-type");
- // model-ver specific
- String oldModelName = obj.getValue("model-name");
- String oldModelVersionId = obj.getValue("model-name-version-id");
- String oldModelVersion = obj.getValue("model-version");
-
- // copy attributes from the v8 model object to the v10 model object
- newModelObj.setValue("model-invariant-id", oldModelInvariantId);
- newModelObj.setValue("model-type", oldModelType);
-
- Introspector modelVersObj = newModelObj.newIntrospectorInstanceOfProperty("model-vers");
-
- newModelObj.setValue("model-vers", modelVersObj.getUnderlyingObject());
-
- List<Object> modelVerList = (List<Object>)modelVersObj.getValue("model-ver");
-
- //create a model-ver object
- Introspector modelVerObj = newLoader.introspectorFromName("ModelVer");
- // load attributes from the v8 model object into the v10 model-ver object
- modelVerObj.setValue("model-version-id", oldModelVersionId);
- modelVerObj.setValue("model-name", oldModelName);
- modelVerObj.setValue("model-version", oldModelVersion);
-
-
- if (obj.hasProperty(MODEL_ELEMENTS)) {
- Introspector oldModelElements = obj.getWrappedValue(MODEL_ELEMENTS);
- if (oldModelElements != null) {
- Introspector newModelElements = modelVerObj.newIntrospectorInstanceOfProperty(MODEL_ELEMENTS);
- modelVerObj.setValue(MODEL_ELEMENTS, newModelElements.getUnderlyingObject());
- repackModelElements(oldModelElements, newModelElements, modelVersionIdToModelInvariantIdMap);
- }
- }
-
- modelVerList.add(modelVerObj.getUnderlyingObject());
-
- String outputMediaType = getMediaType(headers.getAcceptableMediaTypes());
- MarshallerProperties marshallerProperties =
- new MarshallerProperties.Builder(org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build();
-
- String result = newModelObj.marshal(marshallerProperties);
- response = Response.ok(result).build();
-
- } catch (AAIException e) {
-
- ArrayList<String> templateVars = new ArrayList<String>(2);
- templateVars.add("POST modeltransform");
- templateVars.add("model-ver.model-version-id");
- response = Response
- .status(e.getErrorObject().getHTTPResponseCode())
- .entity(ErrorLogHelper.getRESTAPIErrorResponse(
- headers.getAcceptableMediaTypes(), e,
- templateVars)).build();
- success = false;
- } catch (Exception e) {
- ArrayList<String> templateVars = new ArrayList<String>(2);
- templateVars.add("POST modeltransform");
- templateVars.add("model-ver.model-version-id");
- ex = new AAIException("AAI_4000", e);
- response = Response
- .status(Status.INTERNAL_SERVER_ERROR)
- .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars))
- .build();
- LOGGER.error("Internal server error", e);
- success = false;
- } finally {
- if (dbEngine != null) {
- if (success) {
- dbEngine.commit();
- } else {
- dbEngine.rollback();
- }
- }
- }
- return response;
- }
-
-
- private void repackModelElements(Introspector oldModelElements, Introspector newModelElements, Map<String, String> modelVersionIdToModelInvariantIdMap)
- throws AAIUnknownObjectException, AAIException {
-
- List<Introspector> oldModelElementList = oldModelElements.getWrappedListValue("model-element");
- List<Object> newModelElementList = (List<Object>)newModelElements.getValue("model-element");
-
- for (Introspector oldModelElement : oldModelElementList) {
- Introspector newModelElement = newModelElements.getLoader().introspectorFromName("model-element");
-
- ArrayList<String> attrs = new ArrayList<String>();
-
- attrs.add("model-element-uuid");
- attrs.add("new-data-del-flag");
- attrs.add("cardinality");
- attrs.add("linkage-points");
-
- for (String attr : attrs) {
- if (oldModelElement.hasProperty(attr)) {
- newModelElement.setValue(attr, oldModelElement.getValue(attr));
- }
- }
-
- if (oldModelElement.hasProperty("relationship-list")) {
-
- Introspector oldRelationshipList = oldModelElement.getWrappedValue("relationship-list");
- Introspector newRelationshipList = newModelElements.getLoader().introspectorFromName("relationship-list");
- newModelElement.setValue("relationship-list", newRelationshipList.getUnderlyingObject());
-
- List<Introspector> oldRelationshipListList = oldRelationshipList.getWrappedListValue(RELATIONSHIP);
- List<Object> newRelationshipListList = (List<Object>)newRelationshipList.getValue(RELATIONSHIP);
-
- for (Introspector oldRelationship : oldRelationshipListList) {
-
- Introspector newRelationship = newModelElements.getLoader().introspectorFromName(RELATIONSHIP);
- newRelationshipListList.add(newRelationship.getUnderlyingObject());
-
- List<Introspector> oldRelationshipData = oldRelationship.getWrappedListValue("relationship-data");
- List<Object> newRelationshipData = (List<Object>)newRelationship.getValue("relationship-data");
-
- newRelationship.setValue("related-to", "model-ver");
-
- for (Introspector oldRelationshipDatum : oldRelationshipData) {
-
- String oldProp = null;
- String oldVal = null;
-
- if (oldRelationshipDatum.hasProperty("relationship-key")) {
- oldProp = oldRelationshipDatum.getValue("relationship-key");
- }
- if (oldRelationshipDatum.hasProperty("relationship-value")) {
- oldVal = oldRelationshipDatum.getValue("relationship-value");
- }
-
- if ("model.model-name-version-id".equals(oldProp)) {
- // make two new relationshipDatum for use w/ the new style model
-
- // you should have the model in the list of models we collected earlier
- if (modelVersionIdToModelInvariantIdMap.containsKey(oldVal)) {
- Introspector newRelationshipDatum1 = newModelElements.getLoader().introspectorFromName("relationship-data");
- Introspector newRelationshipDatum2 = newModelElements.getLoader().introspectorFromName("relationship-data");
-
- String modelId = modelVersionIdToModelInvariantIdMap.get(oldVal);
-
- // the first one points at the model-invariant-id of found model
- newRelationshipDatum1.setValue("relationship-key", "model.model-invariant-id");
- newRelationshipDatum1.setValue("relationship-value", modelId);
-
- // the second one points at the model-version-id which corresponds to the old model-name-version-id
- newRelationshipDatum2.setValue("relationship-key", "model-ver.model-version-id");
- newRelationshipDatum2.setValue("relationship-value", oldVal);
-
- newRelationshipData.add(newRelationshipDatum1.getUnderlyingObject());
- newRelationshipData.add(newRelationshipDatum2.getUnderlyingObject());
- } else {
- throw new AAIException("AAI_6114", "No model-ver found using model-ver.model-version-id=" + oldVal);
- }
- }
- }
-
- }
- }
-
- if (oldModelElement.hasProperty(MODEL_ELEMENTS)) {
- Introspector nextOldModelElements = oldModelElement.getWrappedValue(MODEL_ELEMENTS);
- if (nextOldModelElements != null) {
- Introspector nextNewModelElements = newModelElement.newIntrospectorInstanceOfProperty(MODEL_ELEMENTS);
- newModelElement.setValue(MODEL_ELEMENTS, nextNewModelElements.getUnderlyingObject());
- repackModelElements(nextOldModelElements, nextNewModelElements, modelVersionIdToModelInvariantIdMap);
- }
- }
- newModelElementList.add(newModelElement.getUnderlyingObject());
- }
- return;
-
- }
-
- private Map<String, String> getCurrentModelsFromGraph(HttpHeaders headers, String transactionId, UriInfo info) throws NoEdgeRuleFoundException, AAIException {
-
- TransactionalGraphEngine dbEngine = null;
- Map<String, String> modelVerModelMap = new HashMap<String,String>() ;
- try {
-
- Version version = AAIProperties.LATEST;
- DBConnectionType type = DBConnectionType.REALTIME;
-
- final HttpEntry httpEntry = new HttpEntry(version, introspectorFactoryType, queryStyle, type);
- dbEngine = httpEntry.getDbEngine();
-
- List<Vertex> modelVertices = dbEngine.asAdmin().getTraversalSource().V().has(AAIProperties.NODE_TYPE,"model").toList();
- for (Vertex modelVtx : modelVertices) {
-
- List<Vertex> modelVerVerts = dbEngine.getQueryBuilder(modelVtx).createEdgeTraversal(EdgeType.TREE, "model", "model-ver").toList();
- for (Vertex v : modelVerVerts) {
- modelVerModelMap.put(v.value("model-version-id"), modelVtx.value("model-invariant-id"));
- }
- }
- } catch (NoSuchElementException e) {
- throw new NoSuchElementException();
- } catch (Exception e1) {
- LOGGER.error("Exception while getting current models from graph"+ LogFormatTools.getStackTop(e1));
- }
- return modelVerModelMap;
-
- }
-
- /**
- * Validate request.
- *
- * @param uri the uri
- * @param headers the headers
- * @param req the req
- * @param action the action
- * @param info the info
- * @throws AAIException the AAI exception
- * @throws UnsupportedEncodingException the unsupported encoding exception
- */
- private void validateRequest(UriInfo info) throws AAIException, UnsupportedEncodingException {
-
- if (!ValidateEncoding.getInstance().validate(info)) {
- throw new AAIException("AAI_3008", "uri=" + getPath(info));
- }
- }
-
- /**
- * Gets the path.
- *
- * @param info the info
- * @return the path
- */
- private String getPath(UriInfo info) {
- String path = info.getPath(false);
- MultivaluedMap<String, String> map = info.getQueryParameters(false);
- String params = "?";
- List<String> parmList = new ArrayList<>();
- for (String key : map.keySet()) {
- for (String value : map.get(key)) {
- parmList.add(key + "=" + value);
- }
- }
- String queryParams = Joiner.on("&").join(parmList);
- if (map.keySet().isEmpty()) {
- path += params + queryParams;
- }
-
- return path;
-
- }
-
- protected boolean isEmptyObject(Introspector obj) {
- return "{}".equals(obj.marshal(false));
- }
-
-
-}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8Models.java b/aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java
index b023827..931ab0b 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/retired/V7V8Models.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/util/LogFormatTools.java
@@ -17,11 +17,19 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.aai.rest.retired;
+package org.onap.aai.rest.util;
-import javax.ws.rs.Path;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
-@Path("{version: v[78]}/service-design-and-creation/models")
-public class V7V8Models extends RetiredConsumer {
+public class LogFormatTools {
+ private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
+ private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern(DATE_FORMAT)
+ .withZone(ZoneOffset.UTC);
+
+ public static String getCurrentDateTime() {
+ return DTF.format(ZonedDateTime.now());
+ }
}
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java b/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java
index 3b4ea73..7d04bf7 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/util/ValidateEncoding.java
@@ -133,6 +133,9 @@ public class ValidateEncoding {
valid = false;
}
for (String item : params.get(key)) {
+ if(item.contains("+")){
+ item = item.replaceAll("\\+", "%20");
+ }
if (!this.checkEncoding(item)) {
valid = false;
}