NIHVIVO-3542 Call PolicyHelper.isAuthorizedForActions() instead of EditingPolicyHelper.isActionAuthorized(). Remove the EditingPolicyHelper as a parameter to methods and constructors where it is no longer used.

This commit is contained in:
j2blake 2012-02-17 16:58:21 +00:00
parent d6925f93c6
commit 1b2ac02770
7 changed files with 24 additions and 42 deletions

View file

@ -2,15 +2,12 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.List;
import java.util.HashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropDataPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropDataPropStmt;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt;
@ -19,7 +16,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
@ -33,7 +29,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
//Extended to include vitro request to check for special parameters //Extended to include vitro request to check for special parameters
public DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, public DataPropertyStatementTemplateModel(String subjectUri, String propertyUri,
Literal literal, EditingPolicyHelper policyHelper, VitroRequest vreq) { Literal literal, EditingPolicyHelper policyHelper, VitroRequest vreq) {
super(subjectUri, propertyUri, policyHelper, vreq); super(subjectUri, propertyUri, vreq);
//attempt to strip any odd HTML //attempt to strip any odd HTML
this.value = cleanTextForDisplay( literal.getLexicalForm() ); this.value = cleanTextForDisplay( literal.getLexicalForm() );
@ -47,8 +43,8 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
* to handle rdfs:label like vitro links and vitroPublic image, because it is not possible to construct a DataProperty from * to handle rdfs:label like vitro links and vitroPublic image, because it is not possible to construct a DataProperty from
* rdfs:label. * rdfs:label.
*/ */
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq, EditingPolicyHelper policyHelper) { DataPropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq) {
super(subjectUri, propertyUri, policyHelper, vreq); super(subjectUri, propertyUri, vreq);
} }
public void setValue(String value) { public void setValue(String value) {
@ -68,12 +64,12 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
String dataPropHash = String.valueOf(RdfLiteralHash.makeRdfLiteralHash(dps)); String dataPropHash = String.valueOf(RdfLiteralHash.makeRdfLiteralHash(dps));
// Do delete url first, since used in building edit url // Do delete url first, since used in building edit url
setDeleteUrl(policyHelper, propertyUri, dps, dataPropHash); setDeleteUrl(propertyUri, dps, dataPropHash);
setEditUrl(policyHelper, propertyUri, dps, dataPropHash); setEditUrl(propertyUri, dps, dataPropHash);
} }
protected void setDeleteUrl(EditingPolicyHelper policyHelper, String propertyUri, DataPropertyStatement dps, String dataPropHash) { protected void setDeleteUrl(String propertyUri, DataPropertyStatement dps, String dataPropHash) {
// Hack for rdfs:label - the policy doesn't prevent deletion. // Hack for rdfs:label - the policy doesn't prevent deletion.
if (propertyUri.equals(VitroVocabulary.LABEL)) { if (propertyUri.equals(VitroVocabulary.LABEL)) {
@ -82,7 +78,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
// Determine whether the statement can be deleted // Determine whether the statement can be deleted
RequestedAction action = new DropDataPropStmt(dps); RequestedAction action = new DropDataPropStmt(dps);
if ( ! policyHelper.isAuthorizedAction(action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }
@ -97,7 +93,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params); deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params);
} }
protected void setEditUrl(EditingPolicyHelper policyHelper, String propertyUri, DataPropertyStatement dps, String dataPropHash) { protected void setEditUrl(String propertyUri, DataPropertyStatement dps, String dataPropHash) {
// vitro:moniker is deprecated. We display existing data values so editors can // vitro:moniker is deprecated. We display existing data values so editors can
// move them to other properties and delete, but don't allow editing. // move them to other properties and delete, but don't allow editing.
@ -107,7 +103,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
// Determine whether the statement can be edited // Determine whether the statement can be edited
RequestedAction action = new EditDataPropStmt(dps); RequestedAction action = new EditDataPropStmt(dps);
if ( ! policyHelper.isAuthorizedAction(action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -11,6 +10,7 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Literal;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropStmt;
@ -57,7 +57,6 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
} }
@Override
protected void setAddUrl(EditingPolicyHelper policyHelper, Property property) { protected void setAddUrl(EditingPolicyHelper policyHelper, Property property) {
if (policyHelper == null) { if (policyHelper == null) {
@ -81,7 +80,7 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
// Determine whether a new statement can be added // Determine whether a new statement can be added
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri, RequestActionConstants.SOME_LITERAL, null, null); RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri, RequestActionConstants.SOME_LITERAL, null, null);
if ( ! policyHelper.isAuthorizedAction(action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }

View file

@ -7,16 +7,11 @@ import org.apache.commons.logging.LogFactory;
import org.openrdf.model.URI; import org.openrdf.model.URI;
import org.openrdf.model.impl.URIImpl; import org.openrdf.model.impl.URIImpl;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral; import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.processEdit.RdfLiteralHash;
public class NameStatementTemplateModel extends public class NameStatementTemplateModel extends
DataPropertyStatementTemplateModel { DataPropertyStatementTemplateModel {
@ -28,7 +23,7 @@ public class NameStatementTemplateModel extends
* Specifically, it allows rdfs:label to be treated like a data property statement and thus have editing links. * Specifically, it allows rdfs:label to be treated like a data property statement and thus have editing links.
*/ */
NameStatementTemplateModel(String subjectUri, VitroRequest vreq, EditingPolicyHelper policyHelper) { NameStatementTemplateModel(String subjectUri, VitroRequest vreq, EditingPolicyHelper policyHelper) {
super(subjectUri, VitroVocabulary.LABEL, vreq, policyHelper); super(subjectUri, VitroVocabulary.LABEL, vreq);
WebappDaoFactory wdf = vreq.getWebappDaoFactory(); WebappDaoFactory wdf = vreq.getWebappDaoFactory();

View file

@ -7,6 +7,7 @@ import java.util.Map;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt;
@ -31,7 +32,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
private final String objectKey; private final String objectKey;
public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey, public ObjectPropertyStatementTemplateModel(String subjectUri, String propertyUri, String objectKey,
Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) { Map<String, String> data, EditingPolicyHelper policyHelper, String templateName, VitroRequest vreq) {
super(subjectUri, propertyUri, policyHelper, vreq); super(subjectUri, propertyUri, vreq);
this.data = data; this.data = data;
this.objectUri = data.get(objectKey); this.objectUri = data.get(objectKey);
@ -49,16 +50,16 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl(subjectUri, propertyUri, objectUri); ObjectPropertyStatement ops = new ObjectPropertyStatementImpl(subjectUri, propertyUri, objectUri);
// Do delete url first, since used in building edit url // Do delete url first, since used in building edit url
setDeleteUrl(policyHelper, ops); setDeleteUrl();
setEditUrl(policyHelper, ops); setEditUrl(ops);
} }
} }
protected void setDeleteUrl(EditingPolicyHelper policyHelper, ObjectPropertyStatement ops) { protected void setDeleteUrl() {
// Determine whether the statement can be deleted // Determine whether the statement can be deleted
RequestedAction action = new DropObjectPropStmt(subjectUri, propertyUri, objectUri); RequestedAction action = new DropObjectPropStmt(subjectUri, propertyUri, objectUri);
if ( ! policyHelper.isAuthorizedAction(action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }
@ -92,11 +93,11 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
} }
} }
protected void setEditUrl(EditingPolicyHelper policyHelper, ObjectPropertyStatement ops) { protected void setEditUrl(ObjectPropertyStatement ops) {
// Determine whether the statement can be edited // Determine whether the statement can be edited
RequestedAction action = new EditObjPropStmt(ops); RequestedAction action = new EditObjPropStmt(ops);
if ( ! policyHelper.isAuthorizedAction(action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }

View file

@ -6,7 +6,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -22,10 +21,10 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction; 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.AddObjectPropStmt;
@ -111,7 +110,6 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
setAddUrl(policyHelper, op); setAddUrl(policyHelper, op);
} }
@Override
protected void setAddUrl(EditingPolicyHelper policyHelper, Property property) { protected void setAddUrl(EditingPolicyHelper policyHelper, Property property) {
if (policyHelper == null) { if (policyHelper == null) {
@ -120,7 +118,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
// Determine whether a new statement can be added // Determine whether a new statement can be added
RequestedAction action = new AddObjectPropStmt(subjectUri, propertyUri, RequestActionConstants.SOME_URI); RequestedAction action = new AddObjectPropStmt(subjectUri, propertyUri, RequestActionConstants.SOME_URI);
if ( ! policyHelper.isAuthorizedAction(action) ) { if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return; return;
} }

View file

@ -2,10 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual; package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
@ -24,7 +20,7 @@ public abstract class PropertyStatementTemplateModel extends BaseTemplateModel {
protected String deleteUrl; protected String deleteUrl;
PropertyStatementTemplateModel(String subjectUri, String propertyUri, EditingPolicyHelper policyHelper, VitroRequest vreq) { PropertyStatementTemplateModel(String subjectUri, String propertyUri, VitroRequest vreq) {
this.vreq = vreq; this.vreq = vreq;
this.subjectUri = subjectUri; this.subjectUri = subjectUri;
this.propertyUri = propertyUri; this.propertyUri = propertyUri;

View file

@ -94,9 +94,6 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
this.name = name; this.name = name;
} }
protected abstract void setAddUrl(EditingPolicyHelper policyHelper, Property property);
/* Template properties */ /* Template properties */
public abstract String getType(); public abstract String getType();