use of com.linkedin.restli.server.BatchCreateResult in project rest.li by linkedin.
the class ValidationDemoResource method batchCreate.
@RestMethod.BatchCreate
public BatchCreateResult<Integer, ValidationDemo> batchCreate(final BatchCreateRequest<Integer, ValidationDemo> entities, @ValidatorParam RestLiDataValidator validator) {
List<CreateResponse> results = new ArrayList<CreateResponse>();
int id = 0;
for (ValidationDemo entity : entities.getInput()) {
ValidationResult result = validator.validateInput(entity);
if (result.isValid()) {
results.add(new CreateResponse(id));
id++;
} else {
results.add(new CreateResponse(new RestLiServiceException(HttpStatus.S_422_UNPROCESSABLE_ENTITY, result.getMessages().toString())));
}
}
return new BatchCreateResult<Integer, ValidationDemo>(results);
}
Aggregations