Пример #1
0
  protected void fillFeedWithCurrent(GuiFeed feed) {
    List<StaleGroup> groups = dao.retrieveCurrentStale();
    log.debug("Got " + groups.size() + " stale groups");

    if (!groups.isEmpty()) {
      feed.setUpdated(new Date(groups.get(0).getUpdated()));
      Long fromUpdated =
          dao.updatedLessThanUpdatedOf(Long.valueOf(groups.get(groups.size() - 1).getUpdated()));
      if (fromUpdated != null) {
        feed.setPrevArchive(feed.getId() + "archive/" + fromUpdated);
      }
    }
    feed.setEntries(new ArrayList<GuiEntry>());
    for (StaleGroup g : groups) {
      GuiEntry ge = transformToGuiEntry(g);
      feed.getEntries().add(ge);
    }
  }
Пример #2
0
 protected GuiFeed createFeedWithDefaults(HttpServletRequest req) {
   GuiFeed feed = new GuiFeed();
   int lifetimeSeconds = dao.resolveLifetimeSeconds();
   feed.setLifetime(lifetimeSeconds);
   feed.setPrecision(StaleGroupMongoDao.RESOLUTION_SECONDS);
   feed.setSelf(req.getRequestURL().toString());
   feed.setUpdated(new Date());
   /*
          log.info("--------------- *-PathTranslated: "+req.getPathTranslated()+
           "\nContextPath: "+req.getContextPath()+
           "\nPathInfo: "+req.getPathInfo()+
           "\nreqURI: "+req.getRequestURI()+
           "\nServletPath(): "+req.getServletPath()+
           "\nRequestURL(): "+req.getRequestURL()
   );
   */
   String pathInfo = req.getPathInfo();
   if (pathInfo == null) {
     pathInfo = req.getServletPath();
   }
   // Id shall typically be http://somewhere:port/atomizer/event/
   feed.setId(feed.getSelf().substring(0, (feed.getSelf().indexOf(pathInfo)) + 1) + "event/");
   feed.setTitle("Atomizer");
   feed.setEntries(new ArrayList<GuiEntry>());
   String host = null;
   try {
     host = new URL(req.getRequestURL().toString()).getHost();
   } catch (MalformedURLException ex) {
     log.error(
         "Could not extract hostname from the requestURL. Defaulting to localhost. Masked exception: "
             + ex);
     host = "localhost";
   }
   feed.setAuthor(host);
   return feed;
 }