Project

General

Profile

« Previous | Next » 

Revision 4761

Added by daigle almost 16 years ago

Check for existance of backup file location at startup time.

View differences:

src/edu/ucsb/nceas/metacat/service/PropertyService.java
37 37

  
38 38
import org.apache.log4j.Logger;
39 39

  
40
import edu.ucsb.nceas.metacat.util.SystemUtil;
40 41
import edu.ucsb.nceas.metacat.util.UtilException;
41 42
import edu.ucsb.nceas.utilities.FileUtil;
42 43
import edu.ucsb.nceas.utilities.GeneralPropertyException;
......
184 185
		} catch (TransformerException te) {
185 186
			throw new GeneralPropertyException(te.getMessage());
186 187
		}
187

  
188
		String backupDirPath = getProperty("application.backupDir") + FileUtil.getFS() + ".metacat";
189 188
		
190
		// The mainBackupProperties hold properties that were backed up the 
191
		// last time the application was configured.  On disk, the file will
192
		// look like a smaller version of metacat.properties.  It is stored 
193
		// in the data storage directory outside the application directories.
194
		mainBackupPropertiesFilePath = backupDirPath + FileUtil.getFS() + MAIN_CONFIG_NAME + ".backup";
195
		mainBackupProperties = new SortedProperties(mainBackupPropertiesFilePath);
196
		mainBackupProperties.load();
189
		String backupBasePath = getProperty("application.backupDir");
197 190
		
198
		// The authBackupProperties hold properties that were backed up the 
199
		// last time the auth was configured.  On disk, the file will
200
		// look like a smaller version of metacat.properties.  It is stored 
201
		// in the data storage directory outside the application directories.
202
		authBackupPropertiesFilePath = backupDirPath + FileUtil.getFS() +  AUTH_CONFIG_NAME + ".backup";
203
		authBackupProperties = new SortedProperties(authBackupPropertiesFilePath);
204
		authBackupProperties.load();
191
		// If the backupBasePath does not exist in metacat.properties, see if we can discover it.
192
		if (backupBasePath == null || backupBasePath.equals("")) {
193
			backupBasePath = SystemUtil.discoverExternalBaseDir();
194
		}
195

  
196
		// if backupBasePath is still null, no reason to initialize the backup properties. The
197
		// system will need to prompt the user for the backup properties and reinitialize 
198
		// PropertyService.
199
		if (backupBasePath != null && !backupBasePath.equals("")) {
200
			setProperty("application.backupDir", backupBasePath);
201
			
202
			String backupDirPath = backupBasePath + FileUtil.getFS() + ".metacat";
203

  
204
			// The mainBackupProperties hold properties that were backed up the
205
			// last time the application was configured. On disk, the file will
206
			// look like a smaller version of metacat.properties. It is stored
207
			// in the data storage directory outside the application
208
			// directories.
209
			mainBackupPropertiesFilePath = 
210
				backupDirPath + FileUtil.getFS() + MAIN_CONFIG_NAME + ".backup";
211
			mainBackupProperties = new SortedProperties(mainBackupPropertiesFilePath);
212
			mainBackupProperties.load();
213

  
214
			// The authBackupProperties hold properties that were backed up the
215
			// last time the auth was configured. On disk, the file will
216
			// look like a smaller version of metacat.properties. It is stored
217
			// in the data storage directory outside the application
218
			// directories.
219
			authBackupPropertiesFilePath = 
220
				backupDirPath + FileUtil.getFS() + AUTH_CONFIG_NAME + ".backup";
221
			authBackupProperties = new SortedProperties(authBackupPropertiesFilePath);
222
			authBackupProperties.load();
223
		}
205 224
	}
206 225

  
207 226
	/**

Also available in: Unified diff