use of org.dcache.vehicles.BeanQueryAllPropertiesMessage in project dcache by dCache.
the class ProbeResponseEngine method queryUrl.
@Override
public void queryUrl(HttpRequest request) throws HttpException {
try {
String[] urlItems = request.getRequestTokens();
if (urlItems.length < 2) {
throw new HttpException(404, "No such property");
}
/* urlItems[0] is the mount point.
*/
BeanQueryMessage queryMessage = (urlItems.length == 3) ? new BeanQuerySinglePropertyMessage(urlItems[2]) : new BeanQueryAllPropertiesMessage();
BeanQueryMessage queryReply = stub.sendAndWait(new CellPath(urlItems[1]), queryMessage);
request.setContentType("application/json; charset=utf-8");
Writer writer = new OutputStreamWriter(request.getOutputStream(), UTF_8);
writer.append(new GsonBuilder().serializeSpecialFloatingPointValues().setPrettyPrinting().disableHtmlEscaping().create().toJson(queryReply.getResult()));
writer.flush();
} catch (NoRouteToCellException e) {
throw new HttpException(503, "The cell was unreachable, suspect trouble.");
} catch (TimeoutCacheException e) {
throw new HttpException(503, "The cell took too long to reply, suspect trouble.");
} catch (InvalidMessageCacheException e) {
throw new HttpException(404, "No such property");
} catch (CacheException | IOException e) {
throw new HttpException(500, e.getMessage());
} catch (InterruptedException e) {
throw new HttpException(503, "Received interrupt whilst processing data. Please try again later.");
}
}
Aggregations