From 1af92dc3508ba088ae329e5584c8369517f2f59e Mon Sep 17 00:00:00 2001 From: bdc34 Date: Tue, 16 Mar 2010 16:51:18 +0000 Subject: [PATCH] Adding ability for user accounts to be associated with individuals. NIHVIVO-121 --- webapp/config/web.xml | 12 ++-- .../UserToIndIdentifierFactorySetup.java | 31 ++++++++++ webapp/web/edit/n3Delete.jsp | 10 ++-- .../web/templates/edit/specific/user_edit.jsp | 58 +++++++++++++++---- 4 files changed, 91 insertions(+), 20 deletions(-) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactorySetup.java diff --git a/webapp/config/web.xml b/webapp/config/web.xml index 5a7a63cdd..271dd8b68 100644 --- a/webapp/config/web.xml +++ b/webapp/config/web.xml @@ -104,16 +104,18 @@ edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup - - edu.cornell.mannlib.vitro.webapp.auth.policy.setup.EditorEditingPolicySetup diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactorySetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactorySetup.java new file mode 100644 index 000000000..f0e554308 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/identifier/UserToIndIdentifierFactorySetup.java @@ -0,0 +1,31 @@ +package edu.cornell.mannlib.vitro.webapp.auth.identifier; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Setups context so that Identifiers for Individuals associated with Users are + * added to requests. + * + * This only adds identifiers. A self-editing policy is also needed. + * + * @author bdc34 + * + */ +public class UserToIndIdentifierFactorySetup implements ServletContextListener{ + private static final Log log = LogFactory.getLog(UserToIndIdentifierFactorySetup.class.getName()); + + public void contextInitialized(ServletContextEvent sce) { + ServletContext sc = sce.getServletContext(); + ServletIdentifierBundleFactory + .addIdentifierBundleFactory(sc, new UserToIndIdentifierFactory()); + log.info("Set up Identifier Factory UserToIndIdentifierFactory."); + } + + public void contextDestroyed(ServletContextEvent arg0) { + } +} diff --git a/webapp/web/edit/n3Delete.jsp b/webapp/web/edit/n3Delete.jsp index 5d685d306..23b8a8125 100644 --- a/webapp/web/edit/n3Delete.jsp +++ b/webapp/web/edit/n3Delete.jsp @@ -58,8 +58,8 @@ /* the post parameters seem to get consumed by the parsing so * we have to make a copy. */ - Map > queryParameters = null; - queryParameters = request.getParameterMap(); + Map queryParameters = null; + queryParameters = request.getParameterMap(); List errorMessages = new ArrayList(); @@ -68,7 +68,7 @@ %><% } EditN3Generator n3Subber = editConfig.getN3Generator(); - EditSubmission submission = new EditSubmission(queryParameters, editConfig); + EditSubmission submission = new EditSubmission(queryParameters, editConfig); Map errors = submission.getValidationErrors(); EditSubmission.putEditSubmissionInSession(session,submission); @@ -205,10 +205,12 @@ } OntModel queryModel = editConfig.getQueryModelSelector().getModel(request,application); + Model emptyModel = ModelFactory.createDefaultModel(); + if( editConfig.isUseDependentResourceDelete() ){ Model depResRetractions = DependentResourceDeleteJena - .getDependentResourceDeleteForChange(null,allPossibleToDelete,queryModel); + .getDependentResourceDeleteForChange(emptyModel,allPossibleToDelete,queryModel); allPossibleToDelete.add( depResRetractions ); } diff --git a/webapp/web/templates/edit/specific/user_edit.jsp b/webapp/web/templates/edit/specific/user_edit.jsp index 8623cfe4a..867158710 100644 --- a/webapp/web/templates/edit/specific/user_edit.jsp +++ b/webapp/web/templates/edit/specific/user_edit.jsp @@ -1,8 +1,8 @@ + - - - + +
@@ -10,10 +10,10 @@
- - + @@ -22,7 +22,7 @@ - + @@ -36,14 +36,50 @@ +
+
- +
- + -
-
-
+ + + + + + + + + + + + + ${user.URI} + ${requestScope.predicateUri} + ${stmt.objectURI} + admin/mayEditAs.jsp + + + + + + + + + + +
+ Add new individual that user may edit as + + ${user.URI} + admin/mayEditAs.jsp + + add +
User may edit as the following Individuals:
${stmt.objectURI}delete
There are no Individuals in the system that the user may edit as.
+ +
+ +