X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fcontrollers%2FPolicyController.java;h=b5388610caaec61ce538bfa77a0521344271ceee;hb=137656019166c0a9eeb6882e4abf27af8b31444e;hp=e8c75ec9ea914717096eb84d64e60ba6b3c207dd;hpb=6f609c727d66ad20b5b31eae472fcde5e4acd569;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java index e8c75ec9..b5388610 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/controllers/PolicyController.java @@ -28,6 +28,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -46,6 +47,8 @@ import org.oransc.policyagent.repository.Ric; import org.oransc.policyagent.repository.Rics; import org.oransc.policyagent.repository.Service; import org.oransc.policyagent.repository.Services; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -84,6 +87,7 @@ public class PolicyController { @Autowired private Services services; + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static Gson gson = new GsonBuilder() // .serializeNulls() // .create(); // @@ -205,6 +209,7 @@ public class PolicyController { @RequestParam(name = "id", required = true) String instanceId, // @RequestParam(name = "ric", required = true) String ricName, // @RequestParam(name = "service", required = true) String service, // + @RequestParam(name = "transient", required = false, defaultValue = "false") boolean isTransient, // @RequestBody Object jsonBody) { String jsonString = gson.toJson(jsonBody); @@ -221,6 +226,7 @@ public class PolicyController { .ric(ric) // .ownerServiceName(service) // .lastModified(getTimeStampUtc()) // + .isTransient(isTransient) // .build(); final boolean isCreate = this.policies.get(policy.id()) == null; @@ -263,6 +269,7 @@ public class PolicyController { RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + // ", RIC name: " + current.ric().name() + // ", new name: " + policy.ric().name(), HttpStatus.CONFLICT); + logger.debug("Request rejected, {}", e.getMessage()); return Mono.error(e); } return Mono.just("OK"); @@ -270,6 +277,7 @@ public class PolicyController { private Mono checkSupportedType(Ric ric, PolicyType type) { if (!ric.isSupportingType(type.name())) { + logger.debug("Request rejected, type not supported, RIC: {}", ric); RejectionException e = new RejectionException( "Type: " + type.name() + " not supported by RIC: " + ric.name(), HttpStatus.NOT_FOUND); return Mono.error(e); @@ -281,6 +289,7 @@ public class PolicyController { if (ric.getState() == Ric.RicState.AVAILABLE) { return Mono.just("OK"); } else { + logger.debug("Request rejected RIC not IDLE, ric: {}", ric); RejectionException e = new RejectionException( "Ric is not operational, RIC name: " + ric.name() + ", state: " + ric.getState(), HttpStatus.LOCKED); return Mono.error(e); @@ -399,7 +408,7 @@ public class PolicyController { policyInfo.service = p.ownerServiceName(); policyInfo.lastModified = p.lastModified(); if (!policyInfo.validate()) { - throw new NullPointerException("BUG, all fields must be set"); + logger.error("BUG, all fields must be set"); } v.add(policyInfo); }