Project

General

Profile

« Previous | Next » 

Revision 4795

Added by daigle over 15 years ago

Allow for backup properties to be written to context based subdirectory of the external configuration directory. This allow multiple instances of metacat to be run side by side.

View differences:

BackupAdmin.java
40 40
import edu.ucsb.nceas.metacat.service.ServiceService;
41 41
import edu.ucsb.nceas.metacat.util.RequestUtil;
42 42
import edu.ucsb.nceas.metacat.util.SystemUtil;
43
import edu.ucsb.nceas.metacat.util.UtilException;
43 44
import edu.ucsb.nceas.utilities.FileUtil;
44
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
45 45
import edu.ucsb.nceas.utilities.GeneralPropertyException;
46 46

  
47 47
/**
......
98 98
			// the web form for configuring metacat
99 99
			
100 100
			try {
101
				String backupBaseDir = SystemUtil.discoverExternalBaseDir();
101
				String backupBaseDir = SystemUtil.discoverExternalDir();
102 102
				logMetacat.debug("Backup dir discovered as: " + backupBaseDir);
103 103
				String backupDirStatus = getBackupDirStatus(backupBaseDir);
104 104
				logMetacat.debug("Status of discovered backup dir: " + backupDirStatus);
......
119 119
			} catch (ServletException se) {
120 120
				throw new AdminException("Problem forwarding request while "
121 121
						+ "initializing backup configuration page: " + se.getMessage());
122
			} catch (PropertyNotFoundException pnfe) {
122
			} catch (UtilException ue) {
123 123
				throw new AdminException("Problem discovering backup directory while "
124
						+ "initializing backup configuration page: " + pnfe.getMessage());
124
						+ "initializing backup configuration page: " + ue.getMessage());
125 125
			}
126 126
		} else {
127 127
			// The configuration form is being submitted and needs to be
......
130 130
			Vector<String> processingErrors = new Vector<String>();
131 131
			Vector<String> validationErrors = new Vector<String>();
132 132
			
133
			String backupDir = request.getParameter("backup-dir");
134
			String hiddenBackupDir = backupDir + FileUtil.getFS() + ".metacat";
135

  
136 133
			// Validate that the options provided are legitimate.
137 134
			validationErrors.addAll(validateOptions(request));
138

  
135
			String backupDir = null;
136
			String realApplicationContext = null;
137
			String hiddenBackupDir = null;
138
			
139 139
			if (validationErrors.size() == 0) {
140 140
				try {
141
					backupDir = request.getParameter("backup-dir");
142
					realApplicationContext = ServiceService.getRealApplicationContext();
143
					hiddenBackupDir = 
144
						backupDir + FileUtil.getFS() + "." + realApplicationContext;
145
					
141 146
					FileUtil.createDirectory(hiddenBackupDir);
142 147
					
143 148
					PropertyService.setProperty("application.backupDir", backupDir);
144 149
					ServiceService.refreshService("PropertyService");
150
					PropertyService.setRecommendedExternalDir(backupDir);
151
					
145 152
					ServiceService.refreshService("SkinPropertyService");
146 153
					SystemUtil.storeExternalDirLocation(backupDir);
147 154
				} catch (IOException ue) {

Also available in: Unified diff