Skip to content

Commit caf0a7e

Browse files
author
Yegor Bugayenko
committed
#3 versions up
1 parent 477a38f commit caf0a7e

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<parent>
3434
<groupId>com.jcabi</groupId>
3535
<artifactId>parent</artifactId>
36-
<version>0.31</version>
36+
<version>0.32.1</version>
3737
</parent>
3838
<groupId>co.stateful</groupId>
3939
<artifactId>java-sdk</artifactId>
@@ -117,6 +117,7 @@
117117
<dependency>
118118
<groupId>com.jcabi</groupId>
119119
<artifactId>jcabi-http</artifactId>
120+
<version>1.10.2</version>
120121
</dependency>
121122
<dependency>
122123
<groupId>com.jcabi</groupId>
@@ -147,7 +148,7 @@
147148
<dependency>
148149
<groupId>com.sun.jersey</groupId>
149150
<artifactId>jersey-client</artifactId>
150-
<version>1.18.1</version>
151+
<version>1.18.3</version>
151152
<scope>runtime</scope>
152153
</dependency>
153154
<dependency>

src/main/java/co/stateful/RtLocks.java

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,29 +50,29 @@
5050
@Immutable
5151
@Loggable(Loggable.DEBUG)
5252
@ToString(of = { })
53-
@EqualsAndHashCode(of = "response")
53+
@EqualsAndHashCode(of = "request")
5454
final 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

Comments
 (0)