private Configuration inderscienceAuConfig() {
   Configuration conf = ConfigManager.newConfiguration();
   conf.put("base_url", "http://www.example.com/");
   conf.put("journal_id", "abc");
   conf.put("volume_name", "99");
   return conf;
 }
  /**
   * Main method.
   *
   * @param args
   */
  public static void main(String[] args) throws Exception {
    String tempDirPath = new File(PlatformUtil.getSystemTempDir(), "empty_doc_db").toString();
    String arg;

    for (int i = 0; i < args.length; i++) {
      arg = args[i];

      if (i < args.length - 1 && "-d".equals(arg)) {
        tempDirPath = args[++i];
      }
    }

    ConfigManager.makeConfigManager();
    Logger.resetLogs();
    MockLockssDaemon daemon = new MockLockssDaemon() {};

    // Set the database log.
    System.setProperty(
        "derby.stream.error.file", new File(tempDirPath, "derby.log").getAbsolutePath());

    Properties props = new Properties();
    props.setProperty(LockssRepositoryImpl.PARAM_CACHE_LOCATION, tempDirPath);
    props.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    ConfigurationUtil.setCurrentConfigFromProps(props);

    DbManager dbManager = new DbManager(true);
    daemon.setDbManager(dbManager);
    dbManager.initService(daemon);
    dbManager.startService();
    dbManager.waitForThreadsToFinish(500);
    System.exit(0);
  }
 Configuration natureAuConfig() {
   Configuration conf = ConfigManager.newConfiguration();
   conf.put("base_url", BASE_URL);
   conf.put("journal_id", "aps");
   conf.put("volume_name", "123");
   conf.put("year", "2008");
   return conf;
 }
 Configuration simAuConfig(String rootPath) {
   Configuration conf = ConfigManager.newConfiguration();
   conf.put("root", rootPath);
   conf.put("depth", "2");
   conf.put("branch", "2");
   conf.put("numFiles", "2");
   conf.put("badCachedFileLoc", "2,2");
   conf.put("badCachedFileNum", "2");
   return conf;
 }
 Configuration simAuConfig(String rootPath) {
   Configuration conf = ConfigManager.newConfiguration();
   conf.put("root", rootPath);
   conf.put("base_url", BASE_URL);
   conf.put("depth", "1");
   conf.put("branch", "4");
   conf.put("numFiles", "7");
   conf.put(
       "fileTypes",
       "" + (SimulatedContentGenerator.FILE_TYPE_HTML | SimulatedContentGenerator.FILE_TYPE_PDF));
   conf.put("binFileSize", "" + fileSize);
   return conf;
 }
Exemple #6
0
 protected String getHostName() {
   String res = ConfigManager.getPlatformHostname();
   if (res == null) {
     try {
       InetAddress inet = InetAddress.getLocalHost();
       return inet.getHostName();
     } catch (UnknownHostException e) {
       log.warning("Can't get hostname", e);
       return "unknown";
     }
   }
   return res;
 }
 protected ArchivalUnit createTarAu() throws ArchivalUnit.ConfigurationException {
   // in this directory this is file "test_elsevierdtd5.tdb" but it becomes xml
   try {
     ConfigurationUtil.addFromUrl(getResource("test_elsevierdtd5.xml"));
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   Tdb tdb = ConfigManager.getCurrentConfig().getTdb();
   TdbAu tdbau1 = tdb.getTdbAusLikeName("Elsevier Source Content 2014").get(0);
   assertNotNull("Didn't find named TdbAu", tdbau1);
   return PluginTestUtil.createAndStartAu(tdbau1);
 }
Exemple #8
0
  private boolean startCrawl(ArchivalUnit au, boolean force, boolean deep)
      throws CrawlManagerImpl.NotEligibleException {
    CrawlManagerImpl cmi = (CrawlManagerImpl) crawlMgr;
    if (force) {
      RateLimiter limit = cmi.getNewContentRateLimiter(au);
      if (!limit.isEventOk()) {
        limit.unevent();
      }
    }
    cmi.checkEligibleToQueueNewContentCrawl(au);
    String delayMsg = "";
    String deepMsg = "";
    try {
      cmi.checkEligibleForNewContentCrawl(au);
    } catch (CrawlManagerImpl.NotEligibleException e) {
      delayMsg = ", Start delayed due to: " + e.getMessage();
    }
    Configuration config = ConfigManager.getCurrentConfig();
    int pri = config.getInt(PARAM_CRAWL_PRIORITY, DEFAULT_CRAWL_PRIORITY);

    CrawlReq req;
    try {
      req = new CrawlReq(au);
      req.setPriority(pri);
      if (deep) {
        int d = Integer.parseInt(formDepth);
        if (d < 0) {
          errMsg = "Illegal refetch depth: " + d;
          return false;
        }
        req.setRefetchDepth(d);
        deepMsg = "Deep (" + req.getRefetchDepth() + ") ";
      }
    } catch (NumberFormatException e) {
      errMsg = "Illegal refetch depth: " + formDepth;
      return false;
    } catch (RuntimeException e) {
      log.error("Couldn't create CrawlReq: " + au, e);
      errMsg = "Couldn't create CrawlReq: " + e.toString();
      return false;
    }
    cmi.startNewContentCrawl(req, null);
    statusMsg = deepMsg + "Crawl requested for " + au.getName() + delayMsg;
    return true;
  }
 public void run() {
   try {
     setConfig(ConfigManager.getCurrentConfig());
     if (m_outWriter == null && m_msgHandler == null) {
       useLocalWriter = true;
     } else {
       useLocalWriter = false;
     }
     if (useLocalWriter) {
       openOutputFile();
     }
     checkRules();
     if (useLocalWriter) {
       closeOutputFile();
     }
   } finally {
     if (m_msgHandler != null) {
       m_msgHandler.close();
     }
   }
 }
  public void setUp() throws Exception {
    super.setUp();
    setUpDiskSpace(); // you need this to have startService work properly...

    theDaemon = getMockLockssDaemon();
    theDaemon.getAlertManager();
    theDaemon.getPluginManager().setLoadablePluginsReady(true);
    theDaemon.setDaemonInited(true);
    theDaemon.getPluginManager().startService();
    theDaemon.getCrawlManager();

    // in this directory this is file "test_baseatypon.tdb" but it becomes xml
    ConfigurationUtil.addFromUrl(getResource("test_baseatypon.xml"));
    Tdb tdb = ConfigManager.getCurrentConfig().getTdb();

    TdbAu tdbau1 = tdb.getTdbAusLikeName(goodJournal + " Volume " + goodVolume).get(0);
    assertNotNull("Didn't find named TdbAu", tdbau1);
    bau1 = PluginTestUtil.createAndStartAu(tdbau1);
    assertNotNull(bau1);
    TypedEntryMap auConfig = bau1.getProperties();
    assertEquals(BASE_URL, auConfig.getString(BASE_URL_KEY));
  }
 // Set configuration attributes to create plugin AU (archival unit)
 Configuration palgraveBookAuConfig() {
   Configuration conf = ConfigManager.newConfiguration();
   conf.put(BASE_URL_KEY, BASE_URL);
   conf.put(BOOK_ISBN_KEY, BOOK_ISBN);
   return conf;
 }
Exemple #12
0
 private void doReloadConfig() {
   cfgMgr.requestReload();
 }