aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r--src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java10
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java39
2 files changed, 15 insertions, 34 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
index e6af43363..58f5e0086 100644
--- a/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
+++ b/src/main/java/org/onap/clamp/clds/client/OperationalPolicyDelegate.java
@@ -39,14 +39,13 @@ import org.onap.clamp.clds.model.prop.PolicyChain;
import org.onap.clamp.clds.model.refprop.RefProp;
import org.onap.clamp.clds.util.LoggingUtils;
import org.onap.policy.api.AttributeType;
-import org.onap.policy.api.PolicyEngineException;
import org.onap.policy.controlloop.policy.builder.BuilderException;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Send Operational Policy info to policy api. It uses the policy code to define
* the model and communicate with it. See also the PolicyClient class.
- *
+ *
*/
public class OperationalPolicyDelegate implements JavaDelegate {
protected static final EELFLogger logger = EELFManager.getInstance()
@@ -70,20 +69,17 @@ public class OperationalPolicyDelegate implements JavaDelegate {
* The DelegateExecution
* @throws BuilderException
* In case of issues with OperationalPolicyReq
- * @throws PolicyEngineException
- * In case of issues with the PolicyEngine creation
* @throws UnsupportedEncodingException
*/
@Override
public void execute(DelegateExecution execution)
- throws BuilderException, PolicyEngineException, UnsupportedEncodingException {
+ throws BuilderException, UnsupportedEncodingException {
String responseMessage = null;
- String operationalPolicyRequestUuid = null;
ModelProperties prop = ModelProperties.create(execution);
Policy policy = prop.getType(Policy.class);
if (policy.isFound()) {
for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
- operationalPolicyRequestUuid = LoggingUtils.getRequestId();
+ String operationalPolicyRequestUuid = LoggingUtils.getRequestId();
Map<AttributeType, Map<String, String>> attributes = OperationalPolicyReq.formatAttributes(refProp,
prop, prop.getType(Policy.class).getId(), policyChain);
responseMessage = policyClient.sendBrmsPolicy(attributes, prop, operationalPolicyRequestUuid);
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java
index fcf6cda57..db84a1240 100644
--- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java
+++ b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java
@@ -107,20 +107,21 @@ public class OperationalPolicyReq {
notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService());
controller = refProp.getStringValue("op.controller", global.getService());
}
+
String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService());
// ruleAttributes
+ logger.info("templateName=" + templateName);
+ logger.info("notificationTopic=" + notificationTopic);
Map<String, String> ruleAttributes = new HashMap<>();
+ ruleAttributes.put("templateName", templateName);
+ ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId());
+ ruleAttributes.put("NotificationTopic", notificationTopic);
if (operationTopic == null || operationTopic.isEmpty()) {
- logger.info("templateName=" + templateName);
logger.info("recipeTopic=" + recipeTopic);
- logger.info("notificationTopic=" + notificationTopic);
// if no operationTopic, then don't format yaml - use first policy
// from list
PolicyItem policyItem = policyChain.getPolicyItems().get(0);
- ruleAttributes.put("templateName", templateName);
- ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId());
ruleAttributes.put("RecipeTopic", recipeTopic);
- ruleAttributes.put("NotificationTopic", notificationTopic);
String recipe = policyItem.getRecipe();
String maxRetries = String.valueOf(policyItem.getMaxRetries());
String retryTimeLimit = String.valueOf(policyItem.getRetryTimeLimit());
@@ -134,16 +135,11 @@ public class OperationalPolicyReq {
ruleAttributes.put("RetryTimeLimit", retryTimeLimit);
ruleAttributes.put("ResourceId", targetResourceId);
} else {
- logger.info("templateName=" + templateName);
logger.info("operationTopic=" + operationTopic);
- logger.info("notificationTopic=" + notificationTopic);
// format yaml
String yaml = (tca != null && tca.isFound()) ? formateNodeBYaml(refProp, prop, modelElementId, policyChain)
: formatYaml(refProp, prop, modelElementId, policyChain);
- ruleAttributes.put("templateName", templateName);
- ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId());
ruleAttributes.put("OperationTopic", operationTopic);
- ruleAttributes.put("NotificationTopic", notificationTopic);
ruleAttributes.put("ControlLoopYaml", yaml);
}
// matchingAttributes
@@ -205,22 +201,9 @@ public class OperationalPolicyReq {
}
policyObjMap.put(policyItem.getId(), policyObj);
}
- //
// Build the specification
- //
Results results = builder.buildSpecification();
- if (results.isValid()) {
- logger.info("results.getSpecification()=" + results.getSpecification());
- } else {
- // throw exception with error info
- StringBuilder sb = new StringBuilder();
- sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
- for (Message message : results.getMessages()) {
- sb.append(message.getMessage());
- sb.append("; ");
- }
- throw new BadRequestException(sb.toString());
- }
+ validate(results);
return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
@@ -284,10 +267,13 @@ public class OperationalPolicyReq {
operationsAccumulateParams.setLimit(Integer.valueOf(refProp.getStringValue("op.eNodeB.limit")));
operationsAccumulateParams.setPeriod(refProp.getStringValue("op.eNodeB.period"));
builder.addOperationsAccumulateParams(lastPolicyObj.getId(), operationsAccumulateParams);
- //
// Build the specification
- //
Results results = builder.buildSpecification();
+ validate(results);
+ return URLEncoder.encode(results.getSpecification(), "UTF-8");
+ }
+
+ private static void validate (Results results) {
if (results.isValid()) {
logger.info("results.getSpecification()=" + results.getSpecification());
} else {
@@ -300,7 +286,6 @@ public class OperationalPolicyReq {
}
throw new BadRequestException(sb.toString());
}
- return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
/**