diff options
Diffstat (limited to 'a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java')
-rw-r--r-- | a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java index 1f5f7ca9..c2f6a48a 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v1/PolicyController.java @@ -44,7 +44,6 @@ import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1ClientFactory; import org.onap.ccsdk.oran.a1policymanagementservice.controllers.VoidResponse; import org.onap.ccsdk.oran.a1policymanagementservice.controllers.v2.ErrorResponse; import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.EntityNotFoundException; -import org.onap.ccsdk.oran.a1policymanagementservice.repository.ImmutablePolicy; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Lock.LockType; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policy; @@ -135,7 +134,7 @@ public class PolicyController { description = "The identity of the policy type to get the definition for.") // @RequestParam(name = "id", required = true) String id) throws EntityNotFoundException { PolicyType type = policyTypes.getType(id); - return new ResponseEntity<>(type.schema(), HttpStatus.OK); + return new ResponseEntity<>(type.getSchema(), HttpStatus.OK); } @GetMapping("/policy_types") @@ -175,7 +174,7 @@ public class PolicyController { @Parameter(name = "id", required = true, description = "The identity of the policy instance.") // @RequestParam(name = "id", required = true) String id) throws EntityNotFoundException { Policy p = policies.getPolicy(id); - return new ResponseEntity<>(p.json(), HttpStatus.OK); + return new ResponseEntity<>(p.getJson(), HttpStatus.OK); } @DeleteMapping("/policy") @@ -197,11 +196,11 @@ public class PolicyController { @Parameter(name = "id", required = true, description = "The identity of the policy instance.") // @RequestParam(name = "id", required = true) String id) throws EntityNotFoundException { Policy policy = policies.getPolicy(id); - keepServiceAlive(policy.ownerServiceId()); - Ric ric = policy.ric(); + keepServiceAlive(policy.getOwnerServiceId()); + Ric ric = policy.getRic(); return ric.getLock().lock(LockType.SHARED) // .flatMap(notUsed -> assertRicStateIdle(ric)) // - .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.ric())) // + .flatMap(notUsed -> a1ClientFactory.createA1Client(policy.getRic())) // .doOnNext(notUsed -> policies.remove(policy)) // .flatMap(client -> client.deletePolicy(policy)) // .doOnNext(notUsed -> ric.getLock().unlockBlocking()) // @@ -252,7 +251,7 @@ public class PolicyController { if (ric == null || type == null) { return Mono.just(new ResponseEntity<>(HttpStatus.NOT_FOUND)); } - Policy policy = ImmutablePolicy.builder() // + Policy policy = Policy.builder() // .id(instanceId) // .json(jsonString) // .type(type) // @@ -263,7 +262,7 @@ public class PolicyController { .statusNotificationUri("") // .build(); - final boolean isCreate = this.policies.get(policy.id()) == null; + final boolean isCreate = this.policies.get(policy.getId()) == null; return ric.getLock().lock(LockType.SHARED) // .flatMap(notUsed -> assertRicStateIdle(ric)) // @@ -298,11 +297,11 @@ public class PolicyController { private Mono<Object> validateModifiedPolicy(Policy policy) { // Check that ric is not updated - Policy current = this.policies.get(policy.id()); - if (current != null && !current.ric().id().equals(policy.ric().id())) { - RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.id() + // - ", RIC name: " + current.ric().id() + // - ", new name: " + policy.ric().id(), HttpStatus.CONFLICT); + Policy current = this.policies.get(policy.getId()); + if (current != null && !current.getRic().id().equals(policy.getRic().id())) { + RejectionException e = new RejectionException("Policy cannot change RIC, policyId: " + current.getId() + // + ", RIC name: " + current.getRic().id() + // + ", new name: " + policy.getRic().id(), HttpStatus.CONFLICT); logger.debug("Request rejected, {}", e.getMessage()); return Mono.error(e); } @@ -310,10 +309,10 @@ public class PolicyController { } private Mono<Object> checkSupportedType(Ric ric, PolicyType type) { - if (!ric.isSupportingType(type.id())) { + if (!ric.isSupportingType(type.getId())) { logger.debug("Request rejected, type not supported, RIC: {}", ric); - RejectionException e = new RejectionException("Type: " + type.id() + " not supported by RIC: " + ric.id(), - HttpStatus.NOT_FOUND); + RejectionException e = new RejectionException( + "Type: " + type.getId() + " not supported by RIC: " + ric.id(), HttpStatus.NOT_FOUND); return Mono.error(e); } return Mono.just("OK"); @@ -405,7 +404,7 @@ public class PolicyController { throws EntityNotFoundException { Policy policy = policies.getPolicy(id); - return a1ClientFactory.createA1Client(policy.ric()) // + return a1ClientFactory.createA1Client(policy.getRic()) // .flatMap(client -> client.getPolicyStatus(policy)) // .flatMap(status -> Mono.just(new ResponseEntity<>(status, HttpStatus.OK))) .onErrorResume(this::handleException); @@ -428,7 +427,8 @@ public class PolicyController { } List<Policy> filtered = new ArrayList<>(); for (Policy p : collection) { - if (include(type, p.type().id()) && include(ric, p.ric().id()) && include(service, p.ownerServiceId())) { + if (include(type, p.getType().getId()) && include(ric, p.getRic().id()) + && include(service, p.getOwnerServiceId())) { filtered.add(p); } } @@ -451,12 +451,12 @@ public class PolicyController { List<PolicyInfo> v = new ArrayList<>(policies.size()); for (Policy p : policies) { PolicyInfo policyInfo = new PolicyInfo(); - policyInfo.id = p.id(); - policyInfo.json = fromJson(p.json()); - policyInfo.ric = p.ric().id(); - policyInfo.type = p.type().id(); - policyInfo.service = p.ownerServiceId(); - policyInfo.lastModified = p.lastModified().toString(); + policyInfo.id = p.getId(); + policyInfo.json = fromJson(p.getJson()); + policyInfo.ric = p.getRic().id(); + policyInfo.type = p.getType().getId(); + policyInfo.service = p.getOwnerServiceId(); + policyInfo.lastModified = p.getLastModified().toString(); if (!policyInfo.validate()) { logger.error("BUG, all fields must be set"); } @@ -478,7 +478,7 @@ public class PolicyController { result.append(","); } first = false; - result.append(t.schema()); + result.append(t.getSchema()); } result.append("]"); return result.toString(); @@ -487,7 +487,7 @@ public class PolicyController { private String toPolicyTypeIdsJson(Collection<PolicyType> types) { List<String> v = new ArrayList<>(types.size()); for (PolicyType t : types) { - v.add(t.id()); + v.add(t.getId()); } return gson.toJson(v); } @@ -495,7 +495,7 @@ public class PolicyController { private String toPolicyIdsJson(Collection<Policy> policies) { List<String> v = new ArrayList<>(policies.size()); for (Policy p : policies) { - v.add(p.id()); + v.add(p.getId()); } return gson.toJson(v); } |