List of usage examples for org.springframework.hateoas Link Link
public Link(UriTemplate template, LinkRelation rel)
From source file:org.moserp.common.rest.ExtendedResourceSupport.java
public void addLinkHref(String rel, String href) { add(new Link(href, rel)); }
From source file:com.greglturnquist.EmployeeRepository.java
public Employee findOne(String id) { final Employee frodo = new Employee("Frodo", "ring bearer"); frodo.add(new Link("localhost:8080", "self")); return frodo; }
From source file:bookmarks.BookmarkResource.java
public BookmarkResource(Bookmark bookmark) { String username = bookmark.getAccount().getUsername(); this.bookmark = bookmark; this.add(new Link(bookmark.uri, "bookmark-uri")); this.add(linkTo(BookmarkRestController.class, username).withRel("bookmarks")); this.add(linkTo(methodOn(BookmarkRestController.class, username).readBookmark(null, bookmark.getId())) .withSelfRel());//w ww. j a v a 2 s . c om }
From source file:com.eretailservice.security.BookingResource.java
public BookingResource(Booking booking) { String username = booking.getAccount().getUsername(); this.booking = booking; this.add(new Link(booking.uri, "booking-uri")); this.add(linkTo(BookingRestController.class, username).withRel("bookings")); this.add(linkTo(methodOn(BookingRestController.class, username).readBooking(null, booking.getId())) .withSelfRel());/*from w ww . j a v a 2s .co m*/ }
From source file:com.nebhale.devoxx2013.web.DoorResourceAssemblerTest.java
@Test public void toResource() { Game game = createGame();//w w w . j a va2 s . c o m Door door = this.doorRepository.saveAndFlush(new Door(Door.DoorContent.BICYCLE, game)); Resource<Door> resource = this.resourceAssembler.toResource(door); assertThat(resource.getContent(), is(door)); assertThat(resource.getId(), equalTo( new Link(String.format("http://localhost/games/%d/doors/%d", game.getId(), door.getId()), "self"))); }
From source file:com.nebhale.devoxx2013.web.GameResourceAssemblerTest.java
@Test public void toResource() { final Game game = createGame(); List<Door> doors = createDoors(game); Resource<Game> resource = this.resourceAssembler.toResource(game); assertThat(resource.getContent(), is(game)); assertThat(resource.getId(),// w ww .j a v a 2 s. c o m equalTo(new Link(String.format("http://localhost/games/%d", game.getId()), "self"))); pairWise(doors, getLinks("door", resource), new PairWiseFunction<Door, Link>() { @Override public void exec(Door door, Link link) { assertThat(link, equalTo(new Link( String.format("http://localhost/games/%d/doors/%d", game.getId(), door.getId()), "door"))); } }); }
From source file:edu.pitt.dbmi.ccd.anno.links.ResourceLinks.java
default Link getRequestLink(HttpServletRequest request) { final StringBuffer url = request.getRequestURL(); final String query = request.getQueryString(); if (query == null) { return new Link(url.toString(), Link.REL_SELF); } else {/*from w ww .j av a 2 s . c o m*/ return new Link(url.append("?").append(query).toString(), Link.REL_SELF); } }
From source file:io.curly.advisor.web.hateoas.ArtifactoryLinkCatcher.java
@Override @HystrixCommand(fallbackMethod = "noOpLink") public Link getLink(Review review) { final String artifactory = resolver.resolve(loadBalancerClient.choose("artifactory").getUri(), review.getArtifact());/* w ww . j ava 2s. co m*/ return new Link(artifactory, "artifact"); }
From source file:io.curly.artifact.web.remote.ElskaLinkCatcher.java
@Override @HystrixCommand(fallbackMethod = "noOpLink") public Link getLink(Artifact artifact) { String elska = resolver.resolve(loadBalancerClient.choose("elska").getUri()); log.debug("Found remote link {} from client Elska", elska); return new Link(elska, "heart-it"); }
From source file:io.curly.paperclip.paper.web.hateoas.ArtifactoryLinkCatcher.java
@Override @HystrixCommand(fallbackMethod = "noOpLink") public Link getLink(Paper entity) { String artifactory = zuulAwareMappingResolver.resolve(loadBalancerClient.choose("artifactory").getUri(), entity.getItem());//ww w.j av a 2 s .c o m return new Link(artifactory, "artifact"); }