2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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=========================================================
21 package org.onap.policy.api;
23 import java.util.Collection;
25 import java.util.Properties;
26 import java.util.UUID;
28 import javax.json.JsonObject;
30 import org.onap.policy.api.NotificationHandler;
31 import org.onap.policy.api.PDPNotification;
32 import org.onap.policy.std.StdPolicyEngine;
35 * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine
39 public class PolicyEngine{
40 private final StdPolicyEngine stdPolicyEngine;
41 private NotificationScheme scheme = null;
42 private NotificationHandler handler = null;
45 * PolicyEngine Constructor with <code>Properties</code> structure
47 * @param properties the <code>Properties</code> structure containing the Policy engine parameters
48 * @throws PolicyEngineException PolicyEngine Exception
50 public PolicyEngine(final Properties properties) throws PolicyEngineException {
51 this.stdPolicyEngine= new StdPolicyEngine(properties, (String)null);
55 * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
57 * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
58 * @throws PolicyEngineException PolicyEngine Exception
60 public PolicyEngine(final String propertiesFilePathname) throws PolicyEngineException {
61 this.stdPolicyEngine= new StdPolicyEngine(propertiesFilePathname, (String)null);
65 * PolicyEngine Constructor with <code>Properties</code> structure
67 * @param properties the <code>Properties</code> structure containing the Policy engine parameters
68 * @param clientKey depicts String format of Password/ Client_Key.
69 * @throws PolicyEngineException PolicyEngine Exception
71 public PolicyEngine(final Properties properties, final String clientKey) throws PolicyEngineException {
72 this.stdPolicyEngine= new StdPolicyEngine(properties, clientKey);
76 * PolicyEngine Constructor with <code>String</code> format of propertiesFilePathname
78 * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
79 * @param clientKey depicts String format of Password/ Client_Key.
80 * @throws PolicyEngineException PolicyEngine Exception
82 public PolicyEngine(final String propertiesFilePathname, final String clientKey) throws PolicyEngineException {
83 this.stdPolicyEngine= new StdPolicyEngine(propertiesFilePathname, clientKey);
87 * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname and <code>NotificationScheme</code>
89 * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
90 * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
91 * @throws PolicyEngineException PolicyEngine Exception
93 public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme) throws PolicyEngineException{
95 this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, this.scheme);
99 * PolicyEngine Constructor with <code>String</code> format of PropertiesFilePathname, <code>NotificationScheme</code> and <code>NotificationHandler</code>
101 * @param propertiesFilePathname the <code>String</code> format of the propertiesFilePathname
102 * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
103 * @param handler the <code>NotificationHandler</code> of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received.
104 * @throws PolicyEngineException PolicyEngine Exception
106 public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme, final NotificationHandler handler) throws PolicyEngineException {
107 this.scheme = scheme;
108 this.handler = handler;
109 this.stdPolicyEngine= new StdPolicyEngine(propertiesFilePathname,this.scheme,this.handler);
113 * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the Policy File Name
115 * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required.
116 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
117 * @throws PolicyConfigException PolicyConfig Exception
118 * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead.
121 public Collection<PolicyConfig> getConfigByPolicyName(final String policyName) throws PolicyConfigException {
122 return getConfig(setConfigRequestParameters(policyName, null, null, null, null));
126 * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the Policy File Name
128 * @param policyName the <code>String</code> format of the PolicyFile Name whose configuration is required.
129 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
130 * A different request ID should be passed for each request.
131 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
132 * @throws PolicyConfigException PolicyConfig Exception
133 * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead.
136 public Collection<PolicyConfig> getConfigByPolicyName(final String policyName, final UUID requestID) throws PolicyConfigException {
137 return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID));
141 * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapName
143 * @param onapName the <code>String</code> format of the onapName whose configuration is required.
144 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
145 * @throws PolicyConfigException PolicyConfig Exception
146 * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
149 public Collection<PolicyConfig> getConfig(final String onapName) throws PolicyConfigException {
150 return getConfig(setConfigRequestParameters(null, onapName, null, null, null));
154 * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapName
156 * @param onapName the <code>String</code> format of the onapName whose configuration is required.
157 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
158 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
159 * A different request ID should be passed for each request.
160 * @throws PolicyConfigException PolicyConfig Exception
161 * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
164 public Collection<PolicyConfig> getConfig(final String onapName, final UUID requestID) throws PolicyConfigException {
165 return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID));
169 * Requests the configuration of the <code>String</code> which represents the onapName and <code>String</code>
170 * which represents the configName and returns the configuration if different Configurations exist for the
171 * particular onapName.
173 * @param onapName the <code>String</code> format of the onapName whose configuration is required.
174 * @param configName the <code>String</code> format of the configurationName whose configuration is required.
175 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
176 * @throws PolicyConfigException PolicyConfig Exception
177 * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
180 public Collection<PolicyConfig> getConfig(final String onapName, final String configName) throws PolicyConfigException {
181 return getConfig(setConfigRequestParameters(null, onapName, configName, null, null));
185 * Requests the configuration of the <code>String</code> which represents the onapName and <code>String</code>
186 * which represents the configName and returns the configuration if different Configurations exist for the
187 * particular onapName.
189 * @param onapName the <code>String</code> format of the onapName whose configuration is required.
190 * @param configName the <code>String</code> format of the configurationName whose configuration is required.
191 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
192 * A different request ID should be passed for each request.
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.
198 public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final UUID requestID) throws PolicyConfigException {
199 return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID));
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.
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 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
211 * @throws PolicyConfigException PolicyConfig Exception
212 * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
215 public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final Map<String, String> configAttributes) throws PolicyConfigException{
216 return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null));
220 * Requests the configuration of the <code>String</code> which represents the onapName, <code>String</code>
221 * which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific
222 * configuration related to the configAttributes mentioned.
224 * @param onapName the <code>String</code> format of the onapName whose configuration is required.
225 * @param configName the <code>String</code> format of the configurationName whose configuration is required.
226 * @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
227 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
228 * A different request ID should be passed for each request.
229 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
230 * @throws PolicyConfigException PolicyConfig Exception
231 * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
234 public Collection<PolicyConfig> getConfig(final String onapName, final String configName, final Map<String, String> configAttributes, final UUID requestID) throws PolicyConfigException{
235 return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID));
239 * Requests the configuration of the <code>ConfigRequestParameters</code> which represents the Config policy request parameters
240 * and returns the specific configuration related to the matching parameters.
242 * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the Config policy request parameters.
243 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
244 * @throws PolicyConfigException PolicyConfig Exception
246 public Collection<PolicyConfig> getConfig(final ConfigRequestParameters configRequestParameters) throws PolicyConfigException{
247 return stdPolicyEngine.getConfig(configRequestParameters);
251 * Requests the list of policies based on the <code>ConfigRequestParameters</code> which represents the policy request parameters
252 * and returns the list of policies filtered by the parameters.
254 * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the List Policy request parameters.
255 * @return <code>Collection</code> of <code>String</code> which returns the list of policies.
256 * @throws PolicyConfigException PolicyConfig Exception
258 public Collection<String> listConfig(final ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{
259 return stdPolicyEngine.listConfig(listPolicyRequestParameters);
264 * Sends the Events specified to the PEP and returns back the PolicyResponse.
266 * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
267 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the Response.
268 * @throws PolicyEventException PolicyEvent Exception
269 * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
272 public Collection<PolicyResponse> sendEvent(final Map<String, String> eventAttributes) throws PolicyEventException {
273 return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null);
277 * Sends the Events specified to the PEP and returns back the PolicyResponse.
279 * @param eventAttributes the <code>Map</code> of <code>String,String</code> format of the eventAttributes that must contain the event ID and values.
280 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
281 * A different request ID should be passed for each request.
282 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the Response.
283 * @throws PolicyEventException PolicyEvent Exception
284 * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead.
287 public Collection<PolicyResponse> sendEvent(final Map<String, String> eventAttributes, final UUID requestID) throws PolicyEventException {
288 return stdPolicyEngine.sendEvent(eventAttributes, requestID);
292 * Sends the Events specified to the PEP and returns back the PolicyResponse.
294 * @param eventRequestParameters {@link org.onap.policy.api.EventRequestParameters} which represents the Event Request Parameters.
295 * @return <code>Collection</code> of {@link org.onap.policy.api.PolicyResponse} which has the Response.
296 * @throws PolicyEventException PolicyEvent Exception
298 public Collection<PolicyResponse> sendEvent(final EventRequestParameters eventRequestParameters) throws PolicyEventException {
299 return stdPolicyEngine.sendEvent(eventRequestParameters);
303 * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
305 * @param onapName the <code>String</code> format of the onapName whose Decision is required.
306 * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
307 * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
308 * @throws PolicyDecisionException PolicyDecision Exception
309 * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
312 public DecisionResponse getDecision(final String onapName, final Map<String,String> decisionAttributes) throws PolicyDecisionException {
313 return stdPolicyEngine.getDecision(onapName, decisionAttributes, null);
317 * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
319 * @param onapName the <code>String</code> format of the onapName whose Decision is required.
320 * @param decisionAttributes the <code>Map</code> of <code>String,String</code> format of the decisionAttributes that must contain the ID and values.
321 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
322 * A different request ID should be passed for each request.
323 * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
324 * @throws PolicyDecisionException PolicyDecision Exception
325 * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
328 public DecisionResponse getDecision(final String onapName, final Map<String,String> decisionAttributes, final UUID requestID) throws PolicyDecisionException {
329 return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID);
333 * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
335 * @param decisionRequestParameters {@link org.onap.policy.api.DecisionRequestParameters} which represents the Decision Request Parameters.
336 * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision.
337 * @throws PolicyDecisionException PolicyDecision Exception
339 public DecisionResponse getDecision(final DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException {
340 return stdPolicyEngine.getDecision(decisionRequestParameters);
344 * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole
346 * @param parameters {@link org.onap.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics
347 * @return {@link org.onap.policy.api.MetricsResponse} which consists of the response related to getMetrics Request.
348 * @throws PolicyException PolicyException related to the operation
351 public MetricsResponse getMetrics(final MetricsRequestParameters parameters) throws PolicyException {
352 return stdPolicyEngine.getMetrics(parameters);
356 * Creates a Config Policy based on given arguments
357 * @param policyName the <code>String</code> format of the Policy Name
358 * @param policyDescription the <code>String</code> format of the Policy Description
359 * @param onapName the <code>String</code> format of the ONAP Name
360 * @param configName the <code>String</code> format of the Config Name
361 * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain the key and value.
362 * @param configType the <code>String</code> format of the Config Type
363 * @param body the <code>String</code> format of the Policy Body
364 * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
365 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
366 * A different request ID should be passed for each request.
367 * @param riskLevel the <code>String</code> value of risk Level.
368 * @param riskType the <code>String</code> value of risk Type.
369 * @param guard the <code>String</code> value of guard.
370 * @param ttlDate the <code>String</code> value of time to live Date.
371 * @throws PolicyException PolicyException related to the operation.
372 * @return <code>String</code> format of response
373 * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
376 public String createConfigPolicy(final String policyName, final String policyDescription, final String onapName, final String configName,
377 final Map<String, String> configAttributes, final String configType, final String body, final String policyScope, final UUID requestID,
378 final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
379 return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName,
380 configAttributes, configType, body, policyScope, requestID,
381 riskLevel, riskType, guard, ttlDate, false);
385 * Creates a Config Policy based on given arguments
386 * @param policyName the <code>String</code> format of the Policy Name
387 * @param policyDescription the <code>String</code> format of the Policy Description
388 * @param onapName the <code>String</code> format of the ONAP Name
389 * @param configName the <code>String</code> format of the Config Name
390 * @param configAttributes the <code>List</code> the <code>Map</code> Attributes that must contain the key and value.
391 * @param configType the <code>String</code> format of the Config Type
392 * @param body the <code>String</code> format of the Policy Body
393 * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
394 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
395 * A different request ID should be passed for each request.
396 * @param riskLevel the <code>String</code> value of risk Level.
397 * @param riskType the <code>String</code> value of risk Type.
398 * @param guard the <code>String</code> value of guard.
399 * @param ttlDate the <code>String</code> value of time to live Date.
400 * @throws PolicyException PolicyException related to the operation.
401 * @return <code>String</code> format of response
402 * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
405 public String updateConfigPolicy(final String policyName, final String policyDescription, final String onapName, final String configName,
406 final Map<String, String> configAttributes, final String configType, final String body, final String policyScope, final UUID requestID,
407 final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
408 return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName,
409 configAttributes, configType, body, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true);
413 * Creates a Config Firewall Policy based on given arguments
414 * @param policyName the <code>String</code> format of the Policy Name
415 * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
416 * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
417 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
418 * A different request ID should be passed for each request.
419 * @param riskLevel the <code>String</code> value of risk Level.
420 * @param riskType the <code>String</code> value of risk Type.
421 * @param guard the <code>String</code> value of guard.
422 * @param ttlDate the <code>String</code> value of time to live Date.
423 * @throws PolicyException PolicyException related to the operation.
424 * @return <code>String</code> format of response.
425 * @deprecated use {@link #createPolicy(PolicyParameters)} Instead.
428 public String createConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, final String policyScope, final UUID requestID,
429 final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
430 return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel,
431 riskType, guard, ttlDate, false);
435 * Updates a Config Firewall Policy based on given arguments
436 * @param policyName the <code>String</code> format of the Policy Name
437 * @param firewallJson the <code>JsonObject</code> representation of the Firewall Rules List
438 * @param policyScope the <code>String</code> value of the sub scope directory where the policy will be created and stored
439 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
440 * A different request ID should be passed for each request.
441 * @param riskLevel the <code>String</code> value of risk Level.
442 * @param riskType the <code>String</code> value of risk Type.
443 * @param guard the <code>String</code> value of guard.
444 * @param ttlDate the <code>String</code> value of time to live Date.
445 * @throws PolicyException PolicyException related to the operation.
446 * @return <code>String</code> format of response.
447 * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead.
450 public String updateConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, final String policyScope, final UUID requestID,
451 final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException {
452 return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true);
456 * Retrieves Dictionary Items for a specified dictionary
458 * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item.
459 * @return {@link org.onap.policy.api.DictionaryResponse} which consists of the response related to create dictionary item Request.
460 * @throws PolicyException PolicyException related to the operation
463 public DictionaryResponse getDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
464 return stdPolicyEngine.getDictionaryItem(parameters);
468 * Creates a Dictionary Item based on given Dictionary Parameters
470 * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item.
471 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create dictionary item Request.
472 * @throws PolicyException PolicyException related to the operation.
474 public PolicyChangeResponse createDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
475 return stdPolicyEngine.createDictionaryItem(parameters);
479 * Updates a Dictionary Item based on given Dictionary Parameters
481 * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to update a Dictionary Item.
482 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to update dictionary item Request.
483 * @throws PolicyException PolicyException related to the operation.
485 public PolicyChangeResponse updateDictionaryItem(final DictionaryParameters parameters) throws PolicyException {
486 return stdPolicyEngine.updateDictionaryItem(parameters);
490 * Creates a Policy based on given Policy Parameters.
492 * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to create a Policy.
493 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request.
494 * @throws PolicyException PolicyException related to the operation.
496 public PolicyChangeResponse createPolicy(final PolicyParameters policyParameters) throws PolicyException {
497 return stdPolicyEngine.createPolicy(policyParameters);
501 * Update Policy based on given Policy Parameters.
503 * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to update a Policy.
504 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request.
505 * @throws PolicyException PolicyException related to the operation.
507 public PolicyChangeResponse updatePolicy(final PolicyParameters policyParameters) throws PolicyException {
508 return stdPolicyEngine.updatePolicy(policyParameters);
512 * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used.
514 * @param policyScope the <code>String</code> value of the sub scope directory where the policy is located
515 * @param policyName the <code>String</code> format of the Policy Name being pushed.
516 * @param policyType the <code>String</code> format of the Policy Type which is being pushed.
517 * @param pdpGroup the <code>String</code> format of the PDP Group name to which the policy needs to be pushed to.
518 * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages.
519 * @return <code>String</code> format of the response related to the push Policy Request.
520 * @throws PolicyException PolicyException related to the operation.
521 * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead.
524 public String pushPolicy(final String policyScope, final String policyName, final String policyType, final String pdpGroup, final UUID requestID) throws PolicyException {
525 return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID);
529 * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used.
531 * @param pushPolicyParameters {@link org.onap.policy.api.PushPolicyParameters} which represents the Push Policy parameters required to push a policy.
532 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the push Policy Request.
533 * @throws PolicyException PolicyException related to the operation.
535 public PolicyChangeResponse pushPolicy(final PushPolicyParameters pushPolicyParameters) throws PolicyException {
536 return stdPolicyEngine.pushPolicy(pushPolicyParameters);
540 * Deletes the specified policy from the PAP or PDP.
542 * @param deletePolicyParameters {@link org.onap.policy.api.DeletePolicyParameters} which represents the Delete Policy parameters to delete a policy.
543 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the Delete Policy Request.
544 * @throws PolicyException PolicyException related to the operation.
546 public PolicyChangeResponse deletePolicy(final DeletePolicyParameters deletePolicyParameters) throws PolicyException {
547 return stdPolicyEngine.deletePolicy(deletePolicyParameters);
551 * Creates a new Policy Service based on given Service Parameters.
553 * @param importParameters {@link org.onap.policy.api.ImportParameters} which represents the Service Parameters required to create a Policy Service.
554 * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create import Service.
555 * @throws PolicyException PolicyException related to the operation.
557 public PolicyChangeResponse policyEngineImport(final ImportParameters importParameters) throws PolicyException {
558 return stdPolicyEngine.policyEngineImport(importParameters);
562 * <code>setNotification</code> allows changes to the Notification Scheme and Notification Handler
564 * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
565 * @param handler the <code>NotificationHandler</code> of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received.
567 public void setNotification(final NotificationScheme scheme, final NotificationHandler handler) {
568 this.scheme = scheme;
569 this.handler = handler;
570 stdPolicyEngine.notification(this.scheme,this.handler);
574 * <code>clearNotification</code> shutsDown the Notification Service if the Auto Scehme Notification service is running.
576 public void clearNotification(){
577 stdPolicyEngine.stopNotification();
581 * <code>setNotification</code> allows changes to the Notification Scheme
583 * @param scheme the <code>NotificationScheme</code> of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme
585 public void setScheme(final NotificationScheme scheme){
586 this.scheme = scheme;
587 stdPolicyEngine.setScheme(this.scheme);
591 * Gets the <code>PDPNotification</code> if there is one exists. This is used for Polling Patterns.
593 * @return <code>PDPNotification</code> of {@link org.onap.policy.api.PDPNotification} which has the Notification.
595 public PDPNotification getNotification() {
596 return stdPolicyEngine.getNotification();
600 * setClientKey allows the client to use their own implementation logic for Password Protection
601 * and will be used to set the clear text password, this will be used while making Requests.
603 * @param clientKey depicts String format of Password/ Client_Key.
605 public void setClientKey(final String clientKey){
606 StdPolicyEngine.setClientKey(clientKey);
609 // Internal Setter Method to help build configRequestParameters.
610 private ConfigRequestParameters setConfigRequestParameters(final String policyName, final String onapName, final String configName, final Map<String, String> configAttributes, final UUID requestID){
611 final ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
612 configRequestParameters.setPolicyName(policyName);
613 configRequestParameters.setOnapName(onapName);
614 configRequestParameters.setConfigName(configName);
615 configRequestParameters.setConfigAttributes(configAttributes);
616 configRequestParameters.setRequestID(requestID);
617 return configRequestParameters;