public class FindRequestsTask implements AdminTask {
@Override
public ResponseDefinition execute(Admin admin, Request request) {
RequestPattern requestPattern = buildRequestPatternFrom(request.getBodyAsString());
FindRequestsResult result = admin.findRequestsMatching(requestPattern);
ResponseDefinition response = new ResponseDefinition(HTTP_OK, Json.write(result));
response.setHeaders(new HttpHeaders(httpHeader("Content-Type", "application/json")));
return response;
}