use of edu.umass.cs.gnscommon.exceptions.server.InternalRequestException in project GNS by MobilityFirst.
the class NSFieldAccess method lookupJSONFieldAnywhere.
/**
* Looks up the value of a field in the guid.
* If guid doesn't exists on this Name Server,
* sends a read query from this Name Server to a Local Name Server.
* Returns the value of a field in a GNSProtocol.GUID.toString() as a ValuesMap
*
* @param header
* @param guid
* @param field
* @param gnsApp
* @return ValuesMap containing the value of the field or null if field cannot be found
* @throws edu.umass.cs.gnscommon.exceptions.server.FailedDBOperationException
*/
public static ValuesMap lookupJSONFieldAnywhere(InternalRequestHeader header, String guid, String field, GNSApplicationInterface<String> gnsApp) throws FailedDBOperationException {
ValuesMap result = lookupJSONFieldLocally(null, guid, field, gnsApp);
// if values wasn't found and the guid doesn't exist on this server and we're allowed then send a query to the LNS
if (result == null && !gnsApp.getDB().containsName(guid)) {
try {
String stringResult = gnsApp.getRequestHandler().getInternalClient().execute(GNSCommandInternal.fieldRead(guid, field, header)).getResultString();
if (stringResult != null) {
result = new ValuesMap();
result.put(field, stringResult);
}
} catch (IOException | JSONException | ClientException | InternalRequestException e) {
ClientSupportConfig.getLogger().log(Level.SEVERE, "Problem getting record from remote server: {0}", e);
}
if (result != null) {
ClientSupportConfig.getLogger().log(Level.FINE, "@@@@@@ Field {0} in {1} not found on this server but was found thru remote query.", new Object[] { field, guid });
}
}
return result;
}
use of edu.umass.cs.gnscommon.exceptions.server.InternalRequestException in project GNS by MobilityFirst.
the class NSFieldAccess method lookupJSONFieldLocalNoAuth.
/**
* Looks up the value of a field in the guid on this NameServer.
* Active code is handled if handleActiveCode is true.
*
* Returns the value of a field in a GNSProtocol.GUID.toString() as a ValuesMap.
*
* @param header
* @param guid
* @param field
* @param gnsApp
* @param handleActiveCode
* @return ResultValue
* @throws edu.umass.cs.gnscommon.exceptions.server.FailedDBOperationException
*/
public static ValuesMap lookupJSONFieldLocalNoAuth(InternalRequestHeader header, String guid, String field, GNSApplicationInterface<String> gnsApp, boolean handleActiveCode) throws FailedDBOperationException {
ValuesMap valuesMap = lookupFieldLocalNoAuth(guid, field, ColumnFieldType.USER_JSON, gnsApp.getDB());
if (handleActiveCode) {
try {
JSONObject result = ActiveCodeHandler.handleActiveCode(header, guid, field, ActiveCode.READ_ACTION, valuesMap, gnsApp.getDB());
valuesMap = result != null ? new ValuesMap(result) : valuesMap;
} catch (InternalRequestException e) {
// Active code field lookup failed, do nothing and return the original value
}
}
return valuesMap;
}
Aggregations