- JSONObject jsonObject = new JSONObject(formattedString);
- switch (dmaapMessage.getOperation()) {
- case "getPolicySchemas":
- ricName = (String) jsonObject.get("ricName");
- logger.debug("Received the request for getPolicySchemas with Ric Name- {}", ricName);
- return policyController.getPolicySchemas(ricName);
- case "getPolicySchema":
- String policyTypeId = (String) jsonObject.get("id");
- logger.debug("Received the request for getPolicySchema with Policy Type Id- {}", policyTypeId);
- System.out.println("policyTypeId" + policyTypeId);
- return policyController.getPolicySchema(policyTypeId);
- case "getPolicyTypes":
- ricName = (String) jsonObject.get("ricName");
- logger.debug("Received the request for getPolicyTypes with Ric Name- {}", ricName);
- return policyController.getPolicyTypes(ricName);
- case "getPolicy":
- instance = (String) jsonObject.get("instance");
- logger.debug("Received the request for getPolicy with Instance- {}", instance);
- return policyController.getPolicy(instance);
- case "deletePolicy":
- instance = (String) jsonObject.get("instance");
- logger.debug("Received the request for deletePolicy with Instance- {}", instance);
- return null;// policyController.deletePolicy(deleteInstance);
- case "putPolicy":
- String type = (String) jsonObject.get("type");
- String putPolicyInstance = (String) jsonObject.get("instance");
- String putPolicyRic = (String) jsonObject.get("ric");
- String service = (String) jsonObject.get("service");
- String jsonBody = (String) jsonObject.get("jsonBody");
- return null;// policyController.putPolicy(type, putPolicyInstance, putPolicyRic, service, jsonBody);
- case "getPolicies":
- String getPolicyType = (String) jsonObject.get("type");
- String getPolicyRic = (String) jsonObject.get("ric");
- String getPolicyService = (String) jsonObject.get("service");
- return policyController.getPolicies(getPolicyType, getPolicyRic, getPolicyService);
- default:
+ }
+
+ private String prepareBadOperationErrorMessage(Throwable t, String origianalMessage) {
+ String badOperation = origianalMessage.substring(origianalMessage.indexOf("operation\":\"") + 12,
+ origianalMessage.indexOf(",\"url\":"));
+ String errorMessage = t.getMessage().replace("null", badOperation);
+ return errorMessage;
+ }
+
+ private Mono<String> invokePolicyAgent(DmaapRequestMessage dmaapRequestMessage) {
+ DmaapRequestMessage.Operation operation = dmaapRequestMessage.operation();
+ if (operation == null) {
+ return Mono.error(new ServiceException("Not implemented operation: " + operation));
+ }
+ Mono<String> result = null;
+ String uri = dmaapRequestMessage.url();
+ switch (operation) {
+ case DELETE:
+ result = agentClient.delete(uri);