From 62690268b7e30f706a6e38dbfbff68a20b5cda9c Mon Sep 17 00:00:00 2001 From: szznax Date: Mon, 5 Oct 2009 20:00:56 +0000 Subject: [PATCH] Initial checkin for [HER-1641] migration tool to convert Heritrix 1.14.x order.xml to H3 crawler-beans.cxml --- .../crawler/migrate/MigrateSettings.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 engine/src/main/java/org/archive/crawler/migrate/MigrateSettings.java diff --git a/engine/src/main/java/org/archive/crawler/migrate/MigrateSettings.java b/engine/src/main/java/org/archive/crawler/migrate/MigrateSettings.java new file mode 100644 index 00000000..88afffc7 --- /dev/null +++ b/engine/src/main/java/org/archive/crawler/migrate/MigrateSettings.java @@ -0,0 +1,46 @@ +package org.archive.crawler.migrate; + +import java.io.File; +import javax.xml.parsers.DocumentBuilderFactory; +import org.apache.commons.io.FileUtils; +import org.w3c.dom.Document; + +public class MigrateSettings { + + public void instanceMain(String[] args) throws Exception { + + File orderXmlFile = new File(args[0]); + File newConfigDir = new File(args[1]); + File defaultConfigDir = new File("dist/src/main/conf/jobs"); + + try { + + // copy defaults.xml to configPath + File srcDefaultsXml = new File(defaultConfigDir,"defaults.xml"); + File tgtDefaultsXml = new File(newConfigDir,"defaults.xml"); + FileUtils.copyFile(srcDefaultsXml, tgtDefaultsXml); + + // copy default profile crawler-beans.xml to configPath + File srcCrawlerBeansXml = new File(defaultConfigDir,"profile-crawler-beans.xml"); + File tgtCrawlerBeansXml = new File(newConfigDir,"crawler-beans.xml"); + FileUtils.copyFile(srcCrawlerBeansXml, tgtCrawlerBeansXml); + + // parse order XML + if (!orderXmlFile.canRead()) { + throw new Exception("can not read file: " + + orderXmlFile.getAbsolutePath()); + } else { + Document orderXmlDom = DocumentBuilderFactory.newInstance() + .newDocumentBuilder().parse(orderXmlFile); + } + + } catch (Exception e) { + System.out.println("Caught Exception: " + e.getMessage()); + } + } + + public static void main(String[] args) throws Exception { + new MigrateSettings().instanceMain(args); + } + +}