2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.pap.xacml.rest.controller;
 
  23 import java.io.IOException;
 
  24 import java.util.Date;
 
  25 import java.util.List;
 
  27 import javax.servlet.http.HttpServletRequest;
 
  28 import javax.servlet.http.HttpServletResponse;
 
  30 import org.onap.policy.pap.xacml.rest.adapters.GridData;
 
  31 import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
 
  32 import org.onap.policy.pap.xacml.rest.util.DictionaryUtils;
 
  33 import org.onap.policy.rest.dao.CommonClassDao;
 
  34 import org.onap.policy.rest.jpa.ClosedLoopD2Services;
 
  35 import org.onap.policy.rest.jpa.ClosedLoopSite;
 
  36 import org.onap.policy.rest.jpa.OnapName;
 
  37 import org.onap.policy.rest.jpa.PEPOptions;
 
  38 import org.onap.policy.rest.jpa.UserInfo;
 
  39 import org.onap.policy.rest.jpa.VNFType;
 
  40 import org.onap.policy.rest.jpa.VSCLAction;
 
  41 import org.onap.policy.rest.jpa.VarbindDictionary;
 
  42 import org.springframework.beans.factory.annotation.Autowired;
 
  43 import org.springframework.http.MediaType;
 
  44 import org.springframework.stereotype.Controller;
 
  45 import org.springframework.web.bind.annotation.RequestMapping;
 
  46 import org.springframework.web.bind.annotation.RequestMethod;
 
  47 import org.springframework.web.servlet.ModelAndView;
 
  49 import com.fasterxml.jackson.databind.DeserializationFeature;
 
  50 import com.fasterxml.jackson.databind.JsonNode;
 
  51 import com.fasterxml.jackson.databind.ObjectMapper;
 
  54 public class ClosedLoopDictionaryController{
 
  56         private static CommonClassDao commonClassDao;
 
  57         private static String vsclaction = "vsclaction";
 
  58         private static String operation = "operation";
 
  59         private static String vnftype = "vnftype";
 
  60         private static String pepName = "pepName";
 
  61         private static String varbindName = "varbindName";
 
  62         private static String serviceName = "serviceName";
 
  63         private static String siteName = "siteName";
 
  64         private static String dictionaryFields = "dictionaryFields";
 
  65         private static String duplicateResponseString = "Duplicate";
 
  66         private static String userid = "userid";
 
  67         private static String vsclActionDatas = "vsclActionDictionaryDatas";
 
  68         private static String vnfTypeDatas = "vnfTypeDictionaryDatas";
 
  69         private static String pepOptionDatas = "pepOptionsDictionaryDatas";
 
  70         private static String varbindDatas = "varbindDictionaryDatas";
 
  71         private static String closedLoopDatas = "closedLoopServiceDictionaryDatas";
 
  72         private static String closedLoopSiteDatas = "closedLoopSiteDictionaryDatas";
 
  75         public ClosedLoopDictionaryController(CommonClassDao commonClassDao){
 
  76                 ClosedLoopDictionaryController.commonClassDao = commonClassDao;
 
  79         public void setCommonClassDao(CommonClassDao commonClassDao){
 
  80                 ClosedLoopDictionaryController.commonClassDao = commonClassDao;
 
  83         public static void setCommonClassDao(CommonClassDaoImpl commonClassDaoImpl) {
 
  84         commonClassDao = commonClassDaoImpl;
 
  87         public ClosedLoopDictionaryController(){
 
  91         private DictionaryUtils getDictionaryUtilsInstance(){
 
  92                 return DictionaryUtils.getDictionaryUtils();
 
  95         @RequestMapping(value={"/get_VSCLActionDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
  96         public void getVSCLActionDictionaryByNameEntityData(HttpServletResponse response){
 
  97                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
  98                 utils.getDataByEntity(response, vsclActionDatas, vsclaction, VSCLAction.class);
 
 102         @RequestMapping(value={"/get_VSCLActionData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 103         public void getVSCLActionDictionaryEntityData(HttpServletResponse response){
 
 104                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 105                 utils.getData(response, vsclActionDatas, VSCLAction.class);
 
 108         @RequestMapping(value={"/get_VNFTypeDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 109         public void getVNFTypeDictionaryByNameEntityData(HttpServletResponse response){
 
 110                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 111                 utils.getDataByEntity(response, vnfTypeDatas, vnftype, VNFType.class);
 
 114         @RequestMapping(value={"/get_VNFTypeData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 115         public void getVNFTypeDictionaryEntityData(HttpServletResponse response){
 
 116                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 117                 utils.getData(response, vnfTypeDatas, VNFType.class);
 
 120         @RequestMapping(value={"/get_PEPOptionsDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 121         public void getPEPOptionsDictionaryByNameEntityData(HttpServletResponse response){
 
 122                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 123                 utils.getDataByEntity(response, pepOptionDatas, pepName, PEPOptions.class);
 
 126         @RequestMapping(value={"/get_PEPOptionsData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 127         public void getPEPOptionsDictionaryEntityData(HttpServletResponse response){
 
 128                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 129                 utils.getData(response, pepOptionDatas, PEPOptions.class);
 
 132         @RequestMapping(value={"/get_VarbindDictionaryDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 133         public void getVarbindDictionaryByNameEntityData(HttpServletResponse response){
 
 134                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 135                 utils.getDataByEntity(response, varbindDatas, varbindName, VarbindDictionary.class);
 
 138         @RequestMapping(value={"/get_VarbindDictionaryData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 139         public void getVarbindDictionaryEntityData(HttpServletResponse response){
 
 140                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 141                 utils.getData(response, varbindDatas, VarbindDictionary.class);
 
 144         @RequestMapping(value={"/get_ClosedLoopServicesDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 145         public void getClosedLoopServiceDictionaryByNameEntityData(HttpServletResponse response){
 
 146                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 147                 utils.getDataByEntity(response, closedLoopDatas, serviceName, ClosedLoopD2Services.class);
 
 150         @RequestMapping(value={"/get_ClosedLoopServicesData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 151         public void getClosedLoopServiceDictionaryEntityData(HttpServletResponse response){
 
 152                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 153                 utils.getData(response, closedLoopDatas, ClosedLoopD2Services.class);
 
 156         @RequestMapping(value={"/get_ClosedLoopSiteDataByName"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 157         public void getClosedLoopSiteDictionaryByNameEntityData(HttpServletResponse response){
 
 158                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 159                 utils.getDataByEntity(response, closedLoopSiteDatas, siteName, ClosedLoopSite.class);
 
 162         @RequestMapping(value={"/get_ClosedLoopSiteData"}, method={RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
 
 163         public void getClosedLoopSiteDictionaryEntityData(HttpServletResponse response){
 
 164                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 165                 utils.getData(response, closedLoopSiteDatas, ClosedLoopSite.class);
 
 168         @RequestMapping(value={"/cl_dictionary/save_vsclAction"}, method={RequestMethod.POST})
 
 169         public ModelAndView saveVSCLAction(HttpServletRequest request, HttpServletResponse response)throws IOException{
 
 170                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 172                         boolean fromAPI = utils.isRequestFromAPI(request);
 
 173                         ObjectMapper mapper = new ObjectMapper();
 
 174                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 175                         JsonNode root = mapper.readTree(request.getReader());
 
 176                         VSCLAction vSCLAction;
 
 177                         String userId = null;
 
 179                                 vSCLAction = mapper.readValue(root.get(dictionaryFields).toString(), VSCLAction.class);
 
 182                                 vSCLAction = mapper.readValue(root.get("vsclActionDictionaryData").toString(), VSCLAction.class);
 
 183                                 userId = root.get(userid).textValue();
 
 185                         UserInfo userInfo = utils.getUserInfo(userId);
 
 187                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vSCLAction.getVsclaction(), vsclaction, VSCLAction.class);
 
 188                         boolean duplicateflag = false;
 
 189                         if(!duplicateData.isEmpty()){
 
 190                                 VSCLAction data = (VSCLAction) duplicateData.get(0);
 
 191                                 if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
 
 192                                         vSCLAction.setId(data.getId());
 
 193                                 }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || 
 
 194                                                 (request.getParameter(operation) == null && (data.getId() != vSCLAction.getId()))){
 
 195                                         duplicateflag = true;
 
 198                         String responseString = null;
 
 200                                 vSCLAction.setUserModifiedBy(userInfo);
 
 201                                 if(vSCLAction.getId() == 0){
 
 202                                         vSCLAction.setUserCreatedBy(userInfo);
 
 203                                         commonClassDao.save(vSCLAction);
 
 205                                         vSCLAction.setModifiedDate(new Date());
 
 206                                         commonClassDao.update(vSCLAction); 
 
 208                                 responseString = mapper.writeValueAsString(commonClassDao.getData(VSCLAction.class));
 
 210                                 responseString = duplicateResponseString;
 
 214                                 return utils.getResultForApi(responseString);
 
 216                                 utils.setResponseData(response, vsclActionDatas, responseString);
 
 219                         utils.setErrorResponseData(response, e);
 
 224         @RequestMapping(value={"/cl_dictionary/remove_VsclAction"}, method={RequestMethod.POST})
 
 225         public void removeVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException {
 
 226                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 227                 utils.removeData(request, response, vsclActionDatas, OnapName.class);
 
 230         @RequestMapping(value={"/cl_dictionary/save_vnfType"}, method={RequestMethod.POST})
 
 231         public ModelAndView saveVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException{
 
 232                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 234                         boolean fromAPI = utils.isRequestFromAPI(request);
 
 235                         ObjectMapper mapper = new ObjectMapper();
 
 236                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 237                         JsonNode root = mapper.readTree(request.getReader());
 
 239                         String userId = null;
 
 241                                 vNFType = mapper.readValue(root.get(dictionaryFields).toString(), VNFType.class);
 
 244                                 vNFType = mapper.readValue(root.get("vnfTypeDictionaryData").toString(), VNFType.class);
 
 245                                 userId = root.get(userid).textValue();
 
 247                         UserInfo userInfo = utils.getUserInfo(userId);
 
 249                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(vNFType.getVnftype(), vnftype, VNFType.class);
 
 250                         boolean duplicateflag = false;
 
 251                         if(!duplicateData.isEmpty()){
 
 252                                 VNFType data = (VNFType) duplicateData.get(0);
 
 253                                 if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
 
 254                                         vNFType.setId(data.getId());
 
 255                                 }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || 
 
 256                                                 (request.getParameter(operation) == null && (data.getId() != vNFType.getId()))){
 
 257                                         duplicateflag = true;
 
 260                         String responseString = null;
 
 262                                 vNFType.setUserModifiedBy(userInfo);
 
 263                                 if(vNFType.getId() == 0){
 
 264                                         vNFType.setUserCreatedBy(userInfo);
 
 265                                         commonClassDao.save(vNFType);
 
 267                                         vNFType.setModifiedDate(new Date());
 
 268                                         commonClassDao.update(vNFType); 
 
 270                                 responseString = mapper.writeValueAsString(commonClassDao.getData(VNFType.class));
 
 272                                 responseString = duplicateResponseString;
 
 276                                 return utils.getResultForApi(responseString);
 
 278                                 utils.setResponseData(response, vnfTypeDatas, responseString);
 
 281                         utils.setErrorResponseData(response, e);
 
 286         @RequestMapping(value={"/cl_dictionary/remove_vnfType"}, method={RequestMethod.POST})
 
 287         public void removeVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException {
 
 288                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 289                 utils.removeData(request, response, vnfTypeDatas, VNFType.class);
 
 292         @RequestMapping(value={"/cl_dictionary/save_pepOptions"}, method={RequestMethod.POST})
 
 293         public ModelAndView savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException{
 
 294                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 296                         boolean fromAPI = utils.isRequestFromAPI(request);
 
 297                         ObjectMapper mapper = new ObjectMapper();
 
 298                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 299                         JsonNode root = mapper.readTree(request.getReader());
 
 300             PEPOptions pEPOptions;
 
 302             String userId = null;
 
 304                 pEPOptions = mapper.readValue(root.get(dictionaryFields).toString(), PEPOptions.class);
 
 305                 gridData = mapper.readValue(root.get(dictionaryFields).toString(), GridData.class);
 
 308                 pEPOptions = mapper.readValue(root.get("pepOptionsDictionaryData").toString(), PEPOptions.class);
 
 309                 gridData = mapper.readValue(root.get("pepOptionsDictionaryData").toString(), GridData.class);
 
 310                 userId = root.get(userid).textValue();
 
 312             UserInfo userInfo = utils.getUserInfo(userId);
 
 314                         if(!gridData.getAttributes().isEmpty()){
 
 315                                 pEPOptions.setActions(utils.appendKeyValue(gridData.getAttributes(), ":#@", "=#@"));
 
 318                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(pEPOptions.getPepName(), pepName, PEPOptions.class);
 
 319                         boolean duplicateflag = false;
 
 320                         if(!duplicateData.isEmpty()){
 
 321                                 PEPOptions data = (PEPOptions) duplicateData.get(0);
 
 322                                 if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
 
 323                                         pEPOptions.setId(data.getId());
 
 324                                 }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || 
 
 325                                                 (request.getParameter(operation) == null && (data.getId() != pEPOptions.getId()))){
 
 326                                         duplicateflag = true;
 
 329                         String responseString = null;
 
 331                                 pEPOptions.setUserModifiedBy(userInfo);
 
 332                                 if(pEPOptions.getId() == 0){
 
 333                                         pEPOptions.setUserCreatedBy(userInfo);
 
 334                                         commonClassDao.save(pEPOptions);
 
 336                                         pEPOptions.setModifiedDate(new Date());
 
 337                                         commonClassDao.update(pEPOptions); 
 
 339                                 responseString = mapper.writeValueAsString(commonClassDao.getData(PEPOptions.class));
 
 341                                 responseString = duplicateResponseString;
 
 345                                 return utils.getResultForApi(responseString);
 
 347                                 utils.setResponseData(response, pepOptionDatas, responseString);
 
 350                 utils.setErrorResponseData(response, e);
 
 355         @RequestMapping(value={"/cl_dictionary/remove_pepOptions"}, method={RequestMethod.POST})
 
 356         public void removePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException {
 
 357                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 358                 utils.removeData(request, response, pepOptionDatas, VNFType.class);
 
 361         @RequestMapping(value={"/cl_dictionary/save_service"}, method={RequestMethod.POST})
 
 362         public ModelAndView saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException{
 
 363                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 365                         boolean fromAPI = utils.isRequestFromAPI(request);
 
 366                         ObjectMapper mapper = new ObjectMapper();
 
 367                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 368                         JsonNode root = mapper.readTree(request.getReader());
 
 369             ClosedLoopD2Services serviceData;
 
 370             String userId = null;
 
 372                 serviceData = mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopD2Services.class);
 
 375                 serviceData = mapper.readValue(root.get("closedLoopServiceDictionaryData").toString(), ClosedLoopD2Services.class);
 
 376                 userId = root.get(userid).textValue();
 
 378             UserInfo userInfo = utils.getUserInfo(userId);
 
 380                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(serviceData.getServiceName(), serviceName, ClosedLoopD2Services.class);
 
 381                         boolean duplicateflag = false;
 
 382                         if(!duplicateData.isEmpty()){
 
 383                                 ClosedLoopD2Services data = (ClosedLoopD2Services) duplicateData.get(0);
 
 384                                 if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
 
 385                                         serviceData.setId(data.getId());
 
 386                                 }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || 
 
 387                                                 (request.getParameter(operation) == null && (data.getId() != serviceData.getId()))){
 
 388                                         duplicateflag = true;
 
 391                         String responseString = null;
 
 393                                 serviceData.setUserModifiedBy(userInfo);
 
 394                                 if(serviceData.getId() == 0){
 
 395                                         serviceData.setUserCreatedBy(userInfo);
 
 396                                         commonClassDao.save(serviceData);
 
 398                                         serviceData.setModifiedDate(new Date());
 
 399                                         commonClassDao.update(serviceData); 
 
 401                                 responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopD2Services.class));
 
 403                                 responseString = duplicateResponseString;
 
 406                                 return utils.getResultForApi(responseString);
 
 408                                 utils.setResponseData(response, closedLoopDatas, responseString);
 
 411                 utils.setErrorResponseData(response, e);
 
 416         @RequestMapping(value={"/cl_dictionary/remove_Service"}, method={RequestMethod.POST})
 
 417         public void removeServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException {
 
 418                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 419                 utils.removeData(request, response, closedLoopDatas, VNFType.class);
 
 422         @RequestMapping(value={"/cl_dictionary/save_siteName"}, method={RequestMethod.POST})
 
 423         public ModelAndView saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException{
 
 424                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 426                         boolean fromAPI = utils.isRequestFromAPI(request);
 
 427                         ObjectMapper mapper = new ObjectMapper();
 
 428                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 429                         JsonNode root = mapper.readTree(request.getReader());
 
 430             ClosedLoopSite siteData;
 
 431             String userId = null;
 
 433                 siteData = mapper.readValue(root.get(dictionaryFields).toString(), ClosedLoopSite.class);
 
 436                 siteData = mapper.readValue(root.get("closedLoopSiteDictionaryData").toString(), ClosedLoopSite.class);
 
 437                 userId = root.get(userid).textValue();
 
 439             UserInfo userInfo = utils.getUserInfo(userId);
 
 441             List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(siteData.getSiteName(), siteName, ClosedLoopSite.class);
 
 442                         boolean duplicateflag = false;
 
 443                         if(!duplicateData.isEmpty()){
 
 444                                 ClosedLoopSite data = (ClosedLoopSite) duplicateData.get(0);
 
 445                                 if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
 
 446                                         siteData.setId(data.getId());
 
 447                                 }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || 
 
 448                                                 (request.getParameter(operation) == null && (data.getId() != siteData.getId()))){
 
 449                                         duplicateflag = true;
 
 452             String responseString = null;
 
 454                                 siteData.setUserModifiedBy(userInfo);
 
 455                                 if(siteData.getId() == 0){
 
 456                                         siteData.setUserCreatedBy(userInfo);
 
 457                                         commonClassDao.save(siteData);
 
 459                                         siteData.setModifiedDate(new Date());
 
 460                                         commonClassDao.update(siteData); 
 
 462                                 responseString = mapper.writeValueAsString(commonClassDao.getData(ClosedLoopSite.class));
 
 464                                 responseString = duplicateResponseString;
 
 467                                 return utils.getResultForApi(responseString);
 
 469                                 utils.setResponseData(response, closedLoopSiteDatas, responseString);
 
 471         }catch (Exception e){
 
 472                 utils.setErrorResponseData(response, e);
 
 477         @RequestMapping(value={"/cl_dictionary/remove_site"}, method={RequestMethod.POST})
 
 478         public void removeSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException {
 
 479                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 480                 utils.removeData(request, response, closedLoopSiteDatas, VNFType.class);
 
 483         @RequestMapping(value={"/cl_dictionary/save_varbind"}, method={RequestMethod.POST})
 
 484         public ModelAndView saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
 
 485                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 487                         boolean fromAPI = utils.isRequestFromAPI(request);
 
 488                         ObjectMapper mapper = new ObjectMapper();
 
 489                         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
 
 490                         JsonNode root = mapper.readTree(request.getReader());
 
 491             VarbindDictionary varbindDictionary;
 
 492             String userId = null;
 
 494                 varbindDictionary = mapper.readValue(root.get(dictionaryFields).toString(), VarbindDictionary.class);
 
 497                 varbindDictionary = mapper.readValue(root.get("varbindDictionaryData").toString(), VarbindDictionary.class);
 
 498                 userId = root.get(userid).textValue();
 
 500             UserInfo userInfo = utils.getUserInfo(userId);
 
 502                         List<Object> duplicateData =  commonClassDao.checkDuplicateEntry(varbindDictionary.getVarbindName(), varbindName, VarbindDictionary.class);
 
 503                         boolean duplicateflag = false;
 
 504                         if(!duplicateData.isEmpty()){
 
 505                                 VarbindDictionary data = (VarbindDictionary) duplicateData.get(0);
 
 506                                 if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
 
 507                                         varbindDictionary.setId(data.getId());
 
 508                                 }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) || 
 
 509                                                 (request.getParameter(operation) == null && (data.getId() != varbindDictionary.getId()))){
 
 510                                         duplicateflag = true;
 
 514                         String responseString = null;
 
 516                                 varbindDictionary.setUserModifiedBy(userInfo);
 
 517                                 if(varbindDictionary.getId() == 0){
 
 518                                         varbindDictionary.setUserCreatedBy(userInfo);
 
 519                                         commonClassDao.save(varbindDictionary);
 
 521                                         varbindDictionary.setModifiedDate(new Date());
 
 522                                         commonClassDao.update(varbindDictionary); 
 
 524                                 responseString = mapper.writeValueAsString(commonClassDao.getData(VarbindDictionary.class));
 
 526                                 responseString = duplicateResponseString;
 
 529                                 return utils.getResultForApi(responseString);
 
 531                                 utils.setResponseData(response, varbindDatas, responseString);
 
 533         }catch (Exception e){
 
 534                 utils.setErrorResponseData(response, e);
 
 539         @RequestMapping(value={"/cl_dictionary/remove_varbindDict"}, method={RequestMethod.POST})
 
 540         public void removeVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
 
 541                 DictionaryUtils utils = getDictionaryUtilsInstance();
 
 542                 utils.removeData(request, response, varbindDatas, VNFType.class);