Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop

This commit is contained in:
brianjlowe 2013-05-22 15:03:54 -04:00
commit d65d4109fa
36 changed files with 171 additions and 240 deletions

View file

@ -10,6 +10,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
@ -101,13 +102,7 @@ public class LoginStatusBean {
}
ServletContext ctx = session.getServletContext();
WebappDaoFactory wadf = (WebappDaoFactory) ctx
.getAttribute("webappDaoFactory");
if (wadf == null) {
log.error("No WebappDaoFactory");
return null;
}
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
UserAccountsDao userAccountsDao = wadf.getUserAccountsDao();
if (userAccountsDao == null) {
log.error("No UserAccountsDao");

View file

@ -175,18 +175,12 @@ public class BaseEditController extends VitroHttpServlet {
}
protected WebappDaoFactory getWebappDaoFactory(VitroRequest vreq) {
WebappDaoFactory wadf = (WebappDaoFactory) getServletContext().getAttribute(
"assertionsWebappDaoFactory");
if (wadf == null) {
log.info("Using vreq.getFullWebappDaoFactory()");
wadf = vreq.getFullWebappDaoFactory();
}
return wadf;
protected WebappDaoFactory getWebappDaoFactory() {
return ModelAccess.on(getServletContext()).getBaseWebappDaoFactory();
}
protected WebappDaoFactory getWebappDaoFactory(VitroRequest vreq, String userURI) {
return getWebappDaoFactory(vreq).getUserAwareDaoFactory(userURI);
protected WebappDaoFactory getWebappDaoFactory(String userURI) {
return getWebappDaoFactory().getUserAwareDaoFactory(userURI);
}
public String getDefaultLandingPage(HttpServletRequest request) {

View file

@ -6,6 +6,7 @@ import javax.servlet.ServletContext;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
@ -24,16 +25,7 @@ public abstract class BaseIdentifierBundleFactory implements
throw new NullPointerException("ctx may not be null.");
}
this.ctx = ctx;
Object wdfObject = ctx.getAttribute("webappDaoFactory");
if (wdfObject instanceof WebappDaoFactory) {
this.wdf = (WebappDaoFactory) wdfObject;
} else {
throw new IllegalStateException(
"Didn't find a WebappDaoFactory in the context. Found '"
+ wdfObject + "' instead.");
}
this.wdf = ModelAccess.on(ctx).getWebappDaoFactory();
this.uaDao = wdf.getUserAccountsDao();
this.indDao = wdf.getIndividualDao();
}

View file

@ -273,8 +273,7 @@ public class PermissionSetsLoader implements ServletContextListener {
this.ctx = ctx;
this.ss = ss;
WebappDaoFactory wadf = (WebappDaoFactory) ctx
.getAttribute("webappDaoFactory");
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
if (wadf == null) {
throw new IllegalStateException(
"No webappDaoFactory on the servlet context");

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.auth.policy;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
import javax.servlet.ServletContext;
@ -23,8 +21,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount.Status;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
/**
@ -79,7 +77,8 @@ public class RootUserPolicy implements PolicyIface {
ss = StartupStatus.getBean(ctx);
try {
uaDao = getUserAccountsDao();
uaDao = ModelAccess.on(ctx).getWebappDaoFactory()
.getUserAccountsDao();
configuredRootUser = getRootEmailFromConfig();
otherRootUsers = getEmailsOfAllRootUsers();
@ -105,16 +104,6 @@ public class RootUserPolicy implements PolicyIface {
}
}
private UserAccountsDao getUserAccountsDao() {
WebappDaoFactory wadf = (WebappDaoFactory) ctx
.getAttribute("webappDaoFactory");
if (wadf == null) {
throw new IllegalStateException(
"No webappDaoFactory on the servlet context");
}
return wadf.getUserAccountsDao();
}
private String getRootEmailFromConfig() {
String email = ConfigurationProperties.getBean(ctx).getProperty(
PROPERTY_ROOT_USER_EMAIL);

View file

@ -59,8 +59,7 @@ public abstract class AbstractPageHandler {
userAccountsModel = ModelAccess.on(ctx).getUserAccountsModel();
unionModel = ModelAccess.on(ctx).getOntModel(ModelID.UNION_FULL);
WebappDaoFactory wdf = (WebappDaoFactory) this.ctx
.getAttribute("webappDaoFactory");
WebappDaoFactory wdf = ModelAccess.on(ctx).getWebappDaoFactory();
userAccountsDao = wdf.getUserAccountsDao();
vclassDao = wdf.getVClassDao();
indDao = wdf.getIndividualDao();

View file

@ -71,13 +71,9 @@ public class VitroRequest extends HttpServletRequestWrapper {
setAttribute("unfilteredRDFService", rdfService);
}
public void setWebappDaoFactory( WebappDaoFactory wdf){
setAttribute("webappDaoFactory",wdf);
}
/** gets WebappDaoFactory with appropriate filtering for the request */
public WebappDaoFactory getWebappDaoFactory(){
return (WebappDaoFactory) getAttribute("webappDaoFactory");
return ModelAccess.on(this).getWebappDaoFactory();
}
public void setUnfilteredWebappDaoFactory(WebappDaoFactory wdf) {
@ -92,10 +88,6 @@ public class VitroRequest extends HttpServletRequestWrapper {
return (WebappDaoFactory) getAttribute("unfilteredWebappDaoFactory");
}
public void setFullWebappDaoFactory(WebappDaoFactory wdf) {
setAttribute("fullWebappDaoFactory", wdf);
}
public Dataset getDataset() {
return (Dataset) getAttribute("dataset");
}
@ -106,51 +98,12 @@ public class VitroRequest extends HttpServletRequestWrapper {
/** gets assertions + inferences WebappDaoFactory with no filtering **/
public WebappDaoFactory getFullWebappDaoFactory() {
Object webappDaoFactoryAttr = _req.getAttribute("fullWebappDaoFactory");
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
return (WebappDaoFactory) webappDaoFactoryAttr;
} else {
webappDaoFactoryAttr = _req.getSession().getAttribute("webappDaoFactory");
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
return (WebappDaoFactory) webappDaoFactoryAttr;
} else {
return (WebappDaoFactory) _req.getSession().getServletContext().getAttribute("webappDaoFactory");
}
}
return ModelAccess.on(this).getWebappDaoFactory();
}
/** gets assertions-only WebappDaoFactory with no filtering */
public WebappDaoFactory getAssertionsWebappDaoFactory() {
Object webappDaoFactoryAttr = _req.getSession().getAttribute("assertionsWebappDaoFactory");
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
log.debug("Returning assertionsWebappDaoFactory from session");
return (WebappDaoFactory) webappDaoFactoryAttr;
} else {
webappDaoFactoryAttr = getAttribute("assertionsWebappDaoFactory");
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
log.debug("returning assertionsWebappDaoFactory from request attribute");
return (WebappDaoFactory) webappDaoFactoryAttr;
} else {
log.debug("Returning assertionsWebappDaoFactory from context");
return (WebappDaoFactory) _req.getSession().getServletContext().getAttribute("assertionsWebappDaoFactory");
}
}
}
/** gets assertions-only WebappDaoFactory with no filtering */
public void setAssertionsWebappDaoFactory(WebappDaoFactory wadf) {
setAttribute("assertionsWebappDaoFactory", wadf);
}
/** gets inferences-only WebappDaoFactory with no filtering */
public WebappDaoFactory getDeductionsWebappDaoFactory() {
Object webappDaoFactoryAttr = _req.getSession().getAttribute("deductionsWebappDaoFactory");
if (webappDaoFactoryAttr instanceof WebappDaoFactory) {
return (WebappDaoFactory) webappDaoFactoryAttr;
} else {
return (WebappDaoFactory) _req.getSession().getServletContext().getAttribute("deductionsWebappDaoFactory");
}
return ModelAccess.on(this).getBaseWebappDaoFactory();
}
//Method that retrieves write model, returns special model in case of write model
@ -167,20 +120,18 @@ public class VitroRequest extends HttpServletRequestWrapper {
return ModelAccess.on(this).getOntModelSelector();
}
public void setJenaOntModel(OntModel ontModel) {
ModelAccess.on(this).setJenaOntModel(ontModel);
}
public OntModel getJenaOntModel() {
return ModelAccess.on(this).getJenaOntModel();
}
/** JB - surprising that this comes from session. */
public OntModel getAssertionsOntModel() {
return ModelAccess.on(this).getBaseOntModel();
return ModelAccess.on(this.getSession()).getBaseOntModel();
}
/** JB - surprising that this comes from session. */
public OntModel getInferenceOntModel() {
return ModelAccess.on(this).getInferenceOntModel();
return ModelAccess.on(this.getSession()).getInferenceOntModel();
}
public OntModel getDisplayModel(){

View file

@ -25,6 +25,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.LoginEvent;
@ -302,14 +303,7 @@ public class BasicAuthenticator extends Authenticator {
}
ServletContext servletContext = session.getServletContext();
WebappDaoFactory wadf = (WebappDaoFactory) servletContext
.getAttribute("webappDaoFactory");
if (wadf == null) {
log.error("no WebappDaoFactory");
return null;
}
return wadf;
return ModelAccess.on(servletContext).getWebappDaoFactory();
}
@Override

View file

@ -79,8 +79,7 @@ public class EntityRetryController extends BaseEditController {
}
LoginStatusBean loginBean = LoginStatusBean.getBean(request);
WebappDaoFactory myWebappDaoFactory = getWebappDaoFactory(
vreq, loginBean.getUserURI());
WebappDaoFactory myWebappDaoFactory = getWebappDaoFactory(loginBean.getUserURI());
IndividualDao ewDao = myWebappDaoFactory.getIndividualDao();
epo.setDataAccessObject(ewDao);

View file

@ -27,6 +27,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
@ -52,8 +53,8 @@ public class ClassHierarchyListingController extends BaseEditController {
try {
boolean inferred = (vrequest.getParameter("inferred") != null);
if (vrequest.getAssertionsWebappDaoFactory() != null && !inferred) {
vcDao = vrequest.getAssertionsWebappDaoFactory().getVClassDao();
if (!inferred) {
vcDao = ModelAccess.on(vrequest).getBaseWebappDaoFactory().getVClassDao();
} else {
vcDao = vrequest.getFullWebappDaoFactory().getVClassDao();
}

View file

@ -17,6 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.EditN3Utils;
@ -200,7 +201,7 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
Individual object = EditConfigurationUtils.getIndividual(vreq, objectUri);
if(object == null) {
WebappDaoFactory wadf = (WebappDaoFactory) vreq.getSession().getServletContext().getAttribute("webappDaoFactory");
WebappDaoFactory wadf = ModelAccess.on(vreq.getSession().getServletContext()).getWebappDaoFactory();
object = wadf.getIndividualDao().getIndividualByURI(objectUri);
}

View file

@ -2,7 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Map;
import javax.servlet.ServletContext;
@ -24,29 +24,26 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
*
* <pre>
* VitroRequest.getAssertionsWebappDaoFactory()
* VitroRequest.getDeductionsWebappDaoFactory()
* VitroRequest.getFullWebappDaoFactory()
* VitroRequest.getRDFService()
* VitroRequest.getUnfilteredRDFService()
* VitroRequest.getWebappDaoFactory()
* VitroRequest.getWriteModel()
* VitroRequest.getJenaOntModel()
* VitroRequest.setJenaOntModel()
* OntModelSelector.getAboxModel
* OntModelSelector.getApplicationMetadataModel()
* vreq.setUnfilteredWebappDaoFactory(wadf);
*
* OntModelSelector.getABoxModel
* OntModelSelector.getFullModel()
* OntModelSelector.getTBoxModel()
* OntModelSelector.getTBoxModel(ontologyURI)
* OntModelSelector.getUserAccountsModel()
* VitroModelSource.getModel(URL)
* VitroModelSource.getModel(URL, loadIfAbsent)
* VitroModelSource.openModel(name)
* VitroModelSource.openModelIfPresent(string)
* ServletContext.getAttribute("assertionsWebappDaoFactory")
* ServletContext.getAttribute("deductionsWebappDaoFactory")
* ServletContext.getAttribute("baseOntModelSelector")
* ServletContext.getAttribute("jenaPersistentOntModel")
* ServletContext.getAttribute("pelletOntModel")
* ServletContext.getAttribute("webappDaoFactory")
* VitroJenaModelMaker
* VitroJenaSpecialModelMaker
* JenaDataSourceSetupBase.getApplicationDataSource(ctx)
@ -75,6 +72,10 @@ public class ModelAccess {
UNION_ABOX, UNION_TBOX, UNION_FULL
}
public enum FactoryID {
BASE, UNION
}
private enum Scope {
CONTEXT, SESSION, REQUEST
}
@ -124,7 +125,9 @@ public class ModelAccess {
private final Scope scope;
private final ModelAccess parent;
private final Map<String, OntModel> modelMap = new HashMap<>();
private final Map<ModelID, OntModel> modelMap = new EnumMap<>(ModelID.class);
private final Map<FactoryID, WebappDaoFactory> factoryMap = new EnumMap<>(
FactoryID.class);
public ModelAccess(Scope scope, ModelAccess parent) {
this.scope = scope;
@ -176,19 +179,21 @@ public class ModelAccess {
}
public void setOntModel(ModelID id, OntModel ontModel) {
String key = id.toString();
if (ontModel == null) {
modelMap.remove(key);
modelMap.remove(id);
} else {
modelMap.put(key, ontModel);
modelMap.put(id, ontModel);
}
}
public void removeOntModel(ModelID id) {
setOntModel(id, null);
}
public OntModel getOntModel(ModelID id) {
String key = id.toString();
if (modelMap.containsKey(key)) {
if (modelMap.containsKey(id)) {
log.debug("Using " + id + " model from " + scope);
return modelMap.get(key);
return modelMap.get(id);
} else if (parent != null) {
return parent.getOntModel(id);
} else {
@ -197,6 +202,50 @@ public class ModelAccess {
}
}
// ----------------------------------------------------------------------
// Accessing the Webapp DAO factories.
// ----------------------------------------------------------------------
public void setWebappDaoFactory(WebappDaoFactory wadf) {
setWebappDaoFactory(FactoryID.UNION, wadf);
}
public WebappDaoFactory getWebappDaoFactory() {
return getWebappDaoFactory(FactoryID.UNION);
}
public void setBaseWebappDaoFactory(WebappDaoFactory wadf) {
setWebappDaoFactory(FactoryID.BASE, wadf);
}
public WebappDaoFactory getBaseWebappDaoFactory() {
return getWebappDaoFactory(FactoryID.BASE);
}
public void setWebappDaoFactory(FactoryID id, WebappDaoFactory wadf) {
if (wadf == null) {
factoryMap.remove(id);
} else {
factoryMap.put(id, wadf);
}
}
public void removeWebappDaoFactory(FactoryID id) {
setWebappDaoFactory(id, null);
}
public WebappDaoFactory getWebappDaoFactory(FactoryID id) {
if (factoryMap.containsKey(id)) {
log.debug("Using " + id + " DAO factory from " + scope);
return factoryMap.get(id);
} else if (parent != null) {
return parent.getWebappDaoFactory(id);
} else {
log.warn("No DAO factory found for " + id);
return null;
}
}
// ----------------------------------------------------------------------
// Accessing the OntModelSelectors
// ----------------------------------------------------------------------

View file

@ -174,12 +174,7 @@ public class VClassGroupCache implements IndexingEventListener {
}
protected VClassGroupDao getVCGDao() {
WebappDaoFactory wdf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
if (wdf == null) {
log.error("Cannot get webappDaoFactory from context");
return null;
} else
return wdf.getVClassGroupDao();
return ModelAccess.on(context).getWebappDaoFactory().getVClassGroupDao();
}
public void doSynchronousRebuild(){
@ -242,11 +237,8 @@ public class VClassGroupCache implements IndexingEventListener {
*/
protected static void rebuildCacheUsingSolr( VClassGroupCache cache ) throws SolrServerException{
long start = System.currentTimeMillis();
WebappDaoFactory wdFactory = (WebappDaoFactory) cache.context.getAttribute("webappDaoFactory");
if (wdFactory == null){
log.error("Unable to rebuild cache: could not get 'webappDaoFactory' from Servletcontext");
return;
}
WebappDaoFactory wdFactory = ModelAccess.on(cache.context).getWebappDaoFactory();
SolrServer solrServer = (SolrServer)cache.context.getAttribute(SolrSetup.SOLR_SERVER);
if( solrServer == null){
log.error("Unable to rebuild cache: could not get solrServer from ServletContext");

View file

@ -2,10 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.dwr;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@ -18,7 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
This is a class to support Direct Web Remoting(DWR) in
@ -31,7 +28,7 @@ public class EntityDWR {
public EntityDWR(){
WebContext ctx = WebContextFactory.get();
ServletContext sc= ctx.getServletContext();
entityWADao = ((WebappDaoFactory)sc.getAttribute("webappDaoFactory")).getIndividualDao();
entityWADao = ModelAccess.on(sc).getWebappDaoFactory().getIndividualDao();
}
/**

View file

@ -409,7 +409,7 @@ public class DefaultObjectPropertyFormGenerator implements EditConfigurationGene
if(isSelectFromExisting(vreq)) {
// set ProhibitedFromSearch object so picklist doesn't show
// individuals from classes that should be hidden from list views
OntModel displayOntModel = ModelAccess.on(session).getDisplayModel();
OntModel displayOntModel = ModelAccess.on(session.getServletContext()).getDisplayModel();
ProhibitedFromSearch pfs = new ProhibitedFromSearch(
DisplayVocabulary.SEARCH_INDEX_URI, displayOntModel);
if( editConfig != null )

View file

@ -11,6 +11,7 @@ import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
@ -21,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.PageController;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.PageDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
/**
@ -52,7 +54,9 @@ public class PageRoutingFilter implements Filter{
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain chain)
throws IOException, ServletException {
PageDao pageDao = getPageDao();
ServletContext ctx = filterConfig.getServletContext();
PageDao pageDao = ModelAccess.on(ctx).getWebappDaoFactory().getPageDao();
Map<String,String> urlMappings = pageDao.getPageMappings();
// get URL without hostname or servlet context
@ -81,7 +85,7 @@ public class PageRoutingFilter implements Filter{
String controllerName = getControllerToForwardTo(req, pageUri, pageDao);
log.debug(path + " is being forwarded to controller " + controllerName);
RequestDispatcher rd = filterConfig.getServletContext().getNamedDispatcher( controllerName );
RequestDispatcher rd = ctx.getNamedDispatcher( controllerName );
if( rd == null ){
log.error(path + " should be forwarded to controller " + controllerName + " but there " +
"is no servlet named that defined for the web application in web.xml");
@ -91,7 +95,7 @@ public class PageRoutingFilter implements Filter{
rd.forward(req, response);
}else if( "/".equals( path ) || path.isEmpty() ){
log.debug("url '" +path + "' is being forward to home controller" );
RequestDispatcher rd = filterConfig.getServletContext().getNamedDispatcher( HOME_CONTROLLER_NAME );
RequestDispatcher rd = ctx.getNamedDispatcher( HOME_CONTROLLER_NAME );
rd.forward(req, response);
}else{
doNonDisplayPage(path,arg0,arg1,chain);
@ -132,12 +136,6 @@ public class PageRoutingFilter implements Filter{
return false;
}
protected PageDao getPageDao(){
WebappDaoFactory wdf = (WebappDaoFactory)
filterConfig.getServletContext().getAttribute("webappDaoFactory");
return wdf.getPageDao();
}
@Override
public void destroy() {
//nothing to do here

View file

@ -21,7 +21,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
import freemarker.cache.WebappTemplateLoader;
@ -116,8 +116,7 @@ public class StartupStatusDisplayFilter implements Filter {
private Object getApplicationName() {
String name = "";
try {
WebappDaoFactory wadf = (WebappDaoFactory) ctx
.getAttribute("webappDaoFactory");
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
ApplicationBean app = wadf.getApplicationDao().getApplicationBean();
name = app.getApplicationName();
} catch (Exception e) {

View file

@ -8,7 +8,6 @@ import java.util.List;
import java.util.regex.Pattern;
import javax.servlet.ServletContext;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
@ -18,6 +17,7 @@ import org.apache.commons.logging.LogFactory;
import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapper;
import edu.cornell.mannlib.vitro.webapp.utils.NamespaceMapperFactory;
@ -36,7 +36,7 @@ public class URLRewritingHttpServletResponse extends HttpServletResponseWrapper/
super(response);
this._response = response;
this._context = context;
this.wadf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
this.wadf = ModelAccess.on(context).getWebappDaoFactory();
this.contextPathDepth = slashPattern.split(request.getContextPath()).length-1;
}

View file

@ -123,15 +123,7 @@ public class VitroRequestPrep implements Filter {
VitroRequest vreq = new VitroRequest(req);
//-- setup DAO factory --//
WebappDaoFactory wdf = getWebappDaoFactory(vreq);
//TODO: get accept-language from request and set as preferred languages
// if there is a WebappDaoFactory in the session, use it
Object o = req.getSession().getAttribute("webappDaoFactory");
if (o instanceof WebappDaoFactory) {
wdf = (WebappDaoFactory) o;
log.debug("Found a WebappDaoFactory in the session and using it for this request");
}
WebappDaoFactory wdf = ModelAccess.on(vreq.getSession()).getWebappDaoFactory();
// Set up the DisplayModel with language filtering, if appropriate.
ConfigurationProperties props = ConfigurationProperties.getBean(req);
@ -160,7 +152,7 @@ public class VitroRequestPrep implements Filter {
HideFromDisplayByPolicyFilter filter = new HideFromDisplayByPolicyFilter(
RequestIdentifiers.getIdBundleForRequest(req),
ServletPolicyList.getPolicies(_context));
vreq.setWebappDaoFactory(new WebappDaoFactoryFiltering(wdf, filter));
ModelAccess.on(vreq).setWebappDaoFactory(new WebappDaoFactoryFiltering(wdf, filter));
// support for Dataset interface if using Jena in-memory model
if (vreq.getDataset() == null) {
@ -181,12 +173,6 @@ public class VitroRequestPrep implements Filter {
chain.doFilter(req, response);
}
private WebappDaoFactory getWebappDaoFactory(VitroRequest vreq){
WebappDaoFactory webappDaoFactory = vreq.getWebappDaoFactory();
return (webappDaoFactory != null) ? webappDaoFactory :
(WebappDaoFactory) _context.getAttribute("webappDaoFactory");
}
private VitroFilters getFiltersFromContextFilterFactory( HttpServletRequest request, WebappDaoFactory wdf){
FilterFactory ff = (FilterFactory)_context.getAttribute("FilterFactory");
if( ff == null ){

View file

@ -115,6 +115,7 @@ public class WebappDaoFactorySDBPrep implements Filter {
OntModelSelector oms = ModelAccess.on(_ctx).getUnionOntModelSelector();
wadf = new WebappDaoFactorySDB(rdfService, oms, config);
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
OntModelSelector baseOms = ModelAccess.on(_ctx).getBaseOntModelSelector();
WebappDaoFactory assertions = new WebappDaoFactorySDB(
@ -122,9 +123,7 @@ public class WebappDaoFactorySDBPrep implements Filter {
vreq.setRDFService(rdfService);
vreq.setUnfilteredRDFService(unfilteredRDFService);
vreq.setWebappDaoFactory(wadf);
vreq.setAssertionsWebappDaoFactory(assertions);
vreq.setFullWebappDaoFactory(wadf);
ModelAccess.on(vreq).setBaseWebappDaoFactory(assertions);
vreq.setUnfilteredWebappDaoFactory(new WebappDaoFactorySDB(
rdfService, ModelAccess.on(_ctx).getUnionOntModelSelector()));
vreq.setDataset(dataset);

View file

@ -146,25 +146,17 @@ public class WebappDaoFactorySparqlPrep implements Filter {
Model m = ModelFactory.createModelForGraph(g);
OntModel om = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, m);
dataset = DatasetFactory.create(new SparqlDatasetGraph(endpointURI));
//DataSource datasource = DatasetFactory.create();
//datasource.addNamedModel("fake:fake", m);
//dataset = datasource;
vreq.setAssertionsWebappDaoFactory(wadf);
ModelAccess.on(vreq).setOntModel(ModelID.UNION_ABOX, om);
ModelAccess.on(vreq).setOntModel(ModelID.UNION_TBOX, om);
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, om);
OntModelSelector oms = ModelAccess.on(vreq).getOntModelSelector();
OntModelSelector oms = ModelAccess.on(vreq).getOntModelSelector();
wadf = new WebappDaoFactoryJena(oms, config);
//wadf = new WebappDaoFactorySDB(oms, dataset, config);
vreq.setFullWebappDaoFactory(wadf);
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
ModelAccess.on(vreq).setBaseWebappDaoFactory(wadf);
vreq.setUnfilteredWebappDaoFactory(wadf);
vreq.setWebappDaoFactory(wadf);
dataset = DatasetFactory.create(new SparqlDatasetGraph(endpointURI));
vreq.setDataset(dataset);
}
} catch (Throwable t) {

View file

@ -13,8 +13,6 @@ import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl;
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
@ -44,22 +42,6 @@ public class LanguageFilteringUtils {
}
/**
* Make a new OntModelSelector that containing a new display model and all
* of the other models in the original OntModelSelector.
*/
public static OntModelSelector replaceDisplayModelInSelector(
OntModelSelector oldOms, OntModel newDisplayModel) {
OntModelSelectorImpl newOms = new OntModelSelectorImpl();
newOms.setABoxModel(oldOms.getABoxModel());
newOms.setApplicationMetadataModel(oldOms.getApplicationMetadataModel());
newOms.setDisplayModel(newDisplayModel);
newOms.setFullModel(oldOms.getFullModel());
newOms.setTBoxModel(oldOms.getTBoxModel());
newOms.setUserAccountsModel(oldOms.getUserAccountsModel());
return newOms;
}
/**
* Add a Language Filtering layer to an OntModel by treating it as an RDFService.
*/

View file

@ -155,7 +155,7 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
// This is where the builder gets the list of places to try to
// get objects to index. It is filtered so that non-public text
// does not get into the search index.
WebappDaoFactory wadf = (WebappDaoFactory) context.getAttribute("webappDaoFactory");
WebappDaoFactory wadf = ModelAccess.on(context).getWebappDaoFactory();
VitroFilters vf = VitroFilterUtils.getPublicFilter(context);
wadf = new WebappDaoFactoryFiltering(wadf, vf);

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import static edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode.ASSERTIONS_ONLY;
import static edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetMode.INFERENCES_ONLY;
import java.util.ArrayList;
import java.util.List;
@ -28,6 +27,7 @@ import com.hp.hpl.jena.util.ResourceUtils;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.FactoryID;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
@ -110,15 +110,11 @@ public class ContentModelSetup extends JenaDataSourceSetupBase
OntModelSelector baseOms = models.getBaseOntModelSelector();
WebappDaoFactory baseWadf = new WebappDaoFactorySDB(rdfService, baseOms, config, ASSERTIONS_ONLY);
ctx.setAttribute("assertionsWebappDaoFactory",baseWadf);
OntModelSelector inferenceOms = models.getInferenceOntModelSelector();
WebappDaoFactory infWadf = new WebappDaoFactorySDB(rdfService, inferenceOms, config, INFERENCES_ONLY);
ctx.setAttribute("deductionsWebappDaoFactory", infWadf);
ModelAccess.on(ctx).setBaseWebappDaoFactory(baseWadf);
OntModelSelector unionOms = models.getUnionOntModelSelector();
WebappDaoFactory wadf = new WebappDaoFactorySDB(rdfService, unionOms, config);
ctx.setAttribute("webappDaoFactory",wadf);
ModelAccess.on(ctx).setWebappDaoFactory(FactoryID.UNION, wadf);
log.info("Model makers set up");

View file

@ -11,6 +11,7 @@ import java.util.Iterator;
import java.util.Random;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
@ -43,18 +44,20 @@ public class RunSparqlConstructs implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
try {
WebappDaoFactory wadf = (WebappDaoFactory) sce.getServletContext().getAttribute("webappDaoFactory");
ServletContext ctx = sce.getServletContext();
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
String namespace = (wadf != null && wadf.getDefaultNamespace() != null)
? wadf.getDefaultNamespace() : DEFAULT_DEFAULT_NAMESPACE;
OntModel baseOntModel = ModelAccess.on(sce.getServletContext()).getBaseOntModel();
OntModel baseOntModel = ModelAccess.on(ctx).getBaseOntModel();
Model anonModel = ModelFactory.createDefaultModel();
Model namedModel = ModelFactory.createDefaultModel();
Set<String> resourcePaths = sce.getServletContext().getResourcePaths(SPARQL_DIR);
Set<String> resourcePaths = ctx.getResourcePaths(SPARQL_DIR);
for (String path : resourcePaths) {
log.debug("Attempting to execute SPARQL at " + path);
File file = new File(sce.getServletContext().getRealPath(path));
File file = new File(ctx.getRealPath(path));
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuffer fileContents = new StringBuffer();

View file

@ -23,6 +23,7 @@ import com.hp.hpl.jena.vocabulary.OWL;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector;
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceDataset;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
@ -55,7 +56,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
OntModelSelector inferencesOms = ModelAccess.on(ctx).getInferenceOntModelSelector();
OntModelSelector unionOms = ModelAccess.on(ctx).getUnionOntModelSelector();
WebappDaoFactoryJena wadf = (WebappDaoFactoryJena) sce.getServletContext().getAttribute("webappDaoFactory");
WebappDaoFactoryJena wadf = (WebappDaoFactoryJena) ModelAccess.on(ctx).getWebappDaoFactory();
if (!assertionsOms.getTBoxModel().getProfile().NAMESPACE().equals(OWL.NAMESPACE.getNameSpace())) {
log.error("Not connecting Pellet reasoner - the TBox assertions model is not an OWL model");

View file

@ -99,7 +99,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
settings.setErrorLogFile(ctx.getRealPath(errorLogFileName));
settings.setAddedDataFile(ctx.getRealPath(ADDED_DATA_FILE));
settings.setRemovedDataFile(ctx.getRealPath(REMOVED_DATA_FILE));
WebappDaoFactory wadf = (WebappDaoFactory) ctx.getAttribute("webappDaoFactory");
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
settings.setDefaultNamespace(wadf.getDefaultNamespace());
settings.setAssertionOntModelSelector(ModelAccess.on(ctx).getBaseOntModelSelector());
settings.setInferenceOntModelSelector(ModelAccess.on(ctx).getInferenceOntModelSelector());

View file

@ -22,6 +22,7 @@ import javax.servlet.ServletContextListener;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.UserAccountsDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
@ -99,8 +100,7 @@ public class UpdatePermissionSetUris implements ServletContextListener {
this.ctx = ctx;
this.stats = stats;
WebappDaoFactory wadf = (WebappDaoFactory) ctx
.getAttribute("webappDaoFactory");
WebappDaoFactory wadf = ModelAccess.on(ctx).getWebappDaoFactory();
userAccountsDao = wadf.getUserAccountsDao();
}

View file

@ -29,6 +29,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.PermissionRegistry;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* Can we tell whether a user is logged in as root?
@ -79,7 +80,7 @@ public class HasPermissionFactoryTest extends AbstractTestClass {
wdf.setUserAccountsDao(uaDao);
ctx = new ServletContextStub();
ctx.setAttribute("webappDaoFactory", wdf);
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
session = new HttpSessionStub();
session.setServletContext(ctx);

View file

@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ArrayIdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsRootUser;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* Can we tell whether a user is logged in as root?
@ -56,7 +57,7 @@ public class IsRootUserFactoryTest extends AbstractTestClass {
wdf.setUserAccountsDao(uaDao);
ctx = new ServletContextStub();
ctx.setAttribute("webappDaoFactory", wdf);
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
session = new HttpSessionStub();
session.setServletContext(ctx);

View file

@ -19,6 +19,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ArrayIdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.IsUser;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
* The simplest of the IdentifierBundleFactory classes.
@ -46,7 +47,7 @@ public class IsUserFactoryTest extends AbstractTestClass {
wdf.setUserAccountsDao(uaDao);
ctx = new ServletContextStub();
ctx.setAttribute("webappDaoFactory", wdf);
ModelAccess.on(ctx).setWebappDaoFactory(wdf);
session = new HttpSessionStub();
session.setServletContext(ctx);

View file

@ -47,6 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.AuthenticatorStub;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
/**
*/
@ -147,7 +148,7 @@ public class AuthenticateTest extends AbstractTestClass {
webappDaoFactory.setIndividualDao(individualDao);
servletContext = new ServletContextStub();
servletContext.setAttribute("webappDaoFactory", webappDaoFactory);
ModelAccess.on(servletContext).setWebappDaoFactory(webappDaoFactory);
servletContext.setAttribute(AuthenticatorStub.FACTORY_ATTRIBUTE_NAME,
authenticatorFactory);

View file

@ -28,6 +28,7 @@ import stubs.javax.servlet.http.HttpSessionStub;
import stubs.org.apache.solr.client.solrj.SolrServerStub;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.search.solr.SolrSetup;
/**
@ -106,8 +107,7 @@ public class JsonServletTest extends AbstractTestClass {
resp = new HttpServletResponseStub();
wadf = new WebappDaoFactoryStub();
req.setAttribute("webappDaoFactory", wadf);
ctx.setAttribute("webappDaoFactory", wadf);
ModelAccess.on(ctx).setWebappDaoFactory(wadf);
vcDao = new VClassDaoStub();
wadf.setVClassDao(vcDao);

View file

@ -18,6 +18,7 @@ import com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.SimpleOntModelSelector;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
@ -48,7 +49,7 @@ public class PageDataGetterUtilsTest extends AbstractTestClass{
@Test
public void testGetPageDataGetterObjects() throws Exception{
VitroRequest vreq = new VitroRequest( new HttpServletRequestStub() );
vreq.setWebappDaoFactory(wdf);
ModelAccess.on(vreq).setWebappDaoFactory(wdf);
List<PageDataGetter> pdgList = PageDataGetterUtils.getPageDataGetterObjects(vreq, pageURI);
Assert.assertNotNull(pdgList);
@ -58,7 +59,7 @@ public class PageDataGetterUtilsTest extends AbstractTestClass{
@Test
public void testGetNonPageDataGetterObjects() throws Exception{
VitroRequest vreq = new VitroRequest( new HttpServletRequestStub() );
vreq.setWebappDaoFactory(wdf);
ModelAccess.on(vreq).setWebappDaoFactory(wdf);
List<PageDataGetter> pdgList = PageDataGetterUtils.getPageDataGetterObjects(vreq, pageURI_2);
Assert.assertNotNull(pdgList);

View file

@ -25,6 +25,10 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import stubs.edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDaoStub;
import stubs.edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryStub;
import stubs.freemarker.cache.TemplateLoaderStub;
@ -36,6 +40,8 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess.ModelID;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview.InvalidConfigurationException;
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.customlistview.PropertyListConfig;
@ -123,7 +129,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
hreq.setSession(session);
vreq = new VitroRequest(hreq);
vreq.setWebappDaoFactory(wadf);
ModelAccess.on(vreq).setWebappDaoFactory(wadf);
subject = new IndividualImpl();
@ -273,6 +279,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
@Test
public void constructQueryNodeMissing()
throws InvalidConfigurationException {
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, emptyOntModel());
op = buildOperation("constructQueryMissing");
optm = new NonCollatingOPTM(op, subject, vreq, true);
// Not an error.
@ -281,6 +288,7 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
@Test
public void constructQueryMultipleValues()
throws InvalidConfigurationException {
ModelAccess.on(vreq).setOntModel(ModelID.UNION_FULL, emptyOntModel());
op = buildOperation("constructQueryMultiple");
optm = new NonCollatingOPTM(op, subject, vreq, true);
assertConstructQueries("multiple construct queries", "ONE", "TWO",
@ -367,6 +375,10 @@ public class ObjectPropertyTemplateModel_PropertyListConfigTest extends
// Helper methods
// ----------------------------------------------------------------------
private OntModel emptyOntModel() {
return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
}
/**
* Sets up an operation with name "foobar" and adds it to the
* ObjectPropertyDaoStub.

View file

@ -12,10 +12,11 @@ import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import stubs.javax.servlet.ServletContextStub;
/**
* A simple stand-in for the HttpSession, for use in unit tests.
*/
@SuppressWarnings("deprecation")
public class HttpSessionStub implements HttpSession {
private static final Log log = LogFactory.getLog(HttpSessionStub.class);
@ -49,8 +50,12 @@ public class HttpSessionStub implements HttpSession {
@Override
public ServletContext getServletContext() {
if (this.context == null) {
return new ServletContextStub();
} else {
return this.context;
}
}
@Override
public void setAttribute(String name, Object value) {
@ -149,6 +154,7 @@ public class HttpSessionStub implements HttpSession {
"HttpSessionStub.putValue() not implemented.");
}
@Override
public void removeValue(String arg0) {
throw new RuntimeException(
"HttpSessionStub.removeValue() not implemented.");