Package net.sf.regain.crawler

Examples of net.sf.regain.crawler.Crawler


   * @param shouldPause Whether the crawler should pause.
   */
  public void setShouldPause(boolean shouldPause) {
    // NOTE: We get a local copy of the crawler for the case that is should
    //       change in the meantime
    Crawler crawler = mCrawler;
    if (crawler != null) {
      crawler.setShouldPause(shouldPause);
      TrayIconHandler.getInstance().setIndexUpdateRunning(! shouldPause);
    }
  }
View Full Code Here


        // Create and run the crawler
        TrayIconHandler.getInstance().setIndexUpdateRunning(true);
        try {
          mLog.info("Starting index update on " + new Date());
          mCrawler = new Crawler(config, authProps);
          mCrawler.run(true, false, null);
        }
        catch (RegainException exc) {
          mLog.error("Updating the index failed", exc);
        }
View Full Code Here

   * @throws RegainException If there was an exception.
   */
  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Crawler crawler = IndexUpdateManager.getInstance().getCurrentCrawler();

    // Check whether there was an indexaction
    String indexaction = request.getParameter("indexaction");
    if ("start".equals(indexaction)) {
      IndexUpdateManager.getInstance().startIndexUpdate();
      crawler = IndexUpdateManager.getInstance().getCurrentCrawler();
    }
    else if ("resume".equals(indexaction)) {
      IndexUpdateManager.getInstance().setShouldPause(false);
    }
    else if ("pause".equals(indexaction)) {
      IndexUpdateManager.getInstance().setShouldPause(true);
    }
   
    // Generate the form
    String url = getParameter("url", true);
    String msgBefore = getParameter("msgBefore", "");
    response.print("<form name=\"control\" action=\"" + url + "\" " +
        "style=\"display:inline;\" method=\"post\">" + msgBefore + " ");
    if (crawler == null) {
      // There is currently no index update running -> Provide a start button
      String msgStart = getParameter("msgStart", true);
      response.print("<input type=\"hidden\" name=\"indexaction\" value=\"start\"/>");
      response.print("<input type=\"submit\" value=\"" + msgStart + "\"/>");
    } else {
      if (crawler.getShouldPause()) {
        // The crawler is pausing -> Provide a resume button
        String msgResume = getParameter("msgResume", true);
        response.print("<input type=\"hidden\" name=\"indexaction\" value=\"resume\"/>");
        response.print("<input type=\"submit\" value=\"" + msgResume + "\"/>");
      } else {
View Full Code Here

  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Localizer localizer = mMultiLocalizer.getLocalizer(request.getLocale());

    Crawler crawler = IndexUpdateManager.getInstance().getCurrentCrawler();
    if (crawler == null) {
      response.print(localizer.msg("noIndexUpdate", "Currently is no index update running."));
    } else {
      // Get the IndexConfig
      IndexConfig[] configArr = SearchToolkit.getIndexConfigArr(request);
      if (configArr.length > 1) {
        throw new RegainException("The indexupdate tag can only be used for one index!");
      }
      IndexConfig config = configArr[0];

      // Get the index size
      File indexUpdateDir = new File(config.getDirectory(), "temp");
      long size = RegainToolkit.getDirectorySize(indexUpdateDir);
      String sizeAsString = RegainToolkit.bytesToString(size, request.getLocale());
      String currentJobUrl = crawler.getCurrentJobUrl();
     
      Object[] args = new Object[] {
        new Integer(crawler.getFinishedJobCount()),
        sizeAsString,
        new Integer(crawler.getInitialDocCount()),
        new Integer(crawler.getAddedDocCount()),
        new Integer(crawler.getRemovedDocCount()),
        (currentJobUrl == null) ? "?" : currentJobUrl,
        RegainToolkit.toTimeString(crawler.getCurrentJobTime())
      };
      response.print(localizer.msg("indexInfo", "Processed documents: {0}<br/>" +
            "Size: {1}<br/>Initial document count: {2}<br/>" +
            "Added document count: {3}<br/>Removed document count: {4}<br/>" +
            "Current job: {5} (since {6})", args));
View Full Code Here

TOP

Related Classes of net.sf.regain.crawler.Crawler

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.