Refine search
@Override public String label() throws IOException { final long start = System.currentTimeMillis(); final String label = this.front("label") .uri().queryParam("name", this.lck).back() .method(Request.GET) .fetch() .body(); Logger.info( this, "label of \"%s\" retrieved in %[ms]s: \"%s\"", this.lck, System.currentTimeMillis() - start, label ); return label; }
@Override public boolean unlock(final String label) throws IOException { final long start = System.currentTimeMillis(); final Response rsp = this.front("unlock") .uri().queryParam("label", label) .queryParam("name", this.lck).back() .method(Request.GET) .fetch(); final boolean unlocked = rsp.status() == HttpURLConnection.HTTP_SEE_OTHER; Logger.info( this, "unlock of \"%s\" is %B in %[ms]s", this.lck, unlocked, System.currentTimeMillis() - start ); return unlocked; }
@Override public boolean lock(final String label) throws IOException { final long start = System.currentTimeMillis(); final Response rsp = this.front("lock") .body().formParam("label", label) .formParam("name", this.lck).back() .method(Request.POST) .fetch(); final boolean locked = rsp.status() == HttpURLConnection.HTTP_SEE_OTHER; Logger.info( this, "lock of \"%s\" is %B in %[ms]s: %s", this.lck, locked, System.currentTimeMillis() - start, rsp.body() ); return locked; }
@Override public boolean exists(final String name) throws IOException { return !this.request .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel("/page/links/link[@rel='self']/@href") .method(Request.GET) .fetch() .as(XmlResponse.class) .xml() .nodes(String.format("/page/locks/lock[name='%s']", name)) .isEmpty(); }