final JsonRepresentation propertiesList = objectRepr.getArrayEnsured("members[memberType=property]");
if (propertiesList == null) {
throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, "Could not find properties list (no members[memberType=property]); got %s", objectRepr);
}
final IsisTransactionManager transactionManager = getResourceContext().getPersistenceSession().getTransactionManager();
transactionManager.startTransaction();
try {
if (!DomainResourceHelper.copyOverProperties(getResourceContext(), objectAdapter, propertiesList)) {
transactionManager.abortTransaction();
throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, objectRepr, "Illegal property value");
}
final Consent validity = objectAdapter.getSpecification().isValid(objectAdapter);
if (validity.isVetoed()) {
transactionManager.abortTransaction();
throw JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, objectRepr, validity.getReason());
}
transactionManager.endTransaction();
} finally {
// in case an exception got thrown somewhere...
if (!transactionManager.getTransaction().getState().isComplete()) {
transactionManager.abortTransaction();
}
}
final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), objectAdapter);
return helper.objectRepresentation();