Esempio n. 1
0
 @GET
 @Path("{year : 20[0-9]{2}}")
 public List<Post> getPostByYear(@PathParam("year") String y) {
   return ps.listPublishedPosts()
       .stream()
       .filter(p -> year.format(p.getPublishedDate()).equals(y))
       .collect(toList());
 }
Esempio n. 2
0
 @GET
 @Path("{year : 20[0-9]{2}}/{month : (?:0[1-9]|1[0-2])}")
 public List<Post> getPostByYearMonth(@PathParam("year") String y, @PathParam("month") String m) {
   return ps.listPublishedPosts()
       .stream()
       .filter(p -> year.format(p.getPublishedDate()).equals(y))
       .filter(p -> month.format(p.getPublishedDate()).equals(m))
       .collect(toList());
 }
Esempio n. 3
0
 @GET
 @Path("{year : 20[0-9]{2}}/{month : (?:0[1-9]|1[0-2])}/{permalink}")
 public Post getPost(
     @PathParam("year") String y,
     @PathParam("month") String m,
     @PathParam("permalink") String permalink) {
   List<Post> results =
       ps.listPublishedPosts()
           .stream()
           .filter(p -> p.getPermalink().equals(permalink))
           .filter(p -> year.format(p.getPublishedDate()).equals(y))
           .filter(p -> month.format(p.getPublishedDate()).equals(m))
           .collect(toList());
   if (results.isEmpty()) {
     return null;
   }
   return results.get(0);
 }
Esempio n. 4
0
 @GET
 @Path("tagged/{tag}")
 public List<Post> getRelatedPosts(@PathParam("tag") String tag) {
   return ps.listPublishedPostsWithTagName(tag);
 }
Esempio n. 5
0
 @GET
 @Path("id-{id : \\d+}/related")
 public List<Post> getRelatedPosts(
     @PathParam("id") Long id, @DefaultValue("0") @QueryParam("limit") int limit) {
   return ps.listRelatedPostsFor(id, limit);
 }
Esempio n. 6
0
 @GET
 public List<Post> getPublishedPosts() {
   return ps.listPublishedPosts();
 }