if (!descriptorJson.has("name")) {
throw new ResourceException("Name must be included in POST body", BAD_REQUEST.getStatusCode());
}
String tableName = descriptorJson.get("name").asText();
String keyPrefix = null;
TableCreateDescriptor descriptor = null;
if (descriptorJson.has("keyPrefix")) {
keyPrefix = descriptorJson.get("keyPrefix").asText();
}
if (descriptorJson.has("splitKeys")) {
byte[][] splitKeys = TableConfig.parseSplitKeys(null, descriptorJson.get("splitKeys").asText(), keyPrefix);
descriptor = new TableCreateDescriptor(tableName, splitKeys);
} else if (descriptorJson.has("numRegions")) {
byte[][] splitKeys = TableConfig.parseSplitKeys(descriptorJson.get("numRegions").asInt(), null, keyPrefix);
descriptor = new TableCreateDescriptor(tableName, splitKeys);
} else {
descriptor = new TableCreateDescriptor(tableName);
}
getRepository(uriInfo).getTableManager().createTable(descriptor);
return Response.ok().build();
} catch (Exception e) {
throw new ResourceException("Error creating table", e, INTERNAL_SERVER_ERROR.getStatusCode());