Skip to content

Commit

Permalink
Feed last modified date is the latest modification or publication date
Browse files Browse the repository at this point in the history
  • Loading branch information
shred committed Oct 14, 2018
1 parent d76adda commit 741b6c8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cilla-view/src/main/java/org/shredzone/cilla/view/FeedView.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;


import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
Expand Down Expand Up @@ -209,15 +211,19 @@ private void fetchPages(FilterModel filter, ViewContext context,
HttpServletRequest req, HttpServletResponse resp, HttpServletRequest req, HttpServletResponse resp,
String selfUrl, String feedId, String type) String selfUrl, String feedId, String type)
throws ViewException, CillaServiceException { throws ViewException, CillaServiceException {
Date lastModified = pageDao.fetchMinMaxModification()[1]; SearchResult result = searchService.search(filter);
result.setPaginator(new PaginatorModel(maxEntries));

Date lastModified = result.getPages().stream()
.flatMap(p -> Stream.of(p.getModification(), p.getPublication()))
.filter(Objects::nonNull)
.max(Date::compareTo)
.orElseThrow(PageNotFoundException::new);


if (isNotModifiedSince(req, lastModified)) { if (isNotModifiedSince(req, lastModified)) {
throw new ErrorResponseException(HttpServletResponse.SC_NOT_MODIFIED); throw new ErrorResponseException(HttpServletResponse.SC_NOT_MODIFIED);
} }


SearchResult result = searchService.search(filter);
result.setPaginator(new PaginatorModel(maxEntries));

String contentType = "application/xml"; String contentType = "application/xml";
if (type.startsWith("atom_")) { if (type.startsWith("atom_")) {
contentType = "application/atom+xml"; contentType = "application/atom+xml";
Expand Down

0 comments on commit 741b6c8

Please sign in to comment.