Permalink
Browse files

Feed last modified date is the latest modification or publication date

  • Loading branch information...
shred committed Oct 14, 2018
1 parent d76adda commit 741b6c8c08b61e4322b2a5258c4dd5eaf0be43e4
Showing with 10 additions and 4 deletions.
  1. +10 −4 cilla-view/src/main/java/org/shredzone/cilla/view/FeedView.java
@@ -29,7 +29,9 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
@@ -209,15 +211,19 @@ private void fetchPages(FilterModel filter, ViewContext context,
HttpServletRequest req, HttpServletResponse resp,
String selfUrl, String feedId, String type)
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)) {
throw new ErrorResponseException(HttpServletResponse.SC_NOT_MODIFIED);
}
SearchResult result = searchService.search(filter);
result.setPaginator(new PaginatorModel(maxEntries));
String contentType = "application/xml";
if (type.startsWith("atom_")) {
contentType = "application/atom+xml";

0 comments on commit 741b6c8

Please sign in to comment.