2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.onap.policy.pap.xacml.rest.service;
22 import java.io.IOException;
23 import java.io.UnsupportedEncodingException;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
27 import org.onap.policy.common.logging.flexlogger.FlexLogger;
28 import org.onap.policy.common.logging.flexlogger.Logger;
29 import org.onap.policy.pap.xacml.rest.controller.ActionPolicyDictionaryController;
30 import org.onap.policy.pap.xacml.rest.controller.BRMSDictionaryController;
31 import org.onap.policy.pap.xacml.rest.controller.ClosedLoopDictionaryController;
32 import org.onap.policy.pap.xacml.rest.controller.DecisionPolicyDictionaryController;
33 import org.onap.policy.pap.xacml.rest.controller.DescriptiveDictionaryController;
34 import org.onap.policy.pap.xacml.rest.controller.DictionaryController;
35 import org.onap.policy.pap.xacml.rest.controller.EnforcerDictionaryController;
36 import org.onap.policy.pap.xacml.rest.controller.FirewallDictionaryController;
37 import org.onap.policy.pap.xacml.rest.controller.MicroServiceDictionaryController;
38 import org.onap.policy.pap.xacml.rest.controller.PolicyScopeDictionaryController;
39 import org.onap.policy.pap.xacml.rest.controller.SafePolicyController;
40 import org.onap.policy.xacml.api.XACMLErrorConstants;
41 import org.springframework.stereotype.Service;
42 import org.springframework.web.servlet.ModelAndView;
45 @Service("DictionaryService")
46 public class DictionaryService {
48 private static final Logger LOGGER = FlexLogger.getLogger(DictionaryService.class);
51 * Methods that call the controller method directly to Save and Update dictionary data
53 public String saveOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
55 DictionaryController dictionary = new DictionaryController();
56 String responseString = null;
57 ModelAndView result = dictionary.saveOnapDictionary(request, response);
58 responseString = result.getViewName();
59 return responseString;
63 public String saveAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
65 DictionaryController dictionary = new DictionaryController();
66 String responseString = null;
67 ModelAndView result = dictionary.saveAttributeDictionary(request, response);
68 responseString = result.getViewName();
69 return responseString;
72 public String saveActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
74 ActionPolicyDictionaryController action = new ActionPolicyDictionaryController();
75 String responseString = null;
76 ModelAndView result = action.saveActionPolicyDictionary(request, response);
77 responseString = result.getViewName();
78 return responseString;
81 public String saveBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException {
83 BRMSDictionaryController dictionary = new BRMSDictionaryController();
84 String responseString = null;
85 ModelAndView result = dictionary.saveBRMSParamDictionary(request, response);
86 responseString = result.getViewName();
87 return responseString;
90 public String saveVSCLAction(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
92 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
93 String responseString = null;
94 ModelAndView result = dictionary.saveVSCLAction(request, response);
95 responseString = result.getViewName();
96 return responseString;
99 public String saveVnfType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
101 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
102 String responseString = null;
103 ModelAndView result = dictionary.saveVnfType(request, response);
104 responseString = result.getViewName();
105 return responseString;
108 public String savePEPOptions(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
110 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
111 String responseString = null;
112 ModelAndView result = dictionary.savePEPOptions(request, response);
113 responseString = result.getViewName();
114 return responseString;
117 public String saveVarbind(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
119 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
120 String responseString = null;
121 ModelAndView result = dictionary.saveVarbind(request, response);
122 responseString = result.getViewName();
123 return responseString;
126 public String saveServiceType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
128 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
129 String responseString = null;
130 ModelAndView result = dictionary.saveServiceType(request, response);
131 responseString = result.getViewName();
132 return responseString;
135 public String saveSiteType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
137 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
138 String responseString = null;
139 ModelAndView result = dictionary.saveSiteType(request, response);
140 responseString = result.getViewName();
141 return responseString;
144 public String saveSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
146 DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController();
147 String responseString = null;
148 ModelAndView result = dictionary.saveSettingsDictionary(request, response);
149 responseString = result.getViewName();
150 return responseString;
153 public String saveDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
155 DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController();
156 String responseString = null;
157 ModelAndView result = dictionary.saveDescriptiveDictionary(request, response);
158 responseString = result.getViewName();
159 return responseString;
162 public String saveEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
164 EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
165 String responseString = null;
166 ModelAndView result = dictionary.saveEnforcerDictionary(request, response);
167 responseString = result.getViewName();
168 return responseString;
171 public String saveActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
173 FirewallDictionaryController dictionary = new FirewallDictionaryController();
174 String responseString = null;
175 ModelAndView result = dictionary.saveActionListDictionary(request, response);
176 responseString = result.getViewName();
177 return responseString;
180 public String saveProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
182 FirewallDictionaryController dictionary = new FirewallDictionaryController();
183 String responseString = null;
184 ModelAndView result = dictionary.saveProtocolListDictionary(request, response);
185 responseString = result.getViewName();
186 return responseString;
189 public String saveZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
191 FirewallDictionaryController dictionary = new FirewallDictionaryController();
192 String responseString = null;
193 ModelAndView result = dictionary.saveZoneDictionary(request, response);
194 responseString = result.getViewName();
195 return responseString;
198 public String saveSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
200 FirewallDictionaryController dictionary = new FirewallDictionaryController();
201 String responseString = null;
202 ModelAndView result = dictionary.saveSecurityZoneDictionary(request, response);
203 responseString = result.getViewName();
204 return responseString;
207 public String savePrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
209 FirewallDictionaryController dictionary = new FirewallDictionaryController();
210 String responseString = null;
211 ModelAndView result = dictionary.savePrefixListDictionary(request, response);
212 responseString = result.getViewName();
213 return responseString;
216 public String saveAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
218 FirewallDictionaryController dictionary = new FirewallDictionaryController();
219 String responseString = null;
220 ModelAndView result = dictionary.saveAddressGroupDictionary(request, response);
221 responseString = result.getViewName();
222 return responseString;
225 public String saveServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
227 FirewallDictionaryController dictionary = new FirewallDictionaryController();
228 String responseString = null;
229 ModelAndView result = dictionary.saveServiceGroupDictionary(request, response);
230 responseString = result.getViewName();
231 return responseString;
234 public String saveServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
236 FirewallDictionaryController dictionary = new FirewallDictionaryController();
237 String responseString = null;
238 ModelAndView result = dictionary.saveServiceListDictionary(request, response);
239 responseString = result.getViewName();
240 return responseString;
243 public String saveTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
245 FirewallDictionaryController dictionary = new FirewallDictionaryController();
246 String responseString = null;
247 ModelAndView result = dictionary.saveTermListDictionary(request, response);
248 responseString = result.getViewName();
249 return responseString;
255 public String saveMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
257 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
258 String responseString = null;
259 ModelAndView result = dictionary.saveMicroServiceLocationDictionary(request, response);
260 responseString = result.getViewName();
261 return responseString;
264 public String saveMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
266 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
267 String responseString = null;
268 ModelAndView result = dictionary.saveMicroServiceConfigNameDictionary(request, response);
269 responseString = result.getViewName();
270 return responseString;
273 public String saveDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
275 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
276 String responseString = null;
277 ModelAndView result = dictionary.saveDCAEUUIDDictionary(request, response);
278 responseString = result.getViewName();
279 return responseString;
282 public String saveMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
284 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
285 String responseString = null;
286 ModelAndView result = dictionary.saveMicroServiceModelsDictionary(request, response);
287 responseString = result.getViewName();
288 return responseString;
291 public String saveMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
293 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
294 String responseString = null;
295 ModelAndView result = dictionary.saveMicroServiceAttributeDictionary(request, response);
296 responseString = result.getViewName();
297 return responseString;
300 public String savePSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
302 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
303 String responseString = null;
304 ModelAndView result = dictionary.savePSServiceDictionary(request, response);
305 responseString = result.getViewName();
306 return responseString;
309 public String savePSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
311 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
312 String responseString = null;
313 ModelAndView result = dictionary.savePSResourceDictionary(request, response);
314 responseString = result.getViewName();
315 return responseString;
318 public String savePSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
320 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
321 String responseString = null;
322 ModelAndView result = dictionary.savePSTypeDictionary(request, response);
323 responseString = result.getViewName();
324 return responseString;
327 public String savePSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
329 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
330 String responseString = null;
331 ModelAndView result = dictionary.savePSClosedLoopDictionary(request, response);
332 responseString = result.getViewName();
333 return responseString;
336 public String savePSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
338 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
339 String responseString = null;
340 ModelAndView result = dictionary.savePSGroupScopeDictionary(request, response);
341 responseString = result.getViewName();
342 return responseString;
345 public String saveRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
347 SafePolicyController dictionary = new SafePolicyController();
348 String responseString = null;
349 ModelAndView result = dictionary.saveRiskTypeDictionary(request, response);
350 responseString = result.getViewName();
351 return responseString;
354 public String saveSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
355 SafePolicyController dictionary = new SafePolicyController();
356 String responseString = null;
357 ModelAndView result = dictionary.saveSafePolicyWarningDictionary(request, response);
358 responseString = result.getViewName();
359 return responseString;
364 * Methods that call the controller get methods directly to get dictionary data
366 public void getOnapDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
367 DictionaryController dictionary = new DictionaryController();
368 dictionary.getOnapNameDictionaryEntityData(request, response);
371 public void getAttributeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
372 DictionaryController dictionary = new DictionaryController();
373 dictionary.getAttributeDictionaryEntityData(request, response);
376 public void getActionPolicyDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
377 ActionPolicyDictionaryController action = new ActionPolicyDictionaryController();
378 action.getActionPolicyDictionaryEntityData(request, response);
381 public void getBRMSParamDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
382 BRMSDictionaryController dictionary = new BRMSDictionaryController();
383 dictionary.getBRMSParamDictionaryEntityData(request, response);
386 public void getVSCLAction(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
387 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
388 dictionary.getVSCLActionDictionaryEntityData(request, response);
391 public void getVnfType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
392 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
393 dictionary.getVNFTypeDictionaryEntityData(request, response);
396 public void getPEPOptions(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
397 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
398 dictionary.getPEPOptionsDictionaryEntityData(request, response);
401 public void getVarbind(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
402 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
403 dictionary.getVarbindDictionaryEntityData(request, response);
406 public void getServiceType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
407 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
408 dictionary.getClosedLoopServiceDictionaryEntityData(request, response);
411 public void getSiteType(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
412 ClosedLoopDictionaryController dictionary = new ClosedLoopDictionaryController();
413 dictionary.getClosedLoopSiteDictionaryEntityData(request, response);
416 public void getSettingsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
417 DecisionPolicyDictionaryController dictionary = new DecisionPolicyDictionaryController();
418 dictionary.getSettingsDictionaryEntityData(request, response);
421 public void getDescriptiveDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
422 DescriptiveDictionaryController dictionary = new DescriptiveDictionaryController();
423 dictionary.getDescriptiveDictionaryEntityData(request, response);
426 public void getEnforcerDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
427 EnforcerDictionaryController dictionary = new EnforcerDictionaryController();
428 dictionary.getEnforcerDictionaryEntityData(request, response);
431 public void getActionListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
432 FirewallDictionaryController dictionary = new FirewallDictionaryController();
433 dictionary.getActionListDictionaryEntityData(request, response);
436 public void getProtocolListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
437 FirewallDictionaryController dictionary = new FirewallDictionaryController();
438 dictionary.getProtocolListDictionaryEntityData(request, response);
441 public void getZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
442 FirewallDictionaryController dictionary = new FirewallDictionaryController();
443 dictionary.getZoneDictionaryEntityData(request, response);
446 public void getSecurityZoneDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
447 FirewallDictionaryController dictionary = new FirewallDictionaryController();
448 dictionary.getSecurityZoneDictionaryEntityData(request, response);
451 public void getPrefixListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
452 FirewallDictionaryController dictionary = new FirewallDictionaryController();
453 dictionary.getPrefixListDictionaryEntityData(request, response);
456 public void getAddressGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
457 FirewallDictionaryController dictionary = new FirewallDictionaryController();
458 dictionary.getAddressGroupDictionaryEntityData(request, response);
461 public void getServiceGroupDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
462 FirewallDictionaryController dictionary = new FirewallDictionaryController();
463 dictionary.getServiceGroupDictionaryEntityData(request, response);
466 public void getServiceListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
467 FirewallDictionaryController dictionary = new FirewallDictionaryController();
468 dictionary.getServiceListDictionaryEntityData(request, response);
471 public void getTermListDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
472 FirewallDictionaryController dictionary = new FirewallDictionaryController();
473 dictionary.getTermListDictionaryEntityData(request, response);
477 public void getMicroServiceLocationDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
478 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
479 dictionary.getMicroServiceLocationDictionaryEntityData(request, response);
482 public void getMicroServiceConfigNameDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
483 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
484 dictionary.getMicroServiceConfigNameDictionaryEntityData(request, response);
487 public void getDCAEUUIDDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
488 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
489 dictionary.getDCAEUUIDDictionaryEntityData(request, response);
492 public void getMicroServiceModelsDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
493 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
494 dictionary.getMicroServiceModelsDictionaryEntityData(request, response);
497 public void getMicroServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
498 MicroServiceDictionaryController dictionary = new MicroServiceDictionaryController();
499 dictionary.getMicroServiceModelsDictionaryEntityData(request, response);
502 public void getPSServiceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
503 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
504 dictionary.getPSServiceEntityData(request, response);
507 public void getPSResourceDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
508 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
509 dictionary.getPSResourceEntityData(request, response);
512 public void getPSTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
513 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
514 dictionary.getPSTypeEntityData(request, response);
517 public void getPSClosedLoopDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
518 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
519 dictionary.getPSClosedLoopEntityData(request, response);
522 public void getPSGroupScopeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
523 PolicyScopeDictionaryController dictionary = new PolicyScopeDictionaryController();
524 dictionary.getGroupPolicyScopeEntityData(request, response);
527 public void getRiskTypeDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
528 SafePolicyController dictionary = new SafePolicyController();
529 dictionary.getOnapNameDictionaryEntityData(request, response);
532 public void getSafePolicyWarningDictionary(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException, IOException{
533 SafePolicyController dictionary = new SafePolicyController();
534 dictionary.getSafePolicyWarningeEntityData(request, response);