From ff7ec85b8b2870856387951899c680a11860f2a4 Mon Sep 17 00:00:00 2001 From: ur326r Date: Mon, 14 Aug 2017 14:49:45 -0400 Subject: [AAI-168 Amsterdam] add stored queries Change-Id: I3ab0459c97ebbab98b0a6dc4c9d3cb701aac548f Signed-off-by: ur326r --- .../java/org/openecomp/aai/rest/QueryConsumer.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'aai-traversal/src/main/java/org') diff --git a/aai-traversal/src/main/java/org/openecomp/aai/rest/QueryConsumer.java b/aai-traversal/src/main/java/org/openecomp/aai/rest/QueryConsumer.java index a5f476a..2264f24 100644 --- a/aai-traversal/src/main/java/org/openecomp/aai/rest/QueryConsumer.java +++ b/aai-traversal/src/main/java/org/openecomp/aai/rest/QueryConsumer.java @@ -38,6 +38,7 @@ import javax.ws.rs.QueryParam; 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; @@ -87,7 +88,7 @@ public class QueryConsumer extends RESTAPI { Response response = null; TransactionalGraphEngine dbEngine = null; try { - + this.checkQueryParams(info.getQueryParameters()); Format format = Format.valueOf(queryFormat); if (queryProcessor != null) { processorType = QueryProcessorType.valueOf(queryProcessor); @@ -156,7 +157,7 @@ public class QueryConsumer extends RESTAPI { DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth); FormatFactory ff = new FormatFactory(httpEntry.getLoader(), serializer); - Formatter formater = ff.get(format); + Formatter formater = ff.get(format, info.getQueryParameters()); result = formater.output(vertices).toString(); @@ -178,5 +179,18 @@ public class QueryConsumer extends RESTAPI { return response; } + + public void checkQueryParams(MultivaluedMap params) throws AAIException { + + if (params.containsKey("depth") && params.getFirst("depth").matches("\\d+")) { + String depth = params.getFirst("depth"); + Integer i = Integer.parseInt(depth); + if (i > 1) { + throw new AAIException("AAI_3303"); + } + } + + + } } -- cgit 1.2.3-korg