- private void downloadAllPolicies() {
- /*
- * Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext)
- * .withProperty("blueprintResourceId",
- * resourceUuid).withProperty("blueprintServiceId", serviceUuid)
- * .withProperty("blueprintName", artifactName).build();
- * metricsLogger.info("Attempt n°" + i + " to contact DCAE inventory");
- *
- * Exchange exchangeResponse =
- * camelContext.createProducerTemplate().send("direct:get-all-policy-models",
- * myCamelExchange);
- */
+ public PolicyModel createPolicyModelFromPolicyEngine(String policyType, String policyVersion)
+ throws InterruptedException {
+ return new PolicyModel(policyType, this.downloadOnePolicy(policyType, policyVersion), policyVersion,
+ createPolicyAcronym(policyType));
+ }
+
+ public PolicyModel createPolicyModelFromPolicyEngine(BlueprintMicroService microService)
+ throws InterruptedException {
+ return createPolicyModelFromPolicyEngine(microService.getModelType(), microService.getModelVersion());
+ }
+
+ private static String createPolicyAcronym(String policyType) {
+ String[] policyNameArray = policyType.split("\\.");
+ return policyNameArray[policyNameArray.length - 1];
+ }
+
+ /**
+ * This method can be used to download all policy types + data types defined in
+ * policy engine.
+ *
+ * @return A yaml containing all policy Types and all data types
+ * @throws InterruptedException In case of issue when sleeping during the retry
+ */
+ public String downloadAllPolicies() throws InterruptedException {
+ return callCamelRoute(ExchangeBuilder.anExchange(camelContext).build(), "direct:get-all-policy-models");