diff options
author | pkaras <piotr.karas@nokia.com> | 2019-05-31 14:49:30 +0200 |
---|---|---|
committer | pkaras <piotr.karas@nokia.com> | 2019-06-03 14:05:27 +0200 |
commit | 675ec9e58d26fe0e73ba91004f77729c417364fd (patch) | |
tree | d403e69394aead4672d09d8cda31f9b9a6cf36fe | |
parent | ac2041bbd4f3f7212f91b75bc72d3735b6bc3642 (diff) |
AafPermissionService functional interface was used
Change-Id: Iec23491f492157b5c8d023c48035e4c678427655
Issue-ID: DMAAP-1211
Signed-off-by: piotr.karas <piotr.karas@nokia.com>
-rw-r--r-- | src/main/java/org/onap/dmaap/dbcapi/service/AafPermissionService.java | 23 |
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; + } } |