diff --git a/productMods/edit/forms/manageWebpagesForIndividual.jsp b/productMods/edit/forms/manageWebpagesForIndividual.jsp index e4c3dbca..6923d3a5 100644 --- a/productMods/edit/forms/manageWebpagesForIndividual.jsp +++ b/productMods/edit/forms/manageWebpagesForIndividual.jsp @@ -1,5 +1,25 @@ <%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> +<%-- Custom form for managing webpages associated with an individual + +Object properties: +core:webpage (range: core:URLLink) +core:webpageOf (domain: core:URLLink) (inverse of core:webpage) + +Class: +core:URLLink - the link to be added to the individual + +Data properties of core:URLLink: +core:linkURI +core:linkAnchorText +core:rank + +--%> + +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.Arrays" %> + <%@ page import="com.hp.hpl.jena.rdf.model.Literal" %> <%@ page import="com.hp.hpl.jena.rdf.model.Model" %> <%@ page import="com.hp.hpl.jena.vocabulary.XSD" %> @@ -13,8 +33,8 @@ <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> - -<%@ page import="java.util.List" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %> +<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %> <%@ page import="org.apache.commons.logging.Log" %> <%@ page import="org.apache.commons.logging.LogFactory" %> @@ -98,12 +118,13 @@ + { "formUrl" : "${formUrl}", "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/entity", + "urlPatternToReturnTo" : "${returnPathAfterSubmit}", "subject" : ["subject", "${subjectUriJson}" ], "predicate" : ["predicate", "${predicateUriJson}" ], @@ -190,15 +211,30 @@ title = "Create" + title; submitLabel = "Create link"; } + + List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), + JavaScript.CUSTOM_FORM_UTILS.path(), + "/js/browserUtils.js", + "/edit/forms/js/manageWebpagesForIndividual.js" + )); + request.setAttribute("customJs", customJs); + + List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), + Css.CUSTOM_FORM.path() + )); + request.setAttribute("customCss", customCss); %> + +

<%= title %>

-
" > - - +" > + + +

If left blank, the URL will be used when displaying a link to this webpage.

diff --git a/productMods/templates/freemarker/body/partials/individual/propStatement-webpage.ftl b/productMods/templates/freemarker/body/partials/individual/propStatement-webpage.ftl index e1389092..40076dd4 100644 --- a/productMods/templates/freemarker/body/partials/individual/propStatement-webpage.ftl +++ b/productMods/templates/freemarker/body/partials/individual/propStatement-webpage.ftl @@ -7,11 +7,12 @@ --> <#assign linkText> - <#if statement.anchor?has_content>${statement.anchor} - <#elseif statement.url?has_content>${statement.url} + <#if statement.anchor?has_content>${statement.anchor}<#t> + <#elseif statement.url?has_content>${statement.url}<#t> + <#if statement.url?has_content> ${linkText} <#else> diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/VivoPolicy.java b/src/edu/cornell/mannlib/vivo/auth/policy/VivoPolicy.java index b79054c0..41875879 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/VivoPolicy.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/VivoPolicy.java @@ -17,12 +17,19 @@ 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; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt; public class VivoPolicy extends DefaultInconclusivePolicy{ private static final Log log = LogFactory.getLog(VivoPolicy.class); - private static String AUTHORSHIP_FROM_PUB = "http://vivoweb.org/ontology/core#informationResourceInAuthorship"; - private static String AUTHORSHIP_FROM_PERSON = "http://vivoweb.org/ontology/core#authorInAuthorship"; + private static final String CORE = "http://vivoweb.org/ontology/core#"; + private static final String PUB_TO_AUTHORSHIP = CORE + "informationResourceInAuthorship"; + private static final String PERSON_TO_AUTHORSHIP = CORE + "authorInAuthorship"; + private static final String AUTHORSHIP_TO_PERSON = CORE + "linkedAuthor"; + private static final String AUTHORSHIP_TO_PUB = CORE + "linkedInformationResource"; + private static final String INDIVIDUAL_TO_WEBPAGE = CORE + "webpage"; + private static final String WEBPAGE_TO_INDIVIDUAL = CORE + "webpageOf"; + @Override public PolicyDecision isAuthorized(IdentifierBundle whoToAuth, RequestedAction whatToAuth) { @@ -30,39 +37,67 @@ public class VivoPolicy extends DefaultInconclusivePolicy{ if( whatToAuth instanceof DropObjectPropStmt ){ DropObjectPropStmt dops = (DropObjectPropStmt)whatToAuth; + String predicateUri = dops.getUriOfPredicate(); + /* 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() )) { + if( PUB_TO_AUTHORSHIP.equals( predicateUri )) { return new BasicPolicyDecision(Authorization.UNAUTHORIZED, "Use the custom edit form for core:informationResourceInAuthorship"); } - if( AUTHORSHIP_FROM_PERSON.equals( dops.getUriOfPredicate() )) { + else if( PERSON_TO_AUTHORSHIP.equals( predicateUri )) { return new BasicPolicyDecision(Authorization.UNAUTHORIZED, "Use the custom edit form for core:authorInAuthorship"); } - if( "http://vivoweb.org/ontology/core#linkedAuthor".equals( dops.getUriOfPredicate())){ + else if( AUTHORSHIP_TO_PERSON.equals( predicateUri )){ return new BasicPolicyDecision(Authorization.UNAUTHORIZED, - "Use the custom edit form for on information resource to edit authors."); + "Use the custom edit form on information resource to edit authors."); } - if( "http://vivoweb.org/ontology/core#linkedInformationResource".equals( dops.getUriOfPredicate())){ + else if( AUTHORSHIP_TO_PUB.equals( predicateUri )){ 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."); + "Use the custom edit form on information resource to edit authors."); } + + else if ( INDIVIDUAL_TO_WEBPAGE.equals( predicateUri ) || WEBPAGE_TO_INDIVIDUAL.equals( predicateUri )) { + return new BasicPolicyDecision(Authorization.UNAUTHORIZED, + "Use the custom edit form for core:webpage"); + } + } + else if( whatToAuth instanceof AddObjectPropStmt ){ + + AddObjectPropStmt aops = (AddObjectPropStmt)whatToAuth; + + String predicateUri = aops.getUriOfPredicate(); + + if( AUTHORSHIP_TO_PERSON.equals( predicateUri )){ + return new BasicPolicyDecision(Authorization.UNAUTHORIZED, + "Use the custom edit form on information resource to edit authors."); + } + + else if( AUTHORSHIP_TO_PUB.equals( predicateUri )){ + return new BasicPolicyDecision(Authorization.UNAUTHORIZED, + "Use the custom edit form on information resource to edit authors."); + } + + else if( WEBPAGE_TO_INDIVIDUAL.equals( predicateUri )){ + return new BasicPolicyDecision(Authorization.UNAUTHORIZED, + "Use the custom edit form on an individual to edit webpages."); + } + } + + else if (whatToAuth instanceof EditObjPropStmt ) { + + EditObjPropStmt aops = (EditObjPropStmt)whatToAuth; + + String predicateUri = aops.getUriOfPredicate(); + + if( WEBPAGE_TO_INDIVIDUAL.equals( predicateUri )){ + return new BasicPolicyDecision(Authorization.UNAUTHORIZED, + "Use the custom edit form on an individual to edit webpages."); + } } return super.isAuthorized(whoToAuth, whatToAuth);