* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019 Bell Canada
* ================================================================================
package org.onap.policy.admin;
+import com.att.research.xacml.util.XACMLProperties;
+
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.controller.ActionPolicyController;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.PolicyEntity;
-import com.att.research.xacml.util.XACMLProperties;
-
public class PolicyAdapter {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyAdapter.class);
+ /**
+ * configure.
+ *
+ * @param policyAdapter PolicyRestAdapter object
+ * @param entity PolicyEntity object
+ */
public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
String policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
String configPolicyName = getConfigPolicyName(policyAdapter);
}
private String getConfigPolicyName(PolicyRestAdapter policyAdapter) {
- String configPolicyName = null;
if (policyAdapter.getPolicyName().startsWith("Config_PM")) {
- configPolicyName = "ClosedLoop_PM";
+ return "ClosedLoop_PM";
} else if (policyAdapter.getPolicyName().startsWith("Config_Fault")) {
- configPolicyName = "ClosedLoop_Fault";
+ return "ClosedLoop_Fault";
} else if (policyAdapter.getPolicyName().startsWith("Config_FW")) {
- configPolicyName = "Firewall Config";
+ return "Firewall Config";
} else if (policyAdapter.getPolicyName().startsWith("Config_BRMS_Raw")) {
- configPolicyName = "BRMS_Raw";
+ return "BRMS_Raw";
} else if (policyAdapter.getPolicyName().startsWith("Config_BRMS_Param")) {
- configPolicyName = "BRMS_Param";
+ return "BRMS_Param";
} else if (policyAdapter.getPolicyName().startsWith("Config_MS")) {
- configPolicyName = "Micro Service";
+ return "Micro Service";
} else if (policyAdapter.getPolicyName().startsWith("Config_OOF")) {
- configPolicyName = "Optimization";
- } else if (policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName()
- .startsWith("Decision")) {
- // No configPolicyName is applicable
- } else {
- configPolicyName = "Base";
+ return "Optimization";
+ } else if (policyAdapter.getPolicyName().startsWith("Action")
+ || policyAdapter.getPolicyName().startsWith("Decision")) {
+ return null;
}
- return configPolicyName;
+ return "Base";
}
private void prePopulatePolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
}
}
+ /**
+ * getInstance.
+ *
+ * @return Returns a PolicyAdapter instance
+ */
public static PolicyAdapter getInstance() {
try {
- Class<?> policyAdapter = Class
- .forName(XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
+ Class<?> policyAdapter = Class.forName(
+ XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
return (PolicyAdapter) policyAdapter.newInstance();
- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException e) {
LOGGER.error("Exception Occurred" + e);
}
return null;