[Tynstep-svn] r144 - in trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader: . loaders

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Thu Jul 1 14:50:22 MST 2010


Author: ChrisBurrell
Date: 2010-07-01 14:50:21 -0700 (Thu, 01 Jul 2010)
New Revision: 144

Modified:
   trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/ClientDbProvider.java
   trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/loaders/JSwordModuleInstaller.java
Log:
updates to install logic , to include new version of bible

Modified: trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/ClientDbProvider.java
===================================================================
--- trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/ClientDbProvider.java	2010-06-25 20:52:17 UTC (rev 143)
+++ trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/ClientDbProvider.java	2010-07-01 21:50:21 UTC (rev 144)
@@ -3,40 +3,39 @@
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.sql.Statement;
 
 public class ClientDbProvider {
-	//TODO: shove this in a properties file
-	private static String clientConnection = "jdbc:derby:";
-	private static Connection connection = null;
-	
-	public synchronized static Connection getConnection(String dbPath) throws SQLException {
-		if(connection == null) {
-			String connectionString = clientConnection + dbPath + ";create=true";
-			System.out.println("Using connection string: " + connectionString);
-			connection = DriverManager.getConnection(connectionString);
-		}
-		
-		return connection;
-	}
+    // TODO: shove this in a properties file
+    private static String clientConnection = "jdbc:derby:";
+    private static Connection connection = null;
 
-	public static void finaliseConnection(Connection connection) throws SQLException {
-		if(connection != null && !connection.isClosed()) {
-			connection.close();
-		}
-	}
+    public synchronized static Connection getConnection(final String dbPath) throws SQLException {
+        if (connection == null) {
+            final String connectionString = clientConnection + dbPath + ";create=true";
+            System.out.println("Using connection string: " + connectionString);
+            connection = DriverManager.getConnection(connectionString);
+        }
 
-	public static Connection getConnection() {
-		return connection;
-	}
+        return connection;
+    }
 
-	public static void tearDown() {
-		try {
-			finaliseConnection(getConnection());
-			DriverManager.getConnection("jdbc:derby:;shutdown=true");
-		} catch (SQLException e) {
-			//shutdown exception
-		}
-		
-	}
+    public static void finaliseConnection(final Connection connection) throws SQLException {
+        if (connection != null && !connection.isClosed()) {
+            connection.close();
+        }
+    }
+
+    public static Connection getConnection() {
+        return connection;
+    }
+
+    public static void tearDown() {
+        try {
+            finaliseConnection(getConnection());
+            DriverManager.getConnection("jdbc:derby:;shutdown=true");
+        } catch (final SQLException e) {
+            // shutdown exception
+        }
+
+    }
 }

Modified: trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/loaders/JSwordModuleInstaller.java
===================================================================
--- trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/loaders/JSwordModuleInstaller.java	2010-06-25 20:52:17 UTC (rev 143)
+++ trunk/step-dataloader/src/main/java/com/tyndalehouse/step/dataloader/loaders/JSwordModuleInstaller.java	2010-07-01 21:50:21 UTC (rev 144)
@@ -1,6 +1,5 @@
 package com.tyndalehouse.step.dataloader.loaders;
 
-import org.apache.commons.logging.Log;
 import org.apache.log4j.Logger;
 import org.crosswire.jsword.book.Book;
 import org.crosswire.jsword.book.Books;
@@ -8,86 +7,78 @@
 import org.crosswire.jsword.book.install.sword.HttpSwordInstaller;
 
 public class JSwordModuleInstaller {
-	private final static String proxyHostProperty = "step.http.proxy";
-	private final static String proxyPortProperty = "step.http.port";
+    private final static String proxyHostProperty = "step.http.proxy";
+    private final static String proxyPortProperty = "step.http.port";
 
-	private Logger log = Logger.getLogger(getClass());
+    private final Logger log = Logger.getLogger(getClass());
 
-	/** default set of bibles */
-	String[] defaultModules = new String[] { "ESV", "KJV", "ASV",
-			"StrongsHebrew", "StrongsGreek", "LXX", "BYZ" };
+    /** default set of bibles */
+    String[] defaultModules = new String[] { "ESV", "KJV", "ASV", "StrongsHebrew", "StrongsGreek", "LXX", "BYZ", "WLC" };
 
-	/**
-	 * a default set of modules need to be installed since unit tests rely on
-	 * them to be present TODO: the whole project should probably be cleaned
-	 * up/rewritten in a neater fashion
-	 * 
-	 * @throws InstallException
-	 *             failed to install bible modules
-	 */
-	public void installDefaultModules() {
-		try {
-			log.info("about to create installer");
-			HttpSwordInstaller installer = getInstaller();
-			log.info("got installer, going to reload books");
-			installer.reloadBookList();
-			log.info("reloaded books");
-			for (String s : defaultModules) {
-				installBible(installer, s);
-			}
-		} catch (Exception ex) {
-			log.error(ex.getMessage(), ex);
-		}
-	}
+    /**
+     * a default set of modules need to be installed since unit tests rely on
+     * them to be present TODO: the whole project should probably be cleaned
+     * up/rewritten in a neater fashion
+     * 
+     * @throws InstallException
+     *             failed to install bible modules
+     */
+    public void installDefaultModules() {
+        try {
+            log.info("about to create installer");
+            final HttpSwordInstaller installer = getInstaller();
+            log.info("got installer, going to reload books");
+            installer.reloadBookList();
+            log.info("reloaded books");
+            for (final String s : defaultModules) {
+                installBible(installer, s);
+            }
+        } catch (final Exception ex) {
+            log.error(ex.getMessage(), ex);
+        }
+    }
 
-	private void installBible(HttpSwordInstaller installer, String initials)
-			throws InstallException {
-		log.info("installing " + initials);
+    private void installBible(final HttpSwordInstaller installer, final String initials) throws InstallException {
 
-		Book b = null;
-		try {
-			Books books = Books.installed();
-			if (books != null) {
-				b = books.getBook(initials);
+        Book b = null;
+        try {
+            final Books books = Books.installed();
+            if (books != null) {
+                b = books.getBook(initials);
 
-				if (b == null) {
-					installer.install(installer.getBook(initials));
-				} else {
-					log.warn("Skipping " + initials);
-				}
-			}
-		} catch (Exception ex) {
-			log
-					.info(
-							"An exception occurred while reading the list of installed books (first time?)",
-							ex);
-		}
-	}
+                if (b == null) {
+                    log.info("installing " + initials);
+                    installer.install(installer.getBook(initials));
+                } else {
+                    log.warn("Skipping " + initials);
+                }
+            }
+        } catch (final Exception ex) {
+            log.info("An exception occurred while reading the list of installed books (first time?)", ex);
+        }
+    }
 
-	private HttpSwordInstaller getInstaller() {
-		log.warn("Creating new installer for JSword");
-		HttpSwordInstaller resourceInstaller = new HttpSwordInstaller();
-		System.out.println("Currently hardcoded installer host to:"
-				+ "www.crosswire.org");
-		System.out.println("Currently hardcoded property names for step");
-		String host = "www.crosswire.org";
-		String proxyHost = System.getProperty(proxyHostProperty);
-		String proxyPort = System.getProperty(proxyPortProperty);
-		System.out.println(String.format("Setting to (%1$s via %2$s:%3$s)",
-				"www.crosswire.org", proxyHost, proxyPort));
+    private HttpSwordInstaller getInstaller() {
+        log.warn("Creating new installer for JSword");
+        final HttpSwordInstaller resourceInstaller = new HttpSwordInstaller();
+        System.out.println("Currently hardcoded installer host to:" + "www.crosswire.org");
+        System.out.println("Currently hardcoded property names for step");
+        final String host = "www.crosswire.org";
+        final String proxyHost = System.getProperty(proxyHostProperty);
+        final String proxyPort = System.getProperty(proxyPortProperty);
+        System.out.println(String.format("Setting to (%1$s via %2$s:%3$s)", "www.crosswire.org", proxyHost, proxyPort));
 
-		resourceInstaller.setHost(host);
-		if (proxyHost != null && proxyHost.length() != 0) {
-			resourceInstaller.setProxyHost(proxyHost);
-		}
-		if (proxyPort != null && proxyHost.length() != 0) {
-			resourceInstaller.setProxyPort(Integer.parseInt(proxyPort));
-		}
+        resourceInstaller.setHost(host);
+        if (proxyHost != null && proxyHost.length() != 0) {
+            resourceInstaller.setProxyHost(proxyHost);
+        }
+        if (proxyPort != null && proxyHost.length() != 0) {
+            resourceInstaller.setProxyPort(Integer.parseInt(proxyPort));
+        }
 
-		System.out.println("Setting package and catalog directories");
-		resourceInstaller
-				.setPackageDirectory("/ftpmirror/pub/sword/packages/rawzip");
-		resourceInstaller.setCatalogDirectory("/ftpmirror/pub/sword/raw");
-		return resourceInstaller;
-	}
+        System.out.println("Setting package and catalog directories");
+        resourceInstaller.setPackageDirectory("/ftpmirror/pub/sword/packages/rawzip");
+        resourceInstaller.setCatalogDirectory("/ftpmirror/pub/sword/raw");
+        return resourceInstaller;
+    }
 }




More information about the Tynstep-svn mailing list