diff options
author | Vitaly Takmazov | 2018-09-05 13:37:45 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-09-05 13:37:45 +0300 |
commit | 8aa3602287f7b4ebf115b82182e18f7af3a38507 (patch) | |
tree | 8e8032d8c89499f783d89df26ef6ed1988e51e33 /juick-server/src/main/java/com/juick | |
parent | e4abcc0cf2e7a57b456ba9d84184af4965146321 (diff) |
ActivityStreams: refactor UriComponentsBuilder usage
Diffstat (limited to 'juick-server/src/main/java/com/juick')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/api/activity/Profile.java | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java index 0974444f..c3f838ee 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java @@ -37,24 +37,19 @@ public class Profile { public Person getUser(@PathVariable String userName) { User user = userService.getUserByName(userName); if (!user.isAnonymous()) { + UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); Person person = new Person(); - UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(baseUri); - builder.path(String.format("/u/%s", userName)); - person.setId(builder.toUriString()); + uri.replacePath(String.format("/u/%s", userName)); + person.setId(uri.toUriString()); person.setName(userName); - UriComponentsBuilder inboxBuilder = UriComponentsBuilder.fromUriString(baseUri); - inboxBuilder.path("/post"); - person.setInbox(inboxBuilder.toUriString()); - UriComponentsBuilder outboxBuilder = UriComponentsBuilder.fromUriString(baseUri); - person.setOutbox(outboxBuilder.path(String.format("/u/%s/blog/toc", userName)).toUriString()); - UriComponentsBuilder followersBuilder = UriComponentsBuilder.fromUriString(baseUri); - person.setFollowers(followersBuilder.path(String.format("/u/%s/followers/toc", userName)).toUriString()); - UriComponentsBuilder followingBuilder = UriComponentsBuilder.fromUriString(baseUri); - person.setFollowing(followingBuilder.path(String.format("/u/%s/following/toc", userName)).toUriString()); - UriComponentsBuilder imgBuilder = UriComponentsBuilder.fromUriString(baseImagesUri); - imgBuilder.path(String.format("/a/%d.png", user.getUid())); + uri.replacePath("/post"); + person.setInbox(uri.toUriString()); + person.setOutbox(uri.replacePath(String.format("/u/%s/blog/toc", userName)).toUriString()); + person.setFollowers(uri.replacePath(String.format("/u/%s/followers/toc", userName)).toUriString()); + person.setFollowing(uri.replacePath(String.format("/u/%s/following/toc", userName)).toUriString()); + uri.replacePath(String.format("/a/%d.png", user.getUid())); Image avatar = new Image(); - avatar.setUrl(imgBuilder.toUriString()); + avatar.setUrl(uri.toUriString()); avatar.setMediaType("image/png"); person.setIcon(avatar); return person; |