NIHVIVO-707 Suppress delete link on core:webpage, and suppress add/edit/delete links on core:webpageOf
This commit is contained in:
parent
8dc72f55db
commit
2936d1730c
3 changed files with 100 additions and 28 deletions
|
@ -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 @@
|
|||
|
||||
</v:jsonset>
|
||||
|
||||
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
|
||||
|
||||
<c:set var="editjson" scope="request">
|
||||
{
|
||||
"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<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||
"/js/browserUtils.js",
|
||||
"/edit/forms/js/manageWebpagesForIndividual.js"
|
||||
));
|
||||
request.setAttribute("customJs", customJs);
|
||||
|
||||
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
||||
Css.CUSTOM_FORM.path()
|
||||
));
|
||||
request.setAttribute("customCss", customCss);
|
||||
|
||||
%>
|
||||
|
||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||
|
||||
<jsp:include page="${preForm}"/>
|
||||
|
||||
<h2><%= title %></h2>
|
||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
<v:input type="text" label="URL" id="url" size="70"/>
|
||||
<v:input type="text" label="Link anchor text" id="anchor" size="70"/>
|
||||
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
<v:input type="text" label="URL ${requiredHint}" id="url" size="70"/>
|
||||
<v:input type="text" label="Webpage name" id="anchor" size="70"/>
|
||||
<p><em>If left blank, the URL will be used when displaying a link to this webpage.</em></p>
|
||||
<input type="hidden" name="rank" value="-1" />
|
||||
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/></p>
|
||||
</form>
|
||||
|
|
|
@ -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>
|
||||
</#assign>
|
||||
|
||||
|
||||
<#if statement.url?has_content>
|
||||
<a href="${statement.url}">${linkText}</a>
|
||||
<#else>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue