use of dontweave.gson.JsonObject in project h2o-2 by h2oai.
the class Remove method serve.
@Override
protected Response serve() {
try {
Lockable.delete(_key.value()._key);
} catch (Throwable e) {
return Response.error(e);
}
JsonObject response = new JsonObject();
response.addProperty(KEY, _key.toString());
return Response.redirect(response, StoreView.class, null);
}
use of dontweave.gson.JsonObject in project h2o-2 by h2oai.
the class RemoveAck method serve.
@Override
protected Response serve() {
Value v = _key.value();
String key = v._key.toString();
JsonObject response = new JsonObject();
response.addProperty(RequestStatics.KEY, key);
Response r = Response.done(new JsonObject());
r.addHeader(//
"" + "<div class='alert alert-error'>Are you sure you want to delete key <strong>" + key + //
"</strong>?<br/>" + //
"There is no way back!" + //
"</div>" + //
"<div style='text-align:center'>" + //
"<a href='javascript:history.back()'><button class='btn btn-primary'>No, go back</button></a>" + //
" " + "<a href='Remove.html?" + KEY + "=" + key + //
"'><button class='btn btn-danger'>Yes!</button></a>" + "</div>");
return r;
}
use of dontweave.gson.JsonObject in project h2o-2 by h2oai.
the class ExportHdfs method serve.
@Override
protected Response serve() {
Value value = _source.value();
String path = _path.value();
try {
if (value == null)
throw new IllegalArgumentException("Unknown key: " + _source.record()._originalValue);
byte[] data = null;
Model model = getAsModel(value);
if (model != null) {
// Add extension, used during import
if (!path.endsWith(Extensions.JSON))
path += Extensions.JSON;
data = model.writeJSON(new AutoBuffer()).buf();
}
if (data != null)
PersistHdfs.store(new Path(path), data);
else
throw new UnsupportedOperationException("Only models can be exported");
} catch (Throwable e) {
return Response.error(e);
}
JsonObject json = new JsonObject();
Response r = Response.done(json);
return r;
}
use of dontweave.gson.JsonObject in project h2o-2 by h2oai.
the class GetTimezone method serve.
@Override
protected Response serve() {
String s = ParseTime.getTimezone().getID();
JsonObject response = new JsonObject();
response.addProperty("tz", s);
return Response.done(response);
}
use of dontweave.gson.JsonObject in project h2o-2 by h2oai.
the class Jobs method redirect.
public static Response redirect(JsonObject resp, Key dest) {
JsonObject redir = new JsonObject();
redir.addProperty(KEY, dest.toString());
return Response.redirect(resp, Jobs.class, redir);
}
Aggregations