Fixes for missed sonar critical issues
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / service / DictionaryService.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 package org.onap.policy.pap.xacml.rest.service;
21
22 import java.io.IOException;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
28 import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController;
29 import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
30 import org.onap.policy.pap.xacml.rest.controller.DecisionPolicyDictionaryController;
31 import org.onap.policy.pap.xacml.rest.controller.DescriptiveDictionaryController;
32 import org.onap.policy.pap.xacml.rest.controller.DictionaryController;
33 import org.onap.policy.pap.xacml.rest.controller.EnforcerDictionaryController;
34 import org.onap.policy.pap.xacml.rest.controller.FirewallDictionaryController;
35 import org.onap.policy.pap.xacml.rest.controller.MicroServiceDictionaryController;
36 import org.onap.policy.pap.xacml.rest.controller.PolicyScopeDictionaryController;
37 import org.onap.policy.pap.xacml.rest.controller.SafePolicyController;
38 import org.springframework.stereotype.Service;
39 import org.springframework.web.servlet.ModelAndView;
40
41
42 @Service("DictionaryService")
43 public class DictionaryService {
44
45         /*
46          * Methods that call the controller method directly to Save and Update dictionary data
47          */
48         public String saveOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
49                 
50                 DictionaryController dictionary = new DictionaryController();
51                 String responseString = null;
52                         ModelAndView result = dictionary.saveOnapDictionary(request, response);
53                         responseString = result.getViewName();
54                 return responseString;
55                 
56         }
57         
58         public String saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
59                 
60                 DictionaryController dictionary = new DictionaryController();
61                 String responseString = null;
62                         ModelAndView result = dictionary.saveAttributeDictionary(request, response);
63                         responseString = result.getViewName();
64                 return responseString;
65         }
66         
67         public String saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
68                 
69                 ActionPolicyDictionaryController action = new ActionPolicyDictionaryController();
70                 String responseString = null;
71                         ModelAndView result = action.saveActionPolicyDictionary(request, response);
72                         responseString = result.getViewName();
73                 return responseString;
74         }
75         
76         public String saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException {
77                 
78                 BRMSDictionaryController dictionary = new BRMSDictionaryController();
79                 String responseString = null;
80                         ModelAndView result = dictionary.saveBRMSParamDictionary(request, response);
81                         responseString = result.getViewName();
82                 return responseString;
83         }
84         
85         public String saveVSCLAction(HttpServletRequest request, HttpServletResponse response) throws IOException{
86                 
87                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
88                 String responseString = null;
89                         ModelAndView result = dictionary.saveVSCLAction(request, response);
90                         responseString = result.getViewName();
91                 return responseString;
92         }
93         
94         public String saveVnfType(HttpServletRequest request, HttpServletResponse response) throws IOException{
95                 
96                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
97                 String responseString = null;
98                         ModelAndView result = dictionary.saveVnfType(request, response);
99                         responseString = result.getViewName();
100                 return responseString;
101         }
102         
103         public String savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws IOException{
104                 
105                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
106                 String responseString = null;
107                         ModelAndView result = dictionary.savePEPOptions(request, response);
108                         responseString = result.getViewName();
109                 return responseString;
110         }
111         
112         public String saveVarbind(HttpServletRequest request, HttpServletResponse response) throws IOException{
113                 
114                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
115                 String responseString = null;
116                         ModelAndView result = dictionary.saveVarbind(request, response);
117                         responseString = result.getViewName();
118                 return responseString;
119         }
120         
121         public String saveServiceType(HttpServletRequest request, HttpServletResponse response) throws IOException{
122                 
123                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
124                 String responseString = null;
125                         ModelAndView result = dictionary.saveServiceType(request, response);
126                         responseString = result.getViewName();
127                 return responseString;
128         }
129         
130         public String saveSiteType(HttpServletRequest request, HttpServletResponse response) throws IOException{
131                 
132                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
133                 String responseString = null;
134                         ModelAndView result = dictionary.saveSiteType(request, response);
135                         responseString = result.getViewName();
136                 return responseString;
137         }
138         
139         public String saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
140                 
141                 DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController();
142                 String responseString = null;
143                         ModelAndView result = dictionary.saveSettingsDictionary(request, response);
144                         responseString = result.getViewName();
145                 return responseString;
146         }
147         
148         public String saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
149                 
150                 DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController();
151                 String responseString = null;
152                         ModelAndView result = dictionary.saveDescriptiveDictionary(request, response);
153                         responseString = result.getViewName();
154                 return responseString;
155         }
156         
157         public String saveEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
158                 
159                 EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
160                 String responseString = null;
161                         ModelAndView result = dictionary.saveEnforcerDictionary(request, response);
162                         responseString = result.getViewName();
163                 return responseString;
164         }
165         
166         public String saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
167                 
168                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
169                 String responseString = null;
170                         ModelAndView result = dictionary.saveActionListDictionary(request, response);
171                         responseString = result.getViewName();
172                 return responseString;
173         }
174         
175         public String saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
176                 
177                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
178                 String responseString = null;
179                         ModelAndView result = dictionary.saveProtocolListDictionary(request, response);
180                         responseString = result.getViewName();
181                 return responseString;
182         }
183         
184         public String saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
185                 
186                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
187                 String responseString = null;
188                         ModelAndView result = dictionary.saveZoneDictionary(request, response);
189                         responseString = result.getViewName();
190                 return responseString;
191         }
192         
193         public String saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
194                 
195                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
196                 String responseString = null;
197                         ModelAndView result = dictionary.saveSecurityZoneDictionary(request, response);
198                         responseString = result.getViewName();
199                 return responseString;
200         }
201         
202         public String savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
203                 
204                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
205                 String responseString = null;
206                         ModelAndView result = dictionary.savePrefixListDictionary(request, response);
207                         responseString = result.getViewName();
208                 return responseString;
209         }
210         
211         public String saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
212                 
213                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
214                 String responseString = null;
215                         ModelAndView result = dictionary.saveAddressGroupDictionary(request, response);
216                         responseString = result.getViewName();
217                 return responseString;
218         }
219         
220         public String saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
221                 
222                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
223                 String responseString = null;
224                         ModelAndView result = dictionary.saveServiceGroupDictionary(request, response);
225                         responseString = result.getViewName();
226                 return responseString;
227         }
228         
229         public String saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
230                 
231                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
232                 String responseString = null;
233                         ModelAndView result = dictionary.saveServiceListDictionary(request, response);
234                         responseString = result.getViewName();
235                 return responseString;
236         }
237         
238         public String saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
239                 
240                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
241                 String responseString = null;
242                         ModelAndView result = dictionary.saveTermListDictionary(request, response);
243                         responseString = result.getViewName();
244                 return responseString;
245         }
246         
247         
248         
249         
250         public String saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
251                 
252                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
253                 String responseString = null;
254                         ModelAndView result = dictionary.saveMicroServiceLocationDictionary(request, response);
255                         responseString = result.getViewName();
256                 return responseString;
257         }
258         
259         public String saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
260                 
261                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
262                 String responseString = null;
263                         ModelAndView result = dictionary.saveMicroServiceConfigNameDictionary(request, response);
264                         responseString = result.getViewName();
265                 return responseString;
266         }
267         
268         public String saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
269                 
270                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
271                 String responseString = null;
272                         ModelAndView result = dictionary.saveDCAEUUIDDictionary(request, response);
273                         responseString = result.getViewName();
274                 return responseString;
275         }
276         
277         public String saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
278                 
279                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
280                 String responseString = null;
281                         ModelAndView result = dictionary.saveMicroServiceModelsDictionary(request, response);
282                         responseString = result.getViewName();
283                 return responseString;
284         }
285         
286         public String saveMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
287                 
288                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
289                 String responseString = null;
290                         ModelAndView result = dictionary.saveMicroServiceAttributeDictionary(request, response);
291                         responseString = result.getViewName();
292                 return responseString;
293         }
294         
295         public String savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
296                 
297                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
298                 String responseString = null;
299                         ModelAndView result = dictionary.savePSServiceDictionary(request, response);
300                         responseString = result.getViewName();
301                 return responseString;
302         }
303         
304         public String savePSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
305                 
306                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
307                 String responseString = null;
308                         ModelAndView result = dictionary.savePSResourceDictionary(request, response);
309                         responseString = result.getViewName();
310                 return responseString;
311         }
312         
313         public String savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
314                 
315                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
316                 String responseString = null;
317                         ModelAndView result = dictionary.savePSTypeDictionary(request, response);
318                         responseString = result.getViewName();
319                 return responseString;
320         }
321         
322         public String savePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
323                 
324                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
325                 String responseString = null;
326                         ModelAndView result = dictionary.savePSClosedLoopDictionary(request, response);
327                         responseString = result.getViewName();
328                 return responseString;
329         }
330         
331         public String savePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
332                 
333                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
334                 String responseString = null;
335                         ModelAndView result = dictionary.savePSGroupScopeDictionary(request, response);
336                         responseString = result.getViewName();
337                 return responseString;
338         }
339         
340         public String saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
341                 
342                 SafePolicyController dictionary = new SafePolicyController();
343                 String responseString = null;
344                         ModelAndView result = dictionary.saveRiskTypeDictionary(request, response);
345                         responseString = result.getViewName();
346                 return responseString;
347         }
348         
349         public String saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws IOException{
350                 SafePolicyController dictionary = new SafePolicyController();
351                 String responseString = null;
352                         ModelAndView result = dictionary.saveSafePolicyWarningDictionary(request, response);
353                         responseString = result.getViewName();
354                 return responseString;
355         }
356         
357         
358         /*
359          * Methods that call the controller get methods directly to get dictionary data
360          */
361         public void getOnapDictionary(HttpServletRequest request, HttpServletResponse response){
362                 DictionaryController dictionary = new DictionaryController();
363                         dictionary.getOnapNameDictionaryEntityData(request, response);                                  
364         }
365         
366         public void getAttributeDictionary(HttpServletRequest request, HttpServletResponse response){
367                 DictionaryController dictionary = new DictionaryController();
368                         dictionary.getAttributeDictionaryEntityData(request, response);
369         }
370         
371         public void getActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response){
372                 ActionPolicyDictionaryController action = new ActionPolicyDictionaryController();
373                         action.getActionPolicyDictionaryEntityData(request, response);  
374         }
375         
376         public void getBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response){
377                 BRMSDictionaryController dictionary = new BRMSDictionaryController();
378                         dictionary.getBRMSParamDictionaryEntityData(request, response);
379         }
380         
381         public void getVSCLAction(HttpServletRequest request, HttpServletResponse response){
382                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
383                         dictionary.getVSCLActionDictionaryEntityData(request, response);
384         }
385         
386         public void getVnfType(HttpServletRequest request, HttpServletResponse response){
387                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
388                         dictionary.getVNFTypeDictionaryEntityData(request, response);
389         }
390         
391         public void getPEPOptions(HttpServletRequest request, HttpServletResponse response){
392                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
393                         dictionary.getPEPOptionsDictionaryEntityData(request, response);
394         }
395         
396         public void getVarbind(HttpServletRequest request, HttpServletResponse response){
397                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
398                         dictionary.getVarbindDictionaryEntityData(request, response);
399         }
400         
401         public void getServiceType(HttpServletRequest request, HttpServletResponse response){
402                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
403                         dictionary.getClosedLoopServiceDictionaryEntityData(request, response);
404         }
405         
406         public void getSiteType(HttpServletRequest request, HttpServletResponse response){
407                 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
408                         dictionary.getClosedLoopSiteDictionaryEntityData(request, response);    
409         }
410         
411         public void getSettingsDictionary(HttpServletRequest request, HttpServletResponse response){
412                 DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController();
413                         dictionary.getSettingsDictionaryEntityData(request, response);
414         }
415         
416         public void getDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response){
417                 DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController();
418                         dictionary.getDescriptiveDictionaryEntityData(request, response);
419         }
420         
421         public void getEnforcerDictionary(HttpServletRequest request, HttpServletResponse response){
422                 EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
423                         dictionary.getEnforcerDictionaryEntityData(request, response);
424         }
425         
426         public void getActionListDictionary(HttpServletRequest request, HttpServletResponse response){
427                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
428                         dictionary.getActionListDictionaryEntityData(request, response);
429         }
430         
431         public void getProtocolListDictionary(HttpServletRequest request, HttpServletResponse response){
432                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
433                         dictionary.getProtocolListDictionaryEntityData(request, response);
434         }
435         
436         public void getZoneDictionary(HttpServletRequest request, HttpServletResponse response){
437                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
438                         dictionary.getZoneDictionaryEntityData(request, response);
439         }
440         
441         public void getSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response){
442                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
443                         dictionary.getSecurityZoneDictionaryEntityData(request, response);
444         }
445         
446         public void getPrefixListDictionary(HttpServletRequest request, HttpServletResponse response){
447                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
448                         dictionary.getPrefixListDictionaryEntityData(request, response);
449         }
450         
451         public void getAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response){
452                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
453                         dictionary.getAddressGroupDictionaryEntityData(request, response);
454         }
455         
456         public void getServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response){
457                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
458                         dictionary.getServiceGroupDictionaryEntityData(request, response);
459         }
460         
461         public void getServiceListDictionary(HttpServletRequest request, HttpServletResponse response){
462                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
463                         dictionary.getServiceListDictionaryEntityData(request, response);
464         }
465         
466         public void getTermListDictionary(HttpServletRequest request, HttpServletResponse response){
467                 FirewallDictionaryController dictionary = new FirewallDictionaryController();
468                         dictionary.getTermListDictionaryEntityData(request, response);
469         }
470         
471         
472         public void getMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response){
473                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
474                         dictionary.getMicroServiceLocationDictionaryEntityData(request, response);
475         }
476         
477         public void getMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response){
478                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
479                         dictionary.getMicroServiceConfigNameDictionaryEntityData(request, response);
480         }
481         
482         public void getDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response){
483                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
484                         dictionary.getDCAEUUIDDictionaryEntityData(request, response);
485         }
486         
487         public void getMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response){
488                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
489                         dictionary.getMicroServiceModelsDictionaryEntityData(request, response);
490         }
491         
492         public void getMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response){
493                 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
494                         dictionary.getMicroServiceModelsDictionaryEntityData(request, response);
495         }
496         
497         public void getPSServiceDictionary(HttpServletRequest request, HttpServletResponse response){
498                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
499                         dictionary.getPSServiceEntityData(request, response);
500         }
501         
502         public void getPSResourceDictionary(HttpServletRequest request, HttpServletResponse response){
503                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
504                         dictionary.getPSResourceEntityData(request, response);
505         }
506         
507         public void getPSTypeDictionary(HttpServletRequest request, HttpServletResponse response){
508                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
509                         dictionary.getPSTypeEntityData(request, response);
510         }
511         
512         public void getPSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response){
513                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
514                         dictionary.getPSClosedLoopEntityData(request, response);
515         }
516         
517         public void getPSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response){
518                 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
519                         dictionary.getGroupPolicyScopeEntityData(request, response);
520         }
521         
522         public void getRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response){
523                 SafePolicyController dictionary = new SafePolicyController();
524                         dictionary.getOnapNameDictionaryEntityData(request, response);
525         }
526         
527         public void getSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) {
528                 SafePolicyController dictionary = new SafePolicyController();
529                         dictionary.getSafePolicyWarningeEntityData(request, response);
530         }
531 }