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.commands.Command;
12 import org.apache.karaf.shell.commands.Option;
13 import org.opendaylight.aaa.api.ClaimCache;
14 import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
15 import org.opendaylight.aaa.cli.utils.CliUtils;
16 import org.opendaylight.aaa.cli.utils.DataStoreUtils;
18 @Command(name = "remove-domain", scope = "aaa", description = "Remove domain.")
24 public class RemoveDomain extends AaaCliAbstractCommand {
26 private final ClaimCache claimCache;
28 @Option(name = "-name", aliases = {
29 "--domainName" }, description = "The domain name", required = true, multiValued = false)
30 private String domainName;
32 public RemoveDomain(ClaimCache claimCache) {
33 this.claimCache = claimCache;
37 protected Object doExecute() throws Exception {
38 if (super.doExecute() == null) {
39 return CliUtils.LOGIN_FAILED_MESS;
41 final String domainId = DataStoreUtils.getDomainId(identityStore, domainName);
42 if (domainId == null) {
43 return "User does not exist";
45 if (identityStore.deleteDomain(domainId) == null) {
46 return "Failed to delete domain " + domainName;
49 return "Domain " + domainName + "has been deleted.";