refactoring for NIHVIVO-1571
This commit is contained in:
parent
38227f9115
commit
9a939cd57e
1 changed files with 45 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -92,20 +93,15 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
|
||||||
|
|
||||||
checkForNamespaceMismatch( memModel, defaultNamespace );
|
checkForNamespaceMismatch( memModel, defaultNamespace );
|
||||||
|
|
||||||
// SDB initialization
|
// SDB setup
|
||||||
String layoutStr = ConfigurationProperties.getProperty(
|
StoreDesc storeDesc = makeStoreDesc();
|
||||||
"VitroConnection.DataSource.sdb.layout","layout2/hash");
|
setApplicationStoreDesc(storeDesc, sce.getServletContext());
|
||||||
String dbtypeStr = ConfigurationProperties.getProperty(
|
|
||||||
"VitroConnection.DataSource.dbtype", "MySQL");
|
|
||||||
StoreDesc storeDesc = new StoreDesc(
|
|
||||||
LayoutType.fetch(layoutStr),
|
|
||||||
DatabaseType.fetch(dbtypeStr) );
|
|
||||||
sce.getServletContext().setAttribute("storeDesc", storeDesc);
|
|
||||||
BasicDataSource bds = makeDataSourceFromConfigurationProperties();
|
BasicDataSource bds = makeDataSourceFromConfigurationProperties();
|
||||||
this.setApplicationDataSource(bds, sce.getServletContext());
|
this.setApplicationDataSource(bds, sce.getServletContext());
|
||||||
SDBConnection conn = new SDBConnection(bds.getConnection()) ;
|
|
||||||
Store store = SDBFactory.connectStore(conn, storeDesc);
|
Store store = connectStore(bds, storeDesc);
|
||||||
sce.getServletContext().setAttribute("kbStore", store);
|
setApplicationStore(store, sce.getServletContext());
|
||||||
|
|
||||||
if (!isSetUp(store)) {
|
if (!isSetUp(store)) {
|
||||||
log.debug("Non-SDB system detected. Setting up SDB store");
|
log.debug("Non-SDB system detected. Setting up SDB store");
|
||||||
|
@ -452,6 +448,22 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static StoreDesc makeStoreDesc() {
|
||||||
|
String layoutStr = ConfigurationProperties.getProperty(
|
||||||
|
"VitroConnection.DataSource.sdb.layout","layout2/hash");
|
||||||
|
String dbtypeStr = ConfigurationProperties.getProperty(
|
||||||
|
"VitroConnection.DataSource.dbtype", "MySQL");
|
||||||
|
return new StoreDesc(
|
||||||
|
LayoutType.fetch(layoutStr),
|
||||||
|
DatabaseType.fetch(dbtypeStr) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Store connectStore(BasicDataSource bds, StoreDesc storeDesc)
|
||||||
|
throws SQLException {
|
||||||
|
SDBConnection conn = new SDBConnection(bds.getConnection()) ;
|
||||||
|
return SDBFactory.connectStore(conn, storeDesc);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setupSDB(ServletContext ctx,
|
public static void setupSDB(ServletContext ctx,
|
||||||
Store store,
|
Store store,
|
||||||
Model memModel,
|
Model memModel,
|
||||||
|
@ -514,4 +526,25 @@ public class JenaDataSourceSetupSDB extends JenaDataSourceSetupBase implements j
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String STOREDESC_ATTR = "storeDesc";
|
||||||
|
private static final String STORE_ATTR = "kbStore";
|
||||||
|
|
||||||
|
public static void setApplicationStoreDesc(StoreDesc storeDesc,
|
||||||
|
ServletContext ctx) {
|
||||||
|
ctx.setAttribute(STOREDESC_ATTR, storeDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StoreDesc getApplicationStoreDesc(ServletContext ctx) {
|
||||||
|
return (StoreDesc) ctx.getAttribute(STOREDESC_ATTR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setApplicationStore(Store store,
|
||||||
|
ServletContext ctx) {
|
||||||
|
ctx.setAttribute(STORE_ATTR, store);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Store getApplicationStore(ServletContext ctx) {
|
||||||
|
return (Store) ctx.getAttribute(STORE_ATTR);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue