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