Package fr.eolya.utils

Examples of fr.eolya.utils.XMLConfig


    }

    /* TODO : V4 */
    // check geo localisation
    if (("1".equals(config.getProperty("/crawler/param[@name='geo_location']", "0")))) {
      XMLConfig srcExtra = this.src.getExtra();
      String srcIP = "";
      if (srcExtra!=null) {
        srcIP = srcExtra.getProperty("/geoip/ip", "");
      }
      GeoLocalisation geo;
      try {
        URL hostUrl = new URL(startingUrls.getUrlHome());
        geo = new GeoLocalisation (hostUrl.getHost(), srcIP, null);
      } catch (URISyntaxException e) {
        e.printStackTrace();
        return false;
      } catch (MalformedURLException e) {
        e.printStackTrace();
        return false;
      }
      if (geo.resolve("geoiptool") && geo.hasChanged()) {
        srcExtra.setProperty("/", "geoip", "");
        srcExtra.setProperty("/geoip", "ip", geo.getIp());
        srcExtra.setProperty("/geoip", "latitude", geo.getLatitude());
        srcExtra.setProperty("/geoip", "longitude", geo.getLongitude());
        srcExtra.setProperty("/geoip", "countrycode", geo.getCountryCode());
        srcExtra.setProperty("/geoip", "countryname", geo.getCountryName());
        srcExtra.setProperty("/geoip", "area", geo.getArea());
        srcExtra.setProperty("/geoip", "city", geo.getCity());
        this.src.setExtra(srcExtra);
      }
    }
   
    String scriptPath = config.getProperty("/crawler/param[@name='scripts_path']", "");
View Full Code Here


    }

    propFileName = Utils.getValidPropertyPath(propFileName, null, "HOME");
    System.out.println("Config file = " + propFileName);

    XMLConfig config = new XMLConfig();
    try {
      File configFile =new File(propFileName);
      if (!configFile.exists()) {
        System.out.println("Error configuration file not found [" + propFileName + "]");
        System.exit(-1);
      }
      config.loadFile(propFileName);
    }
    catch(IOException e) {
      System.out.println("Error while reading properties file");
      e.printStackTrace();
      System.exit(-1);     
    }

    String witnessFilesPath = config.getProperty("/crawler/param[@name='witness_files_path']");
    witnessFilesPath = Utils.getValidPropertyPath(witnessFilesPath, null, "HOME");
    if (witnessFilesPath == null || "".equals(witnessFilesPath)) {
      System.out.println("Error : missing witness_files_path propertie");
      System.exit(-1);
    }
View Full Code Here

  public static DocumentCacheItem doc2DocumentCacheItem(BasicDBObject doc) {
    try {
      String itemId = doc.get("item_id").toString();

      XMLConfig extra = null;
      if (doc.get("item_extra")!=null) {
        extra = new XMLConfig();
        extra.loadString(doc.get("item_extra").toString());
      }

      HashMap<String, String> params = new HashMap<String, String>();
      HashMap<String, String> metas = new HashMap<String, String>();
View Full Code Here

 
  public static XMLConfig loadXmlConfig(String relativePath) {
    String home = ServletUtils.locateHome()
    String xmlConfigPath = home + relativePath;
    File xmlConfigFile = new File(xmlConfigPath);
    XMLConfig xmlConfig = null;
    if (xmlConfigFile!=null && xmlConfigFile.exists()) {
      xmlConfig = new XMLConfig();
      try {
        xmlConfig.loadFile(xmlConfigPath);
      } catch (IOException e) {
        e.printStackTrace();
        return null;
      }
      return xmlConfig;
View Full Code Here

        propFileName = Utils.getValidPropertyPath(propFileName, null, "HOME");
        String settingsDirectoryPath = new File(propFileName).getParentFile().getAbsolutePath();
       
        System.out.println("Config file = " + propFileName);
       
        XMLConfig config = new XMLConfig();
        try {
            File configFile =new File(propFileName);
            if (!configFile.exists()) {
                System.out.println("Error configuration file not found [" + propFileName + "]");
                System.exit(-1);
            }
            config.loadFile(propFileName);
        }
        catch(IOException e) {
            System.out.println("Error while reading properties file");
            e.printStackTrace();
            System.exit(-1);     
        }
       
        String witnessFilesPath = config.getProperty("/indexer/param[@name='witnessfilespath']");
        witnessFilesPath = Utils.getValidPropertyPath(witnessFilesPath, null, "HOME");
        if (witnessFilesPath == null || "".equals(witnessFilesPath)) {
            System.out.println("Error : missing witness_files_path propertie");
            System.exit(-1);
        }
       
        String witnessFilesName = config.getProperty("/indexer/param[@name='witnessfilesname']", "indexer");
       
        File filePid = new File(witnessFilesPath + "/" + witnessFilesName + ".pid");
        if (filePid.exists()) {
            System.out.println("A indexer instance is already running");
            System.exit(-1);
View Full Code Here

  public Source (int id, String className, String crawlMode, Map<String,Object> srcData) throws IOException {

    this.srcData = srcData;
    this.memLog = new StringBuffer();

    params = new XMLConfig();
    params.loadString((String)srcData.get("params"));

    extra = new XMLConfig();
    extra.loadString((String)srcData.get("extra"));

    this.id = id;
    this.className = className;
    this.crawlMode = crawlMode;    

    this.depth = getSrcDataInt("crawl_maxdepth", 0);

    processingElapsedTime = 0;
    processingLastTime = new Date().getTime();
    processingLastProcessedPageCount = 0;
    processingInfo = new XMLConfig();
    processingInfo.loadString((String)srcData.get("processing_info"));
    if (processingInfo!=null) {
      String elapsedTime = processingInfo.getProperty("/infos/elapsedtime");
      if (elapsedTime!=null && Utils.isStringNumeric(elapsedTime))
        processingElapsedTime = Long.parseLong(processingInfo.getProperty("/infos/elapsedtime"));
View Full Code Here

TOP

Related Classes of fr.eolya.utils.XMLConfig

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.