adjust to use password-service
[aaa.git] / aaa-cli / src / main / java / org / opendaylight / aaa / cli / dmstore / RemoveRole.java
index 2fbc358a5dce33b862923d0efb77b29a609919f3..5da16d3f3904a459684642a8fd5fad103d1b6c51 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Inocybe Technologies. and others.  All rights reserved.
+ * Copyright (c) 2016, 2017 Inocybe Technologies. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,8 +10,8 @@ package org.opendaylight.aaa.cli.dmstore;
 
 import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.opendaylight.aaa.api.IIDMStore;
+import org.opendaylight.aaa.api.ClaimCache;
+import org.opendaylight.aaa.api.password.service.PasswordHashService;
 import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
 import org.opendaylight.aaa.cli.utils.CliUtils;
 import org.opendaylight.aaa.cli.utils.DataStoreUtils;
@@ -24,15 +24,15 @@ import org.opendaylight.aaa.cli.utils.DataStoreUtils;
  */
 public class RemoveRole extends AaaCliAbstractCommand {
 
-    @Option(name = "-name",
-            aliases = { "--roleName" },
-            description = "The role name",
-            required = true,
-            multiValued = false)
-    private String roleName = "";
+    private final ClaimCache claimCache;
 
-    public RemoveRole(final IIDMStore identityStore) {
-        super(identityStore);
+    @Option(name = "-name", aliases = {
+            "--roleName" }, description = "The role name", required = true, multiValued = false)
+    private String roleName;
+
+    public RemoveRole(final ClaimCache claimCache, final PasswordHashService passwordService) {
+        super(passwordService);
+        this.claimCache = claimCache;
     }
 
     @Override
@@ -44,9 +44,10 @@ public class RemoveRole extends AaaCliAbstractCommand {
         if (roleId == null) {
             return "Role does not exist";
         }
-        if (identityStore.deleteUser(roleId) == null) {
+        if (identityStore.deleteRole(roleId) == null) {
             return "Failed to delete role " + roleName;
         }
+        claimCache.clear();
         return "Role " + roleName + "has been deleted.";
     }
 }