NIHVIVO-2211 Replace ServletIdentifierBundleFactory with ActiveIdentifierBundleFactories and RequestIdentifiers.
This commit is contained in:
parent
90a508808e
commit
2af6f22bd4
12 changed files with 60 additions and 95 deletions
|
@ -11,10 +11,9 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
|
@ -32,8 +31,7 @@ public class AuthTestController extends VitroHttpServlet {
|
|||
public void doGet(HttpServletRequest req, HttpServletResponse res )
|
||||
throws IOException, ServletException{
|
||||
super.doGet(req,res);
|
||||
HttpSession session = req.getSession(false);
|
||||
IdentifierBundle ids = ServletIdentifierBundleFactory.getIdBundleForRequest(req,session,getServletContext());
|
||||
IdentifierBundle ids = RequestIdentifiers.getIdBundleForRequest(req);
|
||||
ServletOutputStream out = res.getOutputStream();
|
||||
|
||||
listIdentifiers(out,ids);
|
||||
|
|
|
@ -3,14 +3,12 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.auth;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
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.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.RequestPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
|
@ -73,15 +71,7 @@ public class AuthorizationHelper {
|
|||
}
|
||||
|
||||
private IdentifierBundle getIdentifiers() {
|
||||
HttpSession session = vreq.getSession();
|
||||
ServletContext context = session.getServletContext();
|
||||
IdentifierBundle ids = ServletIdentifierBundleFactory
|
||||
.getIdBundleForRequest(vreq, session, context);
|
||||
if (ids == null) {
|
||||
return new ArrayIdentifierBundle();
|
||||
} else {
|
||||
return ids;
|
||||
}
|
||||
return RequestIdentifiers.getIdBundleForRequest(vreq);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,18 +3,10 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.auth.identifier;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.RoleBasedPolicy.AuthRole;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.User;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
|
@ -34,9 +26,10 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|||
public class SelfEditing2RoleIdentifierFactory implements
|
||||
IdentifierBundleFactory {
|
||||
|
||||
@Override
|
||||
public IdentifierBundle getIdentifierBundle(ServletRequest request,
|
||||
HttpSession session, ServletContext context) {
|
||||
IdentifierBundle whoToAuth = ServletIdentifierBundleFactory.getExistingIdBundle(request);
|
||||
IdentifierBundle whoToAuth = RequestIdentifiers.getIdBundleForRequest(request);
|
||||
if( whoToAuth != null ){
|
||||
WebappDaoFactory wdf = (WebappDaoFactory)context.getAttribute("webappDaoFactory");
|
||||
if( wdf == null )
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.auth.identifier;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
|
@ -15,9 +14,8 @@ public class SetupFakeSelfEditingIdentifierFactory implements ServletContextList
|
|||
|
||||
private static final Log log = LogFactory.getLog(SetupFakeSelfEditingIdentifierFactory.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext sc = sce.getServletContext();
|
||||
|
||||
WebappDaoFactory wdf = (WebappDaoFactory)sce.getServletContext().getAttribute("webappDaoFactory");
|
||||
if( wdf == null ){
|
||||
log.debug("SetupFakeSelfEditingIdentifierFactory: need a " +
|
||||
|
@ -27,9 +25,11 @@ public class SetupFakeSelfEditingIdentifierFactory implements ServletContextList
|
|||
}
|
||||
|
||||
IdentifierBundleFactory ibfToAdd = new FakeSelfEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sc, ibfToAdd);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, ibfToAdd);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.auth.identifier;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
|
@ -23,18 +22,19 @@ import edu.cornell.mannlib.vitro.webapp.servlet.setup.AbortStartup;
|
|||
public class UserToIndIdentifierFactorySetup implements ServletContextListener{
|
||||
private static final Log log = LogFactory.getLog(UserToIndIdentifierFactorySetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
|
||||
if (AbortStartup.isStartupAborted(sce.getServletContext())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ServletContext sc = sce.getServletContext();
|
||||
ServletIdentifierBundleFactory
|
||||
.addIdentifierBundleFactory(sc, new UserToIndIdentifierFactory());
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new UserToIndIdentifierFactory());
|
||||
log.info("Set up Identifier Factory UserToIndIdentifierFactory.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
// Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ import com.hp.hpl.jena.rdf.model.ModelFactory;
|
|||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.Identifier;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory.NetId;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.DefaultInconclusivePolicy;
|
||||
|
@ -39,8 +39,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.RemoveUser;
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.ServerStatus;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UpdateTextIndex;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.admin.UploadFile;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.AdminRequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.OntoRequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty;
|
||||
|
@ -367,9 +365,7 @@ public class JenaNetidPolicy extends DefaultInconclusivePolicy implements Visiti
|
|||
*
|
||||
*/
|
||||
public class ContextSetup implements ServletContextListener {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.trace("Setting up JenaNetidPolicy");
|
||||
|
@ -383,13 +379,13 @@ public class JenaNetidPolicy extends DefaultInconclusivePolicy implements Visiti
|
|||
ServletPolicyList spl = ServletPolicyList.getPolicies(sce.getServletContext());
|
||||
spl.add(jnip);
|
||||
|
||||
SelfEditingIdentifierFactory niif =new SelfEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new SelfEditingIdentifierFactory());
|
||||
}catch(Exception e){
|
||||
log.error("could not create AuthorizationFactory: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) { /*nothing*/ }
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.setup;
|
|||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -20,12 +19,10 @@ import com.hp.hpl.jena.rdf.model.ResIterator;
|
|||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.CuratorEditingIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.CuratorEditingPolicy;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.VisitingPolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
|
@ -44,6 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
public class CuratorEditingPolicySetup implements ServletContextListener {
|
||||
private static final Log log = LogFactory.getLog(CuratorEditingPolicySetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.debug("Setting up CuratorEditingPolicy");
|
||||
|
@ -54,8 +52,7 @@ public class CuratorEditingPolicySetup implements ServletContextListener {
|
|||
ServletPolicyList.addPolicy(sce.getServletContext(), cep);
|
||||
|
||||
//need to put an IdentifierFactory for CuratorEditingIds into the ServletContext
|
||||
IdentifierBundleFactory ibfToAdd = new CuratorEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), ibfToAdd);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new CuratorEditingIdentifierFactory());
|
||||
|
||||
log.debug( "Finished setting up CuratorEditingPolicy: " + cep );
|
||||
}catch(Exception e){
|
||||
|
@ -64,6 +61,7 @@ public class CuratorEditingPolicySetup implements ServletContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) { /*nothing*/ }
|
||||
|
||||
public static CuratorEditingPolicy makeCuratorEditPolicyFromModel( Model model ){
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
package edu.cornell.mannlib.vitro.webapp.auth.policy.setup;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -19,13 +18,10 @@ import com.hp.hpl.jena.rdf.model.ResIterator;
|
|||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.DbAdminEditingIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.DbAdminEditingPolicy;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.VisitingPolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
|
@ -44,6 +40,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
public class DbAdminEditingPolicySetup implements ServletContextListener {
|
||||
private static final Log log = LogFactory.getLog(DbAdminEditingPolicySetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.debug("Setting up DbAdminEditingPolicy");
|
||||
|
@ -54,8 +51,7 @@ public class DbAdminEditingPolicySetup implements ServletContextListener {
|
|||
ServletPolicyList.addPolicy(sce.getServletContext(), cep);
|
||||
|
||||
//need to put an IdentifierFactory for DbAdminEditingIds into the ServletContext
|
||||
IdentifierBundleFactory ibfToAdd = new DbAdminEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), ibfToAdd);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new DbAdminEditingIdentifierFactory());
|
||||
|
||||
log.debug( "Finished setting up DbAdminEditingPolicy: " + cep );
|
||||
}catch(Exception e){
|
||||
|
@ -64,6 +60,7 @@ public class DbAdminEditingPolicySetup implements ServletContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) { /*nothing*/ }
|
||||
|
||||
public static DbAdminEditingPolicy makeDbAdminEditPolicyFromModel( Model model ){
|
||||
|
|
|
@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.setup;
|
|||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -20,14 +19,10 @@ import com.hp.hpl.jena.rdf.model.ResIterator;
|
|||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.EditorEditingIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.EditorEditingPolicy;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.SelfEditingPolicy;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.VisitingPolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
|
@ -46,6 +41,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|||
public class EditorEditingPolicySetup implements ServletContextListener {
|
||||
private static final Log log = LogFactory.getLog(EditorEditingPolicySetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.debug("Setting up EditorEditingPolicy");
|
||||
|
@ -56,8 +52,7 @@ public class EditorEditingPolicySetup implements ServletContextListener {
|
|||
ServletPolicyList.addPolicy(sce.getServletContext(), cep);
|
||||
|
||||
//need to put an IdentifierFactory for EditorEditingIds into the ServletContext
|
||||
IdentifierBundleFactory ibfToAdd = new EditorEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), ibfToAdd);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new EditorEditingIdentifierFactory());
|
||||
|
||||
log.debug( "Finished setting up EditorEditingPolicy: " + cep );
|
||||
}catch(Exception e){
|
||||
|
@ -66,6 +61,7 @@ public class EditorEditingPolicySetup implements ServletContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) { /*nothing*/ }
|
||||
|
||||
public static EditorEditingPolicy makeEditorEditPolicyFromModel( Model model ){
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.JenaNetidPolicy;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
|
||||
|
@ -29,6 +29,7 @@ public class JenaNetidPolicySetup implements ServletContextListener {
|
|||
|
||||
private static final Log log = LogFactory.getLog(JenaNetidPolicySetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.debug("Setting up JenaNetidPolicy");
|
||||
|
@ -37,7 +38,7 @@ public class JenaNetidPolicySetup implements ServletContextListener {
|
|||
ServletPolicyList.addPolicy(sce.getServletContext(), jnip);
|
||||
|
||||
SelfEditingIdentifierFactory niif =new SelfEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, niif);
|
||||
|
||||
}catch(Exception e){
|
||||
log.error("could not create AuthorizationFactory: " + e);
|
||||
|
@ -45,6 +46,7 @@ public class JenaNetidPolicySetup implements ServletContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
/*nothing*/
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ import javax.servlet.ServletContextListener;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditing2RoleIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
|
||||
/**
|
||||
* Add the SelfEditing2RoleIdentifier factory to the IdentifierFactory list
|
||||
|
@ -29,17 +29,16 @@ public class SelfEditing2RoleIdentifierSetup implements ServletContextListener{
|
|||
|
||||
private static final Log log = LogFactory.getLog(SelfEditing2RoleIdentifierSetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.debug("Setting up SelfEditing2RoleIdentifier");
|
||||
|
||||
SelfEditing2RoleIdentifierFactory niif =new SelfEditing2RoleIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
||||
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new SelfEditing2RoleIdentifierFactory());
|
||||
log.debug( "SelfEditing2RoleIdentifier has been setup. " );
|
||||
}catch(Exception e){
|
||||
log.error("could not run SelfEditing2RoleIdentifier: " + e);
|
||||
|
|
|
@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.policy.setup;
|
|||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
@ -15,17 +14,14 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.ResIterator;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.SelfEditingIdentifierFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.SelfEditingPolicy;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.VisitingPolicyIface;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
|
@ -51,6 +47,7 @@ public class SelfEditingPolicySetup implements ServletContextListener {
|
|||
private static final Log log = LogFactory.getLog(SelfEditingPolicySetup.class.getName());
|
||||
public static final String SELF_EDITING_POLICY_WAS_SETUP= "selfEditingPolicyWasSetup";
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.debug("Setting up SelfEditingPolicy");
|
||||
|
@ -58,9 +55,7 @@ public class SelfEditingPolicySetup implements ServletContextListener {
|
|||
OntModel model = (OntModel)sce.getServletContext().getAttribute("jenaOntModel");
|
||||
replaceSelfEditing(sce.getServletContext(), model);
|
||||
|
||||
|
||||
SelfEditingIdentifierFactory niif =new SelfEditingIdentifierFactory();
|
||||
ServletIdentifierBundleFactory.addIdentifierBundleFactory(sce.getServletContext(), niif);
|
||||
ActiveIdentifierBundleFactories.addFactory(sce, new SelfEditingIdentifierFactory());
|
||||
|
||||
sce.getServletContext().setAttribute(SELF_EDITING_POLICY_WAS_SETUP, Boolean.TRUE);
|
||||
|
||||
|
@ -71,6 +66,7 @@ public class SelfEditingPolicySetup implements ServletContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce) { /*nothing*/ }
|
||||
|
||||
public static SelfEditingPolicy makeSelfEditPolicyFromModel( OntModel model ){
|
||||
|
|
Loading…
Add table
Reference in a new issue