diff options
author | Manoop Talasila <talasila@research.att.com> | 2019-04-11 13:50:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-11 13:50:42 +0000 |
commit | 2c6c55376190b63c8bcb76ba876b0a54f9d4fcc5 (patch) | |
tree | 438de8e66c8af754b9fb83872cbb3afa2acd5bcb /ecomp-sdk | |
parent | 1291e57da45c8c6c501d425d22f05ecb3c224e69 (diff) | |
parent | f6b31f6896ff7e49bd9412832c0bd9be0c26f0c5 (diff) |
Merge "Fix sonar issues in ElasticSearchController"
Diffstat (limited to 'ecomp-sdk')
-rw-r--r-- | ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElasticSearchController.java | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElasticSearchController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElasticSearchController.java index 1adf0dba..37c4eb77 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElasticSearchController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/ElasticSearchController.java @@ -105,23 +105,22 @@ public class ElasticSearchController extends RestrictedBaseController{ SuggestResult result = client.execute(suggest); System.err.println(result.getJsonObject().toString()); - return new ResponseEntity<Result>(new Result(result.getJsonObject().toString()),HttpStatus.OK); + return new ResponseEntity<>(new Result(result.getJsonObject().toString()),HttpStatus.OK); } - @RequestMapping(value="/es_search/{task}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value="/es_search/{task}",method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Result> doSearch(@PathVariable("task") String task) throws IOException { JSONObject obj = new JSONObject(task); String searchTerm = obj.getString("data"); String searchSize = obj.getString("size"); - // String searchFuzzy = obj.getString("fuzzy"); - + JestClientFactory factory = new JestClientFactory(); factory.setHttpClientConfig(new HttpClientConfig .Builder("http://todo_elastic_search_server") .multiThreaded(true) .build()); JestClient client = factory.getObject(); - + Search search = new Search.Builder("{\n" +"\"query\" : {\n" +"\"query_string\" : {\n" @@ -129,16 +128,16 @@ public class ElasticSearchController extends RestrictedBaseController{ +"}\n" +"}\n" +"}").addIndex("customer").setParameter(Parameters.SIZE,Integer.valueOf(searchSize)).build(); - + SearchResult result = client.execute(search); System.err.println(result.getJsonObject().toString()); - return new ResponseEntity<Result>(new Result(result.getJsonObject().toString()),HttpStatus.OK); + return new ResponseEntity<>(new Result(result.getJsonObject().toString()),HttpStatus.OK); } - + public ResponseEntity<Result> sendResult(Result result) { - return new ResponseEntity<Result>(result, HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } - + @Override public boolean isRESTfulCall() { return true; |