diff options
Diffstat (limited to 'src/main/java/org')
3 files changed, 50 insertions, 3 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafService.java b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafService.java index 30efbf2..2444d49 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafService.java @@ -33,6 +33,8 @@ public interface AafService { int addPerm(DmaapPerm perm); + int delPerm(DmaapPerm perm); + int addGrant(DmaapGrant grant); int addUserRole(AafUserRole ur); @@ -41,6 +43,7 @@ public interface AafService { int addRole(AafRole role); - int addNamespace(AafNamespace ns); + + int delNamespace(AafNamespace ns); } diff --git a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafServiceImpl.java b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafServiceImpl.java index 4397a88..a01b30c 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/aaf/AafServiceImpl.java +++ b/src/main/java/org/onap/dmaap/dbcapi/aaf/AafServiceImpl.java @@ -106,6 +106,11 @@ public class AafServiceImpl extends BaseLoggingClass implements AafService { return doPost(perm, "authz/perm", 201); } + @Override + public int delPerm(DmaapPerm perm) { + return 200; + } + public int addGrant(DmaapGrant grant) { logger.info("entry: addGrant() "); return doPost(grant, "authz/role/perm", 201); @@ -160,6 +165,11 @@ public class AafServiceImpl extends BaseLoggingClass implements AafService { return doPost(ns, "authz/ns", 201); } + @Override + public int delNamespace(AafNamespace ns) { + return 200; + } + private int doPost(AafObject obj, String uri, int expect) { int rc = -1; 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..d9dd4fd 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); + 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); + 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"); } |