protected Link resourceLink(RootResourceInformation resourceLink, Resource resource) { ResourceMetadata repoMapping = resourceLink.getResourceMetadata(); Link selfLink = resource.getLink("self"); String rel = repoMapping.getItemResourceRel(); return new Link(selfLink.getHref(), rel); }
@RequestMapping(method = POST) HttpEntity<Void> writeUserProfilePhoto(@PathVariable Long user, @RequestParam MultipartFile file) throws Throwable { byte bytesForProfilePhoto[] = FileCopyUtils.copyToByteArray(file.getInputStream()); this.crmService.writeUserProfilePhoto(user, MediaType.parseMediaType(file.getContentType()), bytesForProfilePhoto); Resource<User> userResource = this.userResourceAssembler.toResource(crmService.findById(user)); List<Link> linkCollection = userResource.getLinks(); Links wrapperOfLinks = new Links(linkCollection); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add("Link", wrapperOfLinks.toString()); // we can't encode the links in the body of the response, so we put them in the "Links:" header. httpHeaders.setLocation(URI.create(userResource.getLink("photo").getHref())); // "Location: /users/{userId}/photo" return new ResponseEntity<>(httpHeaders, HttpStatus.ACCEPTED); }
@RequestMapping(method = POST) HttpEntity<Void> writeUserProfilePhoto(@PathVariable Long user, @RequestParam MultipartFile file) throws Throwable { byte bytesForProfilePhoto[] = FileCopyUtils.copyToByteArray(file.getInputStream()); this.crmService.writeUserProfilePhoto(user, MediaType.parseMediaType(file.getContentType()), bytesForProfilePhoto); Resource<User> userResource = this.userResourceAssembler.toResource(crmService.findById(user)); List<Link> linkCollection = userResource.getLinks(); Links wrapperOfLinks = new Links(linkCollection); HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add("Link", wrapperOfLinks.toString()); // we can't encode the links in the body of the response, so we put them in the "Links:" header. httpHeaders.setLocation(URI.create(userResource.getLink("photo").getHref())); // "Location: /users/{userId}/photo" return new ResponseEntity<>(httpHeaders, HttpStatus.ACCEPTED); }
Link l = new Link(entry.getValue().getLink("self").getHref(), entry.getKey().toString()); links.add(l);
@Override public Object invoke(Object self, Method method, Method proceed, Object[] args) { Link selfLink = resource.getLink(Link.REL_SELF); return selfLink == null ? null : URI.create(selfLink.getHref()); } }
@Override public Object invoke(Object self, Method method, Method proceed, Object[] args) { Link selfLink = resource.getLink(Link.REL_SELF); return selfLink == null ? null : URI.create(selfLink.getHref()); } }
URI resolveForMethod(Method method, Object[] args) { String linkName = getLinkName(method); Link link = resource.getLink(linkName); if (link == null) { throw new ClientProxyException(String.format("Link '%s' could not be found!", linkName)); } return URI.create(link.expand(args).getHref()); }
URI resolveForMethod(Method method, Object[] args) { String linkName = getLinkName(method); Link link = resource.getLink(linkName); if (link == null) { throw new ClientProxyException(String.format("Link '%s' could not be found!", linkName)); } return URI.create(link.expand(args).getHref()); }
protected Link resourceLink(RootResourceInformation resourceLink, Resource resource) { ResourceMetadata repoMapping = resourceLink.getResourceMetadata(); Link selfLink = resource.getLink("self"); String rel = repoMapping.getItemResourceRel(); return new Link(selfLink.getHref(), rel); }
Link l = new Link(entry.getValue().getLink("self").getHref(), entry.getKey().toString()); links.add(l);