@POST
@Path("data/explore/datasets/{dataset}/enable")
public void enableExplore(@SuppressWarnings("UnusedParameters") HttpRequest request, HttpResponder responder,
@PathParam("dataset") final String datasetName) {
try {
Dataset dataset;
try {
dataset = datasetFramework.getDataset(datasetName, DatasetDefinition.NO_ARGUMENTS, null);
} catch (Exception e) {
String className = isClassNotFoundException(e);
if (className == null) {
throw e;
}
LOG.info("Cannot load dataset {} because class {} cannot be found. This is probably because class {} is a " +
"type parameter of dataset {} that is not present in the dataset's jar file. See the developer " +
"guide for more information.", datasetName, className, className, datasetName);
JsonObject json = new JsonObject();
json.addProperty("handle", QueryHandle.NO_OP.getHandle());
responder.sendJson(HttpResponseStatus.OK, json);
return;
}
if (dataset == null) {
responder.sendError(HttpResponseStatus.NOT_FOUND, "Cannot load dataset " + datasetName);
return;
}
if (!(dataset instanceof RecordScannable || dataset instanceof RecordWritable)) {
// It is not an error to get non-RecordEnabled datasets, since the type of dataset may not be known where this
// call originates from.
LOG.debug("Dataset {} neither implements {} nor {}", datasetName, RecordScannable.class.getName(),
RecordWritable.class.getName());
JsonObject json = new JsonObject();
json.addProperty("handle", QueryHandle.NO_OP.getHandle());
responder.sendJson(HttpResponseStatus.OK, json);
return;
}
LOG.debug("Enabling explore for dataset instance {}", datasetName);
String createStatement;
try {
createStatement = generateCreateStatement(datasetName, dataset);
} catch (UnsupportedTypeException e) {
LOG.error("Exception while generating create statement for dataset {}", datasetName, e);
responder.sendError(HttpResponseStatus.BAD_REQUEST, e.getMessage());
return;
}
LOG.debug("Running create statement for dataset {} with row scannable {} - {}",
datasetName,
dataset.getClass().getName(),
createStatement);
QueryHandle handle = exploreService.execute(createStatement);
JsonObject json = new JsonObject();
json.addProperty("handle", handle.getHandle());