More explicit error messages.

This commit is contained in:
jeb228 2010-07-13 18:58:32 +00:00
parent 691feaee81
commit 6f663d2d81

View file

@ -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();