Added Junits for POLICY-SDK-APP
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / onap / policy / api / PolicyEngine.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * PolicyEngineAPI
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.api;
22
23 import java.util.Collection;
24 import java.util.Map;
25 import java.util.UUID;
26
27 import javax.json.JsonObject;
28
29 import org.onap.policy.api.NotificationHandler;
30 import org.onap.policy.api.PDPNotification;
31 import org.onap.policy.std.StdPolicyEngine;
32
33 /**
34  * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine 
35  * 
36  * @version 2.0
37  */
38 public class PolicyEngine{
39         private String propertyFilePath = null;
40         private final StdPolicyEngine stdPolicyEngine;
41         private NotificationScheme scheme = null;
42         private NotificationHandler handler = null;
43         
44         /**
45          * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
46          * 
47          * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname 
48          * @throws PolicyEngineException PolicyEngine Exception
49          */
50         public PolicyEngine(final String propertiesFilePathname) throws PolicyEngineException {
51                 this.propertyFilePath = propertiesFilePathname ; 
52                 this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath, (String)null);
53         }
54         
55         /**
56          * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
57          * 
58          * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
59          * @param clientKey depicts String format of Password/ Client_Key.  
60          * @throws PolicyEngineException PolicyEngine Exception
61          */
62         public PolicyEngine(final String propertiesFilePathname, final String clientKey) throws PolicyEngineException {
63                 this.propertyFilePath = propertiesFilePathname ; 
64                 this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath, clientKey);
65         }
66         
67         /**
68          * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname and <code>NotificationScheme</code>
69          * 
70          * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
71          * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
72          * @throws PolicyEngineException PolicyEngine Exception
73          */
74         public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme) throws PolicyEngineException{
75                 this.propertyFilePath = propertiesFilePathname;
76                 this.scheme = scheme;
77                 this.stdPolicyEngine = new StdPolicyEngine(this.propertyFilePath, this.scheme);
78         }
79         
80         /**
81          * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname, <code>NotificationScheme</code> and <code>NotificationHandler</code>
82          *  
83          *  @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname 
84          *  @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
85          *  @param handler the <code>NotificationHandler</code> of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received.
86          *  @throws PolicyEngineException PolicyEngine Exception
87          */
88         public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme, final NotificationHandler handler) throws PolicyEngineException {
89                 this.propertyFilePath = propertiesFilePathname ;
90                 this.scheme = scheme;
91                 this.handler = handler;
92                 this.stdPolicyEngine= new StdPolicyEngine(this.propertyFilePath,this.scheme,this.handler);
93         }
94         
95         /**
96          * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the Policy File Name 
97          * 
98          * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required. 
99          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration. 
100          * @throws PolicyConfigException PolicyConfig Exception
101          * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead.
102          */
103         @Deprecated
104         public Collection<PolicyConfig> getConfigByPolicyName(final String policyName) throws PolicyConfigException {
105                 return getConfig(setConfigRequestParameters(policyName, null, null, null, null));
106         }
107         
108         /**
109          * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the Policy File Name 
110          * 
111          * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required. 
112          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
113          * A different request ID should be passed for each request.
114          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration. 
115          * @throws PolicyConfigException PolicyConfig Exception
116          * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead.
117          */
118         @Deprecated
119         public Collection<PolicyConfig> getConfigByPolicyName(final String policyName, final UUID requestID) throws PolicyConfigException {
120                 return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID));  
121         }
122         
123         /**
124          * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapName 
125          * 
126          * @param onapName the <code>String</code> format of the onapName whose configuration is required. 
127          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
128          * @throws PolicyConfigException PolicyConfig Exception
129          * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
130          */
131         @Deprecated
132         public Collection<PolicyConfig> getConfig(final String onapName) throws PolicyConfigException {
133                 return getConfig(setConfigRequestParameters(null, onapName, null, null, null));
134         }
135         
136         /**
137          * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapName 
138          * 
139          * @param onapName the <code>String</code> format of the onapName whose configuration is required. 
140          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
141          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
142          * A different request ID should be passed for each request.
143          * @throws PolicyConfigException PolicyConfig Exception
144          * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
145          */
146         @Deprecated
147         public Collection<PolicyConfig> getConfig(final String onapName, final UUID requestID) throws PolicyConfigException {
148                 return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID));
149         }
150         
151         /**
152          * Requests the configuration of the <code>String</code> which represents the onapName and <code>String</code>
153          * which represents the configName and returns the configuration if different Configurations exist for the
154          * particular onapName.  
155          * 
156          * @param onapName the <code>String</code> format of the onapName whose configuration is required.
157          * @param configName the <code>String</code> format of the configurationName whose configuration is required.
158          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration. 
159          * @throws PolicyConfigException PolicyConfig Exception
160          * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
161          */
162         @Deprecated
163         public Collection<PolicyConfig> getConfig(final String onapName, final String configName) throws PolicyConfigException {
164                 return getConfig(setConfigRequestParameters(null, onapName, configName, null, null));
165         }
166         
167         /**
168          * Requests the configuration of the <code>String</code> which represents the onapName and <code>String</code>
169          * which represents the configName and returns the configuration if different Configurations exist for the
170          * particular onapName.  
171          * 
172          * @param onapName the <code>String</code> format of the onapName whose configuration is required.
173          * @param configName the <code>String</code> format of the configurationName whose configuration is required.
174          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
175          * A different request ID should be passed for each request.
176          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration. 
177          * @throws PolicyConfigException PolicyConfig Exception
178          * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
179          */
180         @Deprecated
181         public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final UUID requestID) throws PolicyConfigException {
182                 return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID));
183         }
184         
185         /**
186          * Requests the configuration of the <code>String</code> which represents the onapName, <code>String</code>
187          * which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific 
188          * configuration related to the configAttributes mentioned.
189          * 
190          * @param onapName the <code>String</code> format of the onapName whose configuration is required.
191          * @param configName the <code>String</code> format of the configurationName whose configuration is required.
192          * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
193          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
194          * @throws PolicyConfigException PolicyConfig Exception
195          * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
196          */
197         @Deprecated
198         public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final Map<String, String> configAttributes) throws PolicyConfigException{
199                 return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null));
200         }
201         
202         /**
203          * Requests the configuration of the <code>String</code> which represents the onapName, <code>String</code>
204          * which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific 
205          * configuration related to the configAttributes mentioned.
206          * 
207          * @param onapName the <code>String</code> format of the onapName whose configuration is required.
208          * @param configName the <code>String</code> format of the configurationName whose configuration is required.
209          * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
210          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
211          * A different request ID should be passed for each request.
212          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
213          * @throws PolicyConfigException PolicyConfig Exception
214          * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
215          */
216         @Deprecated
217         public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final Map<String, String> configAttributes, final UUID requestID) throws PolicyConfigException{
218                 return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID));
219         }
220         
221         /**
222          * Requests the configuration of the <code>ConfigRequestParameters</code> which represents the Config policy request parameters 
223          * and returns the specific configuration related to the matching parameters. 
224          * 
225          * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the Config policy request parameters. 
226          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
227          * @throws PolicyConfigException PolicyConfig Exception
228          */
229         public Collection<PolicyConfig> getConfig(final ConfigRequestParameters configRequestParameters)  throws PolicyConfigException{
230                 return stdPolicyEngine.getConfig(configRequestParameters);
231         }
232         
233         /**
234          * Requests the list of policies based on the <code>ConfigRequestParameters</code> which represents the policy request parameters 
235          * and returns the list of policies filtered by the parameters. 
236          * 
237          * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the List Policy request parameters. 
238          * @return <code>Collection</code> of <code>String</code> which returns the list of policies.
239          * @throws PolicyConfigException PolicyConfig Exception
240          */
241         public Collection<String> listConfig(final ConfigRequestParameters listPolicyRequestParameters)  throws PolicyConfigException{
242                 return stdPolicyEngine.listConfig(listPolicyRequestParameters);
243         }
244         
245         
246         /**
247          * Sends the Events specified to the PEP and returns back the PolicyResponse. 
248          * 
249          * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
250          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the Response. 
251          * @throws PolicyEventException PolicyEvent Exception
252          * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
253          */
254         @Deprecated
255         public Collection<PolicyResponse> sendEvent(final Map<String, String> eventAttributes) throws PolicyEventException {
256                 return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null);
257         }
258         
259         /**
260          * Sends the Events specified to the PEP and returns back the PolicyResponse. 
261          * 
262          * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
263          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
264          * A different request ID should be passed for each request.
265          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the Response. 
266          * @throws PolicyEventException PolicyEvent Exception
267          * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
268          */
269         @Deprecated
270         public Collection<PolicyResponse> sendEvent(final Map<String, String> eventAttributes, final UUID requestID) throws PolicyEventException {
271                 return stdPolicyEngine.sendEvent(eventAttributes, requestID);
272         }
273         
274         /**
275          * Sends the Events specified to the PEP and returns back the PolicyResponse.
276          * 
277          * @param eventRequestParameters {@link org.onap.policy.api.EventRequestParameters} which represents the Event Request Parameters. 
278          * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the Response.
279          * @throws PolicyEventException PolicyEvent Exception
280          */
281         public Collection<PolicyResponse> sendEvent(final EventRequestParameters eventRequestParameters) throws PolicyEventException {
282                 return stdPolicyEngine.sendEvent(eventRequestParameters);
283         }
284         
285         /**
286          * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. 
287          * 
288          * @param onapName the <code>String</code> format of the onapName whose Decision is required.
289          * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
290          * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. 
291          * @throws PolicyDecisionException PolicyDecision Exception
292          * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
293          */
294         @Deprecated
295         public DecisionResponse getDecision(final String onapName, final Map<String,String> decisionAttributes) throws PolicyDecisionException {
296                 return stdPolicyEngine.getDecision(onapName, decisionAttributes, null);
297         }
298         
299         /**
300          * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. 
301          * 
302          * @param onapName the <code>String</code> format of the onapName whose Decision is required.
303          * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
304          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
305          * A different request ID should be passed for each request.
306          * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. 
307          * @throws PolicyDecisionException PolicyDecision Exception
308          * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
309          */
310         @Deprecated
311         public DecisionResponse getDecision(final String onapName, final Map<String,String> decisionAttributes, final UUID requestID) throws PolicyDecisionException {
312                 return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID);
313         }
314         
315         /**
316          * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. 
317          * 
318          * @param decisionRequestParameters {@link org.onap.policy.api.DecisionRequestParameters} which represents the Decision Request Parameters.
319          * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
320          * @throws PolicyDecisionException PolicyDecision Exception
321          */
322         public DecisionResponse getDecision(final DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException {
323                 return stdPolicyEngine.getDecision(decisionRequestParameters);
324         }
325         
326         /**
327          * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole
328          * 
329          * @param parameters {@link  org.onap.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics 
330          * @return {@link org.onap.policy.api.MetricsResponse} which consists of the response related to getMetrics Request. 
331          * @throws PolicyException PolicyException related to the operation      
332          * 
333          * */
334         public MetricsResponse getMetrics(final MetricsRequestParameters parameters) throws PolicyException {
335                 return stdPolicyEngine.getMetrics(parameters);
336         }
337         
338         /**
339          * Creates a Config Policy based on given arguments
340          * @param policyName the <code>String</code> format of the Policy Name
341          * @param policyDescription the <code>String</code> format of the Policy Description
342          * @param onapName the <code>String</code> format of the ONAP Name
343          * @param configName the <code>String</code> format of the Config Name
344          * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain the key and value.
345          * @param configType the <code>String</code> format of the Config Type
346          * @param body the <code>String</code> format of the Policy Body
347          * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
348          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
349          * A different request ID should be passed for each request.
350          * @param riskLevel the <code>String</code> value of risk Level. 
351          * @param riskType the <code>String</code> value of risk Type. 
352          * @param guard the <code>String</code> value of guard. 
353          * @param ttlDate the <code>String</code> value of time to live Date. 
354          * @throws PolicyException PolicyException related to the operation. 
355          * @return <code>String</code> format of response
356          * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
357          */
358         @Deprecated
359         public String createConfigPolicy(final String policyName, final String policyDescription, final String onapName, final String configName, 
360                                                                                                 final Map<String, String> configAttributes, final String configType, final String body, final String policyScope, final UUID requestID,
361                                                                                                 final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
362                 return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, 
363                                 configAttributes, configType, body, policyScope, requestID,
364                                 riskLevel, riskType, guard, ttlDate, false);
365         }
366         
367         /**
368          * Creates a Config Policy based on given arguments
369          * @param policyName the <code>String</code> format of the Policy Name
370          * @param policyDescription the <code>String</code> format of the Policy Description
371          * @param onapName the <code>String</code> format of the ONAP Name
372          * @param configName the <code>String</code> format of the Config Name
373          * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain the key and value.
374          * @param configType the <code>String</code> format of the Config Type
375          * @param body the <code>String</code> format of the Policy Body
376          * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
377          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
378          * A different request ID should be passed for each request.
379          * @param riskLevel the <code>String</code> value of risk Level. 
380          * @param riskType the <code>String</code> value of risk Type. 
381          * @param guard the <code>String</code> value of guard. 
382          * @param ttlDate the <code>String</code> value of time to live Date. 
383          * @throws PolicyException PolicyException related to the operation. 
384          * @return <code>String</code> format of response
385          * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
386          */
387         @Deprecated
388         public String updateConfigPolicy(final String policyName, final String policyDescription, final String onapName, final String configName, 
389                                                                                                 final Map<String, String> configAttributes, final String configType, final String body, final String policyScope, final UUID requestID,
390                                                                                                 final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
391                 return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, 
392                                 configAttributes, configType, body, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true);
393         }
394         
395         /**
396          * Creates a Config Firewall Policy based on given arguments
397          * @param policyName the <code>String</code> format of the Policy Name
398          * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
399          * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
400          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
401          * A different request ID should be passed for each request.
402          * @param riskLevel the <code>String</code> value of risk Level. 
403          * @param riskType the <code>String</code> value of risk Type. 
404          * @param guard the <code>String</code> value of guard. 
405          * @param ttlDate the <code>String</code> value of time to live Date. 
406          * @throws PolicyException PolicyException related to the operation. 
407          * @return <code>String</code> format of response.
408          * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
409          */
410         @Deprecated
411         public String createConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, final String policyScope, final UUID requestID,
412                         final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
413                 return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, 
414                                 riskType, guard, ttlDate, false);
415         }
416         
417         /**
418          * Updates a Config Firewall Policy based on given arguments
419          * @param policyName the <code>String</code> format of the Policy Name
420          * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
421          * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
422          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
423          * A different request ID should be passed for each request.
424          * @param riskLevel the <code>String</code> value of risk Level. 
425          * @param riskType the <code>String</code> value of risk Type. 
426          * @param guard the <code>String</code> value of guard. 
427          * @param ttlDate the <code>String</code> value of time to live Date. 
428          * @throws PolicyException PolicyException related to the operation. 
429          * @return <code>String</code> format of response. 
430          * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
431          */
432         @Deprecated
433         public String updateConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, final String policyScope, final UUID requestID,
434                         final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
435                 return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true);
436         }
437         
438         /**
439          * Retrieves Dictionary Items for a specified dictionary
440          * 
441          * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. 
442          * @return {@link org.onap.policy.api.DictionaryResponse} which consists of the response related to create dictionary item Request. 
443          * @throws PolicyException PolicyException related to the operation      
444          * 
445          * */
446         public DictionaryResponse getDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
447                 return stdPolicyEngine.getDictionaryItem(parameters);
448         }
449         
450         /**
451          * Creates a Dictionary Item based on given Dictionary Parameters
452          * 
453          * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. 
454          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create dictionary item Request. 
455          * @throws PolicyException  PolicyException related to the operation. 
456          */
457         public PolicyChangeResponse createDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
458                 return stdPolicyEngine.createDictionaryItem(parameters);
459         }
460         
461         /**
462          * Updates a Dictionary Item based on given Dictionary Parameters
463          * 
464          * @param  parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to update a Dictionary Item. 
465          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to update dictionary item Request. 
466          * @throws PolicyException PolicyException related to the operation. 
467          */
468         public PolicyChangeResponse updateDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
469                 return stdPolicyEngine.updateDictionaryItem(parameters);
470         }
471         
472         /**
473          * Creates a Policy based on given Policy Parameters. 
474          * 
475          * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to create a Policy. 
476          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. 
477          * @throws PolicyException  PolicyException related to the operation. 
478          */
479         public PolicyChangeResponse createPolicy(final PolicyParameters policyParameters) throws PolicyException {
480                 return stdPolicyEngine.createPolicy(policyParameters);
481         }
482         
483         /**
484          * Update Policy based on given Policy Parameters. 
485          * 
486          * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to update a Policy. 
487          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. 
488          * @throws PolicyException  PolicyException related to the operation. 
489          */
490         public PolicyChangeResponse updatePolicy(final PolicyParameters policyParameters) throws PolicyException {
491                 return stdPolicyEngine.updatePolicy(policyParameters);
492         }
493         
494         /**
495          * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. 
496          * 
497          * @param policyScope the <code>String</code> value of the sub scope directory where the policy is located
498          * @param policyName the <code>String</code> format of the Policy Name being pushed. 
499          * @param policyType the <code>String</code> format of the Policy Type which is being pushed.  
500          * @param pdpGroup the <code>String</code> format of the PDP Group name to which the policy needs to be pushed to. 
501          * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
502          * @return <code>String</code> format of the response related to the push Policy Request. 
503          * @throws PolicyException  PolicyException related to the operation. 
504          * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead. 
505          */
506         @Deprecated
507         public String pushPolicy(final String policyScope, final String policyName, final String policyType, final String pdpGroup, final UUID requestID) throws PolicyException {
508                 return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID);
509         }
510         
511         /**
512          * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. 
513          * 
514          * @param pushPolicyParameters {@link org.onap.policy.api.PushPolicyParameters} which represents the Push Policy parameters required to push a policy. 
515          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the push Policy Request. 
516          * @throws PolicyException  PolicyException related to the operation. 
517          */
518         public PolicyChangeResponse pushPolicy(final PushPolicyParameters pushPolicyParameters) throws PolicyException {
519                 return stdPolicyEngine.pushPolicy(pushPolicyParameters);
520         }
521         
522         /**
523          * Deletes the specified policy from the PAP or PDP.
524          * 
525          * @param deletePolicyParameters {@link org.onap.policy.api.DeletePolicyParameters} which represents the Delete Policy parameters to delete a policy.
526          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the Delete Policy Request.
527          * @throws PolicyException PolicyException related to the operation. 
528          */
529         public PolicyChangeResponse deletePolicy(final DeletePolicyParameters deletePolicyParameters) throws PolicyException {
530                 return stdPolicyEngine.deletePolicy(deletePolicyParameters);
531         }
532         
533         /**
534          * Creates a new Policy Service based on given Service Parameters. 
535          * 
536          * @param importParameters {@link org.onap.policy.api.ImportParameters} which represents the Service Parameters required to create a Policy Service. 
537          * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create import Service. 
538          * @throws PolicyException PolicyException related to the operation. 
539          */
540         public PolicyChangeResponse policyEngineImport(final ImportParameters importParameters) throws PolicyException {
541                 return stdPolicyEngine.policyEngineImport(importParameters);
542         }
543         
544         /**
545          * <code>setNotification</code> allows changes to the Notification Scheme and Notification Handler
546          * 
547          * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
548          * @param handler the <code>NotificationHandler</code> of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received.
549          */
550         public void setNotification(final NotificationScheme scheme, final NotificationHandler handler) {
551                 this.scheme = scheme;
552                 this.handler = handler;
553                 stdPolicyEngine.notification(this.scheme,this.handler);
554         }
555         
556         /**
557          * <code>clearNotification</code> shutsDown the Notification Service if the Auto Scehme Notification service is running.
558          */
559         public void clearNotification(){
560                 stdPolicyEngine.stopNotification();
561         }
562         
563         /**
564          * <code>setNotification</code> allows changes to the Notification Scheme
565          * 
566          * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
567          */
568         public void setScheme(final NotificationScheme scheme){
569                 this.scheme = scheme;
570                 stdPolicyEngine.setScheme(this.scheme);
571         }
572         
573         /**
574          * Gets the <code>PDPNotification</code> if there is one exists. This is used for Polling Patterns. 
575          * 
576          * @return <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} which has the Notification. 
577          */
578         public PDPNotification getNotification() {
579                 return stdPolicyEngine.getNotification();
580         }
581         
582         /**
583          * setClientKey allows the client to use their own implementation logic for Password Protection 
584          * and will be used to set the clear text password, this will be used while making Requests. 
585          *   
586          * @param clientKey depicts String format of Password/ Client_Key.  
587          */
588         public void setClientKey(final String clientKey){
589                 StdPolicyEngine.setClientKey(clientKey);
590         }
591         
592         // Internal Setter Method to help build configRequestParameters.
593         private ConfigRequestParameters setConfigRequestParameters(final String policyName, final String onapName, final String configName, final Map<String, String> configAttributes, final UUID requestID){
594                 final ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
595                 configRequestParameters.setPolicyName(policyName);
596                 configRequestParameters.setOnapName(onapName);
597                 configRequestParameters.setConfigName(configName);
598                 configRequestParameters.setConfigAttributes(configAttributes);
599                 configRequestParameters.setRequestID(requestID);
600                 return configRequestParameters;
601         }
602 }