diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-08-08 03:06:03 -0700 |
---|---|---|
committer | Sébastien Determe <sd378r@intl.att.com> | 2017-08-08 12:35:27 +0000 |
commit | 8727db8683fcd11fa3695b2cb4e9a7834a3280e1 (patch) | |
tree | cf0b917840efcb8d20843b2c362ca12e7e2ac91b /src | |
parent | b436cd173daa367e15951f0c1f84f8b842a1e347 (diff) |
Rework the Req classes for all
Rework the req classes for TCA, Operational policy, StringMatch
+ Camunda config classes reworked
Change-Id: I16a1e4b7485416c38ed50087c701aa2e305a768a
Issue-Id: CLAMP-1
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src')
7 files changed, 503 insertions, 310 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java index 35d6c9f5f..a97e9d488 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/DcaeReq.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 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. + * 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. - * See the License for the specific language governing permissions and + * + * 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. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,25 +23,26 @@ package org.onap.clamp.clds.client.req; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.IOException; +import java.util.List; + import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.refprop.RefProp; -import java.io.IOException; -import java.util.List; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Construct a DCAE request given CLDS objects. */ public class DcaeReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(DcaeReq.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * Format DCAE request. @@ -55,39 +56,38 @@ public class DcaeReq { */ public static String format(RefProp refProp, ModelProperties prop) throws IOException { Global globalProp = prop.getGlobal(); - String service = globalProp.getService(); - StringMatch smProp = prop.getStringMatch(); + StringMatch smProp = prop.getType(StringMatch.class); prop.setCurrentModelElementId(smProp.getId()); ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.template"); - // "properties":{ + // "properties":{ ObjectNode properties = rootNode.with("properties"); - // "service_name": + // "service_name": properties.put("service_name", globalProp.getService()); - // "service_ids":[ - List<String> service_ids = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService()); - JsonUtil.addArrayField(properties, "service_ids", service_ids); - // "vnf_ids":[ + // "service_ids":[ + List<String> serviceIds = refProp.decodeToList("dcae.decode.service_ids", globalProp.getService()); + JsonUtil.addArrayField(properties, "service_ids", serviceIds); + // "vnf_ids":[ JsonUtil.addArrayField(properties, "vnf_ids", globalProp.getResourceVf()); - // "location_ids":[ + // "location_ids":[ JsonUtil.addArrayField(properties, "location_ids", globalProp.getLocation()); - // "template":{ + // "template":{ ObjectNode template = rootNode.with("template"); - // "string_matching":{ - ObjectNode string_matching = template.with("string_matching"); - // "dcae":{ - ObjectNode dcae = string_matching.with("dcae"); + // "string_matching":{ + ObjectNode stringMatching = template.with("string_matching"); + // "dcae":{ + ObjectNode dcae = stringMatching.with("dcae"); dcae.put("inputTopic", smProp.getTopicSubscribes()); dcae.put("outputTopic", smProp.getTopicPublishes()); dcae.put("closedLoopControlName", prop.getControlName()); dcae.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - // "serviceConfigurations":[ - StringMatchPolicyReq.appendServiceConfigurations(refProp, service, dcae, smProp); + // "serviceConfigurations":[ + StringMatchPolicyReq.appendServiceConfigurations(refProp, globalProp.getService(), dcae, smProp, prop); String dcaeReq = rootNode.toString(); logger.info("dcaeReq=" + dcaeReq); diff --git a/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java b/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java index 6aba683bc..31bd4ca49 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java +++ b/src/main/java/org/onap/clamp/clds/client/req/JsonUtil.java @@ -41,8 +41,8 @@ public class JsonUtil { * @param node */ public static void addListToArrayNode(List<String> list, ArrayNode node) { - for (String aList : list) { - node.add(aList); + for (String aString : list) { + node.add(aString); } } diff --git a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java index 17e606133..41629cc11 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/OperationalPolicyReq.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 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. + * 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. - * See the License for the specific language governing permissions and + * + * 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. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,37 +23,47 @@ package org.onap.clamp.clds.client.req; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.jboss.resteasy.spi.BadRequestException; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; +import org.onap.clamp.clds.model.prop.PolicyChain; import org.onap.clamp.clds.model.prop.PolicyItem; -import org.onap.policy.controlloop.policy.TargetType; +import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.policy.controlloop.policy.OperationsAccumulateParams; +import org.onap.policy.api.AttributeType; +import org.onap.policy.asdc.Resource; +import org.onap.policy.asdc.ResourceType; +import org.onap.policy.asdc.Service; +import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.policy.Target; +import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.controlloop.policy.builder.BuilderException; import org.onap.policy.controlloop.policy.builder.ControlLoopPolicyBuilder; import org.onap.policy.controlloop.policy.builder.Message; import org.onap.policy.controlloop.policy.builder.Results; -import org.onap.policy.api.AttributeType; -import org.onap.policy.asdc.Resource; -import org.onap.policy.asdc.ResourceType; -import org.onap.policy.asdc.Service; -import org.onap.clamp.clds.model.refprop.RefProp; -import org.jboss.resteasy.spi.BadRequestException; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.*; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFLogger.Level; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Construct an Operational Policy request given CLDS objects. */ public class OperationalPolicyReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(OperationalPolicyReq.class.getName()); - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * Format Operational Policy attributes. @@ -64,29 +74,52 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - public static Map<AttributeType, Map<String, String>> formatAttributes(RefProp refProp, ModelProperties prop) throws BuilderException, UnsupportedEncodingException { + public static Map<AttributeType, Map<String, String>> formatAttributes(RefProp refProp, ModelProperties prop, + String modelElementId, PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { Global global = prop.getGlobal(); - Policy policy = prop.getPolicy(); - prop.setCurrentModelElementId(policy.getId()); - - String templateName = refProp.getStringValue("op.templateName", global.getService()); + prop.setCurrentModelElementId(modelElementId); + prop.setPolicyUniqueId(policyChain.getPolicyId()); + + String templateName = ""; + String operationTopic = ""; + String notificationTopic = ""; + String controller = ""; + Tca tca = prop.getTca(); + if (tca.isFound()) { + if (!global.getActionSet().equalsIgnoreCase("enbRecipe")) { + throw new BadRequestException( + "Operation Policy validation problem: action set is not selected properly."); + } + templateName = refProp.getStringValue("op.eNodeB.templateName", global.getService()); + operationTopic = refProp.getStringValue("op.eNodeB.operationTopic", global.getService()); + notificationTopic = refProp.getStringValue("op.eNodeB.notificationTopic", global.getService()); + controller = refProp.getStringValue("op.eNodeB.controller", global.getService()); + } else { + if (!global.getActionSet().equalsIgnoreCase("vnfRecipe")) { + throw new BadRequestException( + "Operation Policy validation problem: Action set is not selected properly."); + } + templateName = refProp.getStringValue("op.templateName", global.getService()); + operationTopic = refProp.getStringValue("op.operationTopic", global.getService()); + notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService()); + controller = refProp.getStringValue("op.controller", global.getService()); + } String recipeTopic = refProp.getStringValue("op.recipeTopic", global.getService()); - String operationTopic = refProp.getStringValue("op.operationTopic", global.getService()); - String notificationTopic = refProp.getStringValue("op.notificationTopic", global.getService()); // ruleAttributes - Map<String, String> ruleAttributes = new HashMap<>(); + Map<String, String> ruleAttributes = new HashMap<String, String>(); if (operationTopic == null || operationTopic.length() == 0) { 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 = policy.getPolicyItems().get(0); + // 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.getControlName()); + ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId()); ruleAttributes.put("RecipeTopic", recipeTopic); ruleAttributes.put("NotificationTopic", notificationTopic); @@ -105,10 +138,11 @@ public class OperationalPolicyReq { logger.info("notificationTopic=" + notificationTopic); // format yaml - String yaml = formatYaml(refProp, prop); + String yaml = tca.isFound() ? formateNodeBYaml(refProp, prop, modelElementId, policyChain) + : formatYaml(refProp, prop, modelElementId, policyChain); ruleAttributes.put("templateName", templateName); - ruleAttributes.put("ClosedLoopControlName", prop.getControlName()); + ruleAttributes.put("ClosedLoopControlName", prop.getControlNameAndPolicyUniqueId()); ruleAttributes.put("OperationTopic", operationTopic); ruleAttributes.put("NotificationTopic", notificationTopic); @@ -116,20 +150,16 @@ public class OperationalPolicyReq { } // matchingAttributes - String controller = refProp.getStringValue("op.controller", global.getService()); - - Map<String, String> matchingAttributes = new HashMap<>(); + Map<String, String> matchingAttributes = new HashMap<String, String>(); matchingAttributes.put("controller", controller); - Map<AttributeType, Map<String, String>> attributes = new HashMap<>(); + Map<AttributeType, Map<String, String>> attributes = new HashMap<AttributeType, Map<String, String>>(); attributes.put(AttributeType.RULE, ruleAttributes); attributes.put(AttributeType.MATCHING, matchingAttributes); - return attributes; } - /** * Format Operational Policy yaml. * @@ -139,53 +169,50 @@ public class OperationalPolicyReq { * @throws BuilderException * @throws UnsupportedEncodingException */ - private static String formatYaml(RefProp refProp, ModelProperties prop) throws BuilderException, UnsupportedEncodingException { + private static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId, + PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { + // get property objects Global global = prop.getGlobal(); - Policy policy = prop.getPolicy(); - prop.setCurrentModelElementId(policy.getId()); + prop.setCurrentModelElementId(modelElementId); + prop.setPolicyUniqueId(policyChain.getPolicyId()); - // convert values to ASDC objects + // convert values to SDC objects Service service = new Service(global.getService()); Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF); Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC); // create builder - ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), policy.getTimeout(), service, vfResources); + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), + policyChain.getTimeout(), service, vfResources); builder.addResource(vfcResources); // process each policy - HashMap<String, org.onap.policy.controlloop.policy.Policy> policyObjMap = new HashMap<>(); - List<PolicyItem> policyItemList = orderParentFirst(policy.getPolicyItems()); + HashMap<String, org.onap.policy.controlloop.policy.Policy> policyObjMap = new HashMap<String, org.onap.policy.controlloop.policy.Policy>(); + List<PolicyItem> policyItemList = orderParentFirst(policyChain.getPolicyItems()); + Target target = new Target(); + target.setType(TargetType.VM); for (int i = 0; i < policyItemList.size(); i++) { + org.onap.policy.controlloop.policy.Policy policyObj; PolicyItem policyItem = policyItemList.get(i); String policyName = policyItem.getRecipe() + " Policy"; if (i == 0) { - String policyDescription = policyItem.getRecipe() + " Policy - the trigger (no parent) policy - created by CLDS"; - policyObj = builder.setTriggerPolicy( - policyName, - policyDescription, - "APPC", - new Target(TargetType.VM), - policyItem.getRecipe(), - new HashMap<>(), //TODO To verify ! - policyItem.getMaxRetries(), - policyItem.getRetryTimeLimit()); + String policyDescription = policyItem.getRecipe() + + " Policy - the trigger (no parent) policy - created by CLDS"; + policyObj = builder.setTriggerPolicy(policyName, policyDescription, + refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null, + policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); } else { - org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap.get(policyItem.getParentPolicy()); - String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + parentPolicyObj.getName() + " - created by CLDS"; - policyObj = builder.setPolicyForPolicyResult( - policyName, - policyDescription, - "APPC", - new Target(TargetType.VM), - policyItem.getRecipe(), - new HashMap<>(), //TODO To verify ! - policyItem.getMaxRetries(), - policyItem.getRetryTimeLimit(), - parentPolicyObj.getId(), + org.onap.policy.controlloop.policy.Policy parentPolicyObj = policyObjMap + .get(policyItem.getParentPolicy()); + String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + + parentPolicyObj.getName() + " - created by CLDS"; + policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, + refProp.getStringValue("op.policy.appc"), target, policyItem.getRecipe(), null, + policyItem.getMaxRetries(), policyItem.getRetryTimeLimit(), parentPolicyObj.getId(), convertToPolicyResult(policyItem.getParentPolicyConditions())); + logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId()); } policyObjMap.put(policyItem.getId(), policyObj); @@ -199,7 +226,7 @@ public class OperationalPolicyReq { logger.info("results.getSpecification()=" + results.getSpecification()); } else { // throw exception with error info - StringBuilder sb = new StringBuilder(); + StringBuffer sb = new StringBuffer(); sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: "); for (Message message : results.getMessages()) { sb.append(message.getMessage()); @@ -207,11 +234,143 @@ public class OperationalPolicyReq { } throw new BadRequestException(sb.toString()); } - return URLEncoder.encode(results.getSpecification(), "UTF-8"); + + String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8"); + + return encodedYaml; } /** - * Order list of PolicyItems so that parents come before any of their children + * Format Operational Policy yaml. + * + * @param refProp + * @param prop + * @return + * @throws BuilderException + * @throws UnsupportedEncodingException + */ + private static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId, + PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException { + + // get property objects + Global global = prop.getGlobal(); + prop.setCurrentModelElementId(modelElementId); + prop.setPolicyUniqueId(policyChain.getPolicyId()); + + // convert values to SDC objects + Service service = new Service(global.getService()); + Resource[] vfResources = convertToResource(global.getResourceVf(), ResourceType.VF); + Resource[] vfcResources = convertToResource(global.getResourceVfc(), ResourceType.VFC); + + // create builder + ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(), + policyChain.getTimeout(), service, vfResources); + builder.addResource(vfcResources); + + // process each policy + HashMap<String, Policy> policyObjMap = new HashMap<String, Policy>(); + List<PolicyItem> policyItemList = addAOTSActorRecipe(refProp, global.getService(), + policyChain.getPolicyItems()); + Target target = new Target(); + target.setType(TargetType.VM); + Policy lastPolicyObj = new Policy(); + for (int i = 0; i < policyItemList.size(); i++) { + org.onap.policy.controlloop.policy.Policy policyObj; + PolicyItem policyItem = policyItemList.get(i); + 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>(); + payloadMap.put("timeWindow", refProp.getStringValue("op.eNodeB.timeWindow")); + String policyDescription = policyItem.getRecipe() + + " Policy - the trigger (no parent) policy - created by CLDS"; + policyObj = builder.setTriggerPolicy(policyName, policyDescription, policyItem.getActor(), target, + policyItem.getRecipe(), payloadMap, policyItem.getMaxRetries(), policyItem.getRetryTimeLimit()); + } else { + Policy parentPolicyObj = policyObjMap + .get(policyItem.getParentPolicy()); + String policyDescription = policyItem.getRecipe() + " Policy - triggered conditionally by " + + parentPolicyObj.getName() + " - created by CLDS"; + policyObj = builder.setPolicyForPolicyResult(policyName, policyDescription, policyItem.getActor(), + target, policyItem.getRecipe(), null, policyItem.getMaxRetries(), + policyItem.getRetryTimeLimit(), parentPolicyObj.getId(), + convertToPolicyResult(policyItem.getParentPolicyConditions())); + lastPolicyObj = policyObj; + logger.info("policyObj.id=" + policyObj.getId() + "; parentPolicyObj.id=" + parentPolicyObj.getId()); + } + policyObjMap.put(policyItem.getId(), policyObj); + } + //To set up operations accumulate params + OperationsAccumulateParams operationsAccumulateParams = new OperationsAccumulateParams(); + 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(); + if (results.isValid()) { + logger.info("results.getSpecification()=" + results.getSpecification()); + } else { + // throw exception with error info + StringBuffer sb = new StringBuffer(); + 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()); + } + + String encodedYaml = URLEncoder.encode(results.getSpecification(), "UTF-8"); + + return encodedYaml; + } + + /** + * Adding AOTS actor and other recipe for yaml + * + * @param inOrigList + * @return + */ + private static List<PolicyItem> addAOTSActorRecipe(RefProp refProp, String service, List<PolicyItem> inOrigList) { + List<PolicyItem> outList = new ArrayList<PolicyItem>(); + try { + PolicyItem policyItem = inOrigList.get(0); + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("op.eNodeB.recipe", service); + Iterator<JsonNode> itr = rootNode.get("eNodeBRecipes").elements(); + while (itr.hasNext()) { + PolicyItem policyItemObj = (PolicyItem) policyItem.clone(); + JsonNode recipeNode = itr.next(); + policyItemObj.setId(recipeNode.path("Recipe").asText()); + policyItemObj.setActor(recipeNode.path("Actor").asText()); + policyItemObj.setRecipe(recipeNode.path("Recipe").asText()); + policyItemObj.setParentPolicy(recipeNode.path("ParentPolicy").asText()); + if (!recipeNode.path("Retry").asText().isEmpty()) { + policyItemObj.setMaxRetries(Integer.parseInt(recipeNode.path("Retry").asText())); + } + if (!recipeNode.path("TimeLimit").asText().isEmpty()) { + policyItemObj.setRetryTimeLimit(Integer.parseInt(recipeNode.path("TimeLimit").asText())); + } + if (!recipeNode.path("PPConditions").asText().isEmpty()) { + List<String> parentPolicyConditions = new ArrayList<String>(); + for (String ppCondition : recipeNode.path("PPConditions").asText().split(",")) { + parentPolicyConditions.add(ppCondition); + } + policyItemObj.setParentPolicyConditions(parentPolicyConditions); + } + outList.add(policyItemObj); + } + } catch (Exception e) { + logger.log(Level.ERROR, "Error", e); + } + return outList; + } + + /** + * Order list of PolicyItems so that parents come before any of their + * children * * @param inOrigList * @return @@ -222,12 +381,14 @@ public class OperationalPolicyReq { List<PolicyItem> outList = new ArrayList<>(); int prevSize = 0; while (!inList.isEmpty()) { - // check if there's a loop in the policy chain (the inList should have been reduced by at least one) + // check if there's a loop in the policy chain (the inList should + // have been reduced by at least one) if (inList.size() == prevSize) { throw new BadRequestException("Operation Policy validation problem: loop in Operation Policy chain"); } prevSize = inList.size(); - // the following loop should remove at least one PolicyItem from the inList + // the following loop should remove at least one PolicyItem from the + // inList Iterator<PolicyItem> inListItr = inList.iterator(); while (inListItr.hasNext()) { PolicyItem inItem = inListItr.next(); @@ -235,7 +396,8 @@ public class OperationalPolicyReq { String parent = inItem.getParentPolicy(); if (parent == null || parent.length() == 0) { if (outList.size() > 0) { - throw new BadRequestException("Operation Policy validation problem: more than one trigger policy"); + throw new BadRequestException( + "Operation Policy validation problem: more than one trigger policy"); } else { outList.add(inItem); inListItr.remove(); @@ -244,7 +406,8 @@ public class OperationalPolicyReq { // check if this PolicyItem's parent has been processed for (PolicyItem outItem : outList) { if (outItem.getId().equals(parent)) { - // if the inItem parent is already in the outList, then add inItem to outList and remove from inList + // if the inItem parent is already in the outList, + // then add inItem to outList and remove from inList outList.add(inItem); inListItr.remove(); break; @@ -256,29 +419,29 @@ public class OperationalPolicyReq { return outList; } - /** * Convert a List of resource strings to an array of Resource objects. * - * @param rList + * @param stringList * @param resourceType * @return */ - private static Resource[] convertToResource(List<String> rList, ResourceType resourceType) { + private static Resource[] convertToResource(List<String> stringList, ResourceType resourceType) { int size = 0; - if (rList != null) { - size = rList.size(); + if (stringList != null) { + size = stringList.size(); } - Resource[] rArray = new Resource[size]; + Resource[] resourceArray = new Resource[size]; for (int i = 0; i < size; i++) { - String rString = rList.get(i); - rArray[i] = new Resource(rString, resourceType); + String rString = stringList.get(i); + resourceArray[i] = new Resource(rString, resourceType); } - return rArray; + return resourceArray; } /** - * Convert a List of policy result strings to an array of PolicyResult objects. + * Convert a List of policy result strings to an array of PolicyResult + * objects. * * @param prList * @return @@ -296,4 +459,4 @@ public class OperationalPolicyReq { return prArray; } -} +}
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java index 0f66cd9ba..5884c3dd2 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/StringMatchPolicyReq.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 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. + * 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. - * See the License for the specific language governing permissions and + * + * 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. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -23,26 +23,28 @@ package org.onap.clamp.clds.client.req; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import java.io.IOException; +import java.util.Iterator; +import java.util.Map.Entry; + import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.prop.ResourceGroup; import org.onap.clamp.clds.model.prop.ServiceConfiguration; import org.onap.clamp.clds.model.prop.StringMatch; import org.onap.clamp.clds.model.refprop.RefProp; -import java.io.IOException; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.logging.Logger; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; /** * Construct a Policy for String Match Micro Service request given CLDS objects. */ public class StringMatchPolicyReq { - // currently uses the java.util.logging.Logger like the Camunda engine - private static final Logger logger = Logger.getLogger(StringMatchPolicyReq.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(StringMatchPolicyReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); /** * Format Policy String Match request. @@ -56,21 +58,12 @@ public class StringMatchPolicyReq { Global global = prop.getGlobal(); String service = global.getService(); - StringMatch sm = prop.getStringMatch(); + StringMatch sm = prop.getType(StringMatch.class); prop.setCurrentModelElementId(sm.getId()); ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("sm.template", service); - - // "policyName": rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - - // "content":{ ObjectNode content = rootNode.with("content"); - - // "closedLoopControlName": - content.put("closedLoopControlName", prop.getControlName()); - - // "serviceConfigurations":[ - appendServiceConfigurations(refProp, service, content, sm); + appendServiceConfigurations(refProp, service, content, sm, prop); String stringMatchPolicyReq = rootNode.toString(); logger.info("stringMatchPolicyReq=" + stringMatchPolicyReq); @@ -84,55 +77,63 @@ public class StringMatchPolicyReq { * @param sm * @throws IOException */ - public static void appendServiceConfigurations(RefProp refProp, String service, ObjectNode appendToNode, StringMatch sm) throws IOException { - // "serviceConfigurations":{ + public static void appendServiceConfigurations(RefProp refProp, String service, ObjectNode appendToNode, + StringMatch sm, ModelProperties prop) throws IOException { + // "serviceConfigurations":{ ObjectNode scNodes = appendToNode.with("serviceConfigurations"); - Iterator<ServiceConfiguration> scItr = sm.getServiceConfigurations().iterator(); int index = 0; - while (scItr.hasNext()) { - ServiceConfiguration sc = scItr.next(); - - //"ItemX":{ - index++; - String keyValue = "Item" + index; - ObjectNode scNode = (ObjectNode) refProp.getJsonTemplate("sm.sc.template", service); - scNodes.set(keyValue, scNode); - - // "rulegroup":"abc", - String rulegroupInd = refProp.getStringValue("sm.rulegroup", service); - String groupNumber = sc.getGroupNumber(); - if (rulegroupInd != null && rulegroupInd.equalsIgnoreCase("true") && groupNumber != null && groupNumber.length() > 0) { - - //String rulegroup = (sc.getResourceVf() == null ? "" : String.join(" ", sc.getResourceVf())) + " - " + (sc.getResourceVfc() == null ? "" : String.join(" ", sc.getResourceVfc())); - scNode.put("rulegroup", groupNumber); - } - - // "aaiMatchingFields" : ["VM_NAME"], - JsonUtil.addArrayField(scNode, "aaiMatchingFields", sc.getaaiMatchingFields()); - // "aaiSendFields" : ["VMID", "TenantID"], - JsonUtil.addArrayField(scNode, "aaiSendFields", sc.getaaiSendFields()); - - // "stringSet": [ - ArrayNode ssNode = scNode.putArray("stringSet"); - // ObjectNode ssNode = scNode.with("stringSet"); - for (Entry<String, String> entry : sc.getStringSet().entrySet()) { - // exclude eventSourceType - if (!entry.getKey().equals("eventSourceType")) { - ssNode.add(entry.getKey()); - ssNode.add(entry.getValue()); + if (sm != null && sm.getResourceGroups() != null) { + for (ResourceGroup resourceGroup : sm.getResourceGroups()) { + Iterator<ServiceConfiguration> scItr = resourceGroup.getServiceConfigurations().iterator(); + + while (scItr.hasNext()) { + ServiceConfiguration sc = scItr.next(); + + // "ItemX":{ + index++; + String keyValue = "Item" + index; + ObjectNode scNode = (ObjectNode) refProp.getJsonTemplate("sm.sc.template", service); + scNodes.set(keyValue, scNode); + + // "rulegroup":"abc", + String rulegroupInd = refProp.getStringValue("sm.rulegroup", service); + String groupNumber = resourceGroup.getGroupNumber(); + if (rulegroupInd != null && rulegroupInd.equalsIgnoreCase("true") && groupNumber != null + && groupNumber.length() > 0) { + scNode.put("rulegroup", groupNumber); + } + + // "closedLoopControlName": + prop.setPolicyUniqueId(resourceGroup.getPolicyId()); + scNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); + + // "aaiMatchingFields" : ["VM_NAME"], + JsonUtil.addArrayField(scNode, "aaiMatchingFields", sc.getaaiMatchingFields()); + // "aaiSendFields" : ["VMID", "TenantID"], + JsonUtil.addArrayField(scNode, "aaiSendFields", sc.getaaiSendFields()); + + // "stringSet": [ + ArrayNode ssNode = scNode.putArray("stringSet"); + + for (Entry<String, String> entry : sc.getStringSet().entrySet()) { + // exclude eventSourceType + if (!entry.getKey().equals("eventSourceType")) { + ssNode.add(entry.getKey()); + ssNode.add(entry.getValue()); + } + } + + // timeWindow": "0", + scNode.put("timeWindow", sc.getTimeWindow()); + // "ageLimit": "3600", + scNode.put("ageLimit", sc.getAgeLimit()); + // "createClosedLoopEventId" : "Initial", + scNode.put("createClosedLoopEventId", sc.getCreateClosedLoopEventId()); + // "outputEventName": "OnSet" + scNode.put("outputEventName", sc.getOutputEventName()); } } - - // timeWindow": "0", - scNode.put("timeWindow", sc.getTimeWindow()); - // "ageLimit": "3600", - scNode.put("ageLimit", sc.getAgeLimit()); - // "createClosedLoopEventId" : "Initial", - scNode.put("createClosedLoopEventId", sc.getCreateClosedLoopEventId()); - // "outputEventName": "OnSet" - scNode.put("outputEventName", sc.getOutputEventName()); } } - } diff --git a/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java index f8acb64f6..f31062893 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/TcaMPolicyReq.java @@ -1,8 +1,30 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017 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. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + package org.onap.clamp.clds.client.req; import java.io.IOException; import java.util.Iterator; -import java.util.logging.Logger; import org.onap.clamp.clds.model.prop.Global; import org.onap.clamp.clds.model.prop.ModelProperties; @@ -10,84 +32,90 @@ import org.onap.clamp.clds.model.prop.Tca; import org.onap.clamp.clds.model.prop.TcaItem; import org.onap.clamp.clds.model.prop.TcaThreshhold; import org.onap.clamp.clds.model.refprop.RefProp; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; /** - * Construct a Policy for Tca/MTca Service request given CLDS objects. - * + * Construct a Policy for Tca/MTca Service request given CLDS objects. + * * */ public class TcaMPolicyReq { - private static final Logger logger = Logger.getLogger(StringMatchPolicyReq.class.getName()); - - /** - * Format Tca Policy request - * - * @param refProp - * @param prop - * @return - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public static String formatTca(RefProp refProp, ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { - Global global = prop.getGlobal(); - String service = global.getService(); - - Tca tca = prop.getTca(); - prop.setCurrentModelElementId(tca.getId()); - ObjectNode rootNode = (ObjectNode)refProp.getJsonTemplate("tca.template", service); - rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); - ObjectNode content = rootNode.with("content"); - appendSignatures(refProp, service, content, tca, prop); - - String tcaPolicyReq = rootNode.toString(); - logger.info("tcaPolicyReq=" + tcaPolicyReq); - return tcaPolicyReq; - } - - /** - * Add appendSignatures to json - * - * @param refProp - * @param service - * @param appendToNode - * @param tca - * @param prop - * @throws JsonParseException - * @throws JsonMappingException - * @throws IOException - */ - public static void appendSignatures(RefProp refProp, String service, ObjectNode appendToNode, Tca tca, ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { - // "signatures":{ - ArrayNode tcaNodes = appendToNode.withArray("signatures"); - for(TcaItem tcaItem : tca.getTcaItems()){ - ObjectNode tcaNode = (ObjectNode)refProp.getJsonTemplate("tca.signature.template", service); - tcaNode.put("useCaseName", tcaItem.getTcaName()); - tcaNode.put("signatureName", tcaItem.getTcaName()+ "_" + tcaItem.getTcaUuId()); - tcaNode.put("signatureUuid", tcaItem.getTcaUuId()); - prop.setPolicyUniqueId(tcaItem.getPolicyId()); - tcaNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); - tcaNode.put("severity", tcaItem.getSeverity()); - tcaNode.put("maxInterval", tcaItem.getInterval()); - tcaNode.put("minMessageViolations", tcaItem.getViolations()); - - tcaNodes.add(tcaNode); - Iterator<TcaThreshhold> scItr = tcaItem.getTcaThreshholds().iterator(); - while(scItr.hasNext()) { - TcaThreshhold tcaThreshhold = scItr.next(); - // "thresholds": [ - ArrayNode thNodes = tcaNode.withArray("thresholds"); - ObjectNode thNode = thNodes.addObject(); - thNode.put("fieldPath", tcaThreshhold.getFieldPath()); - thNode.put("thresholdName", tcaThreshhold.getMetric()); - thNode.put("thresholdValue", tcaThreshhold.getThreshhold()); - thNode.put("direction", tcaThreshhold.getOperator()); - } - } + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaMPolicyReq.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + + /** + * Format Tca Policy request + * + * @param refProp + * @param prop + * @return + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static String formatTca(RefProp refProp, ModelProperties prop) + throws JsonParseException, JsonMappingException, IOException { + Global global = prop.getGlobal(); + String service = global.getService(); + + Tca tca = prop.getType(Tca.class); + prop.setCurrentModelElementId(tca.getId()); + ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.template", service); + rootNode.put("policyName", prop.getCurrentPolicyScopeAndPolicyName()); + ObjectNode content = rootNode.with("content"); + appendSignatures(refProp, service, content, tca, prop); + + String tcaPolicyReq = rootNode.toString(); + logger.info("tcaPolicyReq=" + tcaPolicyReq); + return tcaPolicyReq; + } + + /** + * Add appendSignatures to json + * + * @param refProp + * @param service + * @param appendToNode + * @param tca + * @param prop + * @throws JsonParseException + * @throws JsonMappingException + * @throws IOException + */ + public static void appendSignatures(RefProp refProp, String service, ObjectNode appendToNode, Tca tca, + ModelProperties prop) throws JsonParseException, JsonMappingException, IOException { + // "signatures":{ + ArrayNode tcaNodes = appendToNode.withArray("signatures"); + for (TcaItem tcaItem : tca.getTcaItems()) { + ObjectNode tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.signature.template", service); + tcaNode.put("useCaseName", tcaItem.getTcaName()); + tcaNode.put("signatureName", tcaItem.getTcaName() + "_" + tcaItem.getTcaUuId()); + tcaNode.put("signatureUuid", tcaItem.getTcaUuId()); + prop.setPolicyUniqueId(tcaItem.getPolicyId()); + tcaNode.put("closedLoopControlName", prop.getControlNameAndPolicyUniqueId()); + tcaNode.put("severity", tcaItem.getSeverity()); + tcaNode.put("maxInterval", tcaItem.getInterval()); + tcaNode.put("minMessageViolations", tcaItem.getViolations()); + + tcaNodes.add(tcaNode); + Iterator<TcaThreshhold> scItr = tcaItem.getTcaThreshholds().iterator(); + while (scItr.hasNext()) { + TcaThreshhold tcaThreshhold = scItr.next(); + // "thresholds": [ + ArrayNode thNodes = tcaNode.withArray("thresholds"); + ObjectNode thNode = thNodes.addObject(); + thNode.put("fieldPath", tcaThreshhold.getFieldPath()); + thNode.put("thresholdName", tcaThreshhold.getMetric()); + thNode.put("thresholdValue", tcaThreshhold.getThreshhold()); + thNode.put("direction", tcaThreshhold.getOperator()); + } } + } }
\ No newline at end of file diff --git a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java index 244b40aa1..a411151a1 100644 --- a/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java +++ b/src/main/java/org/onap/clamp/clds/config/CamundaAuthFilterInitializer.java @@ -5,16 +5,16 @@ * Copyright (C) 2017 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. + * 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. - * See the License for the specific language governing permissions and + * + * 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. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -25,7 +25,6 @@ package org.onap.clamp.clds.config; import java.util.EnumSet; import java.util.Map; -import java.util.logging.Logger; import javax.servlet.DispatcherType; import javax.servlet.Filter; @@ -35,53 +34,57 @@ import javax.servlet.ServletException; import org.camunda.bpm.spring.boot.starter.CamundaBpmAutoConfiguration; import org.camunda.bpm.webapp.impl.security.auth.AuthenticationFilter; +import org.onap.clamp.clds.client.SdcCatalogServices; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.context.annotation.Configuration; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + @Configuration @ConditionalOnWebApplication @AutoConfigureAfter(CamundaBpmAutoConfiguration.class) public class CamundaAuthFilterInitializer implements ServletContextInitializer { - private static final EnumSet<DispatcherType> DISPATCHER_TYPES = EnumSet.of(DispatcherType.REQUEST); - - private static final String AJSC_CADI_PROPS_FILE = "cadi.properties"; + private static final EnumSet<DispatcherType> DISPATCHER_TYPES = EnumSet.of(DispatcherType.REQUEST); - private ServletContext servletContext; + private ServletContext servletContext; - @Value("${com.att.ajsc.camunda.contextPath:/camunda}") - private String CAMUNDA_SUFFIX; + @Value("${com.att.ajsc.camunda.contextPath:/camunda}") + private String camundaSuffix; - private static final Logger log = Logger.getLogger(CamundaAuthFilterInitializer.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(SdcCatalogServices.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - this.servletContext = servletContext; + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + this.servletContext = servletContext; - registerFilter("Authentication Filter", AuthenticationFilter.class, CAMUNDA_SUFFIX + "/*"); - } + registerFilter("Authentication Filter", AuthenticationFilter.class, camundaSuffix + "/*"); + } - private FilterRegistration registerFilter(final String filterName, final Class<? extends Filter> filterClass, - final String... urlPatterns) { - return registerFilter(filterName, filterClass, null, urlPatterns); - } + private FilterRegistration registerFilter(final String filterName, final Class<? extends Filter> filterClass, + final String... urlPatterns) { + return registerFilter(filterName, filterClass, null, urlPatterns); + } - private FilterRegistration registerFilter(final String filterName, final Class<? extends Filter> filterClass, - final Map<String, String> initParameters, final String... urlPatterns) { - FilterRegistration filterRegistration = servletContext.getFilterRegistration(filterName); + private FilterRegistration registerFilter(final String filterName, final Class<? extends Filter> filterClass, + final Map<String, String> initParameters, final String... urlPatterns) { + FilterRegistration filterRegistration = servletContext.getFilterRegistration(filterName); - if (filterRegistration == null) { - filterRegistration = servletContext.addFilter(filterName, filterClass); - filterRegistration.addMappingForUrlPatterns(DISPATCHER_TYPES, true, urlPatterns); + if (filterRegistration == null) { + filterRegistration = servletContext.addFilter(filterName, filterClass); + filterRegistration.addMappingForUrlPatterns(DISPATCHER_TYPES, true, urlPatterns); - if (initParameters != null) { - filterRegistration.setInitParameters(initParameters); - } - } + if (initParameters != null) { + filterRegistration.setInitParameters(initParameters); + } + } - return filterRegistration; - } + return filterRegistration; + } } diff --git a/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java index 949f4ea62..a27cc69ba 100644 --- a/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CamundaEngineConfiguration.java @@ -23,14 +23,14 @@ package org.onap.clamp.clds.config; +import javax.sql.DataSource; + import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import javax.sql.DataSource; - @Configuration public class CamundaEngineConfiguration { @@ -39,11 +39,9 @@ public class CamundaEngineConfiguration { */ @Primary @Bean(name = "camundaBpmDataSource") - @ConfigurationProperties(prefix = "spring.datasource") + @ConfigurationProperties(prefix = "spring.datasource.camunda") public DataSource dataSource() { - return DataSourceBuilder - .create() - .build(); + return DataSourceBuilder.create().build(); } } |