View Javadoc

1   /*
2    * #%L
3    * Bitrepository Integrity Service
4    * %%
5    * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark
6    * %%
7    * This program is free software: you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License as 
9    * published by the Free Software Foundation, either version 2.1 of the 
10   * License, or (at your option) any later version.
11   * 
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Lesser Public License for more details.
16   * 
17   * You should have received a copy of the GNU General Lesser Public 
18   * License along with this program.  If not, see
19   * <http://www.gnu.org/licenses/lgpl-2.1.html>.
20   * #L%
21   */
22  
23  package org.bitrepository.integrityservice.audittrail;
24  
25  import org.bitrepository.common.settings.Settings;
26  import org.bitrepository.service.database.DatabaseCreator;
27  import org.bitrepository.settings.referencesettings.DatabaseSpecifics;
28  
29  public class IntegrityAuditTrailDatabaseCreator extends DatabaseCreator {
30      public static final String DEFAULT_AUDIT_TRAIL_DB_SCRIPT = "sql/derby/auditContributorDBCreation.sql";
31  
32      /**
33       * @param args <ol>
34       * <li> The path to the directory containing the settings. See
35       * {@link org.bitrepository.common.settings.XMLFileSettingsLoader} for details.</li>
36       * <li> The database creation script as found in the classpath. Will revert to  DEFAULT_CHECKSUM_DB_SCRIPT =
37       * "sql/derby/checksumDBCreation.sql" if null.</li>
38       * </ol>
39       */
40      public static void main(String[] args) {
41          IntegrityAuditTrailDatabaseCreator dbCreatorPillar = new IntegrityAuditTrailDatabaseCreator();
42          Settings settings = dbCreatorPillar.loadSettings(null, args[0]);
43  
44          dbCreatorPillar.createIntegrityAuditTrailDatabase(settings, args[1]);
45      }
46  
47      public void createIntegrityAuditTrailDatabase(Settings settings, String pathToSqlCreationScript) {
48          DatabaseSpecifics databaseSpecifics =
49                  settings.getReferenceSettings().getIntegrityServiceSettings().getAuditTrailContributerDatabase();
50  
51          if (pathToSqlCreationScript == null) {
52              pathToSqlCreationScript = DEFAULT_AUDIT_TRAIL_DB_SCRIPT;
53          }
54  
55          createDatabase(databaseSpecifics, pathToSqlCreationScript);
56      }
57  }