summaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src/main
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2019-01-22 17:11:02 -0500
committerKajur, Harish (vk250x) <vk250x@att.com>2019-01-23 17:12:56 -0500
commit47fe584b69f0631aa151c7e6a28378d5b712006c (patch)
treeb4dfbadd8c09c809573e21f3978515138e35af5b /aai-schema-service/src/main
parent2e6edbd56d6644d84fe24b061be06b952ceb773a (diff)
Add the queries endpoint and files
related to the queries endpoint Issue-ID: AAI-1864 Change-Id: I50054dbaa5b069f0cdbe5b0dc0ce8c06a189589a Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-schema-service/src/main')
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryResource.java44
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryService.java68
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java2
3 files changed, 114 insertions, 0 deletions
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryResource.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryResource.java
new file mode 100644
index 0000000..0137d1d
--- /dev/null
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryResource.java
@@ -0,0 +1,44 @@
+/**
+ * ============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.schemaservice.query;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("/v1")
+public class QueryResource {
+
+ private QueryService queryService;
+
+ @Autowired
+ public QueryResource(QueryService queryService){
+ this.queryService = queryService;
+ }
+
+ @GET
+ @Path("/stored-queries")
+ public Response retrieveStoredQueries(){
+ return Response.ok().entity(queryService.getStoredQueries()).build();
+ }
+
+}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryService.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryService.java
new file mode 100644
index 0000000..badb09a
--- /dev/null
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/query/QueryService.java
@@ -0,0 +1,68 @@
+/**
+ * ============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.schemaservice.query;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.stream.Stream;
+
+@Service
+public class QueryService {
+
+ private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(QueryService.class);
+
+ private String queryLocation;
+
+ private String storedQueriesContent;
+
+ public QueryService(@Value("${schema.query.location}") String queryLocation){
+ this.queryLocation = queryLocation;
+ }
+
+ @PostConstruct
+ public void initialize() throws IOException {
+
+ String fileName = queryLocation + File.separator + "stored-queries.json";
+ LOGGER.debug("Loading the following stored queries file {}", fileName);
+
+ StringBuilder contentBuilder = new StringBuilder();
+
+ try(Stream<String> stream = Files.lines(Paths.get(fileName), StandardCharsets.UTF_8)){
+ stream.forEach(s -> contentBuilder.append(s));
+ }
+
+ storedQueriesContent = contentBuilder.toString();
+
+ LOGGER.trace("Contents of the stored query file {}", storedQueriesContent);
+ }
+
+ public String getStoredQueries(){
+ return storedQueriesContent;
+ }
+}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java
index bdd7946..9fbe3a5 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java
@@ -23,6 +23,7 @@ import org.glassfish.jersey.server.ResourceConfig;
import org.onap.aai.schemaservice.edges.EdgeResource;
import org.onap.aai.schemaservice.healthcheck.EchoResource;
import org.onap.aai.schemaservice.nodeschema.NodeSchemaResource;
+import org.onap.aai.schemaservice.query.QueryResource;
import org.onap.aai.schemaservice.versions.VersionResource;
import org.reflections.Reflections;
import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +54,7 @@ public class JerseyConfiguration extends ResourceConfig {
register(VersionResource.class);
register(EchoResource.class);
register(NodeSchemaResource.class);
+ register(QueryResource.class);
register(EdgeResource.class);
//Request Filters