NIHVIVO-2964 unfiltered dao method on VitroRequest

This commit is contained in:
brianjlowe 2011-07-18 17:48:14 +00:00
parent 2fb3cc200f
commit fbf484b537
4 changed files with 21 additions and 2 deletions

View file

@ -58,6 +58,18 @@ public class VitroRequest extends HttpServletRequestWrapper {
return (WebappDaoFactory) getAttribute("webappDaoFactory"); return (WebappDaoFactory) getAttribute("webappDaoFactory");
} }
public void setUnfilteredWebappDaoFactory(WebappDaoFactory wdf) {
setAttribute("unfilteredWebappDaoFactory", wdf);
}
/** Gets a WebappDaoFactory with request-specific dataset but no filtering.
* Use this for any servlets that need to bypass filtering.
* @return
*/
public WebappDaoFactory getUnfilteredWebappDaoFactory() {
return (WebappDaoFactory) getAttribute("unfilteredWebappDaoFactory");
}
public void setFullWebappDaoFactory(WebappDaoFactory wdf) { public void setFullWebappDaoFactory(WebappDaoFactory wdf) {
setAttribute("fullWebappDaoFactory", wdf); setAttribute("fullWebappDaoFactory", wdf);
} }

View file

@ -47,7 +47,9 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterFactory; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterFactory;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
/** /**
@ -165,6 +167,11 @@ public class VitroRequestPrep implements Filter {
vreq.setDataset(dataset); vreq.setDataset(dataset);
} }
vreq.setUnfilteredWebappDaoFactory(new WebappDaoFactorySDB(
ModelContext.getUnionOntModelSelector(
vreq.getSession().getServletContext()),
vreq.getDataset()));
req.setAttribute("VitroRequestPrep.setup", new Integer(1)); req.setAttribute("VitroRequestPrep.setup", new Integer(1));
chain.doFilter(req, response); chain.doFilter(req, response);
} }

View file

@ -172,7 +172,7 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
if (! StringUtils.isBlank(idMatchingProperty)) { if (! StringUtils.isBlank(idMatchingProperty)) {
// Use assertions model to side-step filtering. We need to get the value regardless of whether the property // Use assertions model to side-step filtering. We need to get the value regardless of whether the property
// is visible to the current user. // is visible to the current user.
WebappDaoFactory wdf = vreq.getAssertionsWebappDaoFactory(); WebappDaoFactory wdf = vreq.getUnfilteredWebappDaoFactory();
Collection<DataPropertyStatement> ids = Collection<DataPropertyStatement> ids =
wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, idMatchingProperty); wdf.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(individual, idMatchingProperty);
if (ids.size() > 0) { if (ids.size() > 0) {

View file

@ -89,7 +89,7 @@
} }
vreq.setAttribute("subject", subject); vreq.setAttribute("subject", subject);
WebappDaoFactory unfilteredWdf = vreq.getAssertionsWebappDaoFactory(); WebappDaoFactory unfilteredWdf = vreq.getUnfilteredWebappDaoFactory();
DataProperty dataproperty = unfilteredWdf.getDataPropertyDao().getDataPropertyByURI( predicateUri ); DataProperty dataproperty = unfilteredWdf.getDataPropertyDao().getDataPropertyByURI( predicateUri );
if( dataproperty == null) { if( dataproperty == null) {
// No dataproperty will be returned for rdfs:label, but we shouldn't throw an error. // No dataproperty will be returned for rdfs:label, but we shouldn't throw an error.