NIHVIVO-3957 fixes exceptions when attempting to edit or delete individuals using the backend editor

This commit is contained in:
brianjlowe 2012-09-13 15:32:06 +00:00
parent 2c83351eb6
commit cf7f25af3b
2 changed files with 17 additions and 7 deletions

View file

@ -25,6 +25,7 @@ import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext;
public class BaseEditController extends VitroHttpServlet {
@ -171,6 +172,20 @@ public class BaseEditController extends VitroHttpServlet {
return ontModel;
}
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(VitroRequest vreq, String userURI) {
return getWebappDaoFactory(vreq).getUserAwareDaoFactory(userURI);
}
public String getDefaultLandingPage(HttpServletRequest request) {

View file

@ -77,15 +77,10 @@ public class EntityRetryController extends BaseEditController {
} else {
action = epo.getAction();
}
WebappDaoFactory wadf = vreq.getAssertionsWebappDaoFactory();
if (wadf == null) {
log.info("Using vreq.getFullWebappDaoFactory()");
vreq.getFullWebappDaoFactory();
}
LoginStatusBean loginBean = LoginStatusBean.getBean(request);
WebappDaoFactory myWebappDaoFactory = wadf.getUserAwareDaoFactory(loginBean.getUserURI());
WebappDaoFactory myWebappDaoFactory = getWebappDaoFactory(
vreq, loginBean.getUserURI());
IndividualDao ewDao = myWebappDaoFactory.getIndividualDao();
epo.setDataAccessObject(ewDao);