From c774dc555020293915e2c9d6c0e167d0c2c20baf Mon Sep 17 00:00:00 2001 From: j2blake Date: Fri, 24 Jun 2011 18:53:58 +0000 Subject: [PATCH] NIHVIVO-2758 Move VivoPolicy from Vitro into Vivo. Change the package and merge the Setup class. --- .../vitro/webapp/auth/policy/VivoPolicy.java | 63 ------------------- .../auth/policy/setup/VivoPolicySetup.java | 32 ---------- 2 files changed, 95 deletions(-) delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/VivoPolicy.java delete mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/setup/VivoPolicySetup.java diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/VivoPolicy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/VivoPolicy.java deleted file mode 100644 index ff2da81f0..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/VivoPolicy.java +++ /dev/null @@ -1,63 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.auth.policy; - -import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; -import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization; -import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.DefaultInconclusivePolicy; -import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropStmt; -import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt; - -public class VivoPolicy extends DefaultInconclusivePolicy{ - - private static String AUTHORSHIP_FROM_PUB = "http://vivoweb.org/ontology/core#informationResourceInAuthorship"; - private static String AUTHORSHIP_FROM_PERSON = "http://vivoweb.org/ontology/core#authorInAuthorship"; - @Override - public PolicyDecision isAuthorized(IdentifierBundle whoToAuth, - RequestedAction whatToAuth) { - - if( whatToAuth instanceof DropObjectPropStmt ){ - DropObjectPropStmt dops = (DropObjectPropStmt)whatToAuth; - - /* Do not offer the user the option to delete so they will use the custom form instead */ - /* see issue NIHVIVO-739 */ - if( AUTHORSHIP_FROM_PUB.equals( dops.getUriOfPredicate() )) { - return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for core:informationResourceInAuthorship"); - } - - if( AUTHORSHIP_FROM_PERSON.equals( dops.getUriOfPredicate() )) { - return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for core:authorInAuthorship"); - } - - if( "http://vivoweb.org/ontology/core#linkedAuthor".equals( dops.getUriOfPredicate())){ - return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for on information resource to edit authors."); - } - - if( "http://vivoweb.org/ontology/core#linkedInformationResource".equals( dops.getUriOfPredicate())){ - return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for on information resource to edit authors."); - } - } - if( whatToAuth instanceof AddObjectPropStmt ){ - AddObjectPropStmt aops = (AddObjectPropStmt)whatToAuth; - if( "http://vivoweb.org/ontology/core#linkedAuthor".equals( aops.getUriOfPredicate())){ - return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for on information resource to edit authors."); - } - - if( "http://vivoweb.org/ontology/core#linkedInformationResource".equals( aops.getUriOfPredicate())){ - return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for on information resource to edit authors."); - } - } - - return super.isAuthorized(whoToAuth, whatToAuth); - } - - -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/setup/VivoPolicySetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/setup/VivoPolicySetup.java deleted file mode 100644 index d1e1d5abb..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/policy/setup/VivoPolicySetup.java +++ /dev/null @@ -1,32 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.auth.policy.setup; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList; -import edu.cornell.mannlib.vitro.webapp.auth.policy.VivoPolicy; - -public class VivoPolicySetup implements ServletContextListener{ - private static final Log log = LogFactory.getLog(VivoPolicySetup.class); - - @Override - public void contextInitialized(ServletContextEvent sce) { - log.debug("Setting up VivoPolicy"); - - //need to make a policy and add it to the ServeltContext - ServletPolicyList.addPolicy(sce.getServletContext(), new VivoPolicy()); - - //Note: The VivoPolicy doesn't use any identifier bundles so none are added here. - } - - @Override - public void contextDestroyed(ServletContextEvent arg0) { - //do nothing - } - -}