sleep(60000);
/** * Wait for a certain status of a resource. * * @return either an exception or the status code of the last http response */ public static Either<Exception, Integer> waitForResource(final TrustedHttpClient http, final URI resourceUri, final int expectedStatus, final long timeout, final long pollingInterval) { long now = 0L; while (true) { final HttpHead head = new HttpHead(resourceUri); final Either<Exception, Integer> result = http.<Integer> run(head).apply(getStatusCode); for (final Integer status : result.right()) { if (eq(status, expectedStatus) || now >= timeout) { return right(status); } else if (now < timeout) { if (!sleep(pollingInterval)) { return left(new Exception("Interrupted")); } else { now = now + pollingInterval; } } } for (Exception e : result.left()) { return left(e); } } } }