X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fclients%2FOscA1Client.java;h=90fbd101ee106350e0d1ec3685ed7cee03e12efe;hb=51716d5ce50b8e9b776a2f648261e5191ed921b8;hp=5a0bdc961f086746d0b0566ae0a60fff4c4029b5;hpb=5916f659ffe974b8b00b6d07bc845438695f0896;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/clients/OscA1Client.java b/policy-agent/src/main/java/org/oransc/policyagent/clients/OscA1Client.java index 5a0bdc96..90fbd101 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/clients/OscA1Client.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/clients/OscA1Client.java @@ -23,6 +23,7 @@ package org.oransc.policyagent.clients; import java.lang.invoke.MethodHandles; import java.util.List; +import org.json.JSONObject; import org.oransc.policyagent.configuration.RicConfig; import org.oransc.policyagent.repository.Policy; import org.slf4j.Logger; @@ -125,6 +126,19 @@ public class OscA1Client implements A1Client { uri = new UriBuilder(ricConfig); } + public static Mono extractCreateSchema(String policyTypeResponse, String policyTypeId) { + try { + JSONObject obj = new JSONObject(policyTypeResponse); + JSONObject schemaObj = obj.getJSONObject("create_schema"); + schemaObj.put(TITLE, policyTypeId); + return Mono.just(schemaObj.toString()); + } catch (Exception e) { + String exceptionString = e.toString(); + logger.error("Unexpected response for policy type: {}, exception: {}", policyTypeResponse, exceptionString); + return Mono.error(e); + } + } + @Override public Mono> getPolicyTypeIdentities() { return getPolicyTypeIds() // @@ -142,7 +156,7 @@ public class OscA1Client implements A1Client { public Mono getPolicyTypeSchema(String policyTypeId) { String schemaUri = uri.createGetSchemaUri(policyTypeId); return restClient.get(schemaUri) // - .flatMap(response -> SdncJsonHelper.getCreateSchema(response, policyTypeId)); + .flatMap(response -> extractCreateSchema(response, policyTypeId)); } @Override