throws IOException, WebApplicationException {
JsonNode node = JsonFormat.deserializeNonStd(entityStream);
if (!(node instanceof ObjectNode)) {
throw new ResourceException("Request body should be a JSON object.", BAD_REQUEST.getStatusCode());
}
ObjectNode objectNode = (ObjectNode)node;
try {
// Multiple repositories: ok to use public repo since only non-repository-specific things are needed
return EntityRegistry.findReader(type).fromJson(objectNode, null, repositoryMgr.getDefaultRepository(),
linkTransformer);
} catch (JsonFormatException e) {
throw new ResourceException("Error in submitted JSON.", e, BAD_REQUEST.getStatusCode());
} catch (Exception e) {
throw new ResourceException("Error reading submitted JSON.", e, INTERNAL_SERVER_ERROR.getStatusCode());
}
}