5050@ Immutable
5151@ Loggable (Loggable .DEBUG )
5252@ ToString (of = { })
53- @ EqualsAndHashCode (of = "response " )
53+ @ EqualsAndHashCode (of = "request " )
5454final class RtLocks implements Locks {
5555
5656 /**
5757 * Entry response.
5858 */
59- private final transient XmlResponse response ;
59+ private final transient Request request ;
6060
6161 /**
6262 * Ctor.
6363 * @param req Request
64- * @throws IOException If fails
6564 */
66- RtLocks (final Request req ) throws IOException {
67- this .response = req .fetch ()
68- .as (RestResponse .class )
69- .assertStatus (HttpURLConnection .HTTP_OK )
70- .as (XmlResponse .class );
65+ RtLocks (final Request req ) {
66+ this .request = req ;
7167 }
7268
7369 @ Override
7470 public boolean exists (final String name ) throws IOException {
75- return !this .response
71+ return !this .request
72+ .fetch ()
73+ .as (RestResponse .class )
74+ .assertStatus (HttpURLConnection .HTTP_OK )
75+ .as (XmlResponse .class )
7676 .rel ("/page/links/link[@rel='self']/@href" )
7777 .method (Request .GET )
7878 .fetch ()
@@ -83,13 +83,23 @@ public boolean exists(final String name) throws IOException {
8383 }
8484
8585 @ Override
86- public Lock get (final String name ) {
86+ public Lock get (final String name ) throws IOException {
8787 return new RtLock (
8888 name ,
89- this .response .rel ("/page/links/link[@rel='lock']/@href" )
89+ this .request
90+ .fetch ()
91+ .as (RestResponse .class )
92+ .assertStatus (HttpURLConnection .HTTP_OK )
93+ .as (XmlResponse .class )
94+ .rel ("/page/links/link[@rel='lock']/@href" )
9095 .method (Request .POST )
9196 .body ().formParam ("name" , name ).back (),
92- this .response .rel ("/page/links/link[@rel='unlock']/@href" )
97+ this .request
98+ .fetch ()
99+ .as (RestResponse .class )
100+ .assertStatus (HttpURLConnection .HTTP_OK )
101+ .as (XmlResponse .class )
102+ .rel ("/page/links/link[@rel='unlock']/@href" )
93103 .method (Request .GET )
94104 .uri ().queryParam ("name" , name ).back ()
95105 );
0 commit comments