+ if("search".equalsIgnoreCase(request.getParameter("action"))){
+ try {
+ JsonNode root = mapper.readTree(request.getReader());
+ SearchData searchData = (SearchData)mapper.readValue(root.get("searchdata").toString(), SearchData.class);
+
+ String policyType = searchData.getPolicyType();
+
+ String searchText = searchData.getQuery();
+ String descriptivevalue = searchData.getDescriptiveScope();
+ if(descriptivevalue != null){
+ DescriptiveScope dsSearch = (DescriptiveScope) commonClassDao.getEntityItem(DescriptiveScope.class, "descriptiveScopeName", searchData.getDescriptiveScope());
+ if(dsSearch != null){
+ String[] descriptiveList = dsSearch.getSearch().split("AND");
+ for(String keyValue : descriptiveList){
+ String[] entry = keyValue.split(":");
+ searchKeyValue.put(entry[0], entry[1]);
+ }
+ }
+ }
+
+ if(searchData.getClosedLooppolicyType() != null){
+ String closedLoopType;
+ if("Config_Fault".equalsIgnoreCase(searchData.getClosedLooppolicyType())){
+ closedLoopType = "ClosedLoop_Fault";
+ }else{
+ closedLoopType = "ClosedLoop_PM";
+ }
+ searchKeyValue.put("configPolicyType", closedLoopType);
+ }
+ if(searchData.getEcompName() != null){
+ searchKeyValue.put("ecompName", searchData.getEcompName());
+ }
+ if(searchData.getD2Service() != null){
+ searchKeyValue.put("_all", searchData.getD2Service());
+ }
+ if(searchData.getVnfType() != null){
+ searchKeyValue.put("_all", searchData.getVnfType());
+ }
+ if(searchData.getPolicyStatus() != null){
+ searchKeyValue.put("_all", searchData.getPolicyStatus());
+ }
+ if(searchData.getVproAction() != null){
+ searchKeyValue.put("_all", searchData.getVproAction());
+ }
+ if(searchData.getServiceType() != null){
+ searchKeyValue.put("_all", searchData.getServiceType());
+ }
+ if(searchData.getBindTextSearch() != null){
+ searchKeyValue.put("_all", searchData.getBindTextSearch());
+ }
+ PolicyIndexType type = null;
+ if(policyType != null){
+ if(policyType.equalsIgnoreCase("action")){
+ type = ElkConnector.PolicyIndexType.action;
+ }else if(policyType.equalsIgnoreCase("decision")){
+ type = ElkConnector.PolicyIndexType.decision;
+ }else if(policyType.equalsIgnoreCase("config")){
+ type = ElkConnector.PolicyIndexType.config;
+ }else {
+ type = ElkConnector.PolicyIndexType.closedloop;
+ }
+ }else{
+ type = ElkConnector.PolicyIndexType.all;
+ }
+ JestResult policyResultList = controller.search(type, searchText, searchKeyValue);
+ if(policyResultList.isSucceeded()){
+ result = true;
+ policyResult = true;
+ JsonArray resultObject = policyResultList.getJsonObject().get("hits").getAsJsonObject().get("hits").getAsJsonArray();
+ for(int i =0; i < resultObject.size(); i++){
+ String policyName = resultObject.get(i).getAsJsonObject().get("_id").toString();
+ policyList.add(policyName);
+ }
+ }else{
+ LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server, Check the Logs");
+ }
+ }catch(Exception e){
+ LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server" + e);
+ }
+ }