2 * Copyright (c) 2016, 2017 Inocybe Technologies. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.aaa.cli.dmstore;
11 import org.apache.karaf.shell.api.action.Command;
12 import org.apache.karaf.shell.api.action.Option;
13 import org.apache.karaf.shell.api.action.lifecycle.Service;
14 import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
15 import org.opendaylight.aaa.cli.utils.DataStoreUtils;
23 @Command(name = "remove-role", scope = "aaa", description = "Remove role.")
24 public class RemoveRole extends AaaCliAbstractCommand {
25 @Option(name = "-name",
26 aliases = { "--roleName" },
27 description = "The role name",
30 private String roleName;
33 public Object execute() throws Exception {
34 if (super.execute() == null) {
35 return LOGIN_FAILED_MESS;
37 final String roleId = DataStoreUtils.getRoleId(identityStore, roleName);
39 return "Role does not exist";
41 if (identityStore.deleteRole(roleId) == null) {
42 return "Failed to delete role " + roleName;
44 return "Role " + roleName + "has been deleted.";