diff options
author | Shwetank Dave <shwetank.dave@amdocs.com> | 2018-04-05 10:13:31 -0400 |
---|---|---|
committer | Shwetank Dave <shwetank.dave@amdocs.com> | 2018-04-06 08:31:09 -0400 |
commit | 3c702a13da91564f65fbc2a002b7737325daaf56 (patch) | |
tree | 9140f9964de7a0093a833811147890af98a1962e | |
parent | f9be5d8fc3070659a302d34a9c027569aa807c0f (diff) |
Rename Path search-db to search-data-service.
Fix mixtakes in processGet
Remove requestBody from where it's not needed.
Remove elastic-search dependency
Issue-ID: AAI-598
Change-Id: Ib9693297230daba43ed604013c9cf4d32355da92
Signed-off-by: Shwetank Dave <shwetank.dave@amdocs.com>
-rw-r--r-- | pom.xml | 45 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/sa/rest/AnalyzerApi.java | 19 | ||||
-rw-r--r-- | src/main/java/org/onap/aai/sa/rest/SearchServiceApi.java | 63 | ||||
-rw-r--r-- | src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java | 25 |
4 files changed, 53 insertions, 99 deletions
@@ -34,7 +34,6 @@ limitations under the License. <name>aai-search-data-service</name> <properties> - <docker.location>${basedir}/target</docker.location> <nexusproxy>https://nexus.onap.org</nexusproxy> <java.version>1.8</java.version> @@ -53,13 +52,6 @@ limitations under the License. <dependencies> - <!--<dependency>--> - <!--<groupId>org.springframework</groupId>--> - <!--<artifactId>spring-test</artifactId>--> - <!--<version>5.0.4.RELEASE</version>--> - <!--<scope>test</scope>--> - <!--</dependency>--> - <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> @@ -72,6 +64,7 @@ limitations under the License. <version>1.3</version> <scope>test</scope> </dependency> + <dependency> <groupId>com.jayway.jsonpath</groupId> <artifactId>json-path</artifactId> @@ -84,6 +77,7 @@ limitations under the License. <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> + <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> @@ -91,19 +85,6 @@ limitations under the License. <scope>provided</scope> </dependency> - <!--<dependency>--> - <!--<groupId>com.att.aft</groupId>--> - <!--<artifactId>dme2</artifactId>--> - <!--<version>3.1.200</version>--> - <!--<scope>provided</scope>--> - <!--</dependency>--> - - - <dependency> - <groupId>org.elasticsearch</groupId> - <artifactId>elasticsearch</artifactId> - <version>2.3.1</version> - </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> @@ -117,12 +98,6 @@ limitations under the License. <scope>test</scope> </dependency> - <!--<dependency>--> - <!--<groupId>com.att.aai.cl</groupId>--> - <!--<artifactId>common-logging</artifactId>--> - <!--<version>1.0.6</version>--> - <!--</dependency>--> - <!-- Common logging framework --> <dependency> <groupId>org.onap.aai.logging-service</groupId> @@ -141,13 +116,6 @@ limitations under the License. <artifactId>eelf-logging</artifactId> <version>1.2.2</version> </dependency> - <!-- Jersey Test Framework. --> - <!--<dependency>--> - <!--<groupId>org.glassfish.jersey.test-framework.providers</groupId>--> - <!--<artifactId>jersey-test-framework-provider-grizzly2</artifactId>--> - <!--<version>2.23.2</version>--> - <!--<scope>test</scope>--> - <!--</dependency>--> <!-- For JSON Mapping Support. --> <dependency> @@ -156,8 +124,6 @@ limitations under the License. <version>2.7.8</version> </dependency> - <!-- Added additional dependencies --> - <!-- https://mvnrepository.com/artifact/edu.emory.mathcs.backport/com.springsource.edu.emory.mathcs.backport --> <dependency> <groupId>edu.emory.mathcs.backport</groupId> <artifactId>com.springsource.edu.emory.mathcs.backport</artifactId> @@ -165,42 +131,36 @@ limitations under the License. <scope>provided</scope> </dependency> - <!-- https://mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api --> <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>2.0</version> </dependency> - <!-- https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.lang --> <dependency> <groupId>org.apache.directory.studio</groupId> <artifactId>org.apache.commons.lang</artifactId> <version>2.6</version> </dependency> - <!-- https://mvnrepository.com/artifact/radeox/radeox --> <dependency> <groupId>radeox</groupId> <artifactId>radeox</artifactId> <version>0.9</version> </dependency> - <!-- https://mvnrepository.com/artifact/com.github.fge/json-schema-validator --> <dependency> <groupId>com.github.fge</groupId> <artifactId>json-schema-validator</artifactId> <version>2.0.0</version> </dependency> - <!-- https://mvnrepository.com/artifact/org.json/json --> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20180130</version> </dependency> - <!-- Spring dependencies --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> @@ -217,7 +177,6 @@ limitations under the License. <scope>test</scope> </dependency> - <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-security</artifactId> diff --git a/src/main/java/org/onap/aai/sa/rest/AnalyzerApi.java b/src/main/java/org/onap/aai/sa/rest/AnalyzerApi.java index de7ba59..8db9a42 100644 --- a/src/main/java/org/onap/aai/sa/rest/AnalyzerApi.java +++ b/src/main/java/org/onap/aai/sa/rest/AnalyzerApi.java @@ -40,12 +40,17 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.HttpStatus; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; -//@Path("/analyzers") +@Component +@EnableWebSecurity @RestController -@RequestMapping("/services/search-db-service/v1/analyzers") +@RequestMapping("/services/search-data-service/v1/analyzers/search") public class AnalyzerApi { private SearchServiceApi searchService = null; @@ -59,10 +64,12 @@ public class AnalyzerApi { this.searchService = searchService; } - @GET - public ResponseEntity<String> processGet(@Context HttpServletRequest request, - @Context HttpHeaders headers, - ApiUtils apiUtils) { + @RequestMapping(method = RequestMethod.GET, + consumes = {"application/json"}, + produces = {"application/json"}) + public ResponseEntity<String> processGet(HttpServletRequest request, + @RequestHeader HttpHeaders headers, + ApiUtils apiUtils) { HttpStatus responseCode = HttpStatus.INTERNAL_SERVER_ERROR; String responseString = "Undefined error"; diff --git a/src/main/java/org/onap/aai/sa/rest/SearchServiceApi.java b/src/main/java/org/onap/aai/sa/rest/SearchServiceApi.java index 9552658..7e187ee 100644 --- a/src/main/java/org/onap/aai/sa/rest/SearchServiceApi.java +++ b/src/main/java/org/onap/aai/sa/rest/SearchServiceApi.java @@ -35,12 +35,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.security.cert.X509Certificate; -// import javax.servlet.http.HttpServletRequest; - @Component @EnableWebSecurity @RestController -@RequestMapping("/services/search-db-service/v1") +@RequestMapping("/services/search-data-service/v1/search") public class SearchServiceApi { /** @@ -88,10 +86,9 @@ public class SearchServiceApi { method = RequestMethod.DELETE, consumes = {"application/json"}, produces = {"application/json"}) - public ResponseEntity<String> processDeleteIndex(String requestBody, - HttpServletRequest request, - @RequestHeader HttpHeaders headers, - @PathVariable ("index") String index) { + public ResponseEntity<String> processDeleteIndex(HttpServletRequest request, + @RequestHeader HttpHeaders headers, + @PathVariable ("index") String index) { // Forward the request to our index API to delete the index. IndexApi indexApi = new IndexApi(this); @@ -102,7 +99,7 @@ public class SearchServiceApi { @RequestMapping(value = "/indexes/{index}/documents", method = RequestMethod.POST, consumes = {"application/json"}) - public ResponseEntity<String> processCreateDocWithoutId(String requestBody, + public ResponseEntity<String> processCreateDocWithoutId(@RequestBody String requestBody, HttpServletRequest request, HttpServletResponse httpResponse, @RequestHeader HttpHeaders headers, @@ -117,7 +114,7 @@ public class SearchServiceApi { @RequestMapping(value = "/indexes/{index}/documents/{id}", method = RequestMethod.PUT, consumes = {"application/json"}) - public ResponseEntity<String> processUpsertDoc(String requestBody, + public ResponseEntity<String> processUpsertDoc(@RequestBody String requestBody, HttpServletRequest request, HttpServletResponse httpResponse, @RequestHeader HttpHeaders headers, @@ -131,9 +128,9 @@ public class SearchServiceApi { } @RequestMapping(value = "/indexes/{index}/documents/{id}", - method = RequestMethod.GET) - public ResponseEntity<String> processGetDocument(String requestBody, - HttpServletRequest request, + method = RequestMethod.GET, + consumes = {"application/json"}) + public ResponseEntity<String> processGetDocument(HttpServletRequest request, HttpServletResponse httpResponse, @RequestHeader HttpHeaders headers, @PathVariable ("index") String index, @@ -141,48 +138,46 @@ public class SearchServiceApi { // Forward the request to our document API to retrieve the document. DocumentApi documentApi = new DocumentApi(this); - return documentApi.processGet(requestBody, request, headers, httpResponse, + return documentApi.processGet("", request, headers, httpResponse, index, id, documentStore); } @RequestMapping(value = "/indexes/{index}/documents/{id}", method = RequestMethod.DELETE, consumes = {"application/json"}) - public ResponseEntity<String> processDeleteDoc(String requestBody, - HttpServletRequest request, - HttpServletResponse httpResponse, - @RequestHeader HttpHeaders headers, - @PathVariable ("index") String index, - @PathVariable ("id") String id) { + public ResponseEntity<String> processDeleteDoc(HttpServletRequest request, + HttpServletResponse httpResponse, + @RequestHeader HttpHeaders headers, + @PathVariable ("index") String index, + @PathVariable ("id") String id) { // Forward the request to our document API to delete the document. DocumentApi documentApi = new DocumentApi(this); - return documentApi.processDelete(requestBody, request, headers, httpResponse, + return documentApi.processDelete("", request, headers, httpResponse, index, id, documentStore); } @RequestMapping(value = "/indexes/{index}/query/{queryText}", method = RequestMethod.GET, consumes = {"application/json"}) - public ResponseEntity<String> processInlineQuery(String requestBody, - HttpServletRequest request, - @RequestHeader HttpHeaders headers, - @PathVariable ("index") String index, - @PathVariable ("queryText") String queryText) { + public ResponseEntity<String> processInlineQuery(HttpServletRequest request, + @RequestHeader HttpHeaders headers, + @PathVariable ("index") String index, + @PathVariable ("queryText") String queryText) { // Forward the request to our document API to delete the document. DocumentApi documentApi = new DocumentApi(this); - return documentApi.processSearchWithGet(requestBody, request, headers, + return documentApi.processSearchWithGet("", request, headers, index, queryText, documentStore); } @RequestMapping(value = "/indexes/{index}/query", method = RequestMethod.GET, consumes = {"application/json"}) - public ResponseEntity<String> processQueryWithGet(String requestBody, - HttpServletRequest request, - @RequestHeader HttpHeaders headers, - @PathVariable ("index") String index) { + public ResponseEntity<String> processQueryWithGet(@RequestBody String requestBody, + HttpServletRequest request, + @RequestHeader HttpHeaders headers, + @PathVariable ("index") String index) { // Forward the request to our document API to delete the document. DocumentApi documentApi = new DocumentApi(this); @@ -192,7 +187,7 @@ public class SearchServiceApi { @RequestMapping(value = "/indexes/{index}/query", method = RequestMethod.POST, consumes = {"application/json"}) - public ResponseEntity<String> processQuery(String requestBody, + public ResponseEntity<String> processQuery(@RequestBody String requestBody, HttpServletRequest request, @RequestHeader HttpHeaders headers, @PathVariable ("index") String index) { @@ -205,7 +200,7 @@ public class SearchServiceApi { @RequestMapping(value = "/indexes/{index}/suggest", method = RequestMethod.POST, consumes = {"application/json"}) - public ResponseEntity<String> processSuggestQuery(String requestBody, HttpServletRequest request, + public ResponseEntity<String> processSuggestQuery(@RequestBody String requestBody, HttpServletRequest request, @RequestHeader HttpHeaders headers, @PathVariable("index") String index) { // Forward the request to our document API to query suggestions in the // document. @@ -217,7 +212,7 @@ public class SearchServiceApi { @RequestMapping(value = "/indexes/dynamic/{index}", method = RequestMethod.PUT, consumes = {"application/json"}) - public ResponseEntity<String> processCreateDynamicIndex(String requestBody, + public ResponseEntity<String> processCreateDynamicIndex(@RequestBody String requestBody, HttpServletRequest request, @RequestHeader HttpHeaders headers, @PathVariable ("index") String index) { @@ -230,7 +225,7 @@ public class SearchServiceApi { @RequestMapping(value = "/bulk", method = RequestMethod.POST, consumes = {"application/json"}) - public ResponseEntity<String> processBulkRequest(String requestBody, + public ResponseEntity<String> processBulkRequest(@RequestBody String requestBody, HttpServletRequest request, @RequestHeader HttpHeaders headers) { diff --git a/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java b/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java index 3990b27..f7a281a 100644 --- a/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java +++ b/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java @@ -49,9 +49,6 @@ public class SearchServiceApiHarness extends SearchServiceApi { documentStore = new StubEsController(); } -// @PUT -// @Path("/indexes/dynamic/{index}") -// @Consumes({MediaType.APPLICATION_JSON}) @Override @RequestMapping (value="/indexes/dynamic/{index}", method = RequestMethod.PUT, @@ -81,12 +78,11 @@ public class SearchServiceApiHarness extends SearchServiceApi { @RequestMapping (value="/indexes/{index}", method = RequestMethod.DELETE, consumes = { "application/json"}) - public ResponseEntity<String> processDeleteIndex(@RequestBody String requestBody, - HttpServletRequest request, + public ResponseEntity<String> processDeleteIndex(HttpServletRequest request, @RequestHeader HttpHeaders headers, @PathVariable("index") String index) { - return super.processDeleteIndex(requestBody, request, headers, index); + return super.processDeleteIndex(request, headers, index); } @Override @@ -95,14 +91,13 @@ public class SearchServiceApiHarness extends SearchServiceApi { produces = { "application/json"}, consumes = { "application/json", "application/xml" }) public ResponseEntity<String> processGetDocument( - @RequestBody String requestBody, HttpServletRequest request, HttpServletResponse httpResponse, @RequestHeader HttpHeaders headers, @PathVariable("index") String index, @PathVariable("id") String id) { - return super.processGetDocument(requestBody, request, httpResponse, headers, index, id); + return super.processGetDocument(request, httpResponse, headers, index, id); } @Override @@ -136,27 +131,25 @@ public class SearchServiceApiHarness extends SearchServiceApi { @RequestMapping(value = "/indexes/{index}/documents/{id}", method = RequestMethod.DELETE, consumes = { "application/json"}) - public ResponseEntity<String> processDeleteDoc(@RequestBody String requestBody, - HttpServletRequest request, + public ResponseEntity<String> processDeleteDoc(HttpServletRequest request, HttpServletResponse httpResponse, @RequestHeader HttpHeaders headers, @PathVariable("index") String index, @PathVariable("id") String id) { - return super.processDeleteDoc(requestBody, request, httpResponse, headers, index, id); + return super.processDeleteDoc(request, httpResponse, headers, index, id); } @Override @RequestMapping(value = "/indexes/{index}/query/{queryText}", method = RequestMethod.GET, consumes = { "application/json"}) - public ResponseEntity<String> processInlineQuery(String requestBody, - HttpServletRequest request, + public ResponseEntity<String> processInlineQuery(HttpServletRequest request, @RequestHeader HttpHeaders headers, @PathVariable("index") String index, @PathVariable("queryText") String queryText) { - return super.processInlineQuery(requestBody, request, headers, index, queryText); + return super.processInlineQuery(request, headers, index, queryText); } @Override @@ -175,7 +168,7 @@ public class SearchServiceApiHarness extends SearchServiceApi { @RequestMapping(value = "/indexes/{index}/query", method = RequestMethod.POST, consumes = { "application/json"}) - public ResponseEntity<String> processQuery(String requestBody, + public ResponseEntity<String> processQuery(@RequestBody String requestBody, HttpServletRequest request, @RequestHeader HttpHeaders headers, @PathVariable("index") String index) { @@ -189,7 +182,7 @@ public class SearchServiceApiHarness extends SearchServiceApi { consumes = { "application/json", "application/xml" }) public ResponseEntity<String> processBulkRequest(@RequestBody String requestBody, HttpServletRequest request, - @RequestHeader HttpHeaders headers) { + @RequestHeader HttpHeaders headers) { // If the operations string contains a special keyword, set the // harness to fail the authentication validation. |