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