String operationTopic = "";
String notificationTopic = "";
String controller = "";
- Tca tca = prop.getTca();
- if (tca.isFound()) {
+ Tca tca = prop.getType(Tca.class);
+ if (tca != null && tca.isFound()) {
if (!global.getActionSet().equalsIgnoreCase("enbRecipe")) {
throw new BadRequestException(
"Operation Policy validation problem: action set is not selected properly.");
String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService());
// ruleAttributes
- Map<String, String> ruleAttributes = new HashMap<String, String>();
+ Map<String, String> ruleAttributes = new HashMap<>();
- if (operationTopic == null || operationTopic.length() == 0) {
+ if (operationTopic == null || operationTopic.isEmpty()) {
logger.info("templateName=" + templateName);
logger.info("recipeTopic=" + recipeTopic);
logger.info("notificationTopic=" + notificationTopic);
}
// matchingAttributes
- Map<String, String> matchingAttributes = new HashMap<String, String>();
+ Map<String, String> matchingAttributes = new HashMap<>();
matchingAttributes.put("controller", controller);
- Map<AttributeType, Map<String, String>> attributes = new HashMap<AttributeType, Map<String, String>>();
+ Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
attributes.put(AttributeType.RULE, ruleAttributes);
attributes.put(AttributeType.MATCHING, matchingAttributes);
builder.addResource(vfcResources);
// process each policy
- HashMap<String, org.onap.policy.controlloop.policy.Policy> policyObjMap = new HashMap<String, org.onap.policy.controlloop.policy.Policy>();
+ HashMap<String, org.onap.policy.controlloop.policy.Policy> policyObjMap = new HashMap<>();
List<PolicyItem> policyItemList = orderParentFirst(policyChain.getPolicyItems());
Target target = new Target();
target.setType(TargetType.VM);
logger.info("results.getSpecification()=" + results.getSpecification());
} else {
// throw exception with error info
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
for (Message message : results.getMessages()) {
sb.append(message.getMessage());
}
throw new BadRequestException(sb.toString());
}
-
- String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8");
-
- return encodedYaml;
+ return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
/**
builder.addResource(vfcResources);
// process each policy
- HashMap<String, Policy> policyObjMap = new HashMap<String, Policy>();
+ HashMap<String, Policy> policyObjMap = new HashMap<>();
List<PolicyItem> policyItemList = addAOTSActorRecipe(refProp, global.getService(),
policyChain.getPolicyItems());
Target target = new Target();
String policyName = policyItem.getRecipe() + " Policy";
if (i == 0) {
// To set up time window payload for trigger policy
- Map<String, String> payloadMap = new HashMap<String, String>();
+ Map<String, String> payloadMap = new HashMap<>();
payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow"));
String policyDescription = policyItem.getRecipe()
+ " Policy - the trigger (no parent) policy - created by CLDS";
logger.info("results.getSpecification()=" + results.getSpecification());
} else {
// throw exception with error info
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
for (Message message : results.getMessages()) {
sb.append(message.getMessage());
}
throw new BadRequestException(sb.toString());
}
-
- String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8");
-
- return encodedYaml;
+ return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
/**
* @return
*/
private static List<PolicyItem> addAOTSActorRecipe(RefProp refProp, String service, List<PolicyItem> inOrigList) {
- List<PolicyItem> outList = new ArrayList<PolicyItem>();
+ List<PolicyItem> outList = new ArrayList<>();
try {
PolicyItem policyItem = inOrigList.get(0);
ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("op.eNodeB.recipe", service);
policyItemObj.setRetryTimeLimit(Integer.parseInt(recipeNode.path("TimeLimit").asText()));
}
if (!recipeNode.path("PPConditions").asText().isEmpty()) {
- List<String> parentPolicyConditions = new ArrayList<String>();
+ List<String> parentPolicyConditions = new ArrayList<>();
for (String ppCondition : recipeNode.path("PPConditions").asText().split(",")) {
parentPolicyConditions.add(ppCondition);
}
// check for trigger policy (no parent)
String parent = inItem.getParentPolicy();
if (parent == null || parent.length() == 0) {
- if (outList.size() > 0) {
+ if (!outList.isEmpty()) {
throw new BadRequestException(
"Operation Policy validation problem: more than one trigger policy");
} else {
return new Resource[0];
}
return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new);
- }
+ }
/**
* Convert a List of policy result strings to an array of PolicyResult