*/
@PUT
@Path("/data/datasets/{name}/properties")
public void update(HttpRequest request, final HttpResponder responder,
@PathParam("name") String name) {
DatasetInstanceConfiguration creationProperties = getInstanceConfiguration(request);
LOG.info("Update dataset {}, type name: {}, typeAndProps: {}",
name, creationProperties.getTypeName(), creationProperties.getProperties());
DatasetSpecification existing = instanceManager.get(name);
if (existing == null) {
// update is true , but dataset instance does not exist, return 404.
responder.sendError(HttpResponseStatus.NOT_FOUND,
String.format("Dataset Instance %s does not exist to update", name));
return;
}
if (!existing.getType().equals(creationProperties.getTypeName())) {
String message = String.format("Cannot update dataset %s instance with a different type, existing type is %s",
name, existing.getType());
LOG.warn(message);
responder.sendError(HttpResponseStatus.CONFLICT, message);
return;
}
if (!createDatasetInstance(creationProperties, name, responder, "update")) {
return;
}
// Enable ad-hoc exploration of dataset
// Note: today explore enable is not transactional with dataset create - CDAP-8
try {
datasetExploreFacade.disableExplore(name);
datasetExploreFacade.enableExplore(name);
} catch (Exception e) {
String msg = String.format("Cannot enable exploration of dataset instance %s of type %s: %s",
name, creationProperties.getProperties(), e.getMessage());
LOG.error(msg, e);
// TODO: at this time we want to still allow using dataset even if it cannot be used for exploration
//responder.sendError(HttpResponseStatus.INTERNAL_SERVER_ERROR, msg);
//return;
}