From 6f663d2d817d26b5b48a8d9f26ec08162ec76268 Mon Sep 17 00:00:00 2001 From: jeb228 Date: Tue, 13 Jul 2010 18:58:32 +0000 Subject: [PATCH] More explicit error messages. --- .../servlet/setup/UpdateUploadedFiles.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/UpdateUploadedFiles.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/UpdateUploadedFiles.java index 529ea6e47..2c9dc6e59 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/UpdateUploadedFiles.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/UpdateUploadedFiles.java @@ -2,6 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup; +import static edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao.JENA_ONT_MODEL_ATTRIBUTE_NAME; + import java.io.File; import javax.servlet.ServletContext; @@ -21,7 +23,8 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup; import edu.cornell.mannlib.vitro.webapp.filestorage.updater.FileStorageUpdater; /** - * TODO + * Check that the conditions are met for updating uploaded files. If everything + * is in place, call the updater. */ public class UpdateUploadedFiles implements ServletContextListener { private static final Log log = LogFactory.getLog(UpdateUploadedFiles.class); @@ -46,19 +49,40 @@ public class UpdateUploadedFiles implements ServletContextListener { WebappDaoFactory wadf = (WebappDaoFactory) ctx .getAttribute("webappDaoFactory"); if (wadf == null) { - throw new IllegalStateException("Webapp DAO Factory is null"); + throw new IllegalStateException("Webapp DAO Factory is null. " + + "The ServletContext does not contain an attribute " + + "for '" + "webappDaoFactory" + "'. " + + "Does the log contain a previous exception from " + + "JenaDataSourceSetup? Have you looked in " + + "localhost.log for such an exception? Is it " + + "possible that web.xml is not set up to run " + + "JenaDataSourceSetup before UpdateUploadedFiles?"); } OntModel jenaOntModel = (OntModel) ctx - .getAttribute(JenaBaseDao.JENA_ONT_MODEL_ATTRIBUTE_NAME); + .getAttribute(JENA_ONT_MODEL_ATTRIBUTE_NAME); if (jenaOntModel == null) { - throw new IllegalStateException("Ontology model is null"); + throw new IllegalStateException("Ontology model is null. " + + "The ServletContext does not contain an attribute " + + "for '" + JENA_ONT_MODEL_ATTRIBUTE_NAME + "'. " + + "Does the log contain a previous exception from " + + "JenaDataSourceSetup? Have you looked in " + + "localhost.log for such an exception? Is it " + + "possible that web.xml is not set up to run " + + "JenaDataSourceSetup before UpdateUploadedFiles?"); } FileStorage fileStorage = (FileStorage) ctx .getAttribute(FileStorageSetup.ATTRIBUTE_NAME); if (fileStorage == null) { - throw new IllegalStateException("File storage system is null"); + throw new IllegalStateException("File storage system is null. " + + "The ServletContext does not contain an attribute " + + "for '" + FileStorageSetup.ATTRIBUTE_NAME + "'. " + + "Does the log contain a previous exception from " + + "FileStorageSetup? Have you looked in " + + "localhost.log for such an exception? Is it " + + "possible that web.xml is not set up to run " + + "FileStorageSetup before UpdateUploadedFiles?"); } String uploadDirectoryName = ConfigurationProperties @@ -73,7 +97,6 @@ public class UpdateUploadedFiles implements ServletContextListener { + "' does not exist."); } - FileStorageUpdater fsu = new FileStorageUpdater(wadf, jenaOntModel, fileStorage, uploadDirectory); fsu.update();