@Test void testMementoLinksSingle() { final SortedSet<Instant> mementos = new TreeSet<>(); final Instant time = now(); mementos.add(time); final List<Link> links = MementoResource.getMementoLinks(URL, mementos).collect(toList()); assertEquals(3L, links.size()); checkMementoHeaders(links, 0L, 0L, 1L); assertEquals(1L, links.stream().filter(l -> l.getRels().contains("timegate")).count()); assertEquals(1L, links.stream().filter(l -> l.getRels().contains("original")).count()); }
public static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos) { if (mementos.isEmpty()) { return empty(); } return concat( of( Link.fromUri(identifier).rel(TIMEGATE).rel(ORIGINAL).build(), Link.fromUri(identifier + TIMEMAP_PARAM).rel(TIMEMAP).type(APPLICATION_LINK_FORMAT) .param(FROM, ofInstant(mementos.first().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .param(UNTIL, ofInstant(mementos.last().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .build()), mementos.stream().map(time -> { if (mementos.size() == 1) { return mementoToLink(identifier, time, asList(FIRST, LAST)); } else if (time.equals(mementos.first())) { return mementoToLink(identifier, time, singletonList(FIRST)); } else if (time.equals(mementos.last())) { return mementoToLink(identifier, time, singletonList(LAST)); } return mementoToLink(identifier, time, emptyList()); })); }
MementoResource { public static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos) { if (mementos.isEmpty()) { return empty(); } return concat( of( Link.fromUri(identifier).rel(TIMEGATE).rel(ORIGINAL).build(), Link.fromUri(identifier + TIMEMAP_PARAM).rel(TIMEMAP).type(APPLICATION_LINK_FORMAT) .param(FROM, ofInstant(mementos.first().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .param(UNTIL, ofInstant(mementos.last().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .build()), mementos.stream().map(time -> { if (mementos.size() == 1) { return mementoToLink(identifier, time, asList(FIRST, LAST)); } else if (time.equals(mementos.first())) { return mementoToLink(identifier, time, singletonList(FIRST)); } else if (time.equals(mementos.last())) { return mementoToLink(identifier, time, singletonList(LAST)); } return mementoToLink(identifier, time, emptyList()); })); } }
MementoResource { public static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos) { if (mementos.isEmpty()) { return empty(); } return concat( of( Link.fromUri(identifier).rel(TIMEGATE).rel(ORIGINAL).build(), Link.fromUri(identifier + TIMEMAP_PARAM).rel(TIMEMAP).type(APPLICATION_LINK_FORMAT) .param(FROM, ofInstant(mementos.first().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .param(UNTIL, ofInstant(mementos.last().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .build()), mementos.stream().map(time -> { if (mementos.size() == 1) { return mementoToLink(identifier, time, asList(FIRST, LAST)); } else if (time.equals(mementos.first())) { return mementoToLink(identifier, time, singletonList(FIRST)); } else if (time.equals(mementos.last())) { return mementoToLink(identifier, time, singletonList(LAST)); } return mementoToLink(identifier, time, emptyList()); })); } MementoResource(final ServiceBundler trellis, final boolean includeMementoDates); }
MementoResource { public static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos) { if (mementos.isEmpty()) { return empty(); } return concat( of( Link.fromUri(identifier).rel(TIMEGATE).rel(ORIGINAL).build(), Link.fromUri(identifier + TIMEMAP_PARAM).rel(TIMEMAP).type(APPLICATION_LINK_FORMAT) .param(FROM, ofInstant(mementos.first().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .param(UNTIL, ofInstant(mementos.last().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .build()), mementos.stream().map(time -> { if (mementos.size() == 1) { return mementoToLink(identifier, time, asList(FIRST, LAST)); } else if (time.equals(mementos.first())) { return mementoToLink(identifier, time, singletonList(FIRST)); } else if (time.equals(mementos.last())) { return mementoToLink(identifier, time, singletonList(LAST)); } return mementoToLink(identifier, time, emptyList()); })); } MementoResource(final ServiceBundler trellis, final boolean includeMementoDates); ResponseBuilder getTimeMapBuilder(final SortedSet<Instant> mementos, final TrellisRequest req,
            final String baseUrl); ResponseBuilder getTimeGateBuilder(final SortedSet<Instant> mementos, final TrellisRequest req,
            final String baseUrl); Link filterLinkParams(final Link link); static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos); static Stream<Link> getMementoHeaders(final String identifier, final SortedSet<Instant> mementos,
            final Instant time); static Stream<Link> getMementoHeaders(final String identifier, final SortedSet<Instant> mementos); static Link filterLinkParams(final Link link, final boolean filter); static Link mementoToLink(final String identifier, final Instant time, final List<String> rels); }
MementoResource { public static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos) { if (mementos.isEmpty()) { return empty(); } return concat( of( Link.fromUri(identifier).rel(TIMEGATE).rel(ORIGINAL).build(), Link.fromUri(identifier + TIMEMAP_PARAM).rel(TIMEMAP).type(APPLICATION_LINK_FORMAT) .param(FROM, ofInstant(mementos.first().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .param(UNTIL, ofInstant(mementos.last().truncatedTo(SECONDS), UTC).format(RFC_1123_DATE_TIME)) .build()), mementos.stream().map(time -> { if (mementos.size() == 1) { return mementoToLink(identifier, time, asList(FIRST, LAST)); } else if (time.equals(mementos.first())) { return mementoToLink(identifier, time, singletonList(FIRST)); } else if (time.equals(mementos.last())) { return mementoToLink(identifier, time, singletonList(LAST)); } return mementoToLink(identifier, time, emptyList()); })); } MementoResource(final ServiceBundler trellis, final boolean includeMementoDates); ResponseBuilder getTimeMapBuilder(final SortedSet<Instant> mementos, final TrellisRequest req,
            final String baseUrl); ResponseBuilder getTimeGateBuilder(final SortedSet<Instant> mementos, final TrellisRequest req,
            final String baseUrl); Link filterLinkParams(final Link link); static Stream<Link> getMementoLinks(final String identifier, final SortedSet<Instant> mementos); static Stream<Link> getMementoHeaders(final String identifier, final SortedSet<Instant> mementos,
            final Instant time); static Stream<Link> getMementoHeaders(final String identifier, final SortedSet<Instant> mementos); static Link filterLinkParams(final Link link, final boolean filter); static Link mementoToLink(final String identifier, final Instant time, final List<String> rels);  }