Package com.google.livingstories.client

Examples of com.google.livingstories.client.LivingStory


  private SyndFeed getFeed(HttpServletRequest req) {
    // Get the path info, minus the leading slash.
    String lspUrl = req.getPathInfo().substring(1);
    Date twoWeeksAgo = new Date(new Date().getTime() - 14 * MILLIS_PER_DAY);
   
    LivingStory livingStory = livingStoryService.getLivingStoryByUrl(lspUrl);
    if (livingStory == null) {
      return null;
    }
   
    List<BaseContentItem> updates = contentService.getUpdatesSinceTime(
        livingStory.getId(), twoWeeksAgo);
    Collections.sort(updates, BaseContentItem.REVERSE_COMPARATOR);
   
    SyndFeed feed = new SyndFeedImpl();
    feed.setTitle(livingStory.getTitle());
    feed.setLink(createLspUrl(req));
    SyndContent feedDescription = new SyndContentImpl();
    feedDescription.setType("text/html");
    feedDescription.setValue(StringUtil.stripForExternalSites(livingStory.getSummary()));
    feed.setDescriptionEx(feedDescription);
   
    List<SyndEntry> items = Lists.newArrayList();
    for (BaseContentItem update : updates) {
      SyndContent title = new SyndContentImpl();
View Full Code Here


  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    // Get the path info, minus the leading slash.
    String lspUrl = req.getPathInfo().substring(1);
   
    LivingStory livingStory = livingStoryDataService.retrieveByUrlName(lspUrl, true);
    if (livingStory == null) {
      resp.sendRedirect("/");
      return;
    }
    Long livingStoryId = livingStory.getId();
    Date lastVisitTime = null;
    boolean subscribedToEmails = false;
    FilterSpec defaultView = null;

    String loggedInUser = userLoginService.getUserId();
    if (loggedInUser != null) {
      lastVisitTime = userDataService.getLastVisitTimeForStory(loggedInUser, livingStoryId);
      subscribedToEmails = userDataService.isUserSubscribedToEmails(loggedInUser, livingStoryId);
      defaultView = userDataService.getDefaultStoryView(loggedInUser);
    }

    if (lastVisitTime == null) {
      // No last visit time found (either user was not logged in,
      // or user logged in for the first time)
      // Try to get the cookie with the last visit time
      String cookieName = Constants.getCookieName(lspUrl);
      Cookie[] cookies = req.getCookies();
      if (cookies != null) {
        for (Cookie cookie : cookies) {
          if (cookieName.equals(cookie.getName())) {
            try {
              lastVisitTime = new Date(Long.valueOf(cookie.getValue()));
            } catch (NumberFormatException e) {
            }
          }
        }
      }
    }
   
    // If the last visit time is not available in the default list of summary revisions,
    // we need to query the datastore for the full list of revisions.  This is slow,
    // but is not expected to happen often.
    if (!livingStory.dateWithinAvailableRevisions(lastVisitTime)) {
      // TODO: decide if this should be an async call from the client.
      livingStory = livingStoryDataService.retrieveById(livingStoryId, false);
    }
   
    ExternalServiceKeyChain keyChain = new ExternalServiceKeyChain(getServletContext());
View Full Code Here

    int i = latestRevisionsOnly ? Math.max(0, summaryRevisions.size() - 6) : 0;
    for (; i < summaryRevisions.size(); i++) {
      Summary summary = summaryRevisions.get(i);
      clientRevisions.add(new LivingStory.Summary(summary.getContent(), summary.getTimestamp()));
    }
    return new LivingStory(id, url, title, getPublishState(), clientRevisions);
  }
View Full Code Here

  private static final Logger logger =
      Logger.getLogger(LivingStoryRpcImpl.class.getCanonicalName());

  @Override
  public synchronized LivingStory createLivingStory(String url, String title) {
    LivingStory story = livingStoryDataService.save(null, url, title, PublishState.DRAFT, "");
    Caches.clearLivingStories();
    Caches.clearStartPageBundle();
    return story;
  }
View Full Code Here

  }
 
  @Override
  public synchronized LivingStory saveLivingStory(long id, String url, String title,
      PublishState publishState, String summary) {
    LivingStory story = livingStoryDataService.save(id, url, title, publishState, summary);
    Caches.clearLivingStories();
    Caches.clearStartPageBundle();
    return story;
  }
View Full Code Here

  public boolean hasNext() {
    return count < countLimit && wrapped.hasNext();
  }

  public LivingStory next() {
    LivingStory result = wrapped.next();
    if (result.getId() == excludedStory.getId()) {
      if (hasNext()) {
        return next();
      } else {
        return null;
      }
View Full Code Here

      PublishState publishState, String summary) throws IllegalArgumentException {
   
    // If a new story is being created, first make sure another story with the same URL doesn't
    // already exist.
    if (id == null) {
      LivingStory existingStoryWithSameUrl = retrieveByUrlName(urlName, true);
      if (existingStoryWithSameUrl != null) {
        throw new IllegalArgumentException("Story with the same URL '" + urlName
            + "' already exists.");   
      }
    }
View Full Code Here

TOP

Related Classes of com.google.livingstories.client.LivingStory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.