Sonar fixes for Policy engine
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / controller / DictionaryImportController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP-PAP-REST
4  * ================================================================================
5  * Copyright (C) 2017 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.policy.pap.xacml.rest.controller;
22  /*
23   * 
24   * 
25   * */
26 import java.io.File;
27 import java.io.FileOutputStream;
28 import java.io.FileReader;
29 import java.io.IOException;
30 import java.io.OutputStream;
31 import java.io.UnsupportedEncodingException;
32 import java.util.List;
33
34 import javax.servlet.http.HttpServletRequest;
35 import javax.servlet.http.HttpServletResponse;
36
37 import org.apache.commons.compress.utils.IOUtils;
38 import org.onap.policy.rest.dao.CommonClassDao;
39 import org.onap.policy.rest.jpa.ActionList;
40 import org.onap.policy.rest.jpa.ActionPolicyDict;
41 import org.onap.policy.rest.jpa.AddressGroup;
42 import org.onap.policy.rest.jpa.Attribute;
43 import org.onap.policy.rest.jpa.BRMSParamTemplate;
44 import org.onap.policy.rest.jpa.Category;
45 import org.onap.policy.rest.jpa.Datatype;
46 import org.onap.policy.rest.jpa.DecisionSettings;
47 import org.onap.policy.rest.jpa.DescriptiveScope;
48 import org.onap.policy.rest.jpa.OnapName;
49 import org.onap.policy.rest.jpa.GroupServiceList;
50 import org.onap.policy.rest.jpa.PEPOptions;
51 import org.onap.policy.rest.jpa.PrefixList;
52 import org.onap.policy.rest.jpa.ProtocolList;
53 import org.onap.policy.rest.jpa.SecurityZone;
54 import org.onap.policy.rest.jpa.ServiceList;
55 import org.onap.policy.rest.jpa.TermList;
56 import org.onap.policy.rest.jpa.UserInfo;
57 import org.onap.policy.rest.jpa.VNFType;
58 import org.onap.policy.rest.jpa.VSCLAction;
59 import org.onap.policy.rest.jpa.VarbindDictionary;
60 import org.onap.policy.rest.jpa.Zone;
61 import org.springframework.beans.factory.annotation.Autowired;
62 import org.springframework.stereotype.Controller;
63 import org.springframework.web.bind.annotation.RequestMapping;
64
65 import com.fasterxml.jackson.databind.DeserializationFeature;
66 import com.fasterxml.jackson.databind.ObjectMapper;
67
68 import au.com.bytecode.opencsv.CSVReader;
69
70
71 @Controller
72 public class DictionaryImportController {
73         private String newFile;
74
75         private static CommonClassDao commonClassDao;
76         
77         @Autowired
78         public DictionaryImportController(CommonClassDao commonClassDao){
79                 DictionaryImportController.commonClassDao = commonClassDao;
80         }
81         
82         public DictionaryImportController(){}   
83
84
85         @RequestMapping(value={"/dictionary/import_dictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
86         public void ImportDictionaryData(HttpServletRequest request) throws IOException{
87                 ObjectMapper mapper = new ObjectMapper();
88                 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
89                 String userId = request.getParameter("userId");
90                 String dictionaryName = request.getParameter("dictionaryName");
91
92                 File file = new File(dictionaryName);
93                 OutputStream outputStream = new FileOutputStream(file);
94                 IOUtils.copy(request.getInputStream(), outputStream);
95                 outputStream.close();
96                 this.newFile = file.toString();
97                 CSVReader csvReader = new CSVReader(new FileReader(this.newFile));
98                 List<String[]> dictSheet = csvReader.readAll();
99                 if(dictionaryName.startsWith("Attribute")){
100                         for(int i = 1; i< dictSheet.size(); i++){
101                                 Attribute attribute = new Attribute("");
102                                 UserInfo userinfo = new UserInfo();
103                                 userinfo.setUserLoginId(userId);
104                                 attribute.setUserCreatedBy(userinfo);
105                                 attribute.setUserModifiedBy(userinfo);
106                                 String[] rows = dictSheet.get(i);
107                                 for (int j=0 ; j<rows.length; j++ ){
108                                         if(("xacml_id").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Attribute ID").equalsIgnoreCase(dictSheet.get(0)[j])){
109                                                 attribute.setXacmlId(rows[j]);
110                                         }
111                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
112                                                 attribute.setDescription(rows[j]);
113                                         }
114                                         if(("priority").equalsIgnoreCase(dictSheet.get(0)[j])){
115                                                 attribute.setPriority(rows[j]);
116                                         }
117                                         if(("datatype").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Data Type").equalsIgnoreCase(dictSheet.get(0)[j])){
118                                                 Datatype dataType = new Datatype();
119                                                 if(("string").equalsIgnoreCase(rows[j])){
120                                                         dataType.setId(26);
121                                                 }else if(("integer").equalsIgnoreCase(rows[j])){
122                                                         dataType.setId(12);
123                                                 }else if(("double").equalsIgnoreCase(rows[j])){
124                                                         dataType.setId(25);
125                                                 }else if(("boolean").equalsIgnoreCase(rows[j])){
126                                                         dataType.setId(18);
127                                                 }else if(("user").equalsIgnoreCase(rows[j])){
128                                                         dataType.setId(29);
129                                                 }
130                                                 attribute.setDatatypeBean(dataType);
131                                                 Category category = new Category();
132                                                 category.setId(5);
133                                                 attribute.setCategoryBean(category);
134                                         }
135                                         if(("attribute_value").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Attribute Value").equalsIgnoreCase(dictSheet.get(0)[j])){
136                                                 attribute.setAttributeValue(rows[j]);
137                                         }
138                                 }
139                                 commonClassDao.save(attribute);
140                         }
141                 }
142                 if(dictionaryName.startsWith("ActionPolicyDictionary")){
143                         for(int i = 1; i< dictSheet.size(); i++){
144                                 ActionPolicyDict attribute = new ActionPolicyDict("",  userId);
145                                 UserInfo userinfo = new UserInfo();
146                                 userinfo.setUserLoginId(userId);
147                                 attribute.setUserCreatedBy(userinfo);
148                                 attribute.setUserModifiedBy(userinfo);
149                                 String[] rows = dictSheet.get(i);
150                                 for (int j=0 ; j<rows.length; j++ ){
151                                         if(("attribute_name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Attribute Name").equalsIgnoreCase(dictSheet.get(0)[j])){
152                                                 attribute.setAttributeName(rows[j]);
153                                         }
154                                         if(("body").equalsIgnoreCase(dictSheet.get(0)[j])){
155                                                 attribute.setBody(rows[j]);
156                                         }
157                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
158                                                 attribute.setDescription(rows[j]);
159                                         }
160                                         if(("headers").equalsIgnoreCase(dictSheet.get(0)[j])){
161                                                 attribute.setHeader(rows[j]);
162                                         }
163                                         if(("method").equalsIgnoreCase(dictSheet.get(0)[j])){
164                                                 attribute.setMethod(rows[j]);
165                                         }
166                                         if(("type").equalsIgnoreCase(dictSheet.get(0)[j])){
167                                                 attribute.setMethod(rows[j]);
168                                         }
169                                         if(("url").equalsIgnoreCase(dictSheet.get(0)[j])){
170                                                 attribute.setMethod(rows[j]);
171                                         }
172                                 }
173                                 commonClassDao.save(attribute);
174                         }
175                 }
176                 if(dictionaryName.startsWith("OnapName")){
177                         for(int i = 1; i< dictSheet.size(); i++){
178                                 OnapName attribute = new OnapName("",  userId);
179                                 UserInfo userinfo = new UserInfo();
180                                 userinfo.setUserLoginId(userId);
181                                 attribute.setUserCreatedBy(userinfo);
182                                 attribute.setUserModifiedBy(userinfo);
183                                 String[] rows = dictSheet.get(i);
184                                 for (int j=0 ; j<rows.length; j++ ){
185                                         if(("onap_name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Onap Name").equalsIgnoreCase(dictSheet.get(0)[j])){
186                                                 attribute.setOnapName(rows[j]);
187                                         }
188                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
189                                                 attribute.setDescription(rows[j]);
190                                         }
191                                 }
192                                 commonClassDao.save(attribute);
193                         }
194                 }
195                 if(dictionaryName.startsWith("VNFType")){
196                         for(int i = 1; i< dictSheet.size(); i++){
197                                 VNFType attribute = new VNFType("",  userId);
198                                 UserInfo userinfo = new UserInfo();
199                                 userinfo.setUserLoginId(userId);
200                                 attribute.setUserCreatedBy(userinfo);
201                                 attribute.setUserModifiedBy(userinfo);
202                                 String[] rows = dictSheet.get(i);
203                                 for (int j=0 ; j<rows.length; j++ ){
204                                         if(("vnf_type").equalsIgnoreCase(dictSheet.get(0)[j]) || ("VNF Type").equalsIgnoreCase(dictSheet.get(0)[j])){
205                                                 attribute.setVnftype(rows[j]);
206                                         }
207                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
208                                                 attribute.setDescription(rows[j]);
209                                         }
210                                 }
211                                 commonClassDao.save(attribute);
212                         }
213                 }
214                 if(dictionaryName.startsWith("VSCLAction")){
215                         for(int i = 1; i< dictSheet.size(); i++){
216                                 VSCLAction attribute = new VSCLAction("",  userId);
217                                 UserInfo userinfo = new UserInfo();
218                                 userinfo.setUserLoginId(userId);
219                                 attribute.setUserCreatedBy(userinfo);
220                                 attribute.setUserModifiedBy(userinfo);
221                                 String[] rows = dictSheet.get(i);
222                                 for (int j=0 ; j<rows.length; j++ ){
223                                         if(("vscl_action").equalsIgnoreCase(dictSheet.get(0)[j]) || ("VSCL Action").equalsIgnoreCase(dictSheet.get(0)[j])){
224                                                 attribute.setVsclaction(rows[j]);
225                                         }
226                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
227                                                 attribute.setDescription(rows[j]);
228                                         }
229                                 }
230                                 commonClassDao.save(attribute);
231                         }
232                 }
233                 if(dictionaryName.startsWith("PEPOptions")){
234                         for(int i = 1; i< dictSheet.size(); i++){
235                                 PEPOptions attribute = new PEPOptions("",  userId);
236                                 UserInfo userinfo = new UserInfo();
237                                 userinfo.setUserLoginId(userId);
238                                 attribute.setUserCreatedBy(userinfo);
239                                 attribute.setUserModifiedBy(userinfo);
240                                 String[] rows = dictSheet.get(i);
241                                 for (int j=0 ; j<rows.length; j++ ){
242                                         if(("PEP_NAME").equalsIgnoreCase(dictSheet.get(0)[j]) || ("PEP Name").equalsIgnoreCase(dictSheet.get(0)[j])){
243                                                 attribute.setPepName(rows[j]);
244                                         }
245                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
246                                                 attribute.setDescription(rows[j]);
247                                         }
248                                         if(("Actions").equalsIgnoreCase(dictSheet.get(0)[j])){
249                                                 attribute.setActions(rows[j]);
250                                         }
251                                 }
252                                 commonClassDao.save(attribute);
253                         }
254                 }
255                 if(dictionaryName.startsWith("VarbindDictionary")){
256                         for(int i = 1; i< dictSheet.size(); i++){
257                                 VarbindDictionary attribute = new VarbindDictionary("",  userId);
258                                 UserInfo userinfo = new UserInfo();
259                                 userinfo.setUserLoginId(userId);
260                                 attribute.setUserCreatedBy(userinfo);
261                                 attribute.setUserModifiedBy(userinfo);
262                                 String[] rows = dictSheet.get(i);
263                                 for (int j=0 ; j<rows.length; j++ ){
264                                         if(("varbind_Name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Varbind Name").equalsIgnoreCase(dictSheet.get(0)[j])){
265                                                 attribute.setVarbindName(rows[j]);
266                                         }
267                                         if(("varbind_Description").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Varbind Description").equalsIgnoreCase(dictSheet.get(0)[j])){
268                                                 attribute.setVarbindDescription(rows[j]);
269                                         }
270                                         if(("varbind_oid").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Varbind OID").equalsIgnoreCase(dictSheet.get(0)[j])){
271                                                 attribute.setVarbindOID(rows[j]);
272                                         }
273                                 }
274                                 commonClassDao.save(attribute);
275                         }
276                 }
277                 if(dictionaryName.startsWith("BRMSParamDictionary")){
278                         for(int i = 1; i< dictSheet.size(); i++){
279                                 BRMSParamTemplate attribute = new BRMSParamTemplate();
280                                 UserInfo userinfo = new UserInfo();
281                                 userinfo.setUserLoginId(userId);
282                                 attribute.setUserCreatedBy(userinfo);
283                                 String[] rows = dictSheet.get(i);
284                                 for (int j=0 ; j<rows.length; j++ ){
285                                         if(("param_template_name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Rule Name").equalsIgnoreCase(dictSheet.get(0)[j])){
286                                                 attribute.setRuleName(rows[j]);
287                                         }
288                                         if(("DESCRIPTION").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Description").equalsIgnoreCase(dictSheet.get(0)[j])){
289                                                 attribute.setDescription(rows[j]);
290                                         }
291                                         if(("rule").equalsIgnoreCase(dictSheet.get(0)[j])){
292                                                 attribute.setRule(rows[j]);
293                                         }
294                                 }
295                                 commonClassDao.save(attribute);
296                         }
297                 }
298                 if(dictionaryName.startsWith("Settings")){
299                         for(int i = 1; i< dictSheet.size(); i++){
300                                 DecisionSettings attribute = new DecisionSettings("",  userId);
301                                 UserInfo userinfo = new UserInfo();
302                                 userinfo.setUserLoginId(userId);
303                                 attribute.setUserCreatedBy(userinfo);
304                                 attribute.setUserModifiedBy(userinfo);
305                                 String[] rows = dictSheet.get(i);
306                                 for (int j=0 ; j<rows.length; j++ ){
307                                         if(("xacml_id").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Settings ID").equalsIgnoreCase(dictSheet.get(0)[j])){
308                                                 attribute.setXacmlId(rows[j]);
309                                         }
310                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
311                                                 attribute.setDescription(rows[j]);
312                                         }
313                                         if(("priority").equalsIgnoreCase(dictSheet.get(0)[j])){
314                                                 attribute.setPriority(rows[j]);
315                                         }
316                                         if(("datatype").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Data Type").equalsIgnoreCase(dictSheet.get(0)[j])){
317                                                 Datatype dataType = new Datatype();
318                                                 if(("string").equalsIgnoreCase(rows[j])){
319                                                         dataType.setId(26);
320                                                 }else if(("integer").equalsIgnoreCase(rows[j])){
321                                                         dataType.setId(12);
322                                                 }else if(("double").equalsIgnoreCase(rows[j])){
323                                                         dataType.setId(25);
324                                                 }else if(("boolean").equalsIgnoreCase(rows[j])){
325                                                         dataType.setId(18);
326                                                 }else if(("user").equalsIgnoreCase(rows[j])){
327                                                         dataType.setId(29);
328                                                 }
329                                                 attribute.setDatatypeBean(dataType);
330                                         }
331                                 }
332                                 commonClassDao.save(attribute);
333                         }
334                 }
335                 if(dictionaryName.startsWith("PrefixList")){
336                         for(int i = 1; i< dictSheet.size(); i++){
337                                 PrefixList attribute = new PrefixList("",  userId);
338                                 String[] rows = dictSheet.get(i);
339                                 for (int j=0 ; j<rows.length; j++ ){
340                                         if(("prefixListName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("PrefixList Name").equalsIgnoreCase(dictSheet.get(0)[j])){
341                                                 attribute.setPrefixListName(rows[j]);
342                                         }
343                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
344                                                 attribute.setPrefixListValue(rows[j]);
345                                         }
346                                         if(("prefixListValue").equalsIgnoreCase(dictSheet.get(0)[j]) || ("PrefixList Value").equalsIgnoreCase(dictSheet.get(0)[j])){
347                                                 attribute.setDescription(rows[j]);
348                                         }
349                                 }
350                                 commonClassDao.save(attribute);
351                         }
352                 }
353                 if(dictionaryName.startsWith("SecurityZone")){
354                         for(int i = 1; i< dictSheet.size(); i++){
355                                 SecurityZone attribute = new SecurityZone("",  userId);
356                                 String[] rows = dictSheet.get(i);
357                                 for (int j=0 ; j<rows.length; j++ ){
358                                         if(("zoneName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Zone Name").equalsIgnoreCase(dictSheet.get(0)[j])){
359                                                 attribute.setZoneName(rows[j]);
360                                         }
361                                         if(("zoneValue").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Zone Value").equalsIgnoreCase(dictSheet.get(0)[j])){
362                                                 attribute.setZoneValue(rows[j]);
363                                         }
364                                 }
365                                 commonClassDao.save(attribute);
366                         }
367                 }
368                 if(dictionaryName.startsWith("Zone")){
369                         for(int i = 1; i< dictSheet.size(); i++){
370                                 Zone attribute = new Zone("",  userId);
371                                 String[] rows = dictSheet.get(i);
372                                 for (int j=0 ; j<rows.length; j++ ){
373                                         if(("zoneName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Zone Name").equalsIgnoreCase(dictSheet.get(0)[j])){
374                                                 attribute.setZoneName(rows[j]);
375                                         }
376                                         if(("zoneValue").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Zone Value").equalsIgnoreCase(dictSheet.get(0)[j])){
377                                                 attribute.setZoneValue(rows[j]);
378                                         }
379                                 }
380                                 commonClassDao.save(attribute);
381                         }
382                 }
383                 if(dictionaryName.startsWith("ServiceList")){
384                         for(int i = 1; i< dictSheet.size(); i++){
385                                 ServiceList attribute = new ServiceList("",  userId);
386                                 String[] rows = dictSheet.get(i);
387                                 for (int j=0 ; j<rows.length; j++ ){
388                                         if(("serviceName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Service Name").equalsIgnoreCase(dictSheet.get(0)[j])){
389                                                 attribute.setServiceName(rows[j]);
390                                         }
391                                         if(("serviceDesc").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Description").equalsIgnoreCase(dictSheet.get(0)[j])){
392                                                 attribute.setServiceDescription(rows[j]);
393                                         }
394                                         if(("serviceType").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Service Type").equalsIgnoreCase(dictSheet.get(0)[j])){
395                                                 attribute.setServiceType(rows[j]);
396                                         }
397                                         if(("serviceTrasProtocol").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Transport Protocol").equalsIgnoreCase(dictSheet.get(0)[j])){
398                                                 attribute.setServiceTransProtocol(rows[j]);
399                                         }
400                                         if(("serviceAppProtocol").equalsIgnoreCase(dictSheet.get(0)[j])  || ("APP Protocol").equalsIgnoreCase(dictSheet.get(0)[j])){
401                                                 attribute.setServiceAppProtocol(rows[j]);
402                                         }
403                                         if(("servicePorts").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Ports").equalsIgnoreCase(dictSheet.get(0)[j])){
404                                                 attribute.setServicePorts(rows[j]);
405                                         }
406                                 }
407                                 commonClassDao.save(attribute);
408                         }
409                 }
410                 if(dictionaryName.startsWith("ServiceGroup")){
411                         for(int i = 1; i< dictSheet.size(); i++){
412                                 GroupServiceList attribute = new GroupServiceList("",  userId);
413                                 String[] rows = dictSheet.get(i);
414                                 for (int j=0 ; j<rows.length; j++ ){
415                                         if(("name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Group Name").equalsIgnoreCase(dictSheet.get(0)[j])){
416                                                 attribute.setGroupName(rows[j]);
417                                         }
418                                         if(("serviceList").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Service List").equalsIgnoreCase(dictSheet.get(0)[j])){
419                                                 attribute.setServiceList(rows[j]);
420                                         }
421                                 }
422                                 commonClassDao.save(attribute);
423                         }
424                 }
425                 if(dictionaryName.startsWith("AddressGroup")){
426                         for(int i = 1; i< dictSheet.size(); i++){
427                                 AddressGroup attribute = new AddressGroup("",  userId);
428                                 String[] rows = dictSheet.get(i);
429                                 for (int j=0 ; j<rows.length; j++ ){
430                                         if(("name").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Group Name").equalsIgnoreCase(dictSheet.get(0)[j])){
431                                                 attribute.setGroupName(rows[j]);
432                                         }
433                                         if(("serviceList").equalsIgnoreCase(dictSheet.get(0)[j])  || ("Prefix List").equalsIgnoreCase(dictSheet.get(0)[j])){
434                                                 attribute.setServiceList(rows[j]);
435                                         }
436                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
437                                                 attribute.setDescription(rows[j]);
438                                         }
439                                 }
440                                 commonClassDao.save(attribute);
441                         }
442                 }
443                 if(dictionaryName.startsWith("ProtocolList")){
444                         for(int i = 1; i< dictSheet.size(); i++){
445                                 ProtocolList attribute = new ProtocolList("",  userId);
446                                 String[] rows = dictSheet.get(i);
447                                 for (int j=0 ; j<rows.length; j++ ){
448                                         if(("protocolName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Protocol Name").equalsIgnoreCase(dictSheet.get(0)[j])){
449                                                 attribute.setProtocolName(rows[j]);
450                                         }
451                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
452                                                 attribute.setDescription(rows[j]);
453                                         }
454                                 }
455                                 commonClassDao.save(attribute);
456                         }
457                 }
458                 if(dictionaryName.startsWith("ActionList")){
459                         for(int i = 1; i< dictSheet.size(); i++){
460                                 ActionList attribute = new ActionList("",  userId);
461                                 String[] rows = dictSheet.get(i);
462                                 for (int j=0 ; j<rows.length; j++ ){
463                                         if(("actionName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Action Name").equalsIgnoreCase(dictSheet.get(0)[j])){
464                                                 attribute.setActionName(rows[j]);
465                                         }
466                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
467                                                 attribute.setDescription(rows[j]);
468                                         }
469                                 }
470                                 commonClassDao.save(attribute);
471                         }
472                 }
473                 if(dictionaryName.startsWith("TermList")){
474                         for(int i = 1; i< dictSheet.size(); i++){
475                                 TermList attribute = new TermList("",  userId);
476                                 UserInfo userinfo = new UserInfo();
477                                 userinfo.setUserLoginId(userId);
478                                 attribute.setUserCreatedBy(userinfo);
479                                 attribute.setUserModifiedBy(userinfo);
480                                 String[] rows = dictSheet.get(i);
481                                 for (int j=0 ; j<rows.length; j++ ){
482                                         if(("termName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Term-Name").equalsIgnoreCase(dictSheet.get(0)[j])){
483                                                 attribute.setTermName(rows[j]);
484                                         }
485                                         if(("Term-Description").equalsIgnoreCase(dictSheet.get(0)[j]) || ("termDescription").equalsIgnoreCase(dictSheet.get(0)[j])){
486                                                 attribute.setDescription(rows[j]);
487                                         }
488                                         if(("fromZone").equalsIgnoreCase(dictSheet.get(0)[j])  || ("From Zone").equalsIgnoreCase(dictSheet.get(0)[j])){
489                                                 attribute.setFromZones(rows[j]);
490                                         }
491                                         if(("toZone").equalsIgnoreCase(dictSheet.get(0)[j]) || ("To Zone").equalsIgnoreCase(dictSheet.get(0)[j])){
492                                                 attribute.setToZones(rows[j]);
493                                         }
494                                         if(("srcIPList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Source-IP-List").equalsIgnoreCase(dictSheet.get(0)[j])){
495                                                 attribute.setSrcIPList(rows[j]);
496                                         }
497                                         if(("destIPList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Destination-IP-List").equalsIgnoreCase(dictSheet.get(0)[j])){
498                                                 attribute.setDestIPList(rows[j]);
499                                         }
500                                         if(("srcPortList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Source-Port-List").equalsIgnoreCase(dictSheet.get(0)[j])){
501                                                 attribute.setSrcPortList(rows[j]);
502                                         }
503                                         if(("destPortList").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Destination-Port-List").equalsIgnoreCase(dictSheet.get(0)[j])){
504                                                 attribute.setDestPortList(rows[j]);
505                                         }
506                                         if(("action").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Action List").equalsIgnoreCase(dictSheet.get(0)[j])){
507                                                 attribute.setAction(rows[j]);
508                                         }
509                                 }
510                                 commonClassDao.save(attribute);
511                         }
512                 }
513                 if(dictionaryName.startsWith("SearchCriteria")){
514                         for(int i = 1; i< dictSheet.size(); i++){
515                                 DescriptiveScope attribute = new DescriptiveScope("",  userId);
516                                 UserInfo userinfo = new UserInfo();
517                                 userinfo.setUserLoginId(userId);
518                                 attribute.setUserCreatedBy(userinfo);
519                                 attribute.setUserModifiedBy(userinfo);
520                                 String[] rows = dictSheet.get(i);
521                                 for (int j=0 ; j<rows.length; j++ ){
522                                         if(("descriptiveScopeName").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Descriptive ScopeName").equalsIgnoreCase(dictSheet.get(0)[j])){
523                                                 attribute.setScopeName(rows[j]);
524                                         }
525                                         if(("description").equalsIgnoreCase(dictSheet.get(0)[j])){
526                                                 attribute.setDescription(rows[j]);
527                                         }
528                                         if(("search").equalsIgnoreCase(dictSheet.get(0)[j]) || ("Search Criteria").equalsIgnoreCase(dictSheet.get(0)[j])){
529                                                 attribute.setSearch(rows[j]);
530                                         }
531                                 }
532                                 commonClassDao.save(attribute);
533                         }
534                 }
535                 csvReader.close();
536                 if(file.exists()){
537                         file.delete();
538                 }
539         }
540 }