diff options
Diffstat (limited to 'src')
17 files changed, 778 insertions, 59 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java b/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java index 02e2dd0b6..b3fcb6f18 100644 --- a/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java +++ b/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java @@ -25,17 +25,28 @@ package org.onap.clamp.clds.client; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + import java.util.ArrayList; +import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.builder.ExchangeBuilder; +import org.json.simple.parser.ParseException; import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; +import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelId; import org.onap.clamp.loop.template.PolicyModelsService; +import org.onap.clamp.policy.pdpgroup.PdpGroup; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.yaml.snakeyaml.Yaml; @@ -53,11 +64,9 @@ import org.yaml.snakeyaml.Yaml; public class PolicyEngineServices { private final CamelContext camelContext; - private final PolicyModelsService policyModelsSService; + private final PolicyModelsService policyModelsService; private static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyEngineServices.class); - private static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); private static int retryInterval = 0; private static int retryLimit = 1; @@ -70,12 +79,13 @@ public class PolicyEngineServices { * @param camelContext Camel context bean * @param clampProperties ClampProperties bean * @param policyModelsSService policyModel repository bean + * @param policyModelsService policyModel service */ @Autowired public PolicyEngineServices(CamelContext camelContext, ClampProperties clampProperties, PolicyModelsService policyModelsSService) { this.camelContext = camelContext; - this.policyModelsSService = policyModelsSService; + this.policyModelsService = policyModelsSService; if (clampProperties.getStringValue(POLICY_RETRY_LIMIT) != null) { retryLimit = Integer.parseInt(clampProperties.getStringValue(POLICY_RETRY_LIMIT)); } @@ -122,7 +132,7 @@ public class PolicyEngineServices { policyTypesList.parallelStream().forEach(policyType -> { Map.Entry<String, Object> policyTypeEntry = (Map.Entry<String, Object>) new ArrayList(policyType.entrySet()).get(0); - policyModelsSService.createPolicyInDbIfNeeded( + policyModelsService.createPolicyInDbIfNeeded( createPolicyModelFromPolicyEngine(policyTypeEntry.getKey(), ((String) ((LinkedHashMap<String, Object>) policyTypeEntry.getValue()).get("version")))); }); @@ -135,7 +145,7 @@ public class PolicyEngineServices { * @return A yaml containing all policy Types and all data types */ public String downloadAllPolicies() { - return callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-policy-models"); + return callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-policy-models", "Get all policies"); } /** @@ -147,16 +157,43 @@ public class PolicyEngineServices { */ public String downloadOnePolicy(String policyType, String policyVersion) { return callCamelRoute(ExchangeBuilder.anExchange(camelContext).withProperty("policyModelName", policyType) - .withProperty("policyModelVersion", policyVersion).build(), "direct:get-policy-model"); + .withProperty("policyModelVersion", policyVersion).build(), "direct:get-policy-model", "Get one policy"); + } + + /** + * This method can be used to download all Pdp Groups data from policy engine. + * + */ + public void downloadPdpGroups() { + String responseBody = callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-pdp-groups", "Get Pdp Groups"); + + if (responseBody == null || responseBody.isEmpty()) { + logger.warn("getPdpGroups returned by policy engine could not be decoded, as it's null or empty"); + return; + } + + JsonObject jsonObj = JsonUtils.GSON.fromJson(responseBody, JsonObject.class); + + List<PdpGroup> pdpGroupList = new LinkedList<>(); + JsonArray itemsArray = (JsonArray) jsonObj.get("groups"); + + Iterator it = itemsArray.iterator(); + while (it.hasNext()) { + JsonObject item = (JsonObject) it.next(); + PdpGroup pdpGroup = JsonUtils.GSON.fromJson(item.toString(), PdpGroup.class); + pdpGroupList.add(pdpGroup); + } + + policyModelsService.updatePdpGroupInfo(pdpGroupList); } - private String callCamelRoute(Exchange exchange, String camelFlow) { + private String callCamelRoute(Exchange exchange, String camelFlow, String logMsg) { for (int i = 0; i < retryLimit; i++) { Exchange exchangeResponse = camelContext.createProducerTemplate().send(camelFlow, exchange); if (Integer.valueOf(200).equals(exchangeResponse.getIn().getHeader("CamelHttpResponseCode"))) { return (String) exchangeResponse.getIn().getBody(); } else { - logger.info("Policy query " + retryInterval + "ms before retrying ..."); + logger.info(logMsg + " query " + retryInterval + "ms before retrying ..."); // wait for a while and try to connect to DCAE again try { Thread.sleep(retryInterval); diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java index fd0110c79..7334eceb8 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java @@ -23,6 +23,7 @@ package org.onap.clamp.loop.template; +import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; import java.io.Serializable; import java.util.HashSet; @@ -34,6 +35,11 @@ import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.ManyToMany; import javax.persistence.Table; + +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; +import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.common.AuditEntity; import org.onap.clamp.util.SemanticVersioning; @@ -44,6 +50,7 @@ import org.onap.clamp.util.SemanticVersioning; @Entity @Table(name = "policy_models") @IdClass(PolicyModelId.class) +@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)}) public class PolicyModel extends AuditEntity implements Serializable, Comparable<PolicyModel> { /** @@ -78,6 +85,10 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable @ManyToMany(mappedBy = "policyModels", fetch = FetchType.EAGER) private Set<LoopElementModel> usedByElementModels = new HashSet<>(); + @Type(type = "json") + @Column(columnDefinition = "json", name = "policy_pdp_group") + private JsonObject policyPdpGroup; + /** * usedByElementModels getter. * @@ -88,6 +99,24 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable } /** + * policyPdpGroup getter. + * + * @return the policyPdpGroup + */ + public JsonObject getPolicyPdpGroup() { + return policyPdpGroup; + } + + /** + * policyPdpGroup setter. + * + * @param policyPdpGroup the policyPdpGroup to set + */ + public void setPolicyPdpGroup(JsonObject policyPdpGroup) { + this.policyPdpGroup = policyPdpGroup; + } + + /** * policyModelTosca getter. * * @return the policyModelTosca diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java index eb83c6608..b38be942e 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModelsService.java @@ -23,12 +23,14 @@ package org.onap.clamp.loop.template; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.onap.clamp.clds.tosca.ToscaSchemaConstants; import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; +import org.onap.clamp.policy.pdpgroup.PdpGroup; import org.onap.clamp.util.SemanticVersioning; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -47,13 +49,30 @@ public class PolicyModelsService { toscaYamlToJsonConvertor = convertor; } + /** + * Save or Update Policy Model. + * + * @param policyModel + * The policyModel + * @return The Policy Model + */ public PolicyModel saveOrUpdatePolicyModel(PolicyModel policyModel) { return policyModelsRepository.save(policyModel); } /** - * Creates the Tosca Policy Model from a policy tosca file, - * if the same type already exists in database, it increases the version automatically. + * Verify whether Policy Model exist by ID. + * + * @param policyModelId + * The policyModel Id + * @return The flag indicates whether Policy Model exist + */ + public boolean existsById(PolicyModelId policyModelId) { + return policyModelsRepository.existsById(policyModelId); + } + + /** + * Creates or updates the Tosca Policy Model. * * @param policyModelType The policyModeltype in Tosca yaml * @param policyModelTosca The Policymodel object @@ -137,4 +156,30 @@ public class PolicyModelsService { policyModelsRepository.save(policyModel); } } + + /** + * Update the Pdp Group info in Policy Model DB. + * + * @param pdpGroupList The list of Pdp Group info received from Policy Engine + */ + public void updatePdpGroupInfo(List<PdpGroup> pdpGroupList) { + List<PolicyModel> policyModelList = policyModelsRepository.findAll(); + for (PolicyModel policyModel : policyModelList) { + JsonArray supportedPdpGroups = new JsonArray(); + for (PdpGroup pdpGroup : pdpGroupList) { + JsonObject supportedPdpGroup = pdpGroup.getSupportedSubgroups(policyModel.getPolicyModelType(), + policyModel.getVersion()); + if (supportedPdpGroup != null) { + supportedPdpGroups.add(supportedPdpGroup); + } + } + + if (supportedPdpGroups.size() > 0) { + JsonObject supportedPdpJson = new JsonObject (); + supportedPdpJson.add("supportedPdpGroups", supportedPdpGroups); + policyModel.setPolicyPdpGroup(supportedPdpJson); + policyModelsRepository.save(policyModel); + } + } + } } diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java index e1c08eeaa..cce9e567f 100644 --- a/src/main/java/org/onap/clamp/policy/Policy.java +++ b/src/main/java/org/onap/clamp/policy/Policy.java @@ -68,6 +68,10 @@ public abstract class Policy extends AuditEntity { @Column(name = "pdp_group") private String pdpGroup; + @Expose + @Column(name = "pdp_sub_group") + private String pdpSubGroup; + public abstract String createPolicyPayload() throws UnsupportedEncodingException; /** @@ -155,6 +159,24 @@ public abstract class Policy extends AuditEntity { } /** + * pdpSubGroup getter. + * + * @return the pdpSubGroup + */ + public String getPdpSubGroup() { + return pdpSubGroup; + } + + /** + * pdpSubGroup setter. + * + * @param pdpSubGroup the pdpSubGroup to set + */ + public void setPdpSubGroup(String pdpSubGroup) { + this.pdpSubGroup = pdpSubGroup; + } + + /** * Generate the policy name. * * @param policyType The policy type diff --git a/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java b/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java index bd20eccb6..ac054d8af 100644 --- a/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java +++ b/src/main/java/org/onap/clamp/policy/downloader/PolicyEngineController.java @@ -28,6 +28,7 @@ import com.att.eelf.configuration.EELFManager; import java.time.Instant; +import org.json.simple.parser.ParseException; import org.onap.clamp.clds.client.PolicyEngineServices; import org.onap.clamp.loop.template.PolicyModelsRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -70,5 +71,8 @@ public class PolicyEngineController { return lastInstantExecuted; } - + @Scheduled(fixedRate = 300000) + public synchronized void downloadPdpGroups() throws ParseException { + policyEngineServices.downloadPdpGroups(); + } } diff --git a/src/main/java/org/onap/clamp/policy/pdpgroup/PdpGroup.java b/src/main/java/org/onap/clamp/policy/pdpgroup/PdpGroup.java new file mode 100644 index 000000000..a3cf4e053 --- /dev/null +++ b/src/main/java/org/onap/clamp/policy/pdpgroup/PdpGroup.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.policy.pdpgroup; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.annotations.Expose; + +import java.util.List; + +/** + * This class maps the get Pdp Group response to a nice pojo. + */ +public class PdpGroup { + + @Expose + private String name; + + @Expose + private String pdpGroupState; + + @Expose + private List<PdpSubgroup> pdpSubgroups; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPdpGroupState() { + return pdpGroupState; + } + + public void setPdpGroupState(String pdpGroupState) { + this.pdpGroupState = pdpGroupState; + } + + public List<PdpSubgroup> getPdpSubgroups() { + return pdpSubgroups; + } + + public void setPdpSubgroups(List<PdpSubgroup> pdpSubgroups) { + this.pdpSubgroups = pdpSubgroups; + } + + /** + * Get supported subGroups based on the defined policy type and version. + * @param policyType The policy type + * @param version The version + * @return The supported subGroup list in Json format + */ + public JsonObject getSupportedSubgroups(String policyType, String version) { + if (!pdpGroupState.equalsIgnoreCase("ACTIVE")) { + return null; + } + JsonArray supportedSubgroups = new JsonArray(); + for (PdpSubgroup subGroup : pdpSubgroups) { + if (subGroup.getSupportedPolicyTypes().contains(new PolicyModelKey(policyType, version))) { + supportedSubgroups.add(subGroup.getPdpType()); + } + } + if (supportedSubgroups.size() > 0) { + JsonObject supportedPdpGroup = new JsonObject(); + supportedPdpGroup.add(this.name, supportedSubgroups); + return supportedPdpGroup; + } + return null; + } +} diff --git a/src/main/java/org/onap/clamp/policy/pdpgroup/PdpSubgroup.java b/src/main/java/org/onap/clamp/policy/pdpgroup/PdpSubgroup.java new file mode 100644 index 000000000..28de79abf --- /dev/null +++ b/src/main/java/org/onap/clamp/policy/pdpgroup/PdpSubgroup.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.policy.pdpgroup; + +import com.google.gson.annotations.Expose; +import java.util.List; + +/** + * This class maps the Policy get PDP Group response to a nice pojo. + */ +public class PdpSubgroup { + + @Expose + private String pdpType; + + @Expose + private List<PolicyModelKey> supportedPolicyTypes; + + public String getPdpType() { + return pdpType; + } + + public void setPdpType(String pdpType) { + this.pdpType = pdpType; + } + + public List<PolicyModelKey> getSupportedPolicyTypes() { + return supportedPolicyTypes; + } + + public void setSupportedPolicyTypes(List<PolicyModelKey> supportedPolicyTypes) { + this.supportedPolicyTypes = supportedPolicyTypes; + } + +} diff --git a/src/main/java/org/onap/clamp/policy/pdpgroup/PolicyModelKey.java b/src/main/java/org/onap/clamp/policy/pdpgroup/PolicyModelKey.java new file mode 100644 index 000000000..707b3bd2f --- /dev/null +++ b/src/main/java/org/onap/clamp/policy/pdpgroup/PolicyModelKey.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.policy.pdpgroup; + +import com.google.gson.annotations.Expose; + +import java.io.Serializable; + +public class PolicyModelKey implements Serializable { + + /** + * The serial version ID. + */ + private static final long serialVersionUID = 3307410842013230886L; + + @Expose + private String name; + + @Expose + private String version; + + /** + * Constructor. + */ + public PolicyModelKey(String name, String version) { + this.name = name; + this.version = version; + } + + /** + * name getter. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * name setter. + * + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * version getter. + * + * @return the version + */ + public String getVersion() { + return version; + } + + /** + * version setter. + * + * @param version the version to set + */ + public void setVersion(String version) { + this.version = version; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((version == null) ? 0 : version.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + PolicyModelKey other = (PolicyModelKey) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + if (!name.matches(other.name)) { + return false; + } + } + if (version == null) { + if (other.version != null) { + return false; + } + } else if (!version.equals(other.version)) { + return false; + } + return true; + } +} diff --git a/src/main/resources/META-INF/resources/swagger.html b/src/main/resources/META-INF/resources/swagger.html index 16938529b..0138d9a30 100644 --- a/src/main/resources/META-INF/resources/swagger.html +++ b/src/main/resources/META-INF/resources/swagger.html @@ -444,25 +444,25 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </li> <li><a href="#_paths">2. Paths</a> <ul class="sectlevel2"> -<li><a href="#_route123">2.1. GET /v1/healthcheck</a> +<li><a href="#_route92">2.1. GET /v1/healthcheck</a> <ul class="sectlevel3"> <li><a href="#_responses">2.1.1. Responses</a></li> <li><a href="#_produces">2.1.2. Produces</a></li> </ul> </li> -<li><a href="#_route124">2.2. GET /v1/user/getUser</a> +<li><a href="#_route93">2.2. GET /v1/user/getUser</a> <ul class="sectlevel3"> <li><a href="#_responses_2">2.2.1. Responses</a></li> <li><a href="#_produces_2">2.2.2. Produces</a></li> </ul> </li> -<li><a href="#_route111">2.3. GET /v2/dictionary</a> +<li><a href="#_route80">2.3. GET /v2/dictionary</a> <ul class="sectlevel3"> <li><a href="#_responses_3">2.3.1. Responses</a></li> <li><a href="#_produces_3">2.3.2. Produces</a></li> </ul> </li> -<li><a href="#_route113">2.4. PUT /v2/dictionary</a> +<li><a href="#_route82">2.4. PUT /v2/dictionary</a> <ul class="sectlevel3"> <li><a href="#_parameters">2.4.1. Parameters</a></li> <li><a href="#_responses_4">2.4.2. Responses</a></li> @@ -491,7 +491,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_7">2.7.4. Produces</a></li> </ul> </li> -<li><a href="#_route115">2.8. DELETE /v2/dictionary/{name}</a> +<li><a href="#_route84">2.8. DELETE /v2/dictionary/{name}</a> <ul class="sectlevel3"> <li><a href="#_parameters_4">2.8.1. Parameters</a></li> <li><a href="#_responses_8">2.8.2. Responses</a></li> @@ -505,75 +505,75 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_9">2.9.3. Produces</a></li> </ul> </li> -<li><a href="#_route107">2.10. PUT /v2/loop/delete/{loopName}</a> +<li><a href="#_route76">2.10. PUT /v2/loop/delete/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_6">2.10.1. Parameters</a></li> <li><a href="#_responses_10">2.10.2. Responses</a></li> </ul> </li> -<li><a href="#_route101">2.11. PUT /v2/loop/deploy/{loopName}</a> +<li><a href="#_route70">2.11. PUT /v2/loop/deploy/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_7">2.11.1. Parameters</a></li> <li><a href="#_responses_11">2.11.2. Responses</a></li> <li><a href="#_produces_10">2.11.3. Produces</a></li> </ul> </li> -<li><a href="#_route95">2.12. GET /v2/loop/getAllNames</a> +<li><a href="#_route64">2.12. GET /v2/loop/getAllNames</a> <ul class="sectlevel3"> <li><a href="#_responses_12">2.12.1. Responses</a></li> <li><a href="#_produces_11">2.12.2. Produces</a></li> </ul> </li> -<li><a href="#_route108">2.13. GET /v2/loop/getstatus/{loopName}</a> +<li><a href="#_route77">2.13. GET /v2/loop/getstatus/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_8">2.13.1. Parameters</a></li> <li><a href="#_responses_13">2.13.2. Responses</a></li> <li><a href="#_produces_12">2.13.3. Produces</a></li> </ul> </li> -<li><a href="#_route102">2.14. PUT /v2/loop/refreshOpPolicyJsonSchema/{loopName}</a> +<li><a href="#_route71">2.14. PUT /v2/loop/refreshOpPolicyJsonSchema/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_9">2.14.1. Parameters</a></li> <li><a href="#_responses_14">2.14.2. Responses</a></li> <li><a href="#_produces_13">2.14.3. Produces</a></li> </ul> </li> -<li><a href="#_route105">2.15. PUT /v2/loop/restart/{loopName}</a> +<li><a href="#_route74">2.15. PUT /v2/loop/restart/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_10">2.15.1. Parameters</a></li> <li><a href="#_responses_15">2.15.2. Responses</a></li> <li><a href="#_produces_14">2.15.3. Produces</a></li> </ul> </li> -<li><a href="#_route104">2.16. PUT /v2/loop/stop/{loopName}</a> +<li><a href="#_route73">2.16. PUT /v2/loop/stop/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_11">2.16.1. Parameters</a></li> <li><a href="#_responses_16">2.16.2. Responses</a></li> <li><a href="#_produces_15">2.16.3. Produces</a></li> </ul> </li> -<li><a href="#_route106">2.17. PUT /v2/loop/submit/{loopName}</a> +<li><a href="#_route75">2.17. PUT /v2/loop/submit/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_12">2.17.1. Parameters</a></li> <li><a href="#_responses_17">2.17.2. Responses</a></li> <li><a href="#_produces_16">2.17.3. Produces</a></li> </ul> </li> -<li><a href="#_route97">2.18. GET /v2/loop/svgRepresentation/{loopName}</a> +<li><a href="#_route66">2.18. GET /v2/loop/svgRepresentation/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_13">2.18.1. Parameters</a></li> <li><a href="#_responses_18">2.18.2. Responses</a></li> <li><a href="#_produces_17">2.18.3. Produces</a></li> </ul> </li> -<li><a href="#_route103">2.19. PUT /v2/loop/undeploy/{loopName}</a> +<li><a href="#_route72">2.19. PUT /v2/loop/undeploy/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_14">2.19.1. Parameters</a></li> <li><a href="#_responses_19">2.19.2. Responses</a></li> <li><a href="#_produces_18">2.19.3. Produces</a></li> </ul> </li> -<li><a href="#_route98">2.20. POST /v2/loop/updateGlobalProperties/{loopName}</a> +<li><a href="#_route67">2.20. POST /v2/loop/updateGlobalProperties/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_15">2.20.1. Parameters</a></li> <li><a href="#_responses_20">2.20.2. Responses</a></li> @@ -581,7 +581,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_19">2.20.4. Produces</a></li> </ul> </li> -<li><a href="#_route100">2.21. POST /v2/loop/updateMicroservicePolicy/{loopName}</a> +<li><a href="#_route69">2.21. POST /v2/loop/updateMicroservicePolicy/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_16">2.21.1. Parameters</a></li> <li><a href="#_responses_21">2.21.2. Responses</a></li> @@ -589,7 +589,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_20">2.21.4. Produces</a></li> </ul> </li> -<li><a href="#_route99">2.22. POST /v2/loop/updateOperationalPolicies/{loopName}</a> +<li><a href="#_route68">2.22. POST /v2/loop/updateOperationalPolicies/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_17">2.22.1. Parameters</a></li> <li><a href="#_responses_22">2.22.2. Responses</a></li> @@ -597,14 +597,14 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_21">2.22.4. Produces</a></li> </ul> </li> -<li><a href="#_route96">2.23. GET /v2/loop/{loopName}</a> +<li><a href="#_route65">2.23. GET /v2/loop/{loopName}</a> <ul class="sectlevel3"> <li><a href="#_parameters_18">2.23.1. Parameters</a></li> <li><a href="#_responses_23">2.23.2. Responses</a></li> <li><a href="#_produces_22">2.23.3. Produces</a></li> </ul> </li> -<li><a href="#_route118">2.24. GET /v2/policyToscaModels</a> +<li><a href="#_route87">2.24. GET /v2/policyToscaModels</a> <ul class="sectlevel3"> <li><a href="#_responses_24">2.24.1. Responses</a></li> <li><a href="#_produces_23">2.24.2. Produces</a></li> @@ -624,7 +624,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_25">2.26.3. Produces</a></li> </ul> </li> -<li><a href="#_route119">2.27. PUT /v2/policyToscaModels/{policyModelType}</a> +<li><a href="#_route88">2.27. PUT /v2/policyToscaModels/{policyModelType}</a> <ul class="sectlevel3"> <li><a href="#_parameters_21">2.27.1. Parameters</a></li> <li><a href="#_responses_27">2.27.2. Responses</a></li> @@ -632,7 +632,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <li><a href="#_produces_26">2.27.4. Produces</a></li> </ul> </li> -<li><a href="#_route122">2.28. GET /v2/templates</a> +<li><a href="#_route91">2.28. GET /v2/templates</a> <ul class="sectlevel3"> <li><a href="#_responses_28">2.28.1. Responses</a></li> <li><a href="#_produces_27">2.28.2. Produces</a></li> @@ -692,7 +692,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <div class="sect2"> <h3 id="_uri_scheme"><a class="anchor" href="#_uri_scheme"></a><a class="link" href="#_uri_scheme">1.2. URI scheme</a></h3> <div class="paragraph"> -<p><em>Host</em> : localhost:32977<br> +<p><em>Host</em> : localhost:33631<br> <em>BasePath</em> : /restservices/clds/<br> <em>Schemes</em> : HTTP</p> </div> @@ -703,7 +703,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b <h2 id="_paths"><a class="anchor" href="#_paths"></a><a class="link" href="#_paths">2. Paths</a></h2> <div class="sectionbody"> <div class="sect2"> -<h3 id="_route123"><a class="anchor" href="#_route123"></a><a class="link" href="#_route123">2.1. GET /v1/healthcheck</a></h3> +<h3 id="_route92"><a class="anchor" href="#_route92"></a><a class="link" href="#_route92">2.1. GET /v1/healthcheck</a></h3> <div class="sect3"> <h4 id="_responses"><a class="anchor" href="#_responses"></a><a class="link" href="#_responses">2.1.1. Responses</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -740,7 +740,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route124"><a class="anchor" href="#_route124"></a><a class="link" href="#_route124">2.2. GET /v1/user/getUser</a></h3> +<h3 id="_route93"><a class="anchor" href="#_route93"></a><a class="link" href="#_route93">2.2. GET /v1/user/getUser</a></h3> <div class="sect3"> <h4 id="_responses_2"><a class="anchor" href="#_responses_2"></a><a class="link" href="#_responses_2">2.2.1. Responses</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -774,7 +774,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route111"><a class="anchor" href="#_route111"></a><a class="link" href="#_route111">2.3. GET /v2/dictionary</a></h3> +<h3 id="_route80"><a class="anchor" href="#_route80"></a><a class="link" href="#_route80">2.3. GET /v2/dictionary</a></h3> <div class="sect3"> <h4 id="_responses_3"><a class="anchor" href="#_responses_3"></a><a class="link" href="#_responses_3">2.3.1. Responses</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -811,7 +811,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route113"><a class="anchor" href="#_route113"></a><a class="link" href="#_route113">2.4. PUT /v2/dictionary</a></h3> +<h3 id="_route82"><a class="anchor" href="#_route82"></a><a class="link" href="#_route82">2.4. PUT /v2/dictionary</a></h3> <div class="sect3"> <h4 id="_parameters"><a class="anchor" href="#_parameters"></a><a class="link" href="#_parameters">2.4.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1060,7 +1060,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route115"><a class="anchor" href="#_route115"></a><a class="link" href="#_route115">2.8. DELETE /v2/dictionary/{name}</a></h3> +<h3 id="_route84"><a class="anchor" href="#_route84"></a><a class="link" href="#_route84">2.8. DELETE /v2/dictionary/{name}</a></h3> <div class="sect3"> <h4 id="_parameters_4"><a class="anchor" href="#_parameters_4"></a><a class="link" href="#_parameters_4">2.8.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1184,7 +1184,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route107"><a class="anchor" href="#_route107"></a><a class="link" href="#_route107">2.10. PUT /v2/loop/delete/{loopName}</a></h3> +<h3 id="_route76"><a class="anchor" href="#_route76"></a><a class="link" href="#_route76">2.10. PUT /v2/loop/delete/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_6"><a class="anchor" href="#_parameters_6"></a><a class="link" href="#_parameters_6">2.10.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1233,7 +1233,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route101"><a class="anchor" href="#_route101"></a><a class="link" href="#_route101">2.11. PUT /v2/loop/deploy/{loopName}</a></h3> +<h3 id="_route70"><a class="anchor" href="#_route70"></a><a class="link" href="#_route70">2.11. PUT /v2/loop/deploy/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_7"><a class="anchor" href="#_parameters_7"></a><a class="link" href="#_parameters_7">2.11.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1295,7 +1295,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route95"><a class="anchor" href="#_route95"></a><a class="link" href="#_route95">2.12. GET /v2/loop/getAllNames</a></h3> +<h3 id="_route64"><a class="anchor" href="#_route64"></a><a class="link" href="#_route64">2.12. GET /v2/loop/getAllNames</a></h3> <div class="sect3"> <h4 id="_responses_12"><a class="anchor" href="#_responses_12"></a><a class="link" href="#_responses_12">2.12.1. Responses</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1332,7 +1332,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route108"><a class="anchor" href="#_route108"></a><a class="link" href="#_route108">2.13. GET /v2/loop/getstatus/{loopName}</a></h3> +<h3 id="_route77"><a class="anchor" href="#_route77"></a><a class="link" href="#_route77">2.13. GET /v2/loop/getstatus/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_8"><a class="anchor" href="#_parameters_8"></a><a class="link" href="#_parameters_8">2.13.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1394,7 +1394,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route102"><a class="anchor" href="#_route102"></a><a class="link" href="#_route102">2.14. PUT /v2/loop/refreshOpPolicyJsonSchema/{loopName}</a></h3> +<h3 id="_route71"><a class="anchor" href="#_route71"></a><a class="link" href="#_route71">2.14. PUT /v2/loop/refreshOpPolicyJsonSchema/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_9"><a class="anchor" href="#_parameters_9"></a><a class="link" href="#_parameters_9">2.14.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1456,7 +1456,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route105"><a class="anchor" href="#_route105"></a><a class="link" href="#_route105">2.15. PUT /v2/loop/restart/{loopName}</a></h3> +<h3 id="_route74"><a class="anchor" href="#_route74"></a><a class="link" href="#_route74">2.15. PUT /v2/loop/restart/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_10"><a class="anchor" href="#_parameters_10"></a><a class="link" href="#_parameters_10">2.15.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1518,7 +1518,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route104"><a class="anchor" href="#_route104"></a><a class="link" href="#_route104">2.16. PUT /v2/loop/stop/{loopName}</a></h3> +<h3 id="_route73"><a class="anchor" href="#_route73"></a><a class="link" href="#_route73">2.16. PUT /v2/loop/stop/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_11"><a class="anchor" href="#_parameters_11"></a><a class="link" href="#_parameters_11">2.16.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1580,7 +1580,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route106"><a class="anchor" href="#_route106"></a><a class="link" href="#_route106">2.17. PUT /v2/loop/submit/{loopName}</a></h3> +<h3 id="_route75"><a class="anchor" href="#_route75"></a><a class="link" href="#_route75">2.17. PUT /v2/loop/submit/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_12"><a class="anchor" href="#_parameters_12"></a><a class="link" href="#_parameters_12">2.17.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1642,7 +1642,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route97"><a class="anchor" href="#_route97"></a><a class="link" href="#_route97">2.18. GET /v2/loop/svgRepresentation/{loopName}</a></h3> +<h3 id="_route66"><a class="anchor" href="#_route66"></a><a class="link" href="#_route66">2.18. GET /v2/loop/svgRepresentation/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_13"><a class="anchor" href="#_parameters_13"></a><a class="link" href="#_parameters_13">2.18.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1704,7 +1704,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route103"><a class="anchor" href="#_route103"></a><a class="link" href="#_route103">2.19. PUT /v2/loop/undeploy/{loopName}</a></h3> +<h3 id="_route72"><a class="anchor" href="#_route72"></a><a class="link" href="#_route72">2.19. PUT /v2/loop/undeploy/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_14"><a class="anchor" href="#_parameters_14"></a><a class="link" href="#_parameters_14">2.19.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1766,7 +1766,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route98"><a class="anchor" href="#_route98"></a><a class="link" href="#_route98">2.20. POST /v2/loop/updateGlobalProperties/{loopName}</a></h3> +<h3 id="_route67"><a class="anchor" href="#_route67"></a><a class="link" href="#_route67">2.20. POST /v2/loop/updateGlobalProperties/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_15"><a class="anchor" href="#_parameters_15"></a><a class="link" href="#_parameters_15">2.20.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1844,7 +1844,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route100"><a class="anchor" href="#_route100"></a><a class="link" href="#_route100">2.21. POST /v2/loop/updateMicroservicePolicy/{loopName}</a></h3> +<h3 id="_route69"><a class="anchor" href="#_route69"></a><a class="link" href="#_route69">2.21. POST /v2/loop/updateMicroservicePolicy/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_16"><a class="anchor" href="#_parameters_16"></a><a class="link" href="#_parameters_16">2.21.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -1922,7 +1922,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route99"><a class="anchor" href="#_route99"></a><a class="link" href="#_route99">2.22. POST /v2/loop/updateOperationalPolicies/{loopName}</a></h3> +<h3 id="_route68"><a class="anchor" href="#_route68"></a><a class="link" href="#_route68">2.22. POST /v2/loop/updateOperationalPolicies/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_17"><a class="anchor" href="#_parameters_17"></a><a class="link" href="#_parameters_17">2.22.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -2000,7 +2000,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route96"><a class="anchor" href="#_route96"></a><a class="link" href="#_route96">2.23. GET /v2/loop/{loopName}</a></h3> +<h3 id="_route65"><a class="anchor" href="#_route65"></a><a class="link" href="#_route65">2.23. GET /v2/loop/{loopName}</a></h3> <div class="sect3"> <h4 id="_parameters_18"><a class="anchor" href="#_parameters_18"></a><a class="link" href="#_parameters_18">2.23.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -2062,7 +2062,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route118"><a class="anchor" href="#_route118"></a><a class="link" href="#_route118">2.24. GET /v2/policyToscaModels</a></h3> +<h3 id="_route87"><a class="anchor" href="#_route87"></a><a class="link" href="#_route87">2.24. GET /v2/policyToscaModels</a></h3> <div class="sect3"> <h4 id="_responses_24"><a class="anchor" href="#_responses_24"></a><a class="link" href="#_responses_24">2.24.1. Responses</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -2223,7 +2223,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route119"><a class="anchor" href="#_route119"></a><a class="link" href="#_route119">2.27. PUT /v2/policyToscaModels/{policyModelType}</a></h3> +<h3 id="_route88"><a class="anchor" href="#_route88"></a><a class="link" href="#_route88">2.27. PUT /v2/policyToscaModels/{policyModelType}</a></h3> <div class="sect3"> <h4 id="_parameters_21"><a class="anchor" href="#_parameters_21"></a><a class="link" href="#_parameters_21">2.27.1. Parameters</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -2301,7 +2301,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> </div> <div class="sect2"> -<h3 id="_route122"><a class="anchor" href="#_route122"></a><a class="link" href="#_route122">2.28. GET /v2/templates</a></h3> +<h3 id="_route91"><a class="anchor" href="#_route91"></a><a class="link" href="#_route91">2.28. GET /v2/templates</a></h3> <div class="sect3"> <h4 id="_responses_28"><a class="anchor" href="#_responses_28"></a><a class="link" href="#_responses_28">2.28.1. Responses</a></h4> <table class="tableblock frame-all grid-all stretch"> @@ -3758,7 +3758,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b </div> <div id="footer"> <div id="footer-text"> -Last updated 2020-02-12 02:20:53 PST +Last updated 2019-05-27 14:30:20 CEST </div> </div> </body> diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml index c28e45435..ce37fe1d6 100644 --- a/src/main/resources/clds/camel/routes/policy-flows.xml +++ b/src/main/resources/clds/camel/routes/policy-flows.xml @@ -175,7 +175,7 @@ message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}"></log> <toD uri="{{clamp.config.policy.api.url}}/policy/api/v1/policytypes/${exchangeProperty[policyModelName]}/versions/${exchangeProperty[policyModelVersion]}?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> - <convertBodyTo type="java.lang.String"/> + <convertBodyTo type="java.lang.String"/> <doFinally> <to uri="direct:reset-raise-http-exception-flag"/> <to @@ -584,4 +584,38 @@ </doFinally> </doTry> </route> + <route id="get-all-pdp-groups"> + <from uri="direct:get-all-pdp-groups"/> + <doTry> + <log loggingLevel="INFO" + message="Getting the list of PDP Groups"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('Policy', 'Getting the PDP Group list')"/> + <setHeader headerName="CamelHttpMethod"> + <constant>GET</constant> + </setHeader> + <setHeader headerName="X-ONAP-RequestID"> + <simple>${exchangeProperty[X-ONAP-RequestID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-InvocationID"> + <simple>${exchangeProperty[X-ONAP-InvocationID]} + </simple> + </setHeader> + <setHeader headerName="X-ONAP-PartnerName"> + <simple>${exchangeProperty[X-ONAP-PartnerName]} + </simple> + </setHeader> + <log loggingLevel="INFO" + message="Endpoint to get policy model: {{clamp.config.policy.pap.url}}/policy/pap/v1/pdps"></log> + <toD + uri="{{clamp.config.policy.api.url}}/policy/pap/v1/pdps?bridgeEndpoint=true&useSystemProperties=true&throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&authMethod=Basic&authUsername={{clamp.config.policy.api.userName}}&authPassword={{clamp.config.policy.api.password}}&connectionTimeToLive=5000&httpClient.connectTimeout=10000&httpClient.socketTimeout=20000&authenticationPreemptive=true&connectionClose=true"/> + <convertBodyTo type="java.lang.String" /> + <doFinally> + <to uri="direct:reset-raise-http-exception-flag"/> + <to + uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/> + </doFinally> + </doTry> + </route> </routes>
\ No newline at end of file diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java index 152648712..5eca90c7f 100644 --- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java @@ -46,6 +46,7 @@ import org.onap.clamp.policy.operational.OperationalPolicy; import org.onap.clamp.policy.operational.OperationalPolicyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.Commit; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @@ -148,6 +149,7 @@ public class LoopServiceTestItCase { @Test @Transactional + //@Commit public void shouldCreateNewMicroservicePolicyAndUpdateJsonRepresentationOfOldOne() { // given saveTestLoopToDb(); diff --git a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java index abeecd1b2..f8aadbad5 100644 --- a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java +++ b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java @@ -25,6 +25,7 @@ package org.onap.clamp.loop; import static org.assertj.core.api.Assertions.assertThat; +import java.util.LinkedList; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -33,14 +34,20 @@ import javax.transaction.Transactional; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; +import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.loop.template.PolicyModelId; import org.onap.clamp.loop.template.PolicyModelsRepository; import org.onap.clamp.loop.template.PolicyModelsService; +import org.onap.clamp.policy.pdpgroup.PdpGroup; +import org.onap.clamp.policy.pdpgroup.PdpSubgroup; +import org.onap.clamp.policy.pdpgroup.PolicyModelKey; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import com.google.gson.JsonObject; + @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class PolicyModelServiceItCase { @@ -167,4 +174,71 @@ public class PolicyModelServiceItCase { assertThat(listToCheck.get(1)).isEqualByComparingTo(policyModel1); assertThat(listToCheck.get(2)).isEqualByComparingTo(policyModel3); } + + @Test + @Transactional + public void shouldAddPdpGroupInfo() { + PolicyModel policyModel1 = getPolicyModel(POLICY_MODEL_TYPE_1, "yaml", POLICY_MODEL_TYPE_1_VERSION_1, "TEST", + "VARIANT", "user"); + policyModelsService.saveOrUpdatePolicyModel(policyModel1); + PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST", + "VARIANT", "user"); + policyModelsService.saveOrUpdatePolicyModel(policyModel2); + PolicyModel policyModel3 = getPolicyModel(POLICY_MODEL_TYPE_3, "yaml", POLICY_MODEL_TYPE_3_VERSION_1, "TEST", + "VARIANT", "user"); + policyModelsService.saveOrUpdatePolicyModel(policyModel3); + + + PolicyModelKey type1 = new PolicyModelKey("org.onap.testos", "1.0.0"); + PolicyModelKey type2 = new PolicyModelKey("org.onap.testos2", "2.0.0"); + + PdpSubgroup pdpSubgroup1 = new PdpSubgroup(); + pdpSubgroup1.setPdpType("subGroup1"); + List<PolicyModelKey> pdpTypeList = new LinkedList<PolicyModelKey>(); + pdpTypeList.add(type1); + pdpTypeList.add(type2); + pdpSubgroup1.setSupportedPolicyTypes(pdpTypeList); + + PolicyModelKey type3 = new PolicyModelKey("org.onap.testos3", "2.0.0"); + PdpSubgroup pdpSubgroup2 = new PdpSubgroup(); + pdpSubgroup2.setPdpType("subGroup2"); + List<PolicyModelKey> pdpTypeList2 = new LinkedList<PolicyModelKey>(); + pdpTypeList2.add(type2); + pdpTypeList2.add(type3); + pdpSubgroup2.setSupportedPolicyTypes(pdpTypeList2); + + List<PdpSubgroup> pdpSubgroupList = new LinkedList<PdpSubgroup>(); + pdpSubgroupList.add(pdpSubgroup1); + + PdpGroup pdpGroup1 = new PdpGroup(); + pdpGroup1.setName("pdpGroup1"); + pdpGroup1.setPdpGroupState("ACTIVE"); + pdpGroup1.setPdpSubgroups(pdpSubgroupList); + + List<PdpSubgroup> pdpSubgroupList2 = new LinkedList<PdpSubgroup>(); + pdpSubgroupList2.add(pdpSubgroup1); + pdpSubgroupList2.add(pdpSubgroup2); + PdpGroup pdpGroup2 = new PdpGroup(); + pdpGroup2.setName("pdpGroup2"); + pdpGroup2.setPdpGroupState("ACTIVE"); + pdpGroup2.setPdpSubgroups(pdpSubgroupList2); + + List<PdpGroup> pdpGroupList = new LinkedList<PdpGroup>(); + pdpGroupList.add(pdpGroup1); + pdpGroupList.add(pdpGroup2); + policyModelsService.updatePdpGroupInfo(pdpGroupList); + + JsonObject res1 = policyModelsService.getPolicyModel("org.onap.testos", "1.0.0").getPolicyPdpGroup(); + String expectedRes1 = "{\"supportedPdpGroups\":[{\"pdpGroup1\":[\"subGroup1\"]},{\"pdpGroup2\":[\"subGroup1\"]}]}"; + JsonObject expectedJson1 = JsonUtils.GSON.fromJson(expectedRes1, JsonObject.class); + assertThat(res1).isEqualTo(expectedJson1); + + JsonObject res2 = policyModelsService.getPolicyModel("org.onap.testos2", "2.0.0").getPolicyPdpGroup(); + String expectedRes2 = "{\"supportedPdpGroups\":[{\"pdpGroup1\":[\"subGroup1\"]},{\"pdpGroup2\":[\"subGroup1\",\"subGroup2\"]}]}"; + JsonObject expectedJson2 = JsonUtils.GSON.fromJson(expectedRes2, JsonObject.class); + assertThat(res2).isEqualTo(expectedJson2); + + JsonObject res3 = policyModelsService.getPolicyModel("org.onap.testos3", "1.0.0").getPolicyPdpGroup(); + assertThat(res3).isNull(); + } } diff --git a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java index b42e15367..3f502ff78 100644 --- a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java +++ b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java @@ -24,15 +24,19 @@ package org.onap.clamp.policy.downloader; import static org.assertj.core.api.Assertions.assertThat; +import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import java.io.IOException; import java.time.Instant; import java.util.List; import javax.transaction.Transactional; +import org.json.simple.parser.ParseException; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; +import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelId; import org.onap.clamp.loop.template.PolicyModelsRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -76,4 +80,30 @@ public class PolicyEngineControllerTestItCase { assertThat(firstExecution).isBefore(secondExecution); } + @Test + @Transactional + public void downloadPdpGroupsTest() throws JsonSyntaxException, IOException, InterruptedException, ParseException { + PolicyModel policyModel1 = new PolicyModel("onap.policies.monitoring.test", null, "1.0.0"); + policyModelsRepository.saveAndFlush(policyModel1); + PolicyModel policyModel2 = new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0"); + policyModelsRepository.saveAndFlush(policyModel2); + + policyController.downloadPdpGroups(); + + List<PolicyModel> policyModelsList = policyModelsRepository.findAll(); + assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(2); + + PolicyModel policy1 = policyModelsRepository + .getOne(new PolicyModelId("onap.policies.monitoring.test", "1.0.0")); + PolicyModel policy2 = policyModelsRepository + .getOne(new PolicyModelId("onap.policies.controlloop.Operational", "1.0.0")); + + String expectedRes1 = "{\"supportedPdpGroups\":[{\"monitoring\":[\"xacml\"]}]}"; + JsonObject expectedJson1 = JsonUtils.GSON.fromJson(expectedRes1, JsonObject.class); + assertThat(policy1.getPolicyPdpGroup()).isEqualTo(expectedJson1); + String expectedRes2 = "{\"supportedPdpGroups\":[{\"controlloop\":[\"apex\",\"drools\"]}]}"; + JsonObject expectedJson2 = JsonUtils.GSON.fromJson(expectedRes2, JsonObject.class); + assertThat(policy2.getPolicyPdpGroup()).isEqualTo(expectedJson2); + + } } diff --git a/src/test/java/org/onap/clamp/policy/pdpgroup/PdpGroupTest.java b/src/test/java/org/onap/clamp/policy/pdpgroup/PdpGroupTest.java new file mode 100644 index 000000000..b6f7c5491 --- /dev/null +++ b/src/test/java/org/onap/clamp/policy/pdpgroup/PdpGroupTest.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2020 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.policy.pdpgroup; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +import org.junit.Test; + +public class PdpGroupTest { + + + @Test + public void testGetSupportedSubgroups() throws IOException { + PdpGroup pdpGroup1 = new PdpGroup(); + pdpGroup1.setName("pdpGroup1"); + pdpGroup1.setPdpGroupState("INACTIVE"); + assertThat(pdpGroup1.getSupportedSubgroups("test", "1.0.0")).isNull(); + + PdpGroup pdpGroup2 = new PdpGroup(); + pdpGroup2.setName("pdpGroup2"); + pdpGroup2.setPdpGroupState("ACTIVE"); + + PolicyModelKey type1 = new PolicyModelKey("type1", "1.0.0"); + PolicyModelKey type2 = new PolicyModelKey("type2", "2.0.0"); + + PdpSubgroup pdpSubgroup1 = new PdpSubgroup(); + pdpSubgroup1.setPdpType("subGroup1"); + List<PolicyModelKey> pdpTypeList = new LinkedList<PolicyModelKey>(); + pdpTypeList.add(type1); + pdpTypeList.add(type2); + pdpSubgroup1.setSupportedPolicyTypes(pdpTypeList); + + PolicyModelKey type3 = new PolicyModelKey("type3", "1.0.0"); + PdpSubgroup pdpSubgroup2 = new PdpSubgroup(); + pdpSubgroup2.setPdpType("subGroup2"); + List<PolicyModelKey> pdpTypeList2 = new LinkedList<PolicyModelKey>(); + pdpTypeList2.add(type2); + pdpTypeList2.add(type3); + pdpSubgroup2.setSupportedPolicyTypes(pdpTypeList2); + + List<PdpSubgroup> pdpSubgroupList = new LinkedList<PdpSubgroup>(); + pdpSubgroupList.add(pdpSubgroup1); + pdpSubgroupList.add(pdpSubgroup2); + pdpGroup2.setPdpSubgroups(pdpSubgroupList); + + JsonObject res1 = pdpGroup2.getSupportedSubgroups("type2", "2.0.0"); + assertThat(res1.get("pdpGroup2")).isNotNull(); + JsonArray resSubList = res1.getAsJsonArray("pdpGroup2"); + assertThat(resSubList.size()).isEqualTo(2); + assertThat(resSubList.toString().contains("subGroup1")).isTrue(); + assertThat(resSubList.toString().contains("subGroup2")).isTrue(); + + JsonObject res2 = pdpGroup2.getSupportedSubgroups("type1", "1.0.0"); + assertThat(res2.get("pdpGroup2")).isNotNull(); + JsonArray resSubList2 = res2.getAsJsonArray("pdpGroup2"); + assertThat(resSubList2.size()).isEqualTo(1); + + assertThat(pdpGroup2.getSupportedSubgroups("type3", "1.0.1")).isNull(); + } +} diff --git a/src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.file b/src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.file new file mode 100644 index 000000000..6b6b372cf --- /dev/null +++ b/src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.file @@ -0,0 +1,76 @@ +{ + "groups": [ + { + "description": "This group should be used for managing all control loop related policies and pdps", + "name": "controlloop", + "pdpGroupState": "ACTIVE", + "pdpSubgroups": [ + { + "currentInstanceCount": 0, + "desiredInstanceCount": 1, + "pdpInstances": [], + "pdpType": "apex", + "policies": [], + "properties": {}, + "supportedPolicyTypes": [ + { + "name": "onap.policies.controlloop.Operational", + "version": "1.0.0" + } + ] + }, + { + "currentInstanceCount": 0, + "desiredInstanceCount": 1, + "pdpInstances": [], + "pdpType": "drools", + "policies": [], + "properties": {}, + "supportedPolicyTypes": [ + { + "name": "onap.policies.controlloop.Operational", + "version": "1.0.0" + } + ] + }, + { + "currentInstanceCount": 0, + "desiredInstanceCount": 1, + "pdpInstances": [], + "pdpType": "xacml", + "policies": [], + "properties": {}, + "supportedPolicyTypes": [ + { + "name": "onap.policies.controlloop.Guard", + "version": "1.0.0" + } + ] + } + ], + "properties": {} + }, + { + "description": "This group should be used for managing all monitoring related policies and pdps", + "name": "monitoring", + "pdpGroupState": "ACTIVE", + "pdpSubgroups": [ + { + "currentInstanceCount": 0, + "desiredInstanceCount": 1, + "pdpInstances": [], + "pdpType": "xacml", + "policies": [], + "properties": {}, + "supportedPolicyTypes": [ + { + "name": "onap.policies.monitoring.*", + "version": "1.0.0" + } + ] + } + ], + "properties": {} + } + ] +} diff --git a/src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.header b/src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.header new file mode 100644 index 000000000..6a280d972 --- /dev/null +++ b/src/test/resources/http-cache/example/policy/pap/v1/pdps?connectionTimeToLive=5000/.header @@ -0,0 +1 @@ +{"Transfer-Encoding": "chunked", "Set-Cookie": "JSESSIONID=158qxkdtdobkd1umr3ikkgrmlx;Path=/", "Expires": "Thu, 01 Jan 1970 00:00:00 GMT", "Server": "Jetty(9.3.21.v20170918)", "Content-Type": "application/json", "X-ECOMP-RequestID": "e2ddb3c8-994f-47df-b4dc-097d4fb55c08"}
\ No newline at end of file diff --git a/src/test/resources/http-cache/third_party_proxy.py b/src/test/resources/http-cache/third_party_proxy.py index 32f7faf4e..79e152ebb 100755 --- a/src/test/resources/http-cache/third_party_proxy.py +++ b/src/test/resources/http-cache/third_party_proxy.py @@ -297,6 +297,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): self.send_response(404) self.end_headers() self.wfile.write('404 Not found, no remote HOST specified on the emulator !!!') + print("HOST value is: %s " % (options.proxy)) return "404 Not found, no remote HOST specified on the emulator !!!" url = '%s%s' % (HOST, self.path) @@ -315,6 +316,7 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): return response.content else: print("Request for data currently present in cache: %s" % (cached_file_folder,)) + print("HOST value is: %s " % (HOST)) self._send_content(cached_file_header, cached_file_content) |