1 23 24 package org.cofax.util; 25 26 import java.util.*; 27 28 import org.cofax.*; 29 import org.cofax.cms.*; 30 31 39 40 public class LifeCycleUpdater { 41 42 public static void main(String args[]) { 43 44 System.out.println("Cofax v1.0 - Update life cycles"); 46 47 String configLocation = args[0]; 49 XMLConfig configFile = new XMLConfig(); 50 configFile.setXMLFileName(configLocation); 51 if (!configFile.load()) { 52 System.err.println(configFile.getLastError()); 53 } 54 String dataStoreName = configFile.getString("dataStoreName"); 56 String dataStore = configFile.getString("dataStoreClass"); 57 String databaseIdentifier = configFile.getString("databaseIdentifier"); 58 Properties dbProps = new Properties(); 59 60 dbProps.setProperty("drivers", configFile.getString("dataStoreDriver")); 61 dbProps.setProperty("logfile", configFile.getString("dataStoreLogFile")); 62 dbProps.setProperty(dataStoreName + ".url", configFile.getString("dataStoreUrl")); 63 dbProps.setProperty(dataStoreName + ".user", configFile.getString("dataStoreUser")); 64 dbProps.setProperty(dataStoreName + ".password", configFile.getString("dataStorePassword")); 65 dbProps.setProperty(dataStoreName + ".initconns", configFile.getString("dataStoreInitconns")); 66 dbProps.setProperty(dataStoreName + ".maxconns", configFile.getString("dataStoreMaxconns")); 67 dbProps.setProperty(dataStoreName + ".connusagelimit", configFile.getString("dataStoreConnusagelimit")); 68 dbProps.setProperty(dataStoreName + ".testquery", configFile.getString("dataStoreTestquery")); 69 dbProps.setProperty(dataStoreName + ".loglevel", configFile.getString("dataStoreLoglevel")); 70 71 System.out.print("Connecting to SQL database...\n"); 73 DataStore db = null; 74 try { 75 System.out.print("DataStore = " + (Class.forName(dataStore))); 76 db = (DataStore) (Class.forName(dataStore)).newInstance(); 77 db.init(dbProps); 78 db.setDataStoreName(dataStoreName); 79 } catch (ClassNotFoundException e) { 80 System.out.println("ERROR: Data store class not found.: " + e); 81 return; 82 } catch (InstantiationException e) { 83 System.out.println("ERROR loading data store class.: " + e); 84 return; 85 } catch (IllegalAccessException e) { 86 System.out.println("Error loading data store class.: " + e); 87 return; 88 } 89 System.out.print("Connected\n"); 90 91 if (db.connect()) { 92 try { 93 CofaxToolsLifeCycle htCycle = new CofaxToolsLifeCycle(); 94 boolean success = htCycle.updateAllPublications(db); 95 System.out.print("Done\n"); 96 } catch (Exception e) { 97 System.out.print("updateLifeCycles : Exception : " + e); 98 } finally { 99 db.disConnect(); 100 } 101 } else { 102 System.out.println("\nERROR: Could not get a connection." + db.getLastError()); 103 } 104 } 105 } 106 | Popular Tags |