@Override
protected int executeCommand() throws CommandException {
CLICommand command = null;
if (domainDirParam != null && nodeDir != null) {
throw new CommandException(strings.get("both.domaindir.nodedir.not.allowed"));
}
try {
if (isDomain()) { // is it domain
command = CLICommand.getCommand(habitat,
CHANGE_MASTER_PASSWORD_DAS);
return command.execute(argv);
}
if (nodeDir != null) {
command = CLICommand.getCommand(habitat,
CHANGE_MASTER_PASSWORD_NODE);
return command.execute(argv);
} else {
// nodeDir is not specified and domainNameOrNodeName is not a domain.
// It could be a node
// We add defaultNodeDir parameter to args
ArrayList arguments = new ArrayList<String>(Arrays.asList(argv));
arguments.remove(argv.length -1);
arguments.add("--nodedir");
arguments.add(getDefaultNodesDirs().getAbsolutePath());
arguments.add(domainNameOrNodeName);
String[] newargs = (String[]) arguments.toArray(new String[arguments.size()]);
command = CLICommand.getCommand(habitat,
CHANGE_MASTER_PASSWORD_NODE);
return command.execute(newargs);
}
} catch (IOException e) {
throw new CommandException(e.getMessage(),e);
}
}