+ .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);