use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class GroupSingleAddTest method test_210_GroupCreate.
/**
*
*/
@Test
public void test_210_GroupCreate() {
String mygroupName = "mygroup" + RandomString.randomString(12);
try {
try {
clientCommands.lookupGuid(mygroupName);
Utils.failWithStackTrace(mygroupName + " entity should not exist");
} catch (ClientException e) {
}
mygroupEntry = clientCommands.guidCreate(masterGuid, mygroupName);
} catch (IOException | ClientException e) {
Utils.failWithStackTrace("Exception while creating guids: ", e);
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class AccountDelete method parse.
@Override
public void parse(String commandText) throws Exception {
StringTokenizer st = new StringTokenizer(commandText.trim());
if ((st.countTokens() != 1)) {
wrongArguments();
return;
}
String aliasName = st.nextToken();
try {
GNSClientCommands gnsClient = module.getGnsClient();
try {
gnsClient.lookupGuid(aliasName);
} catch (IOException | ClientException expected) {
printString("Alias " + aliasName + " doesn't exist.\n");
return;
}
GuidEntry myGuid = KeyPairUtils.getGuidEntry(module.getGnsInstance(), aliasName);
if (myGuid == null) {
printString("Unable to retrieve GUID for alias " + aliasName + "\n");
return;
}
gnsClient.accountGuidRemove(myGuid);
KeyPairUtils.removeKeyPair(module.getGnsInstance(), aliasName);
module.setCurrentGuidAndCheckForVerified(null);
module.setPromptString(ConsoleModule.CONSOLE_PROMPT + ">");
if (!module.isSilent()) {
printString("Removed account GUID " + myGuid.getGuid() + "\n");
}
} catch (ClientException | IOException e) {
printString("Failed to delete guid ( " + e + ")\n");
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class GuidLookup method parse.
@Override
public void parse(String commandText) throws Exception {
try {
StringTokenizer st = new StringTokenizer(commandText.trim());
if (st.countTokens() != 1) {
wrongArguments();
return;
}
String alias = st.nextToken();
GNSClientCommands gnsClient = module.getGnsClient();
String value = gnsClient.lookupGuid(alias);
console.printString(alias + " has GUID " + value);
console.printNewline();
} catch (IOException | ClientException e) {
console.printString("Failed to access GNS ( " + e + ")\n");
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class GroupMemberAdd method parse.
@Override
public void parse(String commandText) throws Exception {
GNSClientCommands gnsClient = module.getGnsClient();
try {
StringTokenizer st = new StringTokenizer(commandText.trim());
String groupGuid;
switch(st.countTokens()) {
case 1:
groupGuid = module.getCurrentGuid().getGuid();
break;
case 2:
groupGuid = st.nextToken();
if (!StringUtil.isValidGuidString(groupGuid)) {
// We probably have an alias, lookup the GUID
groupGuid = gnsClient.lookupGuid(groupGuid);
}
break;
default:
wrongArguments();
return;
}
String guidToAdd = st.nextToken();
gnsClient.groupAddGuid(groupGuid, guidToAdd, module.getCurrentGuid());
printString("GUID " + guidToAdd + " added to group " + groupGuid + "\n");
} catch (IOException | ClientException e) {
printString("Failed to access GNS ( " + e + ")\n");
}
}
use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class GroupMemberList method parse.
@Override
public void parse(String commandText) throws Exception {
GNSClientCommands gnsClient = module.getGnsClient();
try {
StringTokenizer st = new StringTokenizer(commandText.trim());
String groupGuid;
switch(st.countTokens()) {
case 0:
groupGuid = module.getCurrentGuid().getGuid();
break;
case 1:
groupGuid = st.nextToken();
if (!StringUtil.isValidGuidString(groupGuid)) {
// We probably have an alias, lookup the GUID
groupGuid = gnsClient.lookupGuid(groupGuid);
}
break;
default:
wrongArguments();
return;
}
console.printString("Members in group " + groupGuid);
console.printNewline();
JSONArray members = gnsClient.groupGetMembers(groupGuid, module.getCurrentGuid());
for (int i = 0; i < members.length(); i++) {
console.printString(i + ": " + members.getString(i));
console.printNewline();
}
} catch (IOException | ClientException | JSONException e) {
console.printString("Failed to access GNS ( " + e + ")\n");
}
}
Aggregations