- StringBuilder fromZoneValue = new StringBuilder();
- int counter = 0;
- if(!termListDatas.getFromZoneDatas().isEmpty()){
- for(Object fromZone : termListDatas.getFromZoneDatas()){
- if(fromZone instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) fromZone).get(option).toString();
- if(counter>0){
- fromZoneValue.append(",");
- }
- fromZoneValue.append(key);
- counter ++;
- }
- }
- }
- termList.setFromZones(fromZoneValue.toString());
-
- StringBuilder toZoneValue = new StringBuilder();
- int toZonecounter = 0;
- if(!termListDatas.getToZoneDatas().isEmpty()){
- for(Object toZone : termListDatas.getToZoneDatas()){
- if(toZone instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) toZone).get(option).toString();
- if(toZonecounter>0){
- toZoneValue.append(",");
- }
- toZoneValue.append(key);
- toZonecounter ++;
- }
- }
- }
- termList.setToZones(toZoneValue.toString());
-
- StringBuilder srcListValues = new StringBuilder();
- int srcListcounter = 0;
- if(!termListDatas.getSourceListDatas().isEmpty()){
- for(Object srcList : termListDatas.getSourceListDatas()){
- if(srcList instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) srcList).get(option).toString();
- if(srcListcounter>0){
- srcListValues.append(",");
- }
- srcListValues.append(key);
- srcListcounter ++;
- }
- }
- }
- termList.setSrcIPList(srcListValues.toString());
-
- StringBuilder desListValues = new StringBuilder();
- int destListcounter = 0;
- if(!termListDatas.getDestinationListDatas().isEmpty()){
- for(Object desList : termListDatas.getDestinationListDatas()){
- if(desList instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) desList).get(option).toString();
- if(destListcounter>0){
- desListValues.append(",");
- }
- desListValues.append(key);
- destListcounter ++;
- }
- }
- }
- termList.setDestIPList(desListValues.toString());
-
- StringBuilder srcSerValue = new StringBuilder();
- int srcSercounter = 0;
- if(!termListDatas.getSourceServiceDatas().isEmpty()){
- for(Object srcSrc : termListDatas.getSourceServiceDatas()){
- if(srcSrc instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) srcSrc).get(option).toString();
- if(srcSercounter>0){
- srcSerValue.append(",");
- }
- srcSerValue.append(key);
- srcSercounter ++;
- }
- }
- }
- termList.setSrcPortList(srcSerValue.toString());
-
- StringBuilder desSrcValue = new StringBuilder();
- int desSrccounter = 0;
- if(!termListDatas.getDestinationServiceDatas().isEmpty()){
- for(Object desSrc : termListDatas.getDestinationServiceDatas()){
- if(desSrc instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) desSrc).get(option).toString();
- if(desSrccounter>0){
- desSrcValue.append(",");
- }
- desSrcValue.append(key);
- desSrccounter ++;
- }
- }
- }
- termList.setDestPortList(desSrcValue.toString());
-
- StringBuilder actionValue = new StringBuilder();
- int actioncounter = 0;
- if(!termListDatas.getActionListDatas().isEmpty()){
- for(Object actionList : termListDatas.getActionListDatas()){
- if(actionList instanceof LinkedHashMap<?, ?>){
- String key = ((LinkedHashMap<?, ?>) actionList).get(option).toString();
- if(actioncounter>0){
- actionValue.append(",");
- }
- actionValue.append(key);
- actioncounter ++;
- }
+
+ termList.setFromZones(utils.appendKey(termListDatas.getFromZoneDatas(), option, ","));
+ termList.setToZones(utils.appendKey(termListDatas.getToZoneDatas(), option, ","));
+ termList.setSrcIPList(utils.appendKey(termListDatas.getSourceListDatas(), option, ","));
+ termList.setDestIPList(utils.appendKey(termListDatas.getDestinationListDatas(), option, ","));
+ termList.setSrcPortList(utils.appendKey(termListDatas.getSourceServiceDatas(), option, ","));
+ termList.setDestPortList(utils.appendKey(termListDatas.getDestinationServiceDatas(), option, ","));
+ termList.setAction(utils.appendKey(termListDatas.getActionListDatas(), option, ","));
+
+ UserInfo userInfo = utils.getUserInfo(userId);
+ List<Object> duplicateData = commonClassDao.checkDuplicateEntry(termList.getTermName(), termName, TermList.class);
+ boolean duplicateflag = false;
+ if(!duplicateData.isEmpty()){
+ TermList data = (TermList) duplicateData.get(0);
+ if(request.getParameter(operation) != null && "update".equals(request.getParameter(operation))){
+ termList.setId(data.getId());
+ }else if((request.getParameter(operation) != null && !"update".equals(request.getParameter(operation))) ||
+ (request.getParameter(operation) == null && (data.getId() != termList.getId()))){
+ duplicateflag = true;