X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fservice%2FAafTopicSetupService.java;h=9480b6acfac030cbc5831796590c60f9081b5ee2;hb=27a9a302a7d7e1894732535a8eb61f3460637b24;hp=a1fc89ed47ea556ead1da7b1c33e91b13d73d9c1;hpb=411cb435b5878b2663bfa9b6d2495c707353cd63;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/AafTopicSetupService.java b/src/main/java/org/onap/dmaap/dbcapi/service/AafTopicSetupService.java index a1fc89e..9480b6a 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/service/AafTopicSetupService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/service/AafTopicSetupService.java @@ -78,6 +78,21 @@ class AafTopicSetupService extends BaseLoggingClass { } ApiError aafTopicCleanup(Topic topic) { + try { + + String instance = ":topic." + topic.getFqtn(); + String topicPerm = dmaapService.getTopicPerm(); + removePermission(topicPerm, instance, "pub"); + removePermission(topicPerm, instance, "sub"); + removePermission(topicPerm, instance, "view"); + + if (createTopicRoles && topic.getFqtn().startsWith(getTopicsNsRoot())) { + removeNamespace(topic); + } + + } catch (TopicSetupException ex) { + return new ApiError(ex.getCode(), ex.getMessage(), ex.getFields()); + } return okStatus(); } @@ -122,9 +137,8 @@ class AafTopicSetupService extends BaseLoggingClass { } private AafRole createRole(Topic topic, String roleName) throws TopicSetupException { - int rc; AafRole role = new AafRole(topic.getFqtn(), roleName); - rc = aafService.addRole(role); + int rc = aafService.addRole(role); if (rc != 201 && rc != 409) { throw new TopicSetupException(500, format("Unexpected response from AAF: %d topic=%s role=%s", @@ -133,6 +147,26 @@ class AafTopicSetupService extends BaseLoggingClass { return role; } + private void removePermission(String permission, String instance, String action) throws TopicSetupException { + DmaapPerm perm = new DmaapPerm(permission, instance, action); + int rc = aafService.delPerm(perm, true); + if (rc != 200 && rc != 404) { + throw new TopicSetupException(500, + format("Unexpected response from AAF: %d permission=%s instance=%s action=%s", + rc, perm, instance, action)); + } + } + + private void removeNamespace(Topic topic) throws TopicSetupException { + AafNamespace ns = new AafNamespace(topic.getFqtn(), aafService.getIdentity()); + int rc = aafService.delNamespace(ns, true); + if (rc != 200 && rc != 404) { + throw new TopicSetupException(500, + format("Unexpected response from AAF: %d namespace=%s identity=%s", + rc, topic.getFqtn(), aafService.getIdentity())); + } + } + private ApiError okStatus() { return new ApiError(200, "OK"); }