Project

General

Profile

« Previous | Next » 

Revision 5030

Added by daigle over 14 years ago

Change location of PropertyService to properties directory

View differences:

DBAdmin.java
54 54
import edu.ucsb.nceas.metacat.database.DBConnection;
55 55
import edu.ucsb.nceas.metacat.database.DBConnectionPool;
56 56
import edu.ucsb.nceas.metacat.database.DBVersion;
57
import edu.ucsb.nceas.metacat.service.PropertyService;
58
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
57
import edu.ucsb.nceas.metacat.properties.PropertyService;
59 58
import edu.ucsb.nceas.metacat.util.DatabaseUtil;
60 59
import edu.ucsb.nceas.metacat.util.RequestUtil;
61 60
import edu.ucsb.nceas.metacat.util.SystemUtil;
......
108 107
			versionSet = DatabaseUtil.getUpgradeVersions();
109 108
			scriptSuffixMap = DatabaseUtil.getScriptSuffixes();
110 109
		} catch (PropertyNotFoundException pnfe) {
111
			throw new AdminException("Could not retrieve database upgrade " 
110
			throw new AdminException("DBAdmin() - Could not retrieve database upgrade " 
112 111
					+ "versions during instantiation" + pnfe.getMessage());
113 112
		} catch (NumberFormatException nfe) {
114
			throw new AdminException("Bad version format numbering: "
113
			throw new AdminException("DBAdmin() - Bad version format numbering: "
115 114
					+ nfe.getMessage());
116 115
		}
117 116
	}
......
181 180
				RequestUtil.forwardRequest(request, response,
182 181
						"/admin/database-configuration.jsp", null);
183 182
			} catch (GeneralPropertyException gpe) {
184
				throw new AdminException("Problem getting or setting property while " 
185
						+ "initializing system properties page: " + gpe.getMessage());
183
				throw new AdminException("DBAdmin.configureDatabase - Problem getting or " + 
184
						"setting property while initializing system properties page: " + gpe.getMessage());
186 185
			} catch (IOException ioe) {
187
				throw new AdminException("IO problem while initializing "
186
				throw new AdminException("DBAdmin.configureDatabase - IO problem while initializing "
188 187
						+ "system properties page:" + ioe.getMessage());
189 188
			} catch (ServletException se) {
190
				throw new AdminException("problem forwarding request while "
189
				throw new AdminException("DBAdmin.configureDatabase - problem forwarding request while "
191 190
						+ "initializing system properties page: " + se.getMessage());
192 191
			}  
193 192
		} else {
......
227 226

  
228 227
				PropertyService.persistMainBackupProperties();
229 228
			} catch (GeneralPropertyException gpe) {
230
				throw new AdminException("Problem getting or setting property while "
231
						+ "upgrading database: " + gpe.getMessage());
229
				throw new AdminException("DBAdmin.configureDatabase - Problem getting or setting " +
230
						"property while upgrading database: " + gpe.getMessage());
232 231
			}  catch (IOException ioe) {
233
				throw new AdminException("IO problem while upgrading database: "
232
				throw new AdminException("DBAdmin.configureDatabase - IO problem while upgrading database: "
234 233
						 + ioe.getMessage());
235 234
			} catch (ServletException se) {
236
				throw new AdminException("problem forwarding request while "
235
				throw new AdminException("DBAdmin.configureDatabase - problem forwarding request while "
237 236
						+ "upgrading database: " + se.getMessage());
238 237
			}
239 238
		}
......
272 271
		// properties have been configured
273 272
		try {
274 273
			if (!PropertyService.arePropertiesConfigured()) {
275
				throw new AdminException("An attempt was made to get the database version "
276
								+ "before system properties were configured");
274
				throw new AdminException("DBAdmin.getDBVersion - An attempt was made to get " + 
275
						"the database version before system properties were configured");
277 276
			}
278
		} catch (MetacatUtilException ue) {
279
			throw new AdminException("Could not determine the database version: "
280
					+ ue.getMessage());
277
		} catch (GeneralPropertyException gpe) {
278
			throw new AdminException("DBAdmin.getDBVersion - Could not determine the database version: "
279
					+ gpe.getMessage());
281 280
		}
282 281
		if (databaseVersion == null) {
283 282
			databaseVersion = discoverDBVersion();
284 283
		}
285 284

  
286 285
		if (databaseVersion == null) {
287
			throw new AdminException("Could not find database version");
286
			throw new AdminException("DBAdmin.getDBVersion - Could not find database version");
288 287
		}
289 288

  
290 289
		return databaseVersion;
......
304 303
		try {
305 304
			int dbStatus = getDBStatus();
306 305
			if (dbStatus == DB_DOES_NOT_EXIST) {
307
				throw new AdminException(
308
						"Database does not exist for connection"
309
						+ PropertyService.getProperty("database.connectionURI"));
306
				throw new AdminException("DBAdmin.discoverDBVersion - Database does not exist " + 
307
						"for connection" + PropertyService.getProperty("database.connectionURI"));
310 308
			} else if (dbStatus == TABLES_DO_NOT_EXIST) {
311 309
				databaseVersion = new DBVersion("0.0.0");
312 310
				return databaseVersion;
......
320 318
			databaseVersion = getUnRegisteredDBVersion();
321 319
			
322 320
		} catch (SQLException sqle) {
323
			String errorMessage = "SQL error during  database version discovery: "
321
			String errorMessage = "DBAdmin.discoverDBVersion - SQL error during  database version discovery: "
324 322
				+ sqle.getMessage();
325 323
			logMetacat.error(errorMessage);
326 324
			throw new AdminException(errorMessage);
327 325
		} catch (PropertyNotFoundException pnfe) {
328
			String errorMessage = "Property not found during  database version discovery: "
329
					+ pnfe.getMessage();
326
			String errorMessage = "DBAdmin.discoverDBVersion - Property not found during  database " + 
327
			"version discovery: " + pnfe.getMessage();
330 328
			logMetacat.error(errorMessage);
331 329
			throw new AdminException(errorMessage);
332 330
		} catch (NumberFormatException nfe) {
333
			throw new AdminException("Bad version format numbering: "
331
			throw new AdminException("DBAdmin.discoverDBVersion - Bad version format numbering: "
334 332
					+ nfe.getMessage());
335 333
		}
336 334
		
337 335
		if (databaseVersion == null) {
338
			throw new AdminException("Database version discovery returned null");
336
			throw new AdminException("DBAdmin.discoverDBVersion - Database version discovery returned null");
339 337
		}
340 338
		return databaseVersion;
341 339
	}
......
382 380
			return new DBVersion(dbVersionString);
383 381
			
384 382
		} catch (SQLException sqle) {
385
			throw new AdminException("Could not run SQL to get registered db version: " 
383
			throw new AdminException("DBAdmin.getRegisteredDBVersion - Could not run SQL to get registered db version: " 
386 384
					+ sqle.getMessage());			
387 385
		} catch (PropertyNotFoundException pnfe) {
388
			throw new AdminException("Could not get property for registered db version: " 
386
			throw new AdminException("DBAdmin.getRegisteredDBVersion - Could not get property for registered db version: " 
389 387
					+ pnfe.getMessage());		
390 388
		} catch (NumberFormatException nfe) {
391
			throw new AdminException("Bad version format numbering: "
389
			throw new AdminException("DBAdmin.getRegisteredDBVersion - Bad version format numbering: "
392 390
					+ nfe.getMessage());
393 391
		} finally {
394 392
			if (pstmt != null) {
......
440 438
				return new DBVersion(dbVersionString);
441 439
			}
442 440
		} catch (PropertyNotFoundException pnfe) {
443
			throw new AdminException(
444
					"Could not get property for unregistered db version: "
445
							+ pnfe.getMessage());
441
			throw new AdminException("DBAdmin.getUnRegisteredDBVersion - Could not get " + 
442
					"property for unregistered db version: " + pnfe.getMessage());
446 443
		} catch (NumberFormatException nfe) {
447
			throw new AdminException("Bad version format numbering: "
444
			throw new AdminException("DBAdmin.getUnRegisteredDBVersion - Bad version format numbering: "
448 445
					+ nfe.getMessage());
449 446
		}
450 447
	}
......
463 460
		try {
464 461

  
465 462
			// check out DBConnection
466
			conn = DBConnectionPool
467
					.getDBConnection("DBAdmin.updateDBVersion()");
463
			conn = DBConnectionPool.getDBConnection("DBAdmin.updateDBVersion()");
468 464
			serialNumber = conn.getCheckOutSerialNumber();
469 465
			conn.setAutoCommit(false);
470 466

  
......
483 479
			conn.commit();
484 480
		} catch (SQLException e) {
485 481
			conn.rollback();
486
			throw new SQLException("DBAdmin.getDBVersion(). " + e.getMessage());
482
			throw new SQLException("DBAdmin.updateDBVersion - sql error: " + e.getMessage());
487 483
		} catch (PropertyNotFoundException pnfe) {
488 484
			conn.rollback();
489
			throw new SQLException("DBAdmin.getDBVersion(). " + pnfe.getMessage());
485
			throw new SQLException("DBAdmin.updateDBVersion - property error" + pnfe.getMessage());
490 486
		}
491 487
		finally {
492 488
			try {
......
698 694
			sqlFileLocation = SystemUtil.getSQLDir();
699 695
			databaseType = PropertyService.getProperty("database.type");
700 696
		} catch (PropertyNotFoundException pnfe) {
701
			throw new AdminException("Could not get property while trying " 
697
			throw new AdminException("DBAdmin.getUpdateScripts - Could not get property while trying " 
702 698
					+ "to retrieve database update scripts: " + pnfe.getMessage());
703 699
		}
704 700
		
......
763 759
			// update the db version to be the metacat version
764 760
			databaseVersion = new DBVersion(SystemUtil.getMetacatVersion().getVersionString());
765 761
		} catch (SQLException sqle) {
766
			throw new AdminException("SQL error when running upgrade scripts: "
762
			throw new AdminException("DBAdmin.upgradeDatabase - SQL error when running upgrade scripts: "
767 763
					+ sqle.getMessage());
768 764
		} catch (PropertyNotFoundException pnfe) {
769
			throw new AdminException("SQL error when running upgrade scripts: "
765
			throw new AdminException("DBAdmin.upgradeDatabase - SQL error when running upgrade scripts: "
770 766
					+ pnfe.getMessage());
771 767
		}catch (NumberFormatException nfe) {
772
			throw new AdminException("Bad version format numbering: "
768
			throw new AdminException("DBAdmin.upgradeDatabase - Bad version format numbering: "
773 769
					+ nfe.getMessage());
774 770
		}
775 771
	}
......
800 796

  
801 797
			// load the sql from the file into a vector of individual statements
802 798
			// and execute them.
803
			logMetacat.debug("processing File: " + sqlFileName);
799
			logMetacat.debug("DBAdmin.runSQLFile - processing File: " + sqlFileName);
804 800
			Vector<String> sqlCommands = loadSQLFromFile(sqlFileName);
805 801
			for (String sqlStatement : sqlCommands) {
806 802
				Statement statement = connection.createStatement();
......
816 812
							 sqle.getMessage().contains("ORA-04098") ||
817 813
							 sqle.getMessage().contains("ORA-04080") ||
818 814
							 sqle.getMessage().contains("ORA-00942"))) {
819
						logMetacat.warn("did not process sql drop statement: " + sqle.getMessage());
815
						logMetacat.warn("DBAdmin.runSQLFile - did not process sql drop statement: " + sqle.getMessage());
820 816
					} else {
821 817
						throw sqle;
822 818
					}
......
825 821
			connection.commit();
826 822
			
827 823
		} catch (IOException ioe) {
828
			throw new AdminException("Could not read SQL file" 
824
			throw new AdminException("DBAdmin.runSQLFile - Could not read SQL file" 
829 825
					+ ioe.getMessage());
830 826
		} catch (PropertyNotFoundException pnfe) {
831
			throw new AdminException("Could not find property to run SQL file" 
827
			throw new AdminException("DBAdmin.runSQLFile - Could not find property to run SQL file" 
832 828
					+ pnfe.getMessage());
833 829
		} catch (SQLException sqle) {
834 830
			if (connection != null) {

Also available in: Unified diff