aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShwetank Dave <shwetank.dave@amdocs.com>2018-06-04 13:56:08 -0400
committerShwetank Dave <shwetank.dave@amdocs.com>2018-06-04 13:57:49 -0400
commitca46bdfcfb109b856c293862f6ed77fe78eb510f (patch)
tree61e9d84905d5aa71d3d80fe9b821131174ae6494
parentd4e297058fbd58b7164a69f506a0c0af0274ed48 (diff)
Adding "_reserved_" properties in the query params
Adding "_reserved_version" and "_reserved_aai-type" to the query parameters when making downstream queries. Change-Id: Ibabf671618ac10813740d835d368ce30195f7937 Issue-ID: AAI-1202 Signed-off-by: Shwetank Dave <shwetank.dave@amdocs.com>
-rw-r--r--src/main/java/org/onap/crud/service/CrudRestService.java45
-rw-r--r--src/main/java/org/onap/crud/util/CrudServiceConstants.java2
-rw-r--r--src/main/java/org/onap/schema/OxmModelValidator.java5
3 files changed, 30 insertions, 22 deletions
diff --git a/src/main/java/org/onap/crud/service/CrudRestService.java b/src/main/java/org/onap/crud/service/CrudRestService.java
index b9062b0..5539374 100644
--- a/src/main/java/org/onap/crud/service/CrudRestService.java
+++ b/src/main/java/org/onap/crud/service/CrudRestService.java
@@ -98,10 +98,7 @@ public class CrudRestService {
logger.debug("Incoming request..." + content);
Response response = null;
- Map<String, String> params = new HashMap<String, String>();
- for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
- params.put(e.getKey(), e.getValue().get(0));
- }
+ Map<String, String> params = addParams ( uriInfo, false, type, version );
try {
if (validateRequest(req, uri, content, Action.GET, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) {
@@ -136,14 +133,7 @@ public class CrudRestService {
try {
if (validateRequest(req, uri, content, Action.GET, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) {
String propertiesKey = CrudProperties.get(CrudServiceConstants.CRD_COLLECTION_PROPERTIES_KEY);
-
- Map<String, String> filter = new HashMap<String, String>();
-
- for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
- if (!e.getKey().equals(propertiesKey)) {
- filter.put(e.getKey(), e.getValue().get(0));
- }
- }
+ Map<String, String> filter = addParams ( uriInfo, true, type, version );
HashSet<String> properties;
if (uriInfo.getQueryParameters().containsKey(propertiesKey)) {
@@ -180,10 +170,7 @@ public class CrudRestService {
logger.debug("Incoming request..." + content);
Response response = null;
- Map<String, String> params = new HashMap<String, String>();
- for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
- params.put(e.getKey(), e.getValue().get(0));
- }
+ Map<String, String> params = addParams ( uriInfo, false, type, version );
try {
if (validateRequest(req, uri, content, Action.GET, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) {
@@ -215,12 +202,7 @@ public class CrudRestService {
logger.debug("Incoming request..." + content);
Response response = null;
-
-
- Map<String, String> filter = new HashMap<String, String>();
- for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
- filter.put(e.getKey(), e.getValue().get(0));
- }
+ Map<String, String> filter = addParams ( uriInfo, true, type, version );
try {
if (validateRequest(req, uri, content, Action.GET, CrudServiceConstants.CRD_AUTH_POLICY_NAME, headers)) {
@@ -828,4 +810,23 @@ public class CrudRestService {
// uses our transaction id.
MDC.clear();
}
+
+ private Map<String, String> addParams ( UriInfo info, boolean filter, String type, String version ) {
+ String propertiesKey = CrudProperties.get ( CrudServiceConstants.CRD_COLLECTION_PROPERTIES_KEY );
+ Map<String, String> params = new HashMap<String, String> ();
+ params.put ( CrudServiceConstants.CRD_RESERVED_VERSION, version );
+ params.put ( CrudServiceConstants.CRD_RESERVED_NODE_TYPE, type );
+ if (filter) {
+ for (Map.Entry<String, List<String>> e : info.getQueryParameters ().entrySet ()) {
+ if (!e.getKey ().equals ( propertiesKey )) {
+ params.put ( e.getKey (), e.getValue ().get ( 0 ) );
+ }
+ }
+ } else {
+ for (Map.Entry<String, List<String>> e : info.getQueryParameters ().entrySet ()) {
+ params.put ( e.getKey (), e.getValue ().get ( 0 ) );
+ }
+ }
+ return params;
+ }
}
diff --git a/src/main/java/org/onap/crud/util/CrudServiceConstants.java b/src/main/java/org/onap/crud/util/CrudServiceConstants.java
index 4b88353..3a02852 100644
--- a/src/main/java/org/onap/crud/util/CrudServiceConstants.java
+++ b/src/main/java/org/onap/crud/util/CrudServiceConstants.java
@@ -37,4 +37,6 @@ public class CrudServiceConstants {
public static final String CRD_ASYNC_REQUEST_TIMEOUT = "crud.async.request.timeout";
public static final String CRD_ASYNC_RESPONSE_PROCESS_POLL_INTERVAL = "crud.async.response.process.poll.interval";
public static final String CRD_COLLECTION_PROPERTIES_KEY = "crud.collection.properties.key";
+ public static final String CRD_RESERVED_VERSION = "_reserved_version";
+ public static final String CRD_RESERVED_NODE_TYPE = "_reserved_aai-type";
}
diff --git a/src/main/java/org/onap/schema/OxmModelValidator.java b/src/main/java/org/onap/schema/OxmModelValidator.java
index dda4341..6bc8bcf 100644
--- a/src/main/java/org/onap/schema/OxmModelValidator.java
+++ b/src/main/java/org/onap/schema/OxmModelValidator.java
@@ -32,6 +32,7 @@ import org.eclipse.persistence.oxm.XMLField;
import org.onap.aaiutils.oxm.OxmModelLoader;
import org.onap.crud.entity.Vertex;
import org.onap.crud.exception.CrudException;
+import org.onap.crud.util.CrudServiceConstants;
import org.onap.crud.util.CrudServiceUtil;
import java.util.HashMap;
@@ -87,6 +88,10 @@ public class OxmModelValidator {
final DynamicType reservedObjectType = jaxbContext.getDynamicType("ReservedPropNames");
for (String key : filter.keySet()) {
+ if ((key == CrudServiceConstants.CRD_RESERVED_VERSION ) || key == CrudServiceConstants.CRD_RESERVED_NODE_TYPE ) {
+ result.put ( key, filter.get ( key ) );
+ continue;
+ }
String keyJavaName = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, key);
DatabaseMapping mapping = modelObjectType.getDescriptor().getMappingForAttributeName(keyJavaName);