diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelMaker.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelMaker.java index 1a40088fb..8dd7223a7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelMaker.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaModelMaker.java @@ -26,7 +26,7 @@ import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.util.iterator.ExtendedIterator; import com.hp.hpl.jena.util.iterator.WrappedIterator; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; /** @@ -56,8 +56,8 @@ public class VitroJenaModelMaker implements ModelMaker { this.username = username; this.password = password; this.dbTypeStr = dbTypeStr; - String driverName = ConfigurationProperties - .getProperty("VitroConnection.DataSource.driver"); + String driverName = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.driver"); // This property is no longer used? // We'll change it all around in 1.2 anyway. if(driverName == null) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/FileServingHelper.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/FileServingHelper.java index c684f7180..a171d2e5b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/FileServingHelper.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filestorage/FileServingHelper.java @@ -10,7 +10,7 @@ import javax.servlet.ServletContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup; /** @@ -28,7 +28,7 @@ public class FileServingHelper { * the suffix. */ private static String getDefaultNamespace(ServletContext ctx) { - String defaultNamespace = ConfigurationProperties + String defaultNamespace = ConfigurationProperties.getBean(ctx) .getProperty(FileStorageSetup.PROPERTY_DEFAULT_NAMESPACE); if (defaultNamespace == null) { throw new IllegalArgumentException( 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 17b1ee0d7..69102739e 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 @@ -13,7 +13,7 @@ import javax.servlet.ServletContextListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; /** * Initializes the file storage system, and stores a reference in the servlet @@ -48,8 +48,8 @@ public class FileStorageSetup implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { try { - File baseDirectory = figureBaseDir(); - Collection fileNamespace = confirmDefaultNamespace(); + File baseDirectory = figureBaseDir(sce); + Collection fileNamespace = confirmDefaultNamespace(sce); FileStorage fs = new FileStorageImpl(baseDirectory, fileNamespace); ServletContext sc = sce.getServletContext(); @@ -65,9 +65,9 @@ public class FileStorageSetup implements ServletContextListener { * * For use by the constructor in implementations of {@link FileStorage}. */ - private File figureBaseDir() { - String baseDirPath = ConfigurationProperties - .getProperty(PROPERTY_FILE_STORAGE_BASE_DIR); + private File figureBaseDir(ServletContextEvent sce) { + String baseDirPath = ConfigurationProperties.getBean(sce) + .getProperty(PROPERTY_FILE_STORAGE_BASE_DIR); if (baseDirPath == null) { throw new IllegalArgumentException( "Configuration properties must contain a value for '" @@ -85,8 +85,8 @@ public class FileStorageSetup implements ServletContextListener { * * @returns a collection containing the default namespace. */ - private Collection confirmDefaultNamespace() { - String defaultNamespace = ConfigurationProperties + private Collection confirmDefaultNamespace(ServletContextEvent sce) { + String defaultNamespace = ConfigurationProperties.getBean(sce) .getProperty(PROPERTY_DEFAULT_NAMESPACE); if (defaultNamespace == null) { throw new IllegalArgumentException( diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetup.java index 3154abd44..1d22721c2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetup.java @@ -25,8 +25,9 @@ import org.apache.lucene.search.BooleanQuery; import com.hp.hpl.jena.ontology.OntModel; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils; @@ -38,7 +39,6 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ObjectSourceIface; import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch; import edu.cornell.mannlib.vitro.webapp.search.indexing.IndexBuilder; import edu.cornell.mannlib.vitro.webapp.servlet.setup.AbortStartup; -import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; /** * Setup objects for lucene searching and indexing. @@ -69,6 +69,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { * Gets run to set up DataSource when the webapp servlet context gets * created. */ + @Override public void contextInitialized(ServletContextEvent sce) { if (AbortStartup.isStartupAborted(sce.getServletContext())) { @@ -78,7 +79,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { try { ServletContext context = sce.getServletContext(); - String baseIndexDir = getBaseIndexDirName(); + String baseIndexDir = getBaseIndexDirName(context); log.info("Setting up Lucene index. Base directory of lucene index: " + baseIndexDir); setBoolMax(); @@ -98,7 +99,9 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { // Here we want to put the LuceneIndex object into the application scope. // This will attempt to create a new directory and empty index if there is none. - LuceneIndexer indexer = new LuceneIndexer(getBaseIndexDirName(),liveIndexDir, null, getAnalyzer()); + LuceneIndexer indexer = new LuceneIndexer( + getBaseIndexDirName(context), liveIndexDir, null, + getAnalyzer()); context.setAttribute(ANALYZER, getAnalyzer()); OntModel displayOntModel = (OntModel) sce.getServletContext().getAttribute("displayOntModel"); @@ -139,7 +142,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { SearchReindexingListener srl = new SearchReindexingListener(builder); ModelContext.registerListenerForChanges(ctx, srl); - if( (Boolean)sce.getServletContext().getAttribute(INDEX_REBUILD_REQUESTED_AT_STARTUP) instanceof Boolean && + if( sce.getServletContext().getAttribute(INDEX_REBUILD_REQUESTED_AT_STARTUP) instanceof Boolean && (Boolean)sce.getServletContext().getAttribute(INDEX_REBUILD_REQUESTED_AT_STARTUP) ){ log.info("Rebuild of lucene index required before startup."); builder.doIndexRebuild(); @@ -148,7 +151,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { n++; if( n % 20 == 0 ) //output message every 10 sec. log.info("Still rebuilding lucene index"); - Thread.currentThread().sleep(500); + Thread.sleep(500); } } @@ -163,6 +166,7 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { /** * Gets run when the webApp Context gets destroyed. */ + @Override public void contextDestroyed(ServletContextEvent sce) { log.debug("**** Running " + this.getClass().getName() + ".contextDestroyed()"); IndexBuilder builder = (IndexBuilder) sce.getServletContext().getAttribute(IndexBuilder.class.getName()); @@ -195,9 +199,9 @@ public class LuceneSetup implements javax.servlet.ServletContextListener { * @throws IOException * if the directory doesn't exist and we fail to create it. */ - private String getBaseIndexDirName() + private String getBaseIndexDirName(ServletContext ctx) throws IOException { - String dirName = ConfigurationProperties + String dirName = ConfigurationProperties.getBean(ctx) .getProperty("LuceneSetup.indexDir"); if (dirName == null) { throw new IllegalStateException( diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetupCJK.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetupCJK.java index 13c406603..e36db8463 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetupCJK.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/lucene/LuceneSetupCJK.java @@ -19,8 +19,8 @@ import org.apache.lucene.search.BooleanQuery; import com.hp.hpl.jena.ontology.OntModel; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering; @@ -61,12 +61,13 @@ public class LuceneSetupCJK implements javax.servlet.ServletContextListener { /** * Gets run to set up DataSource when the webapp servlet context gets created. */ - @SuppressWarnings("unchecked") + @Override + @SuppressWarnings("unchecked") public void contextInitialized(ServletContextEvent sce) { ServletContext context = sce.getServletContext(); log.info("**** Running "+this.getClass().getName()+".contextInitialized()"); try{ - indexDir = getIndexDirName(); + indexDir = getIndexDirName(sce); log.info("Lucene indexDir: " + indexDir); setBoolMax(); @@ -129,7 +130,8 @@ public class LuceneSetupCJK implements javax.servlet.ServletContextListener { /** * Gets run when the webApp Context gets destroyed. */ - public void contextDestroyed(ServletContextEvent sce) { + @Override + public void contextDestroyed(ServletContextEvent sce) { log.info("**** Running "+this.getClass().getName()+".contextDestroyed()"); IndexBuilder builder = (IndexBuilder)sce.getServletContext().getAttribute(IndexBuilder.class.getName()); @@ -160,9 +162,9 @@ public class LuceneSetupCJK implements javax.servlet.ServletContextListener { * @throws IOException * if the directory doesn't exist and we fail to create it. */ - private String getIndexDirName() + private String getIndexDirName(ServletContextEvent sce) throws IOException { - String dirName = ConfigurationProperties + String dirName = ConfigurationProperties.getBean(sce) .getProperty("LuceneSetup.indexDir"); if (dirName == null) { throw new IllegalStateException( diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/AttachSubmodels.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/AttachSubmodels.java index eb88d26b6..be8cfa223 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/AttachSubmodels.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/AttachSubmodels.java @@ -5,9 +5,9 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.IOException; import java.util.Set; +import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; @@ -18,7 +18,7 @@ import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao; public class AttachSubmodels implements ServletContextListener { @@ -27,18 +27,20 @@ public class AttachSubmodels implements ServletContextListener { private static final Log log = LogFactory.getLog( AttachSubmodels.class ); + @Override public void contextInitialized( ServletContextEvent sce ) { - if (AbortStartup.isStartupAborted(sce.getServletContext())) { + ServletContext ctx = sce.getServletContext(); + if (AbortStartup.isStartupAborted(ctx)) { return; } try { //FIXME refactor this - String tripleStoreTypeStr = - ConfigurationProperties.getProperty( - "VitroConnection.DataSource.tripleStoreType", "RDB"); + String tripleStoreTypeStr = ConfigurationProperties.getBean(sce) + .getProperty("VitroConnection.DataSource.tripleStoreType", + "RDB"); if ("SDB".equals(tripleStoreTypeStr)) { (new FileGraphSetup()).contextInitialized(sce); return; @@ -46,13 +48,13 @@ public class AttachSubmodels implements ServletContextListener { } int attachmentCount = 0; - OntModel baseModel = (OntModel) sce.getServletContext().getAttribute( JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME ); - Set pathSet = sce.getServletContext().getResourcePaths( PATH ); + OntModel baseModel = (OntModel) ctx.getAttribute( JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME ); + Set pathSet = ctx.getResourcePaths( PATH ); if (pathSet == null) { return; } for ( String p : pathSet ) { - File file = new File( sce.getServletContext().getRealPath( p ) ); + File file = new File( ctx.getRealPath( p ) ); try { FileInputStream fis = new FileInputStream( file ); try { @@ -96,6 +98,7 @@ public class AttachSubmodels implements ServletContextListener { } + @Override public void contextDestroyed( ServletContextEvent sce ) { // nothing to worry about } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java index 44db80764..b7be76239 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetup.java @@ -21,8 +21,8 @@ import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.util.iterator.ClosableIterator; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDaoCon; @@ -45,7 +45,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java ServletContext ctx = sce.getServletContext(); String tripleStoreTypeStr = - ConfigurationProperties.getProperty( + ConfigurationProperties.getBean(sce).getProperty( "VitroConnection.DataSource.tripleStoreType", "RDB"); if ("SDB".equals(tripleStoreTypeStr)) { @@ -89,7 +89,7 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java inferenceOms.setDisplayModel(displayModel); unionOms.setDisplayModel(displayModel); - checkForNamespaceMismatch( memModel, defaultNamespace ); + checkForNamespaceMismatch( memModel, defaultNamespace, sce ); ctx.setAttribute("baseOntModel", memModel); WebappDaoFactory baseWadf = new WebappDaoFactoryJena( @@ -148,8 +148,9 @@ public class JenaDataSourceSetup extends JenaDataSourceSetupBase implements java } - private void checkForNamespaceMismatch(OntModel model, String defaultNamespace) { - String defaultNamespaceFromDeployProperties = ConfigurationProperties.getProperty("Vitro.defaultNamespace"); + private void checkForNamespaceMismatch(OntModel model, String defaultNamespace, ServletContextEvent sce) { + String defaultNamespaceFromDeployProperties = ConfigurationProperties + .getBean(sce).getProperty("Vitro.defaultNamespace"); if( defaultNamespaceFromDeployProperties == null ){ log.error("Could not get namespace from deploy.properties."); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java index a26609a60..42972b2c6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupBase.java @@ -24,7 +24,7 @@ import com.hp.hpl.jena.sdb.StoreDesc; import com.hp.hpl.jena.sdb.store.DatabaseType; import com.hp.hpl.jena.sdb.store.LayoutType; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDaoCon; import edu.cornell.mannlib.vitro.webapp.dao.jena.RDBGraphGenerator; @@ -119,8 +119,8 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { static final OntModelSpec MEM_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM; private String getJdbcUrl(ServletContext ctx) { - String jdbcUrl = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.url"); + String jdbcUrl = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.url"); // Ensure that MySQL handles unicode properly, else all kinds of // horrible nastiness ensues. @@ -142,14 +142,14 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { String jdbcUrl = getJdbcUrl(ctx); - String username = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.username"); - String password = ConfigurationProperties.getProperty( + String username = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.username"); + String password = ConfigurationProperties.getBean(ctx).getProperty( "VitroConnection.DataSource.password"); BasicDataSource ds = makeBasicDataSource( getDbDriverClassName(ctx), jdbcUrl, username, password, ctx); - String dns = ConfigurationProperties.getProperty( + String dns = ConfigurationProperties.getBean(ctx).getProperty( "Vitro.defaultNamespace"); defaultNamespace = (dns != null && dns.length() > 0) ? dns : null; @@ -166,13 +166,14 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { * a properties file. */ public final BasicDataSource makeDataSourceFromConfigurationProperties(ServletContext ctx){ - String dbDriverClassname = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.driver", getDbDriverClassName(ctx)); + String dbDriverClassname = ConfigurationProperties.getBean(ctx) + .getProperty("VitroConnection.DataSource.driver", + getDbDriverClassName(ctx)); String jdbcUrl = getJdbcUrl(ctx); - String username = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.username"); - String password = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.password"); + String username = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.username"); + String password = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.password"); return makeBasicDataSource( dbDriverClassname, jdbcUrl, username, password, ctx); } @@ -203,8 +204,8 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { ds.setUsername(username); ds.setPassword(password); int maxActiveInt = DEFAULT_MAXACTIVE; - String maxActiveStr = ConfigurationProperties - .getProperty("VitroConnection.DataSource.pool.maxActive"); + String maxActiveStr = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.pool.maxActive"); if (!StringUtils.isEmpty(maxActiveStr)) { try { maxActiveInt = Integer.parseInt(maxActiveStr); @@ -216,8 +217,8 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { int maxIdleInt = (maxActiveInt > DEFAULT_MAXACTIVE) ? maxActiveInt / 4 : DEFAULT_MAXIDLE; - String maxIdleStr = ConfigurationProperties - .getProperty("VitroConnection.DataSource.pool.maxIdle"); + String maxIdleStr = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.pool.maxIdle"); if (!StringUtils.isEmpty(maxIdleStr)) { try { maxIdleInt = Integer.parseInt(maxIdleStr); @@ -282,11 +283,13 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { ds, dbType, jenaDbModelName)); break; case SDB: - String layoutStr = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.sdb.layout", - "layout2/hash"); - String dbtypeStr = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.dbtype", "MySQL"); + String layoutStr = ConfigurationProperties.getBean(ctx) + .getProperty( + "VitroConnection.DataSource.sdb.layout", + "layout2/hash"); + String dbtypeStr = ConfigurationProperties.getBean(ctx) + .getProperty("VitroConnection.DataSource.dbtype", + "MySQL"); StoreDesc desc = new StoreDesc( LayoutType.fetch(layoutStr), DatabaseType.fetch(dbtypeStr) ); @@ -346,7 +349,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { */ protected void createInitialAdminUser(Model model, ServletContext ctx) { String initialAdminUsername = ConfigurationProperties - .getProperty("initialAdminUser"); + .getBean(ctx).getProperty("initialAdminUser"); if (initialAdminUsername == null) { return; } @@ -380,9 +383,9 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { protected void makeModelMakerFromConnectionProperties(TripleStoreType type, ServletContext ctx){ String jdbcUrl = getJdbcUrl(ctx); - String username = ConfigurationProperties.getProperty( + String username = ConfigurationProperties.getBean(ctx).getProperty( "VitroConnection.DataSource.username"); - String password = ConfigurationProperties.getProperty( + String password = ConfigurationProperties.getBean(ctx).getProperty( "VitroConnection.DataSource.password"); if (TripleStoreType.RDB.equals(type)){ @@ -426,7 +429,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { public static boolean isSDBActive(ServletContext ctx) { String tripleStoreTypeStr = - ConfigurationProperties.getProperty( + ConfigurationProperties.getBean(ctx).getProperty( "VitroConnection.DataSource.tripleStoreType", "RDB"); return ("SDB".equals(tripleStoreTypeStr)); } @@ -439,21 +442,20 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon { return vsmm; } - private static String getDbType(ServletContext ctx) { - return ConfigurationProperties.getProperty( // database type - "VitroConnection.DataSource.dbtype","MySQL"); - } - - private static String getDbDriverClassName(ServletContext ctx) { - return ConfigurationProperties.getProperty( - "VitroConnection.DataSource.driver", - "com.mysql.jdbc.Driver"); + private static String getDbType(ServletContext ctx) { + return ConfigurationProperties.getBean(ctx).getProperty( // database type + "VitroConnection.DataSource.dbtype", "MySQL"); + } - } - private static String getValidationQuery(ServletContext ctx) { - return ConfigurationProperties.getProperty( - "VitroConnection.DataSource.validationQuery", "SELECT 1"); - } + private static String getDbDriverClassName(ServletContext ctx) { + return ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.driver", "com.mysql.jdbc.Driver"); + } + + private static String getValidationQuery(ServletContext ctx) { + return ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.validationQuery", "SELECT 1"); + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java index 1c5628dd5..909d256e1 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/JenaDataSourceSetupSDB.java @@ -41,8 +41,8 @@ import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.util.iterator.ClosableIterator; import com.hp.hpl.jena.vocabulary.RDF; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDaoCon; @@ -117,14 +117,14 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j inferenceOms.setDisplayModel(displayModel); unionOms.setDisplayModel(displayModel); - checkForNamespaceMismatch( memModel, defaultNamespace ); + checkForNamespaceMismatch( memModel, defaultNamespace, sce ); // SDB setup // union default graph SDB.getContext().set(SDB.unionDefaultGraph, true) ; - StoreDesc storeDesc = makeStoreDesc(); + StoreDesc storeDesc = makeStoreDesc(ctx); setApplicationStoreDesc(storeDesc, ctx); BasicDataSource bds = makeDataSourceFromConfigurationProperties(ctx); @@ -343,8 +343,9 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j } - private void checkForNamespaceMismatch(OntModel model, String defaultNamespace) { - String defaultNamespaceFromDeployProperites = ConfigurationProperties.getProperty("Vitro.defaultNamespace"); + private void checkForNamespaceMismatch(OntModel model, String defaultNamespace, ServletContextEvent sce) { + String defaultNamespaceFromDeployProperites = ConfigurationProperties + .getBean(sce).getProperty("Vitro.defaultNamespace"); if( defaultNamespaceFromDeployProperites == null ){ log.error("Could not get namespace from deploy.properties."); } @@ -562,11 +563,11 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j return; } - public static StoreDesc makeStoreDesc() { - String layoutStr = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.sdb.layout","layout2/hash"); - String dbtypeStr = ConfigurationProperties.getProperty( - "VitroConnection.DataSource.dbtype", "MySQL"); + public static StoreDesc makeStoreDesc(ServletContext ctx) { + String layoutStr = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.sdb.layout", "layout2/hash"); + String dbtypeStr = ConfigurationProperties.getBean(ctx).getProperty( + "VitroConnection.DataSource.dbtype", "MySQL"); return new StoreDesc( LayoutType.fetch(layoutStr), DatabaseType.fetch(dbtypeStr) ); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/PelletReasonerSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/PelletReasonerSetup.java index b37d7a6b4..a241ea84b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/PelletReasonerSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/PelletReasonerSetup.java @@ -10,20 +10,17 @@ import org.apache.commons.logging.LogFactory; import org.mindswap.pellet.PelletOptions; import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.vocabulary.OWL; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ReasonerConfiguration; public class PelletReasonerSetup implements ServletContextListener { - private static final Log log = LogFactory.getLog(PelletReasonerSetup.class.getName()); - - + @Override public void contextInitialized(ServletContextEvent sce) { if (AbortStartup.isStartupAborted(sce.getServletContext())) { @@ -34,7 +31,7 @@ public class PelletReasonerSetup implements ServletContextListener { //FIXME refactor this String tripleStoreTypeStr = - ConfigurationProperties.getProperty( + ConfigurationProperties.getBean(sce).getProperty( "VitroConnection.DataSource.tripleStoreType", "RDB"); if ("SDB".equals(tripleStoreTypeStr)) { (new SimpleReasonerSetup()).contextInitialized(sce); @@ -76,6 +73,7 @@ public class PelletReasonerSetup implements ServletContextListener { } } + @Override public void contextDestroyed(ServletContextEvent arg0) { // } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/SimpleReasonerSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/SimpleReasonerSetup.java index 988567432..b3a6040d2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/SimpleReasonerSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/SimpleReasonerSetup.java @@ -14,7 +14,7 @@ import org.mindswap.pellet.PelletOptions; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.vocabulary.OWL; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener; @@ -75,7 +75,7 @@ public class SimpleReasonerSetup implements ServletContextListener { ServletContext ctx = sce.getServletContext(); BasicDataSource bds = JenaDataSourceSetupBase .getApplicationDataSource(ctx); - String dbType = ConfigurationProperties.getProperty( // database type + String dbType = ConfigurationProperties.getBean(ctx).getProperty( // database type "VitroConnection.DataSource.dbtype","MySQL"); 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 1a12745e7..aacc889b2 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 @@ -13,7 +13,7 @@ import org.apache.commons.logging.LogFactory; import com.hp.hpl.jena.ontology.OntModel; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao; import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorage; @@ -94,7 +94,7 @@ public class UpdateUploadedFiles implements ServletContextListener { + "UpdateUploadedFiles?"); } - String uploadDirectoryName = ConfigurationProperties + String uploadDirectoryName = ConfigurationProperties.getBean(ctx) .getProperty(FileStorageSetup.PROPERTY_FILE_STORAGE_BASE_DIR); if (uploadDirectoryName == null) { throw new IllegalStateException("Upload directory name is null"); @@ -106,7 +106,7 @@ public class UpdateUploadedFiles implements ServletContextListener { + "' does not exist."); } - String vivoDefaultNamespace = ConfigurationProperties + String vivoDefaultNamespace = ConfigurationProperties.getBean(ctx) .getProperty(FileStorageSetup.PROPERTY_DEFAULT_NAMESPACE); if (vivoDefaultNamespace == null) { throw new IllegalStateException("Default namespace is null."); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/MailUtil.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/MailUtil.java index 225c21aef..ec520c5aa 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/MailUtil.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/MailUtil.java @@ -16,21 +16,23 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet; public class MailUtil { private static final Log log = LogFactory.getLog(MailUtil.class); private String smtpHost = ""; - public MailUtil(HttpServletRequest req){ - smtpHost = ConfigurationProperties.getProperty(ContactMailServlet.SMTPHOST_PROPERTY, ""); - if (smtpHost.isEmpty()) { - log.debug("No Vitro.smtpHost specified"); - } else { - log.debug("Found Vitro.smtpHost value of " + smtpHost); - } - } + + public MailUtil(HttpServletRequest req) { + smtpHost = ConfigurationProperties.getBean(req) + .getProperty(ContactMailServlet.SMTPHOST_PROPERTY, ""); + if (smtpHost.isEmpty()) { + log.debug("No Vitro.smtpHost specified"); + } else { + log.debug("Found Vitro.smtpHost value of " + smtpHost); + } + } public void sendMessage(String messageText, String subject, String from, String to, List deliverToArray) throws IOException{ Properties props = System.getProperties(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java index eb974832c..559b775df 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/widgets/LoginWidget.java @@ -12,7 +12,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import edu.cornell.mannlib.vedit.beans.LoginStatusBean; -import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties; +import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginInProcessFlag; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route; @@ -41,7 +41,8 @@ public class LoginWidget extends Widget { this.macroName = macroName; } - public String toString() { + @Override + public String toString() { return macroName; } @@ -63,7 +64,8 @@ public class LoginWidget extends Widget { this.variableName = variableName; } - public String toString() { + @Override + public String toString() { return variableName; } @@ -131,7 +133,8 @@ public class LoginWidget extends Widget { values.put(TemplateVariable.FORM_ACTION.toString(), getAuthenticateUrl(request)); values.put(TemplateVariable.LOGIN_NAME.toString(), bean.getUsername()); - String externalAuthDisplayName = ConfigurationProperties.getProperty("externalAuth.buttonText"); + String externalAuthDisplayName = ConfigurationProperties.getBean( + request).getProperty("externalAuth.buttonText"); if (externalAuthDisplayName != null) { values.put(TemplateVariable.EXTERNAL_AUTH_URL.toString(), UrlBuilder.getUrl(EXTERNAL_AUTH_SETUP_URL));