NIHVIVO-927 Merge 5386 from branch.

This commit is contained in:
jeb228 2010-07-22 15:22:18 +00:00
parent 7911fa6490
commit 1c62224b6d
3 changed files with 38 additions and 31 deletions

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.filestorage.backend;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
@ -11,6 +10,9 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
/**
@ -18,6 +20,8 @@ import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
* context.
*/
public class FileStorageSetup implements ServletContextListener {
private static final Log log = LogFactory.getLog(FileStorageSetup.class);
/**
* The implementation of the {@link FileStorage} system will be stored in
* the {@link ServletContext} as an attribute with this name.
@ -43,18 +47,16 @@ public class FileStorageSetup implements ServletContextListener {
*/
@Override
public void contextInitialized(ServletContextEvent sce) {
FileStorage fs;
try {
File baseDirectory = figureBaseDir();
Collection<String> fileNamespace = confirmDefaultNamespace();
fs = new FileStorageImpl(baseDirectory, fileNamespace);
} catch (IOException e) {
throw new IllegalStateException(
"Failed to initialize the file system.", e);
}
FileStorage fs = new FileStorageImpl(baseDirectory, fileNamespace);
ServletContext sc = sce.getServletContext();
sc.setAttribute(ATTRIBUTE_NAME, fs);
ServletContext sc = sce.getServletContext();
sc.setAttribute(ATTRIBUTE_NAME, fs);
} catch (Exception e) {
log.fatal("Failed to initialize the file system.", e);
}
}
/**

View file

@ -52,10 +52,9 @@ public class UpdateUploadedFiles implements ServletContextListener {
+ "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?");
+ "JenaDataSourceSetup? Is it possible that web.xml "
+ "is not set up to run JenaDataSourceSetup before "
+ "UpdateUploadedFiles?");
}
OntModel jenaOntModel = (OntModel) ctx
@ -65,10 +64,9 @@ public class UpdateUploadedFiles implements ServletContextListener {
+ "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?");
+ "JenaDataSourceSetup? Is it possible that web.xml "
+ "is not set up to run JenaDataSourceSetup before "
+ "UpdateUploadedFiles?");
}
FileStorage fileStorage = (FileStorage) ctx
@ -78,10 +76,9 @@ public class UpdateUploadedFiles implements ServletContextListener {
+ "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?");
+ "FileStorageSetup? Is it possible that web.xml is "
+ "not set up to run FileStorageSetup before "
+ "UpdateUploadedFiles?");
}
String uploadDirectoryName = ConfigurationProperties
@ -104,8 +101,7 @@ public class UpdateUploadedFiles implements ServletContextListener {
fileStorage, uploadDirectory, webappImageDirectory);
fsu.update();
} catch (Exception e) {
log.error("Unknown problem", e);
throw new RuntimeException(e);
log.fatal("Unknown problem", e);
}
}
}