From 78241be68579c28947284240e6d2342c1dfba701 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 13 Nov 2014 17:17:38 -0500 Subject: [PATCH] VIVO-906 Assemble application at runtime. Create an object to represent VitroHomeDirectory Instantiate TripleSources, FileStorage, etc, based on the config file. --- build.xml | 1 + config/applicationSetup.n3 | 35 +++++++++++++++++++ .../WEB-INF/resources/startup_listeners.txt | 7 ++-- .../harvester/FileHarvestController.java | 10 ++---- 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 config/applicationSetup.n3 diff --git a/build.xml b/build.xml index 9c22fa3f..3245b7b4 100644 --- a/build.xml +++ b/build.xml @@ -75,6 +75,7 @@ + diff --git a/config/applicationSetup.n3 b/config/applicationSetup.n3 new file mode 100644 index 00000000..8f7ccf8e --- /dev/null +++ b/config/applicationSetup.n3 @@ -0,0 +1,35 @@ +@prefix : . + +:application + a , + ; + :hasSearchEngine :searchEngineWrapper ; + :hasImageProcessor :imageProcessor ; + :hasFileStorage :fileStorage ; + :hasContentTripleSource :contentTripleSource ; + :hasConfigurationTripleSource :configurationTripleSource . + +:imageProcessor + a , + . + +:fileStorage + a , + . + +:searchEngineWrapper + a , + ; + :wraps :searchEngine . + +:searchEngine + a , + . + +:contentTripleSource + a , + . + +:configurationTripleSource + a , + . \ No newline at end of file diff --git a/productMods/WEB-INF/resources/startup_listeners.txt b/productMods/WEB-INF/resources/startup_listeners.txt index 2871e488..db43cc7e 100644 --- a/productMods/WEB-INF/resources/startup_listeners.txt +++ b/productMods/WEB-INF/resources/startup_listeners.txt @@ -7,6 +7,8 @@ edu.cornell.mannlib.vitro.webapp.servlet.setup.JvmSmokeTests +edu.cornell.mannlib.vitro.webapp.application.ApplicationSetup + edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSetup edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSmokeTests @@ -16,15 +18,12 @@ edu.cornell.mannlib.vitro.webapp.servlet.setup.GuardAgainstUnmigratedRDB edu.cornell.mannlib.vitro.webapp.utils.developer.DeveloperSettings$Setup -edu.cornell.mannlib.vitro.webapp.application.ApplicationImpl$Setup +edu.cornell.mannlib.vitro.webapp.application.ApplicationImpl$ComponentsSetup edu.cornell.mannlib.vitro.webapp.config.RevisionInfoSetup edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory$Setup -# In 1.8, this should replace JenaPersistentDataSourceSetup, RDFServiceSetup, and maybe more. -edu.cornell.mannlib.vitro.webapp.servlet.setup.rdfsetup.RDFSetup - edu.cornell.mannlib.vitro.webapp.servlet.setup.ConfigurationModelsSetup edu.cornell.mannlib.vitro.webapp.servlet.setup.ContentModelSetup diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java b/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java index 548b9c68..aa3cdf00 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/harvester/FileHarvestController.java @@ -34,6 +34,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils; import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; @@ -213,13 +214,8 @@ public class FileHarvestController extends FreemarkerHttpServlet { */ private static String getUploadPathBase(ServletContext context) throws Exception { - String vitroHomeDirectoryName = ConfigurationProperties.getBean(context).getProperty(FileStorageImplWrapper.PROPERTY_VITRO_HOME_DIR); - if (vitroHomeDirectoryName == null) { - throw new Exception("Vitro home directory name could not be found."); - } - - String pathBase = vitroHomeDirectoryName + "/" + FileStorageImplWrapper.FILE_STORAGE_SUBDIRECTORY + "/" + PATH_TO_UPLOADS; - return pathBase; + String vitroHomeDirectoryName = ApplicationUtils.instance().getHomeDirectory().getPath().toString(); + return vitroHomeDirectoryName + "/" + FileStorageImplWrapper.FILE_STORAGE_SUBDIRECTORY + "/" + PATH_TO_UPLOADS; } /**