X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=PolicyEngineAPI%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2FPolicyEngine.java;h=a664496e7c5df845384404a020b1ef0949c0f4af;hb=e2111a6738792f7fa83bc07749fa94d3b2bc4dbb;hp=b8b077c9914233644264dcd3eb46fa78bfed917d;hpb=301d66ae2647f94c066196110a5cd83fdd573591;p=policy%2Fengine.git diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java index b8b077c99..a664496e7 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * PolicyEngineAPI * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,596 +24,705 @@ import java.util.Collection; import java.util.Map; import java.util.Properties; import java.util.UUID; - import javax.json.JsonObject; - -import org.onap.policy.api.NotificationHandler; -import org.onap.policy.api.PDPNotification; import org.onap.policy.std.StdPolicyEngine; /** - * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine - * + * PolicyEngine is the Interface that applications use to make policy queries against a PEPEngine + * * @version 2.0 */ -public class PolicyEngine{ - private final StdPolicyEngine stdPolicyEngine; - private NotificationScheme scheme = null; - private NotificationHandler handler = null; - - /** - * PolicyEngine Constructor with Properties structure - * - * @param properties the Properties structure containing the Policy engine parameters - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(final Properties properties) throws PolicyEngineException { - this.stdPolicyEngine= new StdPolicyEngine(properties, (String)null); - } - - /** - * PolicyEngine Constructor with String format of propertiesFilePathname - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(final String propertiesFilePathname) throws PolicyEngineException { - this.stdPolicyEngine= new StdPolicyEngine(propertiesFilePathname, (String)null); - } - - /** - * PolicyEngine Constructor with Properties structure - * - * @param properties the Properties structure containing the Policy engine parameters - * @param clientKey depicts String format of Password/ Client_Key. - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(final Properties properties, final String clientKey) throws PolicyEngineException { - this.stdPolicyEngine= new StdPolicyEngine(properties, clientKey); - } - - /** - * PolicyEngine Constructor with String format of propertiesFilePathname - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @param clientKey depicts String format of Password/ Client_Key. - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(final String propertiesFilePathname, final String clientKey) throws PolicyEngineException { - this.stdPolicyEngine= new StdPolicyEngine(propertiesFilePathname, clientKey); - } - - /** - * PolicyEngine Constructor with String format of PropertiesFilePathname and NotificationScheme - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme) throws PolicyEngineException{ - this.scheme = scheme; - this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, this.scheme); - } - - /** - * PolicyEngine Constructor with String format of PropertiesFilePathname, NotificationScheme and NotificationHandler - * - * @param propertiesFilePathname the String format of the propertiesFilePathname - * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme - * @param handler the NotificationHandler of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received. - * @throws PolicyEngineException PolicyEngine Exception - */ - public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme, final NotificationHandler handler) throws PolicyEngineException { - this.scheme = scheme; - this.handler = handler; - this.stdPolicyEngine= new StdPolicyEngine(propertiesFilePathname,this.scheme,this.handler); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the Policy File Name - * - * @param policyName the String format of the PolicyFile Name whose configuration is required. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfigByPolicyName(final String policyName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(policyName, null, null, null, null)); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the Policy File Name - * - * @param policyName the String format of the PolicyFile Name whose configuration is required. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfigByPolicyName(final String policyName, final UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID)); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapName - * - * @param onapName the String format of the onapName whose configuration is required. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(final String onapName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapName, null, null, null)); - } - - /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapName - * - * @param onapName the String format of the onapName whose configuration is required. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(final String onapName, final UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID)); - } - - /** - * Requests the configuration of the String which represents the onapName and String - * which represents the configName and returns the configuration if different Configurations exist for the - * particular onapName. - * - * @param onapName the String format of the onapName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(final String onapName, final String configName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapName, configName, null, null)); - } - - /** - * Requests the configuration of the String which represents the onapName and String - * which represents the configName and returns the configuration if different Configurations exist for the - * particular onapName. - * - * @param onapName the String format of the onapName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(final String onapName, final String configName, final UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID)); - } - - /** - * Requests the configuration of the String which represents the onapName, String - * which represents the configName and Map of String,String which has the configAttribute and returns the specific - * configuration related to the configAttributes mentioned. - * - * @param onapName the String format of the onapName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @param configAttributes the Map of String,String format of the configuration attributes which are required. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(final String onapName, final String configName, final Map configAttributes) throws PolicyConfigException{ - return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null)); - } - - /** - * Requests the configuration of the String which represents the onapName, String - * which represents the configName and Map of String,String which has the configAttribute and returns the specific - * configuration related to the configAttributes mentioned. - * - * @param onapName the String format of the onapName whose configuration is required. - * @param configName the String format of the configurationName whose configuration is required. - * @param configAttributes the Map of String,String format of the configuration attributes which are required. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. - */ - @Deprecated - public Collection getConfig(final String onapName, final String configName, final Map configAttributes, final UUID requestID) throws PolicyConfigException{ - return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID)); - } - - /** - * Requests the configuration of the ConfigRequestParameters which represents the Config policy request parameters - * and returns the specific configuration related to the matching parameters. - * - * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the Config policy request parameters. - * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. - * @throws PolicyConfigException PolicyConfig Exception - */ - public Collection getConfig(final ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ - return stdPolicyEngine.getConfig(configRequestParameters); - } - - /** - * Requests the list of policies based on the ConfigRequestParameters which represents the policy request parameters - * and returns the list of policies filtered by the parameters. - * - * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which represents the List Policy request parameters. - * @return Collection of String which returns the list of policies. - * @throws PolicyConfigException PolicyConfig Exception - */ - public Collection listConfig(final ConfigRequestParameters listPolicyRequestParameters) throws PolicyConfigException{ - return stdPolicyEngine.listConfig(listPolicyRequestParameters); - } - - - /** - * Sends the Events specified to the PEP and returns back the PolicyResponse. - * - * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. - * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the Response. - * @throws PolicyEventException PolicyEvent Exception - * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. - */ - @Deprecated - public Collection sendEvent(final Map eventAttributes) throws PolicyEventException { - return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null); - } - - /** - * Sends the Events specified to the PEP and returns back the PolicyResponse. - * - * @param eventAttributes the Map of String,String format of the eventAttributes that must contain the event ID and values. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the Response. - * @throws PolicyEventException PolicyEvent Exception - * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. - */ - @Deprecated - public Collection sendEvent(final Map eventAttributes, final UUID requestID) throws PolicyEventException { - return stdPolicyEngine.sendEvent(eventAttributes, requestID); - } - - /** - * Sends the Events specified to the PEP and returns back the PolicyResponse. - * - * @param eventRequestParameters {@link org.onap.policy.api.EventRequestParameters} which represents the Event Request Parameters. - * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the Response. - * @throws PolicyEventException PolicyEvent Exception - */ - public Collection sendEvent(final EventRequestParameters eventRequestParameters) throws PolicyEventException { - return stdPolicyEngine.sendEvent(eventRequestParameters); - } - - /** - * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. - * - * @param onapName the String format of the onapName whose Decision is required. - * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. - * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. - * @throws PolicyDecisionException PolicyDecision Exception - * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. - */ - @Deprecated - public DecisionResponse getDecision(final String onapName, final Map decisionAttributes) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(onapName, decisionAttributes, null); - } - - /** - * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. - * - * @param onapName the String format of the onapName whose Decision is required. - * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. - * @throws PolicyDecisionException PolicyDecision Exception - * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. - */ - @Deprecated - public DecisionResponse getDecision(final String onapName, final Map decisionAttributes, final UUID requestID) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID); - } - - /** - * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. - * - * @param decisionRequestParameters {@link org.onap.policy.api.DecisionRequestParameters} which represents the Decision Request Parameters. - * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. - * @throws PolicyDecisionException PolicyDecision Exception - */ - public DecisionResponse getDecision(final DecisionRequestParameters decisionRequestParameters) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(decisionRequestParameters); - } - - /** - * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole - * - * @param parameters {@link org.onap.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics - * @return {@link org.onap.policy.api.MetricsResponse} which consists of the response related to getMetrics Request. - * @throws PolicyException PolicyException related to the operation - * - * */ - public MetricsResponse getMetrics(final MetricsRequestParameters parameters) throws PolicyException { - return stdPolicyEngine.getMetrics(parameters); - } - - /** - * Creates a Config Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param policyDescription the String format of the Policy Description - * @param onapName the String format of the ONAP Name - * @param configName the String format of the Config Name - * @param configAttributes the List the Map Attributes that must contain the key and value. - * @param configType the String format of the Config Type - * @param body the String format of the Policy Body - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response - * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String createConfigPolicy(final String policyName, final String policyDescription, final String onapName, final String configName, - final Map configAttributes, final String configType, final String body, final String policyScope, final UUID requestID, - final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, - configAttributes, configType, body, policyScope, requestID, - riskLevel, riskType, guard, ttlDate, false); - } - - /** - * Creates a Config Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param policyDescription the String format of the Policy Description - * @param onapName the String format of the ONAP Name - * @param configName the String format of the Config Name - * @param configAttributes the List the Map Attributes that must contain the key and value. - * @param configType the String format of the Config Type - * @param body the String format of the Policy Body - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response - * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String updateConfigPolicy(final String policyName, final String policyDescription, final String onapName, final String configName, - final Map configAttributes, final String configType, final String body, final String policyScope, final UUID requestID, - final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, - configAttributes, configType, body, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true); - } - - /** - * Creates a Config Firewall Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param firewallJson the JsonObject representation of the Firewall Rules List - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response. - * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String createConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, final String policyScope, final UUID requestID, - final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, - riskType, guard, ttlDate, false); - } - - /** - * Updates a Config Firewall Policy based on given arguments - * @param policyName the String format of the Policy Name - * @param firewallJson the JsonObject representation of the Firewall Rules List - * @param policyScope the String value of the sub scope directory where the policy will be created and stored - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * A different request ID should be passed for each request. - * @param riskLevel the String value of risk Level. - * @param riskType the String value of risk Type. - * @param guard the String value of guard. - * @param ttlDate the String value of time to live Date. - * @throws PolicyException PolicyException related to the operation. - * @return String format of response. - * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. - */ - @Deprecated - public String updateConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, final String policyScope, final UUID requestID, - final String riskLevel, final String riskType, final String guard, final String ttlDate) throws PolicyException { - return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID,riskLevel, riskType, guard, ttlDate, true); - } - - /** - * Retrieves Dictionary Items for a specified dictionary - * - * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. - * @return {@link org.onap.policy.api.DictionaryResponse} which consists of the response related to create dictionary item Request. - * @throws PolicyException PolicyException related to the operation - * - * */ - public DictionaryResponse getDictionaryItem(final DictionaryParameters parameters) throws PolicyException { - return stdPolicyEngine.getDictionaryItem(parameters); - } - - /** - * Creates a Dictionary Item based on given Dictionary Parameters - * - * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to create a Dictionary Item. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create dictionary item Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse createDictionaryItem(final DictionaryParameters parameters) throws PolicyException { - return stdPolicyEngine.createDictionaryItem(parameters); - } - - /** - * Updates a Dictionary Item based on given Dictionary Parameters - * - * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the Dictionary Parameters required to update a Dictionary Item. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to update dictionary item Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse updateDictionaryItem(final DictionaryParameters parameters) throws PolicyException { - return stdPolicyEngine.updateDictionaryItem(parameters); - } - - /** - * Creates a Policy based on given Policy Parameters. - * - * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to create a Policy. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse createPolicy(final PolicyParameters policyParameters) throws PolicyException { - return stdPolicyEngine.createPolicy(policyParameters); - } - - /** - * Update Policy based on given Policy Parameters. - * - * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy Parameters required to update a Policy. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse updatePolicy(final PolicyParameters policyParameters) throws PolicyException { - return stdPolicyEngine.updatePolicy(policyParameters); - } - - /** - * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. - * - * @param policyScope the String value of the sub scope directory where the policy is located - * @param policyName the String format of the Policy Name being pushed. - * @param policyType the String format of the Policy Type which is being pushed. - * @param pdpGroup the String format of the PDP Group name to which the policy needs to be pushed to. - * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. - * @return String format of the response related to the push Policy Request. - * @throws PolicyException PolicyException related to the operation. - * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead. - */ - @Deprecated - public String pushPolicy(final String policyScope, final String policyName, final String policyType, final String pdpGroup, final UUID requestID) throws PolicyException { - return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID); - } - - /** - * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. - * - * @param pushPolicyParameters {@link org.onap.policy.api.PushPolicyParameters} which represents the Push Policy parameters required to push a policy. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the push Policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse pushPolicy(final PushPolicyParameters pushPolicyParameters) throws PolicyException { - return stdPolicyEngine.pushPolicy(pushPolicyParameters); - } - - /** - * Deletes the specified policy from the PAP or PDP. - * - * @param deletePolicyParameters {@link org.onap.policy.api.DeletePolicyParameters} which represents the Delete Policy parameters to delete a policy. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to the Delete Policy Request. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse deletePolicy(final DeletePolicyParameters deletePolicyParameters) throws PolicyException { - return stdPolicyEngine.deletePolicy(deletePolicyParameters); - } - - /** - * Creates a new Policy Service based on given Service Parameters. - * - * @param importParameters {@link org.onap.policy.api.ImportParameters} which represents the Service Parameters required to create a Policy Service. - * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related to create import Service. - * @throws PolicyException PolicyException related to the operation. - */ - public PolicyChangeResponse policyEngineImport(final ImportParameters importParameters) throws PolicyException { - return stdPolicyEngine.policyEngineImport(importParameters); - } - - /** - * setNotification allows changes to the Notification Scheme and Notification Handler - * - * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme - * @param handler the NotificationHandler of {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a notification is received. - */ - public void setNotification(final NotificationScheme scheme, final NotificationHandler handler) { - this.scheme = scheme; - this.handler = handler; - stdPolicyEngine.notification(this.scheme,this.handler); - } - - /** - * clearNotification shutsDown the Notification Service if the Auto Scehme Notification service is running. - */ - public void clearNotification(){ - stdPolicyEngine.stopNotification(); - } - - /** - * setNotification allows changes to the Notification Scheme - * - * @param scheme the NotificationScheme of {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme - */ - public void setScheme(final NotificationScheme scheme){ - this.scheme = scheme; - stdPolicyEngine.setScheme(this.scheme); - } - - /** - * Gets the PDPNotification if there is one exists. This is used for Polling Patterns. - * - * @return PDPNotification of {@link org.onap.policy.api.PDPNotification} which has the Notification. - */ - public PDPNotification getNotification() { - return stdPolicyEngine.getNotification(); - } - - /** - * setClientKey allows the client to use their own implementation logic for Password Protection - * and will be used to set the clear text password, this will be used while making Requests. - * - * @param clientKey depicts String format of Password/ Client_Key. - */ - public void setClientKey(final String clientKey){ - StdPolicyEngine.setClientKey(clientKey); - } - - // Internal Setter Method to help build configRequestParameters. - private ConfigRequestParameters setConfigRequestParameters(final String policyName, final String onapName, final String configName, final Map configAttributes, final UUID requestID){ - final ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); - configRequestParameters.setPolicyName(policyName); - configRequestParameters.setOnapName(onapName); - configRequestParameters.setConfigName(configName); - configRequestParameters.setConfigAttributes(configAttributes); - configRequestParameters.setRequestID(requestID); - return configRequestParameters; - } -} \ No newline at end of file +public class PolicyEngine { + private final StdPolicyEngine stdPolicyEngine; + private NotificationScheme scheme = null; + private NotificationHandler handler = null; + + /** + * PolicyEngine Constructor with Properties structure + * + * @param properties the Properties structure containing the Policy engine parameters + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(final Properties properties) throws PolicyEngineException { + this.stdPolicyEngine = new StdPolicyEngine(properties, (String) null); + } + + /** + * PolicyEngine Constructor with String format of propertiesFilePathname + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(final String propertiesFilePathname) throws PolicyEngineException { + this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, (String) null); + } + + /** + * PolicyEngine Constructor with Properties structure + * + * @param properties the Properties structure containing the Policy engine parameters + * @param clientKey depicts String format of Password/ Client_Key. + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(final Properties properties, final String clientKey) throws PolicyEngineException { + this.stdPolicyEngine = new StdPolicyEngine(properties, clientKey); + } + + /** + * PolicyEngine Constructor with String format of propertiesFilePathname + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @param clientKey depicts String format of Password/ Client_Key. + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(final String propertiesFilePathname, final String clientKey) throws PolicyEngineException { + this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, clientKey); + } + + /** + * PolicyEngine Constructor with String format of PropertiesFilePathname and + * NotificationScheme + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @param scheme the NotificationScheme of + * {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme) + throws PolicyEngineException { + this.scheme = scheme; + this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, this.scheme); + } + + /** + * PolicyEngine Constructor with String format of PropertiesFilePathname, + * NotificationScheme and NotificationHandler + * + * @param propertiesFilePathname the String format of the propertiesFilePathname + * @param scheme the NotificationScheme of + * {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + * @param handler the NotificationHandler of + * {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a + * notification is received. + * @throws PolicyEngineException PolicyEngine Exception + */ + public PolicyEngine(final String propertiesFilePathname, final NotificationScheme scheme, + final NotificationHandler handler) throws PolicyEngineException { + this.scheme = scheme; + this.handler = handler; + this.stdPolicyEngine = new StdPolicyEngine(propertiesFilePathname, this.scheme, this.handler); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which + * represents the Policy File Name + * + * @param policyName the String format of the PolicyFile Name whose configuration is + * required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfigByPolicyName(final String policyName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(policyName, null, null, null, null)); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which + * represents the Policy File Name + * + * @param policyName the String format of the PolicyFile Name whose configuration is + * required. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters configRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfigByPolicyName(final String policyName, final UUID requestID) + throws PolicyConfigException { + return getConfig(setConfigRequestParameters(policyName, null, null, null, requestID)); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which + * represents the onapName + * + * @param onapName the String format of the onapName whose configuration is required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(final String onapName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, null, null, null)); + } + + /** + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which + * represents the onapName + * + * @param onapName the String format of the onapName whose configuration is required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(final String onapName, final UUID requestID) + throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID)); + } + + /** + * Requests the configuration of the String which represents the onapName and + * String which represents the configName and returns the configuration if different + * Configurations exist for the particular onapName. + * + * @param onapName the String format of the onapName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is + * required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(final String onapName, final String configName) + throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, configName, null, null)); + } + + /** + * Requests the configuration of the String which represents the onapName and + * String which represents the configName and returns the configuration if different + * Configurations exist for the particular onapName. + * + * @param onapName the String format of the onapName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is + * required. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(final String onapName, final String configName, final UUID requestID) + throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID)); + } + + /** + * Requests the configuration of the String which represents the onapName, + * String which represents the configName and Map of + * String,String which has the configAttribute and returns the specific configuration + * related to the configAttributes mentioned. + * + * @param onapName the String format of the onapName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is + * required. + * @param configAttributes the Map of String,String format of the + * configuration attributes which are required. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(final String onapName, final String configName, + final Map configAttributes) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null)); + } + + /** + * Requests the configuration of the String which represents the onapName, + * String which represents the configName and Map of + * String,String which has the configAttribute and returns the specific configuration + * related to the configAttributes mentioned. + * + * @param onapName the String format of the onapName whose configuration is required. + * @param configName the String format of the configurationName whose configuration is + * required. + * @param configAttributes the Map of String,String format of the + * configuration attributes which are required. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. + */ + @Deprecated + public Collection getConfig(final String onapName, final String configName, + final Map configAttributes, final UUID requestID) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID)); + } + + /** + * Requests the configuration of the ConfigRequestParameters which represents the + * Config policy request parameters and returns the specific configuration related to the matching + * parameters. + * + * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which + * represents the Config policy request parameters. + * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the + * configuration. + * @throws PolicyConfigException PolicyConfig Exception + */ + public Collection getConfig(final ConfigRequestParameters configRequestParameters) + throws PolicyConfigException { + return stdPolicyEngine.getConfig(configRequestParameters); + } + + /** + * Requests the list of policies based on the ConfigRequestParameters which represents + * the policy request parameters and returns the list of policies filtered by the parameters. + * + * @param configRequestParameters {@link org.onap.policy.api.ConfigRequestParameters} which + * represents the List Policy request parameters. + * @return Collection of String which returns the list of policies. + * @throws PolicyConfigException PolicyConfig Exception + */ + public Collection listConfig(final ConfigRequestParameters listPolicyRequestParameters) + throws PolicyConfigException { + return stdPolicyEngine.listConfig(listPolicyRequestParameters); + } + + /** + * Requests the list of policies from PDP based on the ConfigNameRequest which + * represents the policy request parameters and returns the list of policies filtered by the + * parameters. + * + * @param ConfigNameRequest {@link org.onap.policy.api.ConfigNameRequest} which represents the List + * Policy request parameters. + * @return Collection of String which returns the list of policies. + * @throws PolicyConfigException PolicyConfig Exception + */ + public Collection listPolicy(final ConfigNameRequest listPolicyParams) throws PolicyConfigException { + return stdPolicyEngine.listPolicy(listPolicyParams); + } + + /** + * Sends the Events specified to the PEP and returns back the PolicyResponse. + * + * @param eventAttributes the Map of String,String format of the + * eventAttributes that must contain the event ID and values. + * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the + * Response. + * @throws PolicyEventException PolicyEvent Exception + * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. + */ + @Deprecated + public Collection sendEvent(final Map eventAttributes) throws PolicyEventException { + return stdPolicyEngine.sendEvent(eventAttributes, (UUID) null); + } + + /** + * Sends the Events specified to the PEP and returns back the PolicyResponse. + * + * @param eventAttributes the Map of String,String format of the + * eventAttributes that must contain the event ID and values. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the + * Response. + * @throws PolicyEventException PolicyEvent Exception + * @deprecated use {@link #sendEvent(EventRequestParameters)} Instead. + */ + @Deprecated + public Collection sendEvent(final Map eventAttributes, final UUID requestID) + throws PolicyEventException { + return stdPolicyEngine.sendEvent(eventAttributes, requestID); + } + + /** + * Sends the Events specified to the PEP and returns back the PolicyResponse. + * + * @param eventRequestParameters {@link org.onap.policy.api.EventRequestParameters} which represents + * the Event Request Parameters. + * @return Collection of {@link org.onap.policy.api.PolicyResponse} which has the + * Response. + * @throws PolicyEventException PolicyEvent Exception + */ + public Collection sendEvent(final EventRequestParameters eventRequestParameters) + throws PolicyEventException { + return stdPolicyEngine.sendEvent(eventRequestParameters); + } + + /** + * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. + * + * @param onapName the String format of the onapName whose Decision is required. + * @param decisionAttributes the Map of String,String format of the + * decisionAttributes that must contain the ID and values. + * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. + * @throws PolicyDecisionException PolicyDecision Exception + * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. + */ + @Deprecated + public DecisionResponse getDecision(final String onapName, final Map decisionAttributes) + throws PolicyDecisionException { + return stdPolicyEngine.getDecision(onapName, decisionAttributes, null); + } + + /** + * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. + * + * @param onapName the String format of the onapName whose Decision is required. + * @param decisionAttributes the Map of String,String format of the + * decisionAttributes that must contain the ID and values. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. + * @throws PolicyDecisionException PolicyDecision Exception + * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. + */ + @Deprecated + public DecisionResponse getDecision(final String onapName, final Map decisionAttributes, + final UUID requestID) throws PolicyDecisionException { + return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID); + } + + /** + * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. + * + * @param decisionRequestParameters {@link org.onap.policy.api.DecisionRequestParameters} which + * represents the Decision Request Parameters. + * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. + * @throws PolicyDecisionException PolicyDecision Exception + */ + public DecisionResponse getDecision(final DecisionRequestParameters decisionRequestParameters) + throws PolicyDecisionException { + return stdPolicyEngine.getDecision(decisionRequestParameters); + } + + /** + * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole + * + * @param parameters {@link org.onap.policy.api.MetricsRequestParameters} which represents the + * Parameters required to get the Policy Metrics + * @return {@link org.onap.policy.api.MetricsResponse} which consists of the response related to + * getMetrics Request. + * @throws PolicyException PolicyException related to the operation + * + */ + public MetricsResponse getMetrics(final MetricsRequestParameters parameters) throws PolicyException { + return stdPolicyEngine.getMetrics(parameters); + } + + /** + * Creates a Config Policy based on given arguments + * + * @param policyName the String format of the Policy Name + * @param policyDescription the String format of the Policy Description + * @param onapName the String format of the ONAP Name + * @param configName the String format of the Config Name + * @param configAttributes the List the Map Attributes that must contain + * the key and value. + * @param configType the String format of the Config Type + * @param body the String format of the Policy Body + * @param policyScope the String value of the sub scope directory where the policy will + * be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response + * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String createConfigPolicy(final String policyName, final String policyDescription, final String onapName, + final String configName, final Map configAttributes, final String configType, + final String body, final String policyScope, final UUID requestID, final String riskLevel, + final String riskType, final String guard, final String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, + configAttributes, configType, body, policyScope, requestID, riskLevel, riskType, guard, ttlDate, false); + } + + /** + * Creates a Config Policy based on given arguments + * + * @param policyName the String format of the Policy Name + * @param policyDescription the String format of the Policy Description + * @param onapName the String format of the ONAP Name + * @param configName the String format of the Config Name + * @param configAttributes the List the Map Attributes that must contain + * the key and value. + * @param configType the String format of the Config Type + * @param body the String format of the Policy Body + * @param policyScope the String value of the sub scope directory where the policy will + * be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response + * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String updateConfigPolicy(final String policyName, final String policyDescription, final String onapName, + final String configName, final Map configAttributes, final String configType, + final String body, final String policyScope, final UUID requestID, final String riskLevel, + final String riskType, final String guard, final String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigPolicy(policyName, policyDescription, onapName, configName, + configAttributes, configType, body, policyScope, requestID, riskLevel, riskType, guard, ttlDate, true); + } + + /** + * Creates a Config Firewall Policy based on given arguments + * + * @param policyName the String format of the Policy Name + * @param firewallJson the JsonObject representation of the Firewall Rules List + * @param policyScope the String value of the sub scope directory where the policy will + * be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response. + * @deprecated use {@link #createPolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String createConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, + final String policyScope, final UUID requestID, final String riskLevel, final String riskType, + final String guard, final String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID, + riskLevel, riskType, guard, ttlDate, false); + } + + /** + * Updates a Config Firewall Policy based on given arguments + * + * @param policyName the String format of the Policy Name + * @param firewallJson the JsonObject representation of the Firewall Rules List + * @param policyScope the String value of the sub scope directory where the policy will + * be created and stored + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. A different request ID should be passed for each request. + * @param riskLevel the String value of risk Level. + * @param riskType the String value of risk Type. + * @param guard the String value of guard. + * @param ttlDate the String value of time to live Date. + * @throws PolicyException PolicyException related to the operation. + * @return String format of response. + * @deprecated use {@link #updatePolicy(PolicyParameters)} Instead. + */ + @Deprecated + public String updateConfigFirewallPolicy(final String policyName, final JsonObject firewallJson, + final String policyScope, final UUID requestID, final String riskLevel, final String riskType, + final String guard, final String ttlDate) throws PolicyException { + return stdPolicyEngine.createUpdateConfigFirewallPolicy(policyName, firewallJson, policyScope, requestID, + riskLevel, riskType, guard, ttlDate, true); + } + + /** + * Retrieves Dictionary Items for a specified dictionary + * + * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the + * Dictionary Parameters required to create a Dictionary Item. + * @return {@link org.onap.policy.api.DictionaryResponse} which consists of the response related to + * create dictionary item Request. + * @throws PolicyException PolicyException related to the operation + * + */ + public DictionaryResponse getDictionaryItem(final DictionaryParameters parameters) throws PolicyException { + return stdPolicyEngine.getDictionaryItem(parameters); + } + + /** + * Creates a Dictionary Item based on given Dictionary Parameters + * + * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the + * Dictionary Parameters required to create a Dictionary Item. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to create dictionary item Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse createDictionaryItem(final DictionaryParameters parameters) throws PolicyException { + return stdPolicyEngine.createDictionaryItem(parameters); + } + + /** + * Updates a Dictionary Item based on given Dictionary Parameters + * + * @param parameters {@link org.onap.policy.api.DictionaryParameters} which represents the + * Dictionary Parameters required to update a Dictionary Item. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to update dictionary item Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse updateDictionaryItem(final DictionaryParameters parameters) throws PolicyException { + return stdPolicyEngine.updateDictionaryItem(parameters); + } + + /** + * Creates a Policy based on given Policy Parameters. + * + * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy + * Parameters required to create a Policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to create policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse createPolicy(final PolicyParameters policyParameters) throws PolicyException { + return stdPolicyEngine.createPolicy(policyParameters); + } + + /** + * Update Policy based on given Policy Parameters. + * + * @param policyParameters {@link org.onap.policy.api.PolicyParameters} which represents the Policy + * Parameters required to update a Policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to create policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse updatePolicy(final PolicyParameters policyParameters) throws PolicyException { + return stdPolicyEngine.updatePolicy(policyParameters); + } + + /** + * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. + * + * @param policyScope the String value of the sub scope directory where the policy is + * located + * @param policyName the String format of the Policy Name being pushed. + * @param policyType the String format of the Policy Type which is being pushed. + * @param pdpGroup the String format of the PDP Group name to which the policy needs to + * be pushed to. + * @param requestID unique request ID which will be passed throughout the ONAP components to + * correlate logging messages. + * @return String format of the response related to the push Policy Request. + * @throws PolicyException PolicyException related to the operation. + * @deprecated use {@link #pushPolicy(PushPolicyParameters)} instead. + */ + @Deprecated + public String pushPolicy(final String policyScope, final String policyName, final String policyType, + final String pdpGroup, final UUID requestID) throws PolicyException { + return stdPolicyEngine.pushPolicy(policyScope, policyName, policyType, pdpGroup, requestID); + } + + /** + * Pushes the specified policy to the PDP Group. If no PDP group is selected default is used. + * + * @param pushPolicyParameters {@link org.onap.policy.api.PushPolicyParameters} which represents the + * Push Policy parameters required to push a policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to the push Policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse pushPolicy(final PushPolicyParameters pushPolicyParameters) throws PolicyException { + return stdPolicyEngine.pushPolicy(pushPolicyParameters); + } + + /** + * Deletes the specified policy from the PAP or PDP. + * + * @param deletePolicyParameters {@link org.onap.policy.api.DeletePolicyParameters} which represents + * the Delete Policy parameters to delete a policy. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to the Delete Policy Request. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse deletePolicy(final DeletePolicyParameters deletePolicyParameters) + throws PolicyException { + return stdPolicyEngine.deletePolicy(deletePolicyParameters); + } + + /** + * Creates a new Policy Service based on given Service Parameters. + * + * @param importParameters {@link org.onap.policy.api.ImportParameters} which represents the Service + * Parameters required to create a Policy Service. + * @return {@link org.onap.policy.api.PolicyChangeResponse} which consists of the response related + * to create import Service. + * @throws PolicyException PolicyException related to the operation. + */ + public PolicyChangeResponse policyEngineImport(final ImportParameters importParameters) throws PolicyException { + return stdPolicyEngine.policyEngineImport(importParameters); + } + + /** + * setNotification allows changes to the Notification Scheme and Notification Handler + * + * @param scheme the NotificationScheme of + * {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + * @param handler the NotificationHandler of + * {@link org.onap.policy.api.NotificationHandler} which defines what should happen when a + * notification is received. + */ + public void setNotification(final NotificationScheme scheme, final NotificationHandler handler) { + this.scheme = scheme; + this.handler = handler; + stdPolicyEngine.notification(this.scheme, this.handler); + } + + /** + * clearNotification shutsDown the Notification Service if the Auto Scehme Notification + * service is running. + */ + public void clearNotification() { + stdPolicyEngine.stopNotification(); + } + + /** + * setNotification allows changes to the Notification Scheme + * + * @param scheme the NotificationScheme of + * {@link org.onap.policy.api.NotificationScheme} which defines the Notification Scheme + */ + public void setScheme(final NotificationScheme scheme) { + this.scheme = scheme; + stdPolicyEngine.setScheme(this.scheme); + } + + /** + * Gets the PDPNotification if there is one exists. This is used for Polling Patterns. + * + * @return PDPNotification of {@link org.onap.policy.api.PDPNotification} which has the + * Notification. + */ + public PDPNotification getNotification() { + return stdPolicyEngine.getNotification(); + } + + /** + * setClientKey allows the client to use their own implementation logic for Password Protection and + * will be used to set the clear text password, this will be used while making Requests. + * + * @param clientKey depicts String format of Password/ Client_Key. + */ + public void setClientKey(final String clientKey) { + StdPolicyEngine.setClientKey(clientKey); + } + + // Internal Setter Method to help build configRequestParameters. + private ConfigRequestParameters setConfigRequestParameters(final String policyName, final String onapName, + final String configName, final Map configAttributes, final UUID requestID) { + final ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); + configRequestParameters.setPolicyName(policyName); + configRequestParameters.setOnapName(onapName); + configRequestParameters.setConfigName(configName); + configRequestParameters.setConfigAttributes(configAttributes); + configRequestParameters.setRequestID(requestID); + return configRequestParameters; + } +}