Skip to content

Commit

Permalink
Fix path lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Sep 30, 2019
1 parent 4160969 commit 5bc8856
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class RegistrationLegacy extends AbstractRegistration {
public RegistrationLegacy(final String tenantId, final HttpUrl deviceRegistryUrl) {
super(tenantId);

this.registrationUrl = deviceRegistryUrl.resolve("/registration/");
this.credentialsUrl = deviceRegistryUrl.resolve("/credentials/");
this.registrationUrl = deviceRegistryUrl.resolve("registration/");
this.credentialsUrl = deviceRegistryUrl.resolve("credentials/");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ public class RegistrationV1 extends AbstractRegistration {
public RegistrationV1(final String tenantId, final HttpUrl deviceRegistryUrl) {
super(tenantId);

this.registrationUrl = deviceRegistryUrl.resolve("/devices/");
this.credentialsUrl = deviceRegistryUrl.resolve("/credentials/");
this.registrationUrl = deviceRegistryUrl
.newBuilder()
.addPathSegment("devices")
.build();
this.credentialsUrl = deviceRegistryUrl
.newBuilder()
.addPathSegment("credentials")
.build();
}

@Override
Expand All @@ -53,8 +59,10 @@ public void device(final String deviceId, final String username,
try (final Response getDevice = this.http.newCall(new Request.Builder()
.url(
this.registrationUrl
.resolve(this.tenantId + "/")
.resolve(deviceId))
.newBuilder()
.addPathSegment(this.tenantId)
.addPathSegment(deviceId)
.build())
.get()
.build()).execute()) {

Expand All @@ -71,8 +79,10 @@ public void device(final String deviceId, final String username,
try (final Response newDevice = this.http.newCall(new Request.Builder()
.url(
this.registrationUrl
.resolve(this.tenantId + "/")
.resolve(deviceId))
.newBuilder()
.addPathSegment(this.tenantId)
.addPathSegment(deviceId)
.build())
.post(RequestBody.create(MT_JSON, "{}" /* empty object */))
.build()).execute()) {

Expand All @@ -96,8 +106,10 @@ public void device(final String deviceId, final String username,
try (Response putCredentials = this.http.newCall(new Request.Builder()
.url(
this.credentialsUrl
.resolve(this.tenantId + "/")
.resolve(deviceId))
.newBuilder()
.addPathSegment(this.tenantId)
.addPathSegment(deviceId)
.build())
.put(RequestBody.create(MT_JSON, encode(new CommonCredential[] { pc })))
.build())
.execute()) {
Expand Down

0 comments on commit 5bc8856

Please sign in to comment.