diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java index f7e944f16..8bfb228f6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/config/ConfigurationPropertiesSmokeTests.java @@ -17,10 +17,11 @@ import javax.servlet.ServletContextListener; import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus; /** - * Test that gets run at servlet context startup to check for the existence and - * validity of properties in the configuration. + * Test that gets run at servlet context startup to check for the existence and + * validity of properties in the configuration. */ -public class ConfigurationPropertiesSmokeTests implements ServletContextListener { +public class ConfigurationPropertiesSmokeTests implements + ServletContextListener { private static final String PROPERTY_HOME_DIRECTORY = "vitro.home.directory"; private static final String PROPERTY_DB_URL = "VitroConnection.DataSource.url"; @@ -138,27 +139,39 @@ public class ConfigurationPropertiesSmokeTests implements ServletContextListener + username + "'", e); } } - + /** - * Confirm that the default namespace is specified and a syntactically valid URI. - */ - private void checkDefaultNamespace(ServletContext ctx, - ConfigurationProperties props, StartupStatus ss) { - String ns = props.getProperty(PROPERTY_DEFAULT_NAMESPACE); - if (ns == null || ns.isEmpty()) { - ss.fatal(this, "deploy.properties does not contain a value for '" - + PROPERTY_DEFAULT_NAMESPACE + "'"); - } else { - try { - URI uri = new URI(ns); - } catch (URISyntaxException e) { - ss.fatal(this, PROPERTY_DEFAULT_NAMESPACE + " '" + ns + - "' is not a valid URI. " + - (e.getMessage() != null ? e.getMessage() : "")); - } - } - } - + * Confirm that the default namespace is specified and a syntactically valid + * URI. It should also end with "/individual/". + */ + private void checkDefaultNamespace(ServletContext ctx, + ConfigurationProperties props, StartupStatus ss) { + String ns = props.getProperty(PROPERTY_DEFAULT_NAMESPACE); + if (ns == null || ns.isEmpty()) { + ss.fatal(this, "deploy.properties does not contain a value for '" + + PROPERTY_DEFAULT_NAMESPACE + "'"); + return; + } + + try { + new URI(ns); + } catch (URISyntaxException e) { + ss.fatal(this, + PROPERTY_DEFAULT_NAMESPACE + " '" + ns + + "' is not a valid URI. " + + (e.getMessage() != null ? e.getMessage() : "")); + return; + } + + String suffix = "/individual/"; + if (!ns.endsWith(suffix)) { + ss.warning(this, + "Default namespace does not match the expected form " + + "(does not end with '" + suffix + "'): '" + ns + + "'"); + } + } + @Override public void contextDestroyed(ServletContextEvent sce) { // nothing to do at shutdown diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/backend/FileStorageSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/backend/FileStorageSetup.java index 221d8fa4d..802508a8c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/backend/FileStorageSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/backend/FileStorageSetup.java @@ -73,14 +73,14 @@ public class FileStorageSetup implements ServletContextListener { * For use by the constructor in implementations of {@link FileStorage}. */ private File figureBaseDir(ServletContextEvent sce) throws IOException { - String homeDirPath = ConfigurationProperties.getBean(sce) - .getProperty(PROPERTY_VITRO_HOME_DIR); + String homeDirPath = ConfigurationProperties.getBean(sce).getProperty( + PROPERTY_VITRO_HOME_DIR); if (homeDirPath == null) { throw new IllegalArgumentException( "Configuration properties must contain a value for '" + PROPERTY_VITRO_HOME_DIR + "'"); } - + File homeDir = new File(homeDirPath); if (!homeDir.exists()) { throw new IllegalStateException("Vitro home directory '" @@ -91,20 +91,16 @@ public class FileStorageSetup implements ServletContextListener { if (!baseDir.exists()) { boolean created = baseDir.mkdir(); if (!created) { - throw new IOException( - "Unable to create uploads directory at '" - + baseDir + "'"); + throw new IOException("Unable to create uploads directory at '" + + baseDir + "'"); } } return baseDir; } /** - * Get the configuration property for the default namespace, and confirm - * that it is in the proper form. The default namespace is assumed to be in - * this form: http://vivo.mydomain.edu/individual/ - * - * For use by the constructor in implementations of {@link FileStorage}. + * Get the configuration property for the default namespace. For use by the + * constructor in implementations of {@link FileStorage}. * * @returns a collection containing the default namespace. */ @@ -117,14 +113,6 @@ public class FileStorageSetup implements ServletContextListener { + PROPERTY_DEFAULT_NAMESPACE + "'"); } - String defaultSuffix = "/individual/"; - - if (!defaultNamespace.endsWith(defaultSuffix)) { - log.warn("Default namespace does not match the expected form " - + "(does not end with '" + defaultSuffix + "'): '" - + defaultNamespace + "'"); - } - return Collections.singleton(defaultNamespace); }