use of edu.umass.cs.gnscommon.exceptions.client.ClientException in project GNS by MobilityFirst.
the class GroupMemberRemove 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 guidToRemove = st.nextToken();
gnsClient.groupRemoveGuid(groupGuid, guidToRemove, module.getCurrentGuid());
printString("GUID " + guidToRemove + " removed from 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 FieldRead method parse.
@Override
public void parse(String commandText) throws Exception {
try {
GNSClientCommands gnsClient = module.getGnsClient();
StringTokenizer st = new StringTokenizer(commandText.trim());
String guid;
switch(st.countTokens()) {
case 1:
guid = module.getCurrentGuid().getGuid();
break;
case 2:
guid = st.nextToken();
if (!StringUtil.isValidGuidString(guid)) {
// We probably have an alias, lookup the GUID
guid = gnsClient.lookupGuid(guid);
}
break;
default:
wrongArguments();
return;
}
String field = st.nextToken();
String value = gnsClient.fieldRead(guid, field, module.getCurrentGuid());
console.printString(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 FieldReadList method parse.
@Override
public void parse(String commandText) throws Exception {
try {
GNSClientCommands gnsClient = module.getGnsClient();
StringTokenizer st = new StringTokenizer(commandText.trim());
String guid;
switch(st.countTokens()) {
case 1:
guid = module.getCurrentGuid().getGuid();
break;
case 2:
guid = st.nextToken();
if (!StringUtil.isValidGuidString(guid)) {
// We probably have an alias, lookup the GUID
guid = gnsClient.lookupGuid(guid);
}
break;
default:
wrongArguments();
return;
}
String field = st.nextToken();
JSONArray value = gnsClient.fieldReadArray(guid, field, module.getCurrentGuid());
console.printString(value.toString());
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 FieldUpdate method parse.
@Override
public void parse(String commandText) throws Exception {
GNSClientCommands gnsClient = module.getGnsClient();
try {
StringTokenizer st = new StringTokenizer(commandText.trim());
String guid;
switch(st.countTokens()) {
case 2:
guid = module.getCurrentGuid().getGuid();
break;
case 3:
guid = st.nextToken();
if (!StringUtil.isValidGuidString(guid)) {
// We probably have an alias, lookup the GUID
guid = gnsClient.lookupGuid(guid);
}
break;
default:
wrongArguments();
return;
}
String field = st.nextToken();
String value = st.nextToken();
gnsClient.fieldUpdate(guid, field, value, module.getCurrentGuid());
console.printString("Value '" + value + "' written to field " + field + " for GUID " + guid);
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 AliasLookup method parse.
@Override
public void parse(String commandText) throws Exception {
try {
StringTokenizer st = new StringTokenizer(commandText.trim());
if (st.countTokens() != 1) {
wrongArguments();
return;
}
String guid = st.nextToken();
GNSClientCommands gnsClient = module.getGnsClient();
JSONObject entityInfo = gnsClient.lookupGuidRecord(guid);
String alias = entityInfo.getString(GNSProtocol.GUID_RECORD_NAME.toString());
console.printString(guid + " has alias " + alias);
console.printNewline();
} catch (IOException | ClientException | JSONException e) {
console.printString("Failed to access GNS ( " + e + ")\n");
}
}
Aggregations