Project

General

Profile

« Previous | Next » 

Revision 6932

Refactoring classes that throw generic Exception class to throw their more specific subclasses so that new exceptions are not hidden behind generic messages. Makes debugging easier.

View differences:

src/edu/ucsb/nceas/metacat/AuthSession.java
38 38
import edu.ucsb.nceas.metacat.properties.PropertyService;
39 39
import edu.ucsb.nceas.metacat.shared.MetacatUtilException;
40 40
import edu.ucsb.nceas.metacat.util.AuthUtil;
41
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
41 42

  
42 43
/**
43 44
 * A Class that implements session tracking for MetaCatServlet users.
......
54 55

  
55 56
	/**
56 57
	 * Construct an AuthSession
58
	 * @throws ClassNotFoundException 
59
	 * @throws IllegalAccessException 
60
	 * @throws InstantiationException 
57 61
	 */
58
	public AuthSession() throws Exception {
62
	public AuthSession() throws InstantiationException, IllegalAccessException, ClassNotFoundException {
59 63
		// Determine our session authentication method and
60 64
		// create an instance of the auth class
61
		this.authClass = PropertyService.getProperty("auth.class");
65
		try {
66
            this.authClass = PropertyService.getProperty("auth.class");
67
        } catch (PropertyNotFoundException e) {
68
            // TODO Auto-generated catch block
69
            e.printStackTrace();
70
        }
62 71
		this.authService = (AuthInterface) createObject(authClass);
63 72
	}
64 73

  
......
265 274
	 *
266 275
	 * @param className the fully qualified name of the class to instantiate
267 276
	 */
268
	private static Object createObject(String className) throws Exception {
277
	private static Object createObject(String className) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
269 278

  
270 279
		Object object = null;
271
		try {
280
//		try {
272 281
			Class classDefinition = Class.forName(className);
273 282
			object = classDefinition.newInstance();
274
		} catch (InstantiationException e) {
275
			throw e;
276
		} catch (IllegalAccessException e) {
277
			throw e;
278
		} catch (ClassNotFoundException e) {
279
			throw e;
280
		}
283
//		} catch (InstantiationException e) {
284
//			throw e;
285
//		} catch (IllegalAccessException e) {
286
//			throw e;
287
//		} catch (ClassNotFoundException e) {
288
//			throw e;
289
//		}
281 290
		return object;
282 291
	}
283 292
	
src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java
263 263
				}
264 264
			}
265 265
		} catch (InstantiationException ie) {
266
			errorVector.add("AuthAdmin.validateOptions - Instantiation error while verifying Metacat Administrators : "
266
			errorVector.add("AuthAdmin.validateOptions - InstantiationException while verifying Metacat Administrators : "
267 267
							+ ie.getMessage());
268
		} catch (Exception e) {
269
			errorVector.add("AuthAdmin.validateOptions - Error while verifying Metacat Administrators : "
270
					+ e.getMessage());
271
		}
268
		} catch (IllegalAccessException e) {
269
		    errorVector.add("AuthAdmin.validateOptions - IllegalAccessException : "
270
                  + e.getMessage());
271
        } catch (ClassNotFoundException e) {
272
            errorVector.add("AuthAdmin.validateOptions - ClassNotFoundException : "
273
                  + e.getMessage());
274
        }
272 275

  
273 276
		return errorVector;
274 277
	}

Also available in: Unified diff