*/
static BucketProperties convert(BucketResponse response) throws IOException {
String schema = response.getBodyAsString();
JsonNode root = OBJECT_MAPPER.readValue(schema, JsonNode.class);
BucketPropertiesBuilder builder = new BucketPropertiesBuilder();
JsonNode props = root.path(Constants.FL_SCHEMA);
if (props.isMissingNode()) {
throw new JsonMappingException("no 'props' field found");
}
builder.allowSiblings(props.path(Constants.FL_SCHEMA_ALLOW_MULT).asBoolean());
builder.lastWriteWins(props.path(Constants.FL_SCHEMA_LAST_WRITE_WINS).asBoolean());
builder.nVal(props.path(Constants.FL_SCHEMA_NVAL).asInt());
builder.backend(props.path(Constants.FL_SCHEMA_BACKEND).textValue());
builder.smallVClock(props.path(Constants.FL_SCHEMA_SMALL_VCLOCK).asInt());
builder.bigVClock(props.path(Constants.FL_SCHEMA_BIG_VCLOCK).asInt());
builder.youngVClock(props.path(Constants.FL_SCHEMA_YOUNG_VCLOCK).asLong());
builder.oldVClock(props.path(Constants.FL_SCHEMA_OLD_VCLOCK).asLong());
for (JsonNode n : props.path(Constants.FL_SCHEMA_PRECOMMIT)) {
if (n.path(Constants.FL_SCHEMA_FUN_NAME).isMissingNode()) {
builder.addPrecommitHook(OBJECT_MAPPER.treeToValue(n, NamedErlangFunction.class));
} else {
builder.addPrecommitHook(OBJECT_MAPPER.treeToValue(n, NamedJSFunction.class));
}
}
for (JsonNode n : props.path(Constants.FL_SCHEMA_POSTCOMMIT)) {
builder.addPostcommitHook(OBJECT_MAPPER.treeToValue(n, NamedErlangFunction.class));
}
builder.r(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_R), Quorum.class));
builder.w(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_W), Quorum.class));
builder.dw(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_DW), Quorum.class));
builder.rw(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_RW), Quorum.class));
// TODO backwards compatibility - remove when riak goes 1.3
if(!props.path(Constants.FL_SCHEMA_PR).isMissingNode()) {
builder.pr(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_PR), Quorum.class));
}
if(!props.path(Constants.FL_SCHEMA_PW).isMissingNode()) {
builder.pw(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_PW), Quorum.class));
}
if(!props.path(Constants.FL_SCHEMA_BASIC_QUORUM).isMissingNode()) {
builder.basicQuorum(props.path(Constants.FL_SCHEMA_BASIC_QUORUM).asBoolean());
}
if(!props.path(Constants.FL_SCHEMA_NOT_FOUND_OK).isMissingNode()) {
builder.notFoundOK(props.path(Constants.FL_SCHEMA_NOT_FOUND_OK).asBoolean());
}
builder.chashKeyFunction(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_CHASHFUN),
NamedErlangFunction.class));
builder.linkWalkFunction(OBJECT_MAPPER.treeToValue(props.path(Constants.FL_SCHEMA_LINKFUN),
NamedErlangFunction.class));
builder.search(props.path(Constants.FL_SCHEMA_SEARCH).asBoolean());
return builder.build();
}