Package com.gwtplatform.crawlerservice.server.domain

Examples of com.gwtplatform.crawlerservice.server.domain.CachedPage


                List<Key<CachedPage>> keys = cachedPageDao.listKeysByProperty("url", url);
                Map<Key<CachedPage>, CachedPage> deprecatedPages = cachedPageDao.get(keys);

                Date currDate = new Date();

                CachedPage matchingPage = extractMatchingPage(deprecatedPages, currDate);
                cachedPageDao.deleteKeys(deprecatedPages.keySet());

                if (needToFetchPage(matchingPage, currDate, out)) {
                    CachedPage cachedPage = createPlaceholderPage(url, currDate);
                    StringBuilder renderedHtml = renderPage(url);
                    storeFetchedPage(cachedPage, renderedHtml);
                    out.println(renderedHtml.toString());
                }
            }
View Full Code Here


     * @param url      The URL of the page for which to create a placeholder.
     * @param currDate The current date, to mark the page.
     * @return The newly created placeholder page.
     */
    private CachedPage createPlaceholderPage(String url, Date currDate) {
        CachedPage result = new CachedPage();
        result.setUrl(url);
        result.setFetchDate(currDate);
        result.setFetchInProgress(true);
        cachedPageDao.put(result);
        return result;
    }
View Full Code Here

     * @param currDate        The current date, to check for expiration.
     * @return The non-expired matching page if found, {@code null} otherwise.
     */
    private CachedPage extractMatchingPage(Map<Key<CachedPage>, CachedPage> deprecatedPages,
            Date currDate) {
        CachedPage matchingPage = findMostRecentPage(deprecatedPages);

        // Keep the matching page only if it has not expired
        if (matchingPage == null ||
                currDate.getTime() >
                        matchingPage.getFetchDate().getTime() + cachedPageTimeoutSec * 1000) {
            matchingPage = null;
        } else {
            deprecatedPages.remove(Key.create(CachedPage.class, matchingPage.getId()));
        }

        return matchingPage;
    }
View Full Code Here

        return matchingPage;
    }

    private CachedPage findMostRecentPage(Map<Key<CachedPage>, CachedPage> pages) {
        CachedPage result = null;
        for (CachedPage page : pages.values()) {
            if (result == null ||
                    page.getFetchDate().after(result.getFetchDate())) {
                result = page;
            }
        }
        return result;
    }
View Full Code Here

        List<Key<CachedPage>> keys = cachedPageDao.listKeysByProperty("url", url);
        Map<Key<CachedPage>, CachedPage> deprecatedPages = cachedPageDao.get(keys);

        Date currDate = new Date();

        CachedPage matchingPage = extractMatchingPage(deprecatedPages, currDate);
        cachedPageDao.deleteKeys(deprecatedPages.keySet());

        if (needToFetchPage(matchingPage, currDate, out)) {
          CachedPage cachedPage = createPlaceholderPage(url, currDate);
          StringBuilder renderedHtml = renderPage(url);
          storeFetchedPage(cachedPage, renderedHtml);
          out.println(renderedHtml.toString());
        }
      }
View Full Code Here

   * @param url The URL of the page for which to create a placeholder.
   * @param currDate The current date, to mark the page.
   * @return The newly created placeholder page.
   */
  private CachedPage createPlaceholderPage(String url, Date currDate) {
    CachedPage result = new CachedPage();
    result.setUrl(url);
    result.setFetchDate(currDate);
    result.setFetchInProgress(true);
    cachedPageDao.put(result);
    return result;
  }
View Full Code Here

   * @param currDate The current date, to check for expiration.
   * @return The non-expired matching page if found, {@code null} otherwise.
   */
  private CachedPage extractMatchingPage(Map<Key<CachedPage>, CachedPage> deprecatedPages,
      Date currDate) {
    CachedPage matchingPage = findMostRecentPage(deprecatedPages);

    // Keep the matching page only if it has not expired
    if (matchingPage == null ||
        currDate.getTime() >
            matchingPage.getFetchDate().getTime() + cachedPageTimeoutSec * 1000) {
      matchingPage = null;
    } else {
      deprecatedPages.remove(new Key<CachedPage>(CachedPage.class, matchingPage.getId()));
    }

    return matchingPage;
  }
View Full Code Here

    return matchingPage;
  }

  private CachedPage findMostRecentPage(Map<Key<CachedPage>, CachedPage> pages) {
    CachedPage result = null;
    for (CachedPage page : pages.values()) {
      if (result == null ||
          page.getFetchDate().after(result.getFetchDate())) {
        result = page;
      }
    }
    return result;
  }
View Full Code Here

                List<Key<CachedPage>> keys = cachedPageDao.listKeysByProperty("url", url);
                Map<Key<CachedPage>, CachedPage> deprecatedPages = cachedPageDao.get(keys);

                Date currDate = new Date();

                CachedPage matchingPage = extractMatchingPage(deprecatedPages, currDate);
                cachedPageDao.deleteKeys(deprecatedPages.keySet());

                if (needToFetchPage(matchingPage, currDate, out)) {
                    CachedPage cachedPage = createPlaceholderPage(url, currDate);
                    String renderedHtml = renderPage(url);
                    storeFetchedPage(cachedPage, renderedHtml);
                    out.println(renderedHtml);
                }
            }
View Full Code Here

     * @param url      The URL of the page for which to create a placeholder.
     * @param currDate The current date, to mark the page.
     * @return The newly created placeholder page.
     */
    private CachedPage createPlaceholderPage(String url, Date currDate) {
        CachedPage result = new CachedPage();
        result.setUrl(url);
        result.setFetchDate(currDate);
        result.setFetchInProgress(true);
        cachedPageDao.put(result);
        return result;
    }
View Full Code Here

TOP

Related Classes of com.gwtplatform.crawlerservice.server.domain.CachedPage

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.