Skip to content

Commit

Permalink
Merge pull request #41 from michpetrov/ely1084
Browse files Browse the repository at this point in the history
ELY-1084: show error when removing non-existent alias
  • Loading branch information
pskopek committed Apr 26, 2017
2 parents f2bbdd8 + 050fad3 commit fac1f30
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Expand Up @@ -185,10 +185,16 @@ public void execute(String[] args) throws Exception {
setStatus(ElytronTool.ElytronToolExitStatus_OK);
} else if (cmdLine.hasOption(REMOVE_ALIAS_PARAM)) {
String alias = cmdLine.getOptionValue(REMOVE_ALIAS_PARAM);
credentialStore.remove(alias, entryTypeToCredential(entryType));
credentialStore.flush();
System.out.println(ElytronToolMessages.msg.aliasRemoved(alias));
setStatus(ElytronTool.ElytronToolExitStatus_OK);
if (credentialStore.exists(alias, entryTypeToCredential(entryType))) {
credentialStore.remove(alias, entryTypeToCredential(entryType));
credentialStore.flush();
System.out.println(ElytronToolMessages.msg.aliasRemoved(alias));
setStatus(ElytronTool.ElytronToolExitStatus_OK);
} else {
System.out.println(ElytronToolMessages.msg.aliasDoesNotExist(alias));
setStatus(ALIAS_NOT_FOUND);
}

} else if (cmdLine.hasOption(CHECK_ALIAS_PARAM)) {
String alias = cmdLine.getOptionValue(CHECK_ALIAS_PARAM);
if (credentialStore.exists(alias, entryTypeToCredential(entryType))) {
Expand All @@ -200,11 +206,15 @@ public void execute(String[] args) throws Exception {
}
} else if (cmdLine.hasOption(ALIASES_PARAM)) {
Set<String> aliases = credentialStore.getAliases();
StringBuilder list = new StringBuilder();
for (String alias: aliases) {
list.append(alias).append(" ");
if (aliases.size() != 0) {
StringBuilder list = new StringBuilder();
for (String alias: aliases) {
list.append(alias).append(" ");
}
System.out.println(ElytronToolMessages.msg.aliases(list.toString()));
} else {
System.out.println(ElytronToolMessages.msg.noAliases());
}
System.out.println(ElytronToolMessages.msg.aliases(list.toString()));
setStatus(ElytronTool.ElytronToolExitStatus_OK);
} else {
setStatus(ACTION_NOT_DEFINED);
Expand Down
Expand Up @@ -128,6 +128,9 @@ public interface ElytronToolMessages extends BasicLogger {
@Message(id = NONE, value = "Credential store contains following aliases: %s")
String aliases(String aliases);

@Message(id = NONE, value = "Credential store contains no aliases")
String noAliases();

@Message(id = NONE, value = "Action to perform on the credential store is not defined")
Exception actionToPerformNotDefined();

Expand Down

0 comments on commit fac1f30

Please sign in to comment.