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