Package net.sf.regain

Examples of net.sf.regain.RegainException


        // NOTE: getCanonicalFile is needed to get rid of "\." is a save way
        try {
          mWorkingDir = new File(realpath).getCanonicalFile().getParentFile();
        }
        catch (IOException exc) {
          throw new RegainException("Getting the working directory of " +
                "the web server failed", exc);
        }
      } else {
        // We got no real path -> Return the current directory
        mWorkingDir = new File(".");
View Full Code Here


  public String getParameter(String name) throws RegainException {
    try {
      return mRequest.getParameter(name);
    }
    catch (IOException exc) {
      throw new RegainException("Getting parameter " + name + " failed", exc);
    }
  }
View Full Code Here

  public String[] getParameters(String name) throws RegainException {
    try {
      return mRequest.getParameters().getParameters(name);
    }
    catch (IOException exc) {
      throw new RegainException("Getting parameter " + name + " failed", exc);
    }
  }
View Full Code Here

    try {
      Parameters params = mRequest.getParameters();
      return params.getParameterNames();
    }
    catch (IOException exc) {
      throw new RegainException("Getting parameter names failed", exc);
    }
  }
View Full Code Here

    try {
      PreparatorSettings[] prepConf = config.getPreparatorSettingsList();
      mPreparatorArr = PreparatorFactory.getInstance().createPreparatorArr(prepConf);
    }
    catch (RegainException exc) {
      throw new RegainException("Creating the document preparators failed", exc);
    }

    // Create a profiler for each preparator
    mPreparatorProfilerArr = new Profiler[mPreparatorArr.length];
    for (int i = 0; i < mPreparatorProfilerArr.length; i++) {
      String name = mPreparatorArr[i].getClass().getName();
      mPreparatorProfilerArr[i] = new Profiler("Preparator " + name, "docs");
    }

    // Create the CrawlerAccessController
    String accessClass = config.getCrawlerAccessControllerClass();
    if (accessClass != null) {
      String accessJar = config.getCrawlerAccessControllerJar();
      mCrawlerAccessController = (CrawlerAccessController)
        RegainToolkit.createClassInstance(accessClass, CrawlerAccessController.class,
                                          accessJar);
     
      Properties accessControllerConfig = config.getCrawlerAccessControllerConfig();
      if (accessControllerConfig == null) {
        accessControllerConfig = new Properties();
      }
      mCrawlerAccessController.init(accessControllerConfig);
     
      mLog.info("Using crawler access controller: " + accessClass);
    }

    // Create the mUseLinkTextAsTitleReArr
    String[] useLinkTextAsTitleRegexArr = config.getUseLinkTextAsTitleRegexList();
    if (useLinkTextAsTitleRegexArr == null) {
      mUseLinkTextAsTitleReArr = new RE[0];
    } else {
      mUseLinkTextAsTitleReArr = new RE[useLinkTextAsTitleRegexArr.length];
      for (int i = 0; i < useLinkTextAsTitleRegexArr.length; i++) {
        try {
          mUseLinkTextAsTitleReArr[i] = new RE(useLinkTextAsTitleRegexArr[i]);
        }
        catch (RESyntaxException exc) {
          throw new RegainException("Regular expression of "
            + "use-link-text-as-title-pattern #" + i + " has wrong syntax '"
            + useLinkTextAsTitleRegexArr[i] + "'", exc);
        }
      }
    }
View Full Code Here

      preparatorProfiler.stopMeasuring(rawDocument.getLength());
    }
    catch (Throwable thr) {
      preparatorProfiler.abortMeasuring();
      throw new RegainException("Preparing " + url
        + " with preparator " + preparator.getClass().getName() + " failed", thr);
    }

    // Check the mandatory information
    if (cleanedContent == null) {
      throw new RegainException("Preparator " + preparator.getClass().getName()
        + " did not extract the content of " + url);
    }

    // Preparing succeed -> Create the document
    Document doc = createDocument(rawDocument, cleanedContent, title,
View Full Code Here

        // The port has changed -> Close the old socket
        try {
          mCurrentSocket.close();
        }
        catch (IOException exc) {
          throw new RegainException("Closing the old socket failed", exc);
        }
      }
     
      // Create the simpleweb connection if nessesary
      if (mSimplewebConnection == null) {
        try {
          FileContext context = new FileContext(new File("web"));
          MapperEngine engine = new MapperEngine(context);
         
          engine.load("SharedTagService", SharedTagService.class.getName());
          engine.link("*", "SharedTagService");
         
          ProtocolHandler handler = HandlerFactory.getInstance(engine);
         
          mSimplewebConnection = ConnectionFactory.getConnection(handler);
        }
        catch (Exception exc) {
          throw new RegainException("Creating simpleweb server failed", exc);
        }
      }

      mLog.info("Listening on port " + port + "...");
      try {
        mCurrentSocket = new ServerSocket(port);
      }
      catch (IOException exc) {
        throw new RegainException("Creating socket for port " + port + " failed.", exc);
      }
      mSimplewebConnection.connect(mCurrentSocket);
    }
  }
View Full Code Here

  public void printEndTag(PageRequest request, PageResponse response)
    throws RegainException
  {
    Document hit = (Document) request.getContextAttribute(ATTR_CURRENT_HIT);
    if (hit == null) {
      throw new RegainException("Tag " + getTagName()
          + " must be inside a list tag!");
    }

    Integer hitIndex = (Integer) request.getContextAttribute(ATTR_CURRENT_HIT_INDEX);
View Full Code Here

      if (indexNameArr == null) {
        // There was no index specified -> Check whether we have default indexes
        // defined
        indexNameArr = mConfig.getDefaultIndexNameArr();
        if (indexNameArr == null) {
          throw new RegainException("Request parameter 'index' not specified and " +
              "no default index configured");
        }
      }
     
      // Get the configurations for these indexes
      configArr = new IndexConfig[indexNameArr.length];
      for (int i = 0; i < indexNameArr.length; i++) {
        configArr[i] = mConfig.getIndexConfig(indexNameArr[i]);
        if (configArr[i] == null) {
          throw new RegainException("The configuration does not contain the index '"
              + indexNameArr[i] + "'");
        }
      }

      // Store the IndexConfig in the page context
View Full Code Here

        // There was no index specified -> Check whether we have default
        // indexes
        // defined
        indexNameArr = mConfig.getDefaultIndexNameArr();
        if (indexNameArr == null) {
          throw new RegainException("Request parameter 'index' not specified and "
              + "no default index configured");
        }
      }

      // Get the configurations for these indexes
      List configList = new ArrayList();
      for (int i = 0; i < indexNameArr.length; i++) {
        IndexConfig index = mConfig.getIndexConfig(indexNameArr[i]);
        if (index == null) {
          throw new RegainException("The configuration does not contain the index '" + indexNameArr[i] + "'");

        }
        // If index is a parent index -> get all childs
        if (index.isParent()) {
          String[] allIndexName = mConfig.getAllIndexNameArr();
View Full Code Here

TOP

Related Classes of net.sf.regain.RegainException

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.