summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/AafPermissionService.java23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/AafPermissionService.java b/src/main/java/org/onap/dmaap/dbcapi/service/AafPermissionService.java
index df60448..00d6066 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/AafPermissionService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/AafPermissionService.java
@@ -57,25 +57,19 @@ public class AafPermissionService extends BaseLoggingClass {
}
ApiError grantClientRolePerms(MR_Client client) {
- try {
- String instance = INSTANCE_PREFIX + client.getFqtn();
-
- for (String action : client.getAction()) {
- grantPermForClientRole(client.getClientRole(), instance, action);
- }
-
- } catch (PermissionServiceException e) {
- return handleErrorStatus(e.getCode(), client, e.getMessage());
- }
- return handleOkStatus(client);
+ return forEachClientAction(client, this::grantPermForClientRole);
}
ApiError revokeClientPerms(MR_Client client) {
+ return forEachClientAction(client, this::revokePermForClientRole);
+ }
+
+ private ApiError forEachClientAction(MR_Client client, PermissionUpdate permissionUpdate) {
try {
String instance = INSTANCE_PREFIX + client.getFqtn();
for (String action : client.getAction()) {
- revokePermForClientRole(client.getClientRole(), instance, action);
+ permissionUpdate.execute(client.getClientRole(), instance, action);
}
} catch (PermissionServiceException e) {
@@ -138,4 +132,9 @@ public class AafPermissionService extends BaseLoggingClass {
return message;
}
}
+
+ @FunctionalInterface
+ interface PermissionUpdate {
+ void execute(String clientRole, String instance, String action) throws PermissionServiceException;
+ }
}