NIHVIVO-1261 Convert to use the new ConfigurationProperties class.

This commit is contained in:
jeb228 2011-02-25 16:50:42 +00:00
parent 3fccf3fa04
commit c2021e7d93
14 changed files with 131 additions and 115 deletions

View file

@ -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) {

View file

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

View file

@ -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<String> fileNamespace = confirmDefaultNamespace();
File baseDirectory = figureBaseDir(sce);
Collection<String> fileNamespace = confirmDefaultNamespace(sce);
FileStorage fs = new FileStorageImpl(baseDirectory, fileNamespace);
ServletContext sc = sce.getServletContext();
@ -65,8 +65,8 @@ public class FileStorageSetup implements ServletContextListener {
*
* For use by the constructor in implementations of {@link FileStorage}.
*/
private File figureBaseDir() {
String baseDirPath = ConfigurationProperties
private File figureBaseDir(ServletContextEvent sce) {
String baseDirPath = ConfigurationProperties.getBean(sce)
.getProperty(PROPERTY_FILE_STORAGE_BASE_DIR);
if (baseDirPath == null) {
throw new IllegalArgumentException(
@ -85,8 +85,8 @@ public class FileStorageSetup implements ServletContextListener {
*
* @returns a collection containing the default namespace.
*/
private Collection<String> confirmDefaultNamespace() {
String defaultNamespace = ConfigurationProperties
private Collection<String> confirmDefaultNamespace(ServletContextEvent sce) {
String defaultNamespace = ConfigurationProperties.getBean(sce)
.getProperty(PROPERTY_DEFAULT_NAMESPACE);
if (defaultNamespace == null) {
throw new IllegalArgumentException(

View file

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

View file

@ -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.
*/
@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,6 +130,7 @@ public class LuceneSetupCJK implements javax.servlet.ServletContextListener {
/**
* Gets run when the webApp Context gets destroyed.
*/
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("**** Running "+this.getClass().getName()+".contextDestroyed()");
@ -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(

View file

@ -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<String> pathSet = sce.getServletContext().getResourcePaths( PATH );
OntModel baseModel = (OntModel) ctx.getAttribute( JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME );
Set<String> 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
}

View file

@ -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.");
}

View file

@ -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,7 +119,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
static final OntModelSpec MEM_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
private String getJdbcUrl(ServletContext ctx) {
String jdbcUrl = ConfigurationProperties.getProperty(
String jdbcUrl = ConfigurationProperties.getBean(ctx).getProperty(
"VitroConnection.DataSource.url");
// Ensure that MySQL handles unicode properly, else all kinds of
@ -142,14 +142,14 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
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");
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,12 +166,13 @@ 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(
String username = ConfigurationProperties.getBean(ctx).getProperty(
"VitroConnection.DataSource.username");
String password = ConfigurationProperties.getProperty(
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(
String layoutStr = ConfigurationProperties.getBean(ctx)
.getProperty(
"VitroConnection.DataSource.sdb.layout",
"layout2/hash");
String dbtypeStr = ConfigurationProperties.getProperty(
"VitroConnection.DataSource.dbtype", "MySQL");
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));
}
@ -440,20 +443,19 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
}
private static String getDbType(ServletContext ctx) {
return ConfigurationProperties.getProperty( // database type
"VitroConnection.DataSource.dbtype","MySQL");
return ConfigurationProperties.getBean(ctx).getProperty( // database type
"VitroConnection.DataSource.dbtype", "MySQL");
}
private static String getDbDriverClassName(ServletContext ctx) {
return ConfigurationProperties.getProperty(
"VitroConnection.DataSource.driver",
"com.mysql.jdbc.Driver");
return ConfigurationProperties.getBean(ctx).getProperty(
"VitroConnection.DataSource.driver", "com.mysql.jdbc.Driver");
}
private static String getValidationQuery(ServletContext ctx) {
return ConfigurationProperties.getProperty(
return ConfigurationProperties.getBean(ctx).getProperty(
"VitroConnection.DataSource.validationQuery", "SELECT 1");
}
}

View file

@ -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,10 +563,10 @@ 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(
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),

View file

@ -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) {
//
}

View file

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

View file

@ -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.");

View file

@ -16,15 +16,17 @@ 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, "");
public MailUtil(HttpServletRequest req) {
smtpHost = ConfigurationProperties.getBean(req)
.getProperty(ContactMailServlet.SMTPHOST_PROPERTY, "");
if (smtpHost.isEmpty()) {
log.debug("No Vitro.smtpHost specified");
} else {

View file

@ -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,6 +41,7 @@ public class LoginWidget extends Widget {
this.macroName = macroName;
}
@Override
public String toString() {
return macroName;
}
@ -63,6 +64,7 @@ public class LoginWidget extends Widget {
this.variableName = variableName;
}
@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));