Project

General

Profile

« Previous | Next » 

Revision 4760

Added by daigle almost 16 years ago

Only show the backup configuration screen if the system cannot discover a directory.

View differences:

src/edu/ucsb/nceas/metacat/admin/MetaCatAdminServlet.java
40 40

  
41 41
import edu.ucsb.nceas.metacat.MetaCatServlet;
42 42
import edu.ucsb.nceas.metacat.service.PropertyService;
43
import edu.ucsb.nceas.metacat.service.ServiceException;
44
import edu.ucsb.nceas.metacat.service.ServiceService;
43 45
import edu.ucsb.nceas.metacat.service.SessionService;
44 46
import edu.ucsb.nceas.metacat.util.AuthUtil;
45 47
import edu.ucsb.nceas.metacat.util.MetacatUtil;
......
47 49
import edu.ucsb.nceas.metacat.util.SkinUtil;
48 50
import edu.ucsb.nceas.metacat.util.SystemUtil;
49 51
import edu.ucsb.nceas.metacat.util.UtilException;
50
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
52
import edu.ucsb.nceas.utilities.GeneralPropertyException;
51 53

  
52 54
/**
53 55
 * Entry servlet for the metadata configuration utility
......
103 105
				SessionService.touchSession(httpSession.getId());
104 106
			}
105 107
			
106
			if (!MetacatUtil.isBackupDirConfigured()) {	
107
				// If the user is logged in, make sure the backup directory has been configured.
108
				// If not, go to the backup configuration page.
109
				processingMessage.add("You must configure the backup directory" + 
110
						" before you can continue with Metacat configuration.");
111
				RequestUtil.setRequestMessage(request, processingMessage);
112
				action = "backup";
113
				logMetacat.debug("Admin action changed to 'backup'");
108
			if (!MetacatUtil.isBackupDirConfigured()) {
109
				String discoveredBackupDir = SystemUtil.discoverExternalBaseDir();
110
				if (discoveredBackupDir == null) {
111
					// if the backup dir has not been configured, and the system 
112
					// cannot find a suitable directory, then show the backup 
113
					// directory configuration screen.
114
					processingMessage.add("You must configure the backup directory"
115
							+ " before you can continue with Metacat configuration.");
116
					RequestUtil.setRequestMessage(request, processingMessage);
117
					action = "backup";
118
					logMetacat.debug("Admin action changed to 'backup'");
119
				} else {
120
					// if the backup dir has not been configured, and the system 
121
					// can find a suitable directory, then set the application.backupDir 
122
					// property to the discovered value
123
					PropertyService.setProperty("application.backupDir", discoveredBackupDir);
124
					ServiceService.refreshService("PropertyService");
125
				}
114 126
			} else if (!AuthUtil.isAuthConfigured()) {
115 127
				// if authentication isn't configured, change the action to auth.  
116 128
				// Authentication needs to be set up before we do anything else
......
183 195
				logMetacat.error(errorMessage);
184 196
				processingErrors.add(errorMessage);
185 197
			} 
186
		} catch (PropertyNotFoundException pnfe) {
198
		} catch (GeneralPropertyException ge) {
187 199
			String errorMessage = 
188
				"Property problem while handling request: " + pnfe.getMessage();
200
				"Property problem while handling request: " + ge.getMessage();
189 201
			logMetacat.error(errorMessage);
190 202
			processingErrors.add(errorMessage);
191 203
		} catch (AdminException ae) {
......
198 210
				"Utility problem while handling request: " + ue.getMessage();
199 211
			logMetacat.error(errorMessage);
200 212
			processingErrors.add(errorMessage);
213
		} catch (ServiceException se) {
214
			String errorMessage = 
215
				"Utility problem while handling request: " + se.getMessage();
216
			logMetacat.error(errorMessage);
217
			processingErrors.add(errorMessage);
201 218
		}
202 219
		
203 220
		if (processingErrors.size() > 0) {
src/edu/ucsb/nceas/metacat/admin/BackupAdmin.java
99 99
			
100 100
			try {
101 101
				String backupBaseDir = SystemUtil.discoverExternalBaseDir();
102
				logMetacat.debug("Backup dir discovered as: " + backupBaseDir);
102 103
				String backupDirStatus = getBackupDirStatus(backupBaseDir);
104
				logMetacat.debug("Status of discovered backup dir: " + backupDirStatus);
103 105
				
104
				request.setAttribute("backupBaseDir", backupBaseDir);
106
				if (backupBaseDir != null) {
107
					request.setAttribute("backupBaseDir", backupBaseDir);
108
				} else {
109
					request.setAttribute("backupBaseDir", "");
110
				}
105 111
				request.setAttribute("backupDirStatus", backupDirStatus);
106 112
				
107 113
				// Forward the request to the JSP page
......
191 197
	 * @return a string corresponding to one of the statuses shown above.
192 198
	 */
193 199
	protected String getBackupDirStatus(String backupBaseDir) {
200
		if (backupBaseDir == null) {
201
			return UNKNOWN;
202
		}
203
		
194 204
		if (FileUtil.getFileStatus(backupBaseDir + FileUtil.getFS() + ".metacat" + FileUtil.getFS()
195 205
				+ "metacat.properties.backup") >= FileUtil.EXISTS_READ_WRITABLE) {
196 206
			return HIDDEN_EXISTS_POPULATED;

Also available in: Unified diff