use of edu.umass.cs.gnsclient.client.GNSClientCommands 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");
}
}
use of edu.umass.cs.gnsclient.client.GNSClientCommands 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.gnsclient.client.GNSClientCommands 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.gnsclient.client.GNSClientCommands 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.gnsclient.client.GNSClientCommands 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");
}
}
Aggregations