aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShwetank Dave <shwetank.dave@amdocs.com>2018-06-04 14:42:53 -0400
committerShwetank Dave <shwetank.dave@amdocs.com>2018-06-04 14:47:46 -0400
commitd448077492f159e5877b73c0e732aecc5b4a7695 (patch)
treec8a8bb953ae8922360529038c0405cff1ae456b8
parenteee27dc7db3e0702be82fe9afb8ae515386b0a3e (diff)
Ignore reserved query params
Change-Id: I3eadc1e238a6f73d2dee1b6ced9b1d6033ded85e Issue-ID: AAI-1203 Signed-off-by: Shwetank Dave <shwetank.dave@amdocs.com>
-rw-r--r--champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java b/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
index 1a68027..4b7c9a7 100644
--- a/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
+++ b/champ-service/src/main/java/org/onap/champ/ChampRESTAPI.java
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Timer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -81,6 +83,8 @@ public class ChampRESTAPI {
private Logger logger = LoggerFactory.getInstance().getLogger(ChampRESTAPI.class);
Logger auditLogger = LoggerFactory.getInstance().getAuditLogger(ChampRESTAPI.class.getName());
private static Logger metricsLogger = LoggerFactory.getInstance().getMetricsLogger(ChampRESTAPI.class.getName());
+ private static final Pattern QUERY_OBJECT_ID_URL_MATCH = Pattern.compile("_reserved_(.*)");
+
public ChampRESTAPI(ChampDataService champDataService, ChampAsyncRequestProcessor champAsyncRequestProcessor) {
this.champDataService = champDataService;
@@ -294,7 +298,7 @@ public class ChampRESTAPI {
Map<String, Object> filter = new HashMap<>();
for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
- if (!e.getKey().equals(propertiesKey)) {
+ if ((!e.getKey().equals(propertiesKey)) && !reservedKeyMatcher ( QUERY_OBJECT_ID_URL_MATCH, e.getKey () )) {
filter.put(e.getKey(), e.getValue().get(0));
}
}
@@ -479,7 +483,9 @@ public class ChampRESTAPI {
List<ChampRelationship> list;
Map<String, Object> filter = new HashMap<>();
for (Map.Entry<String, List<String>> e : uriInfo.getQueryParameters().entrySet()) {
- filter.put(e.getKey(), e.getValue().get(0));
+ if (!reservedKeyMatcher ( QUERY_OBJECT_ID_URL_MATCH, e.getKey () )) {
+ filter.put ( e.getKey (), e.getValue ().get ( 0 ) );
+ }
}
Response response = null;
try {
@@ -590,4 +596,13 @@ public class ChampRESTAPI {
return response;
}
+ private boolean reservedKeyMatcher(Pattern p, String key) {
+ Matcher m = p.matcher ( key );
+ if (m.matches()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
}