NIHVIVO-3404 Rename statement-related RequestedAction classes to consistent naming scheme.
This commit is contained in:
parent
37b0ad0e95
commit
fc2052e0b7
23 changed files with 170 additions and 168 deletions
|
@ -9,8 +9,8 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
|
||||||
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.AbstractDataPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractDataPropertyStatementAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,10 +55,10 @@ public class EditByRolePermission extends Permission {
|
||||||
public boolean isAuthorized(RequestedAction whatToAuth) {
|
public boolean isAuthorized(RequestedAction whatToAuth) {
|
||||||
boolean result;
|
boolean result;
|
||||||
|
|
||||||
if (whatToAuth instanceof AbstractDataPropertyAction) {
|
if (whatToAuth instanceof AbstractDataPropertyStatementAction) {
|
||||||
result = isAuthorized((AbstractDataPropertyAction) whatToAuth);
|
result = isAuthorized((AbstractDataPropertyStatementAction) whatToAuth);
|
||||||
} else if (whatToAuth instanceof AbstractObjectPropertyAction) {
|
} else if (whatToAuth instanceof AbstractObjectPropertyStatementAction) {
|
||||||
result = isAuthorized((AbstractObjectPropertyAction) whatToAuth);
|
result = isAuthorized((AbstractObjectPropertyStatementAction) whatToAuth);
|
||||||
} else {
|
} else {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class EditByRolePermission extends Permission {
|
||||||
* The user may add, edit, or delete this data property if they are allowed
|
* The user may add, edit, or delete this data property if they are allowed
|
||||||
* to modify its subject and its predicate.
|
* to modify its subject and its predicate.
|
||||||
*/
|
*/
|
||||||
private boolean isAuthorized(AbstractDataPropertyAction action) {
|
private boolean isAuthorized(AbstractDataPropertyStatementAction action) {
|
||||||
String subjectUri = action.getSubjectUri();
|
String subjectUri = action.getSubjectUri();
|
||||||
String predicateUri = action.getPredicateUri();
|
String predicateUri = action.getPredicateUri();
|
||||||
return canModifyResource(subjectUri)
|
return canModifyResource(subjectUri)
|
||||||
|
@ -87,7 +87,7 @@ public class EditByRolePermission extends Permission {
|
||||||
* The user may add, edit, or delete this data property if they are allowed
|
* The user may add, edit, or delete this data property if they are allowed
|
||||||
* to modify its subject, its predicate, and its object.
|
* to modify its subject, its predicate, and its object.
|
||||||
*/
|
*/
|
||||||
private boolean isAuthorized(AbstractObjectPropertyAction action) {
|
private boolean isAuthorized(AbstractObjectPropertyStatementAction action) {
|
||||||
String subjectUri = action.getUriOfSubject();
|
String subjectUri = action.getUriOfSubject();
|
||||||
String predicateUri = action.getUriOfPredicate();
|
String predicateUri = action.getUriOfPredicate();
|
||||||
String objectUri = action.getUriOfObject();
|
String objectUri = action.getUriOfObject();
|
||||||
|
|
|
@ -19,10 +19,10 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.RequestIdentifiers;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||||
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.AddDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of static methods to help determine whether requested actions
|
* A collection of static methods to help determine whether requested actions
|
||||||
|
@ -101,11 +101,11 @@ public class PolicyHelper {
|
||||||
|
|
||||||
RequestedAction action;
|
RequestedAction action;
|
||||||
if (objectNode.isResource()) {
|
if (objectNode.isResource()) {
|
||||||
action = new AddObjectPropStmt(subject.getURI(),
|
action = new AddObjectPropertyStatement(subject.getURI(),
|
||||||
predicate.getURI(), objectNode.asResource().getURI());
|
predicate.getURI(), objectNode.asResource().getURI());
|
||||||
} else {
|
} else {
|
||||||
action = new AddDataPropStmt(subject.getURI(), predicate.getURI(),
|
action = new AddDataPropertyStatement(subject.getURI(),
|
||||||
objectNode.asLiteral());
|
predicate.getURI(), objectNode.asLiteral());
|
||||||
}
|
}
|
||||||
return isAuthorizedForActions(req, action);
|
return isAuthorizedForActions(req, action);
|
||||||
}
|
}
|
||||||
|
@ -153,11 +153,11 @@ public class PolicyHelper {
|
||||||
|
|
||||||
RequestedAction action;
|
RequestedAction action;
|
||||||
if (objectNode.isResource()) {
|
if (objectNode.isResource()) {
|
||||||
action = new DropObjectPropStmt(subject.getURI(),
|
action = new DropObjectPropertyStatement(subject.getURI(),
|
||||||
predicate.getURI(), objectNode.asResource().getURI());
|
predicate.getURI(), objectNode.asResource().getURI());
|
||||||
} else {
|
} else {
|
||||||
action = new DropDataPropStmt(subject.getURI(), predicate.getURI(),
|
action = new DropDataPropertyStatement(subject.getURI(),
|
||||||
objectNode.asLiteral());
|
predicate.getURI(), objectNode.asLiteral());
|
||||||
}
|
}
|
||||||
return isAuthorizedForActions(req, action);
|
return isAuthorizedForActions(req, action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||||
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.AbstractObjectPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,16 +23,17 @@ public class RestrictHomeMenuItemEditingPolicy implements PolicyIface {
|
||||||
@Override
|
@Override
|
||||||
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
||||||
RequestedAction whatToAuth) {
|
RequestedAction whatToAuth) {
|
||||||
if (whatToAuth instanceof EditObjPropStmt) {
|
if (whatToAuth instanceof EditObjectPropertyStatement) {
|
||||||
return isAuthorized((EditObjPropStmt) whatToAuth);
|
return isAuthorized((EditObjectPropertyStatement) whatToAuth);
|
||||||
} else if (whatToAuth instanceof DropObjectPropStmt) {
|
} else if (whatToAuth instanceof DropObjectPropertyStatement) {
|
||||||
return isAuthorized((DropObjectPropStmt) whatToAuth);
|
return isAuthorized((DropObjectPropertyStatement) whatToAuth);
|
||||||
} else {
|
} else {
|
||||||
return notHandled();
|
return notHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PolicyDecision isAuthorized(AbstractObjectPropertyAction whatToAuth) {
|
private PolicyDecision isAuthorized(
|
||||||
|
AbstractObjectPropertyStatementAction whatToAuth) {
|
||||||
if (whatToAuth.getUriOfPredicate()
|
if (whatToAuth.getUriOfPredicate()
|
||||||
.equals(DisplayVocabulary.HAS_ELEMENT)
|
.equals(DisplayVocabulary.HAS_ELEMENT)
|
||||||
&& whatToAuth.getUriOfObject().equals(
|
&& whatToAuth.getUriOfObject().equals(
|
||||||
|
|
|
@ -12,8 +12,8 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.HasAssociatedIndi
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||||
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.AbstractDataPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractDataPropertyStatementAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.resource.AbstractResourceAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.resource.AbstractResourceAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
|
||||||
|
|
||||||
|
@ -44,14 +44,14 @@ public class SelfEditingPolicy extends BaseSelfEditingPolicy implements
|
||||||
return inconclusiveDecision("Not self-editing.");
|
return inconclusiveDecision("Not self-editing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whatToAuth instanceof AbstractObjectPropertyAction) {
|
if (whatToAuth instanceof AbstractObjectPropertyStatementAction) {
|
||||||
return isAuthorizedForObjectPropertyAction(userUris,
|
return isAuthorizedForObjectPropertyAction(userUris,
|
||||||
(AbstractObjectPropertyAction) whatToAuth);
|
(AbstractObjectPropertyStatementAction) whatToAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whatToAuth instanceof AbstractDataPropertyAction) {
|
if (whatToAuth instanceof AbstractDataPropertyStatementAction) {
|
||||||
return isAuthorizedForDataPropertyAction(userUris,
|
return isAuthorizedForDataPropertyAction(userUris,
|
||||||
(AbstractDataPropertyAction) whatToAuth);
|
(AbstractDataPropertyStatementAction) whatToAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whatToAuth instanceof AbstractResourceAction) {
|
if (whatToAuth instanceof AbstractResourceAction) {
|
||||||
|
@ -67,7 +67,7 @@ public class SelfEditingPolicy extends BaseSelfEditingPolicy implements
|
||||||
* about him.
|
* about him.
|
||||||
*/
|
*/
|
||||||
private PolicyDecision isAuthorizedForObjectPropertyAction(
|
private PolicyDecision isAuthorizedForObjectPropertyAction(
|
||||||
List<String> userUris, AbstractObjectPropertyAction action) {
|
List<String> userUris, AbstractObjectPropertyStatementAction action) {
|
||||||
String subject = action.getUriOfSubject();
|
String subject = action.getUriOfSubject();
|
||||||
String predicate = action.getUriOfPredicate();
|
String predicate = action.getUriOfPredicate();
|
||||||
String object = action.getUriOfObject();
|
String object = action.getUriOfObject();
|
||||||
|
@ -94,7 +94,7 @@ public class SelfEditingPolicy extends BaseSelfEditingPolicy implements
|
||||||
* about him.
|
* about him.
|
||||||
*/
|
*/
|
||||||
private PolicyDecision isAuthorizedForDataPropertyAction(
|
private PolicyDecision isAuthorizedForDataPropertyAction(
|
||||||
List<String> userUris, AbstractDataPropertyAction action) {
|
List<String> userUris, AbstractDataPropertyStatementAction action) {
|
||||||
String subject = action.getSubjectUri();
|
String subject = action.getSubjectUri();
|
||||||
String predicate = action.getPredicateUri();
|
String predicate = action.getPredicateUri();
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAct
|
||||||
/**
|
/**
|
||||||
* A base class for requestion actions that relate to data properties.
|
* A base class for requestion actions that relate to data properties.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractDataPropertyAction extends RequestedAction {
|
public abstract class AbstractDataPropertyStatementAction extends RequestedAction {
|
||||||
private final String subjectUri;
|
private final String subjectUri;
|
||||||
private final String predicateUri;
|
private final String predicateUri;
|
||||||
|
|
||||||
public AbstractDataPropertyAction(String subjectUri, String predicateUri) {
|
public AbstractDataPropertyStatementAction(String subjectUri, String predicateUri) {
|
||||||
this.subjectUri = subjectUri;
|
this.subjectUri = subjectUri;
|
||||||
this.predicateUri = predicateUri;
|
this.predicateUri = predicateUri;
|
||||||
}
|
}
|
|
@ -8,12 +8,12 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAct
|
||||||
* A base class for requested actions that involve manipulating an object
|
* A base class for requested actions that involve manipulating an object
|
||||||
* property.
|
* property.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractObjectPropertyAction extends RequestedAction {
|
public abstract class AbstractObjectPropertyStatementAction extends RequestedAction {
|
||||||
public final String uriOfSubject;
|
public final String uriOfSubject;
|
||||||
public final String uriOfPredicate;
|
public final String uriOfPredicate;
|
||||||
public final String uriOfObject;
|
public final String uriOfObject;
|
||||||
|
|
||||||
public AbstractObjectPropertyAction(String uriOfSubject, String uriOfPredicate,
|
public AbstractObjectPropertyStatementAction(String uriOfSubject, String uriOfPredicate,
|
||||||
String uriOfObject) {
|
String uriOfObject) {
|
||||||
this.uriOfSubject = uriOfSubject;
|
this.uriOfSubject = uriOfSubject;
|
||||||
this.uriOfPredicate = uriOfPredicate;
|
this.uriOfPredicate = uriOfPredicate;
|
|
@ -5,19 +5,19 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
/** Should we allow the user to add this DataPropertyStatement? */
|
/** Should we allow the user to add this DataPropertyStatement? */
|
||||||
public class AddDataPropStmt extends AbstractDataPropertyAction {
|
public class AddDataPropertyStatement extends AbstractDataPropertyStatementAction {
|
||||||
protected String data;
|
protected String data;
|
||||||
protected String dataType;
|
protected String dataType;
|
||||||
protected String lang;
|
protected String lang;
|
||||||
|
|
||||||
public AddDataPropStmt(String subjectUri, String predicateUri, String value, String dataType, String lang) {
|
public AddDataPropertyStatement(String subjectUri, String predicateUri, String value, String dataType, String lang) {
|
||||||
super(subjectUri, predicateUri);
|
super(subjectUri, predicateUri);
|
||||||
this.data= value;
|
this.data= value;
|
||||||
this.dataType = dataType;
|
this.dataType = dataType;
|
||||||
this.lang = lang;
|
this.lang = lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddDataPropStmt(String subjectUri, String predicateUri, Literal literal) {
|
public AddDataPropertyStatement(String subjectUri, String predicateUri, Literal literal) {
|
||||||
super(subjectUri, predicateUri);
|
super(subjectUri, predicateUri);
|
||||||
this.data= literal.getValue().toString();
|
this.data= literal.getValue().toString();
|
||||||
this.dataType = literal.getDatatypeURI();
|
this.dataType = literal.getDatatypeURI();
|
|
@ -3,9 +3,9 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
||||||
|
|
||||||
/** Should we allow the user to add this ObjectPropertyStatement? */
|
/** Should we allow the user to add this ObjectPropertyStatement? */
|
||||||
public class AddObjectPropStmt extends AbstractObjectPropertyAction {
|
public class AddObjectPropertyStatement extends AbstractObjectPropertyStatementAction {
|
||||||
|
|
||||||
public AddObjectPropStmt(String uriOfSub, String uriOfPred, String uriOfObj) {
|
public AddObjectPropertyStatement(String uriOfSub, String uriOfPred, String uriOfObj) {
|
||||||
super(uriOfSub, uriOfPred, uriOfObj);
|
super(uriOfSub, uriOfPred, uriOfObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,16 +8,16 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
|
|
||||||
/** Should we allow the user to delete this DataPropertyStatement? */
|
/** Should we allow the user to delete this DataPropertyStatement? */
|
||||||
public class DropDataPropStmt extends AbstractDataPropertyAction {
|
public class DropDataPropertyStatement extends AbstractDataPropertyStatementAction {
|
||||||
|
|
||||||
private final DataPropertyStatement dataPropStmt;
|
private final DataPropertyStatement dataPropStmt;
|
||||||
|
|
||||||
public DropDataPropStmt(DataPropertyStatement dps){
|
public DropDataPropertyStatement(DataPropertyStatement dps){
|
||||||
super(dps.getIndividualURI(),dps.getDatapropURI() );
|
super(dps.getIndividualURI(),dps.getDatapropURI() );
|
||||||
this.dataPropStmt = dps;
|
this.dataPropStmt = dps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DropDataPropStmt(String subjectUri, String predicateUri, String data) {
|
public DropDataPropertyStatement(String subjectUri, String predicateUri, String data) {
|
||||||
super(subjectUri, predicateUri);
|
super(subjectUri, predicateUri);
|
||||||
dataPropStmt = new DataPropertyStatementImpl();
|
dataPropStmt = new DataPropertyStatementImpl();
|
||||||
dataPropStmt.setIndividualURI(subjectUri);
|
dataPropStmt.setIndividualURI(subjectUri);
|
||||||
|
@ -25,7 +25,7 @@ public class DropDataPropStmt extends AbstractDataPropertyAction {
|
||||||
dataPropStmt.setData(data);
|
dataPropStmt.setData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DropDataPropStmt(String subjectUri, String predicateUri, Literal data) {
|
public DropDataPropertyStatement(String subjectUri, String predicateUri, Literal data) {
|
||||||
super(subjectUri, predicateUri);
|
super(subjectUri, predicateUri);
|
||||||
dataPropStmt = new DataPropertyStatementImpl();
|
dataPropStmt = new DataPropertyStatementImpl();
|
||||||
dataPropStmt.setIndividualURI(subjectUri);
|
dataPropStmt.setIndividualURI(subjectUri);
|
|
@ -3,9 +3,9 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
||||||
|
|
||||||
/** Should we allow the user to delete this ObjectPropertyStatement? */
|
/** Should we allow the user to delete this ObjectPropertyStatement? */
|
||||||
public class DropObjectPropStmt extends AbstractObjectPropertyAction {
|
public class DropObjectPropertyStatement extends AbstractObjectPropertyStatementAction {
|
||||||
|
|
||||||
public DropObjectPropStmt(String sub, String pred, String obj) {
|
public DropObjectPropertyStatement(String sub, String pred, String obj) {
|
||||||
super(sub, pred, obj);
|
super(sub, pred, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,11 +5,11 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
|
|
||||||
/** Should we allow the user to edit this DataPropertyStatement? */
|
/** Should we allow the user to edit this DataPropertyStatement? */
|
||||||
public class EditDataPropStmt extends AbstractDataPropertyAction {
|
public class EditDataPropertyStatement extends AbstractDataPropertyStatementAction {
|
||||||
|
|
||||||
private final DataPropertyStatement dataPropStmt;
|
private final DataPropertyStatement dataPropStmt;
|
||||||
|
|
||||||
public EditDataPropStmt(DataPropertyStatement dps){
|
public EditDataPropertyStatement(DataPropertyStatement dps){
|
||||||
super(dps.getIndividualURI(), dps.getDatapropURI());
|
super(dps.getIndividualURI(), dps.getDatapropURI());
|
||||||
this.dataPropStmt = dps;
|
this.dataPropStmt = dps;
|
||||||
}
|
}
|
|
@ -5,13 +5,13 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
|
|
||||||
/** Should we allow the user to edit this ObjectPropertyStatement? */
|
/** Should we allow the user to edit this ObjectPropertyStatement? */
|
||||||
public class EditObjPropStmt extends AbstractObjectPropertyAction {
|
public class EditObjectPropertyStatement extends AbstractObjectPropertyStatementAction {
|
||||||
|
|
||||||
public EditObjPropStmt(ObjectPropertyStatement ops) {
|
public EditObjectPropertyStatement(ObjectPropertyStatement ops) {
|
||||||
super(ops.getSubjectURI(), ops.getPropertyURI(), ops.getObjectURI());
|
super(ops.getSubjectURI(), ops.getPropertyURI(), ops.getObjectURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
public EditObjPropStmt(String subjectUri, String keywordPredUri,
|
public EditObjectPropertyStatement(String subjectUri, String keywordPredUri,
|
||||||
String objectUri) {
|
String objectUri) {
|
||||||
super(subjectUri, keywordPredUri, objectUri);
|
super(subjectUri, keywordPredUri, objectUri);
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||||
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.EditObjPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
|
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
|
||||||
|
@ -58,7 +58,7 @@ public class ShowAuthController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private List<Identifier> getSortedIdentifiers(VitroRequest vreq) {
|
private List<Identifier> getSortedIdentifiers(VitroRequest vreq) {
|
||||||
Map<String, Identifier> idMap = new TreeMap<String, Identifier>();
|
Map<String, Identifier> idMap = new TreeMap<String, Identifier>();
|
||||||
for (Identifier id: RequestIdentifiers.getIdBundleForRequest(vreq)) {
|
for (Identifier id : RequestIdentifiers.getIdBundleForRequest(vreq)) {
|
||||||
idMap.put(id.toString(), id);
|
idMap.put(id.toString(), id);
|
||||||
}
|
}
|
||||||
return new ArrayList<Identifier>(idMap.values());
|
return new ArrayList<Identifier>(idMap.values());
|
||||||
|
@ -89,7 +89,7 @@ public class ShowAuthController extends FreemarkerHttpServlet {
|
||||||
* this individual?
|
* this individual?
|
||||||
*/
|
*/
|
||||||
private boolean mayEditIndividual(VitroRequest vreq, String individualUri) {
|
private boolean mayEditIndividual(VitroRequest vreq, String individualUri) {
|
||||||
RequestedAction action = new EditObjPropStmt(individualUri,
|
RequestedAction action = new EditObjectPropertyStatement(individualUri,
|
||||||
RequestActionConstants.SOME_URI,
|
RequestActionConstants.SOME_URI,
|
||||||
RequestActionConstants.SOME_URI);
|
RequestActionConstants.SOME_URI);
|
||||||
return PolicyHelper.isAuthorizedForActions(vreq, action);
|
return PolicyHelper.isAuthorizedForActions(vreq, action);
|
||||||
|
|
|
@ -19,9 +19,9 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||||
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.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -138,13 +138,13 @@ public class ImageUploadController extends FreemarkerHttpServlet {
|
||||||
RequestedAction ra;
|
RequestedAction ra;
|
||||||
if (ACTION_DELETE.equals(action)
|
if (ACTION_DELETE.equals(action)
|
||||||
|| ACTION_DELETE_EDIT.equals(action)) {
|
|| ACTION_DELETE_EDIT.equals(action)) {
|
||||||
ra = new DropObjectPropStmt(entity.getURI(),
|
ra = new DropObjectPropertyStatement(entity.getURI(),
|
||||||
VitroVocabulary.IND_MAIN_IMAGE, imageUri);
|
VitroVocabulary.IND_MAIN_IMAGE, imageUri);
|
||||||
} else if (imageUri != null) {
|
} else if (imageUri != null) {
|
||||||
ra = new EditObjPropStmt(entity.getURI(),
|
ra = new EditObjectPropertyStatement(entity.getURI(),
|
||||||
VitroVocabulary.IND_MAIN_IMAGE, imageUri);
|
VitroVocabulary.IND_MAIN_IMAGE, imageUri);
|
||||||
} else {
|
} else {
|
||||||
ra = new AddObjectPropStmt(entity.getURI(),
|
ra = new AddObjectPropertyStatement(entity.getURI(),
|
||||||
VitroVocabulary.IND_MAIN_IMAGE,
|
VitroVocabulary.IND_MAIN_IMAGE,
|
||||||
RequestActionConstants.SOME_URI);
|
RequestActionConstants.SOME_URI);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||||
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.propstmt.AddDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
|
@ -112,10 +112,10 @@ public abstract class BaseIndividualTemplateModel extends BaseTemplateModel {
|
||||||
* an object property to the Individual being shown.
|
* an object property to the Individual being shown.
|
||||||
*/
|
*/
|
||||||
public boolean isEditable() {
|
public boolean isEditable() {
|
||||||
AddDataPropStmt adps = new AddDataPropStmt(individual.getURI(),
|
AddDataPropertyStatement adps = new AddDataPropertyStatement(individual.getURI(),
|
||||||
RequestActionConstants.SOME_URI,
|
RequestActionConstants.SOME_URI,
|
||||||
RequestActionConstants.SOME_LITERAL, null, null);
|
RequestActionConstants.SOME_LITERAL, null, null);
|
||||||
AddObjectPropStmt aops = new AddObjectPropStmt(individual.getURI(),
|
AddObjectPropertyStatement aops = new AddObjectPropertyStatement(individual.getURI(),
|
||||||
RequestActionConstants.SOME_URI,
|
RequestActionConstants.SOME_URI,
|
||||||
RequestActionConstants.SOME_URI);
|
RequestActionConstants.SOME_URI);
|
||||||
return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops));
|
return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops));
|
||||||
|
|
|
@ -9,8 +9,8 @@ import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
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.DropDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -41,7 +41,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
private String makeDeleteUrl() {
|
private String makeDeleteUrl() {
|
||||||
// Determine whether the statement can be deleted
|
// Determine whether the statement can be deleted
|
||||||
DataPropertyStatement dps = makeStatement();
|
DataPropertyStatement dps = makeStatement();
|
||||||
RequestedAction action = new DropDataPropStmt(dps);
|
RequestedAction action = new DropDataPropertyStatement(dps);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class DataPropertyStatementTemplateModel extends PropertyStatementTemplat
|
||||||
|
|
||||||
// Determine whether the statement can be edited
|
// Determine whether the statement can be edited
|
||||||
DataPropertyStatement dps = makeStatement();
|
DataPropertyStatement dps = makeStatement();
|
||||||
RequestedAction action = new EditDataPropStmt(dps);
|
RequestedAction action = new EditDataPropertyStatement(dps);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
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.AddDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
|
@ -77,7 +77,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 AddDataPropertyStatement(subjectUri, propertyUri, RequestActionConstants.SOME_LITERAL, null, null);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
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.EditDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -62,7 +62,7 @@ public class NameStatementTemplateModel extends PropertyStatementTemplateModel {
|
||||||
private String makeEditUrl(Literal literal) {
|
private String makeEditUrl(Literal literal) {
|
||||||
// Determine whether the statement can be edited
|
// Determine whether the statement can be edited
|
||||||
DataPropertyStatement dps = makeStatement(literal);
|
DataPropertyStatement dps = makeStatement(literal);
|
||||||
RequestedAction action = new EditDataPropStmt(dps);
|
RequestedAction action = new EditDataPropertyStatement(dps);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
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.DropObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
@ -55,7 +55,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the statement can be deleted
|
// Determine whether the statement can be deleted
|
||||||
RequestedAction action = new DropObjectPropStmt(subjectUri, propertyUri, objectUri);
|
RequestedAction action = new DropObjectPropertyStatement(subjectUri, propertyUri, objectUri);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the statement can be edited
|
// Determine whether the statement can be edited
|
||||||
RequestedAction action = new EditObjPropStmt(ops);
|
RequestedAction action = new EditObjectPropertyStatement(ops);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
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.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
|
@ -108,7 +108,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 AddObjectPropertyStatement(subjectUri, propertyUri, RequestActionConstants.SOME_URI);
|
||||||
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyIface;
|
||||||
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.AbstractDataPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractDataPropertyStatementAction;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyAction;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the function of PolicyHelper in authorizing statements and models.
|
* Test the function of PolicyHelper in authorizing statements and models.
|
||||||
|
@ -235,17 +235,17 @@ public class PolicyHelper_StatementsTest extends AbstractTestClass {
|
||||||
@Override
|
@Override
|
||||||
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
||||||
RequestedAction whatToAuth) {
|
RequestedAction whatToAuth) {
|
||||||
if (whatToAuth instanceof AbstractDataPropertyAction) {
|
if (whatToAuth instanceof AbstractDataPropertyStatementAction) {
|
||||||
return isAuthorized((AbstractDataPropertyAction) whatToAuth);
|
return isAuthorized((AbstractDataPropertyStatementAction) whatToAuth);
|
||||||
} else if (whatToAuth instanceof AbstractObjectPropertyAction) {
|
} else if (whatToAuth instanceof AbstractObjectPropertyStatementAction) {
|
||||||
return isAuthorized((AbstractObjectPropertyAction) whatToAuth);
|
return isAuthorized((AbstractObjectPropertyStatementAction) whatToAuth);
|
||||||
} else {
|
} else {
|
||||||
return inconclusive();
|
return inconclusive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PolicyDecision isAuthorized(
|
private PolicyDecision isAuthorized(
|
||||||
AbstractDataPropertyAction whatToAuth) {
|
AbstractDataPropertyStatementAction whatToAuth) {
|
||||||
if ((APPROVED_SUBJECT_URI.equals(whatToAuth.getSubjectUri()))
|
if ((APPROVED_SUBJECT_URI.equals(whatToAuth.getSubjectUri()))
|
||||||
&& (APPROVED_PREDICATE_URI.equals(whatToAuth
|
&& (APPROVED_PREDICATE_URI.equals(whatToAuth
|
||||||
.getPredicateUri()))) {
|
.getPredicateUri()))) {
|
||||||
|
@ -256,7 +256,7 @@ public class PolicyHelper_StatementsTest extends AbstractTestClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PolicyDecision isAuthorized(
|
private PolicyDecision isAuthorized(
|
||||||
AbstractObjectPropertyAction whatToAuth) {
|
AbstractObjectPropertyStatementAction whatToAuth) {
|
||||||
if ((APPROVED_SUBJECT_URI.equals(whatToAuth.uriOfSubject))
|
if ((APPROVED_SUBJECT_URI.equals(whatToAuth.uriOfSubject))
|
||||||
&& (APPROVED_PREDICATE_URI
|
&& (APPROVED_PREDICATE_URI
|
||||||
.equals(whatToAuth.uriOfPredicate))
|
.equals(whatToAuth.uriOfPredicate))
|
||||||
|
|
|
@ -31,11 +31,11 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.CreateOwlC
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineDataProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.DefineObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ontology.RemoveOwlClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||||
|
@ -88,75 +88,75 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
||||||
"http://mannlib.cornell.edu/bad#prp0020" });
|
"http://mannlib.cornell.edu/bad#prp0020" });
|
||||||
PropertyRestrictionPolicyHelper.setBean(ctx, prph);
|
PropertyRestrictionPolicyHelper.setBean(ctx, prph);
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
"http://mannlib.cornell.edu/bad#prp234", SAFE_RESOURCE);
|
"http://mannlib.cornell.edu/bad#prp234", SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SAFE_RESOURCE,
|
whatToAuth = new AddObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
"http://mannlib.cornell.edu/bad#prp234", SELFEDITOR_URI);
|
"http://mannlib.cornell.edu/bad#prp234", SELFEDITOR_URI);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
"http://mannlib.cornell.edu/bad#prp999", SAFE_RESOURCE);
|
"http://mannlib.cornell.edu/bad#prp999", SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SAFE_RESOURCE,
|
whatToAuth = new AddObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
"http://mannlib.cornell.edu/bad#prp999", SELFEDITOR_URI);
|
"http://mannlib.cornell.edu/bad#prp999", SELFEDITOR_URI);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SELFEDITOR_URI);
|
SAFE_PREDICATE, SELFEDITOR_URI);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI, UNSAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
UNSAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
// now with dataprop statements
|
// now with dataprop statements
|
||||||
whatToAuth = new AddDataPropStmt(SELFEDITOR_URI,
|
whatToAuth = new AddDataPropertyStatement(SELFEDITOR_URI,
|
||||||
"http://mannlib.cornell.edu/bad#prp234", "someString", null,
|
"http://mannlib.cornell.edu/bad#prp234", "someString", null,
|
||||||
null);
|
null);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddDataPropStmt(SELFEDITOR_URI,
|
whatToAuth = new AddDataPropertyStatement(SELFEDITOR_URI,
|
||||||
"http://mannlib.cornell.edu/bad#prp999", "someString", null,
|
"http://mannlib.cornell.edu/bad#prp999", "someString", null,
|
||||||
null);
|
null);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddDataPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new AddDataPropertyStatement(SELFEDITOR_URI,
|
||||||
"someString", null, null);
|
SAFE_PREDICATE, "someString", null, null);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddDataPropStmt(SELFEDITOR_URI, UNSAFE_PREDICATE,
|
whatToAuth = new AddDataPropertyStatement(SELFEDITOR_URI,
|
||||||
"someString", null, null);
|
UNSAFE_PREDICATE, "someString", null, null);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVisitIdentifierBundleAddObjectPropStmt() {
|
public void testVisitIdentifierBundleAddObjectPropStmt() {
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SELFEDITOR_URI);
|
SAFE_PREDICATE, SELFEDITOR_URI);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
// this is the case where the editor is not part of the stmt
|
// this is the case where the editor is not part of the stmt
|
||||||
whatToAuth = new AddObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI, UNSAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
UNSAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new AddObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
UNSAFE_RESOURCE);
|
SAFE_PREDICATE, UNSAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,25 +173,25 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
||||||
//
|
//
|
||||||
@Test
|
@Test
|
||||||
public void testVisitIdentifierBundleDropObjectPropStmt() {
|
public void testVisitIdentifierBundleDropObjectPropStmt() {
|
||||||
whatToAuth = new DropObjectPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new DropObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SELFEDITOR_URI);
|
SAFE_PREDICATE, SELFEDITOR_URI);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
// this is the case where the editor is not part of the stmt
|
// this is the case where the editor is not part of the stmt
|
||||||
whatToAuth = new DropObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new DropObjectPropStmt(SELFEDITOR_URI, UNSAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
UNSAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new DropObjectPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
UNSAFE_RESOURCE);
|
SAFE_PREDICATE, UNSAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,50 +219,50 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
||||||
dps.setIndividualURI(SELFEDITOR_URI);
|
dps.setIndividualURI(SELFEDITOR_URI);
|
||||||
dps.setDatapropURI(SAFE_PREDICATE);
|
dps.setDatapropURI(SAFE_PREDICATE);
|
||||||
dps.setData("junk");
|
dps.setData("junk");
|
||||||
whatToAuth = new EditDataPropStmt(dps);
|
whatToAuth = new EditDataPropertyStatement(dps);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
dps = new DataPropertyStatementImpl();
|
dps = new DataPropertyStatementImpl();
|
||||||
dps.setIndividualURI(SELFEDITOR_URI);
|
dps.setIndividualURI(SELFEDITOR_URI);
|
||||||
dps.setDatapropURI(UNSAFE_PREDICATE);
|
dps.setDatapropURI(UNSAFE_PREDICATE);
|
||||||
dps.setData("junk");
|
dps.setData("junk");
|
||||||
whatToAuth = new EditDataPropStmt(dps);
|
whatToAuth = new EditDataPropertyStatement(dps);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
dps = new DataPropertyStatementImpl();
|
dps = new DataPropertyStatementImpl();
|
||||||
dps.setIndividualURI(UNSAFE_RESOURCE);
|
dps.setIndividualURI(UNSAFE_RESOURCE);
|
||||||
dps.setDatapropURI(SAFE_PREDICATE);
|
dps.setDatapropURI(SAFE_PREDICATE);
|
||||||
whatToAuth = new EditDataPropStmt(dps);
|
whatToAuth = new EditDataPropertyStatement(dps);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
dps = new DataPropertyStatementImpl();
|
dps = new DataPropertyStatementImpl();
|
||||||
dps.setIndividualURI(SAFE_RESOURCE);
|
dps.setIndividualURI(SAFE_RESOURCE);
|
||||||
dps.setDatapropURI(SAFE_PREDICATE);
|
dps.setDatapropURI(SAFE_PREDICATE);
|
||||||
whatToAuth = new EditDataPropStmt(dps);
|
whatToAuth = new EditDataPropertyStatement(dps);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testVisitIdentifierBundleEditObjPropStmt() {
|
public void testVisitIdentifierBundleEditObjPropStmt() {
|
||||||
whatToAuth = new EditObjPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new EditObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new EditObjPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new EditObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SELFEDITOR_URI);
|
SAFE_PREDICATE, SELFEDITOR_URI);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
// this is the case where the editor is not part of the stmt
|
// this is the case where the editor is not part of the stmt
|
||||||
whatToAuth = new EditObjPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new EditObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new EditObjPropStmt(SELFEDITOR_URI, UNSAFE_PREDICATE,
|
whatToAuth = new EditObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
UNSAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
|
|
||||||
whatToAuth = new EditObjPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new EditObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
UNSAFE_RESOURCE);
|
SAFE_PREDICATE, UNSAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,24 +273,24 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
||||||
@Test
|
@Test
|
||||||
public void twoSEIsFindObjectPropertySubject() {
|
public void twoSEIsFindObjectPropertySubject() {
|
||||||
setUpTwoSEIs();
|
setUpTwoSEIs();
|
||||||
whatToAuth = new DropObjectPropStmt(SELFEDITOR_URI, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SELFEDITOR_URI,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void twoSEIsFindObjectPropertyObject() {
|
public void twoSEIsFindObjectPropertyObject() {
|
||||||
setUpTwoSEIs();
|
setUpTwoSEIs();
|
||||||
whatToAuth = new DropObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SELFEDITOR_URI);
|
SAFE_PREDICATE, SELFEDITOR_URI);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void twoSEIsDontFindInObjectProperty() {
|
public void twoSEIsDontFindInObjectProperty() {
|
||||||
setUpTwoSEIs();
|
setUpTwoSEIs();
|
||||||
whatToAuth = new DropObjectPropStmt(SAFE_RESOURCE, SAFE_PREDICATE,
|
whatToAuth = new DropObjectPropertyStatement(SAFE_RESOURCE,
|
||||||
SAFE_RESOURCE);
|
SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
||||||
dps.setIndividualURI(SELFEDITOR_URI);
|
dps.setIndividualURI(SELFEDITOR_URI);
|
||||||
dps.setDatapropURI(SAFE_PREDICATE);
|
dps.setDatapropURI(SAFE_PREDICATE);
|
||||||
dps.setData("junk");
|
dps.setData("junk");
|
||||||
whatToAuth = new EditDataPropStmt(dps);
|
whatToAuth = new EditDataPropertyStatement(dps);
|
||||||
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(AUTHORIZED, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ public class SelfEditingPolicyTest extends AbstractTestClass {
|
||||||
dps.setIndividualURI(SAFE_RESOURCE);
|
dps.setIndividualURI(SAFE_RESOURCE);
|
||||||
dps.setDatapropURI(SAFE_PREDICATE);
|
dps.setDatapropURI(SAFE_PREDICATE);
|
||||||
dps.setData("junk");
|
dps.setData("junk");
|
||||||
whatToAuth = new EditDataPropStmt(dps);
|
whatToAuth = new EditDataPropertyStatement(dps);
|
||||||
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
assertDecision(INCONCLUSIVE, policy.isAuthorized(ids, whatToAuth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.common.HasProfile;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionPolicyHelper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjPropStmt;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
@ -112,8 +112,8 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nullIdentifierBundle() {
|
public void nullIdentifierBundle() {
|
||||||
AddObjectPropStmt whatToAuth = new AddObjectPropStmt(SELFEDITOR_URI,
|
AddObjectPropertyStatement whatToAuth = new AddObjectPropertyStatement(
|
||||||
SAFE_PREDICATE, SAFE_RESOURCE);
|
SELFEDITOR_URI, SAFE_PREDICATE, SAFE_RESOURCE);
|
||||||
PolicyDecision dec = policy.isAuthorized(null, whatToAuth);
|
PolicyDecision dec = policy.isAuthorized(null, whatToAuth);
|
||||||
Assert.assertNotNull(dec);
|
Assert.assertNotNull(dec);
|
||||||
Assert.assertEquals(Authorization.INCONCLUSIVE, dec.getAuthorized());
|
Assert.assertEquals(Authorization.INCONCLUSIVE, dec.getAuthorized());
|
||||||
|
@ -261,13 +261,13 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an {@link AddObjectPropStmt}, test it, and compare to expected
|
* Create an {@link AddObjectPropertyStatement}, test it, and compare to
|
||||||
* results.
|
* expected results.
|
||||||
*/
|
*/
|
||||||
private void assertAddObjectPropStmt(String uriOfSub, String uriOfPred,
|
private void assertAddObjectPropStmt(String uriOfSub, String uriOfPred,
|
||||||
String uriOfObj, Authorization expectedAuthorization) {
|
String uriOfObj, Authorization expectedAuthorization) {
|
||||||
AddObjectPropStmt whatToAuth = new AddObjectPropStmt(uriOfSub,
|
AddObjectPropertyStatement whatToAuth = new AddObjectPropertyStatement(
|
||||||
uriOfPred, uriOfObj);
|
uriOfSub, uriOfPred, uriOfObj);
|
||||||
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
||||||
log.debug(dec);
|
log.debug(dec);
|
||||||
Assert.assertNotNull(dec);
|
Assert.assertNotNull(dec);
|
||||||
|
@ -275,13 +275,13 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an {@link EditObjPropStmt}, test it, and compare to expected
|
* Create an {@link EditObjectPropertyStatement}, test it, and compare to
|
||||||
* results.
|
* expected results.
|
||||||
*/
|
*/
|
||||||
private void assertEditObjPropStmt(String uriOfSub, String uriOfPred,
|
private void assertEditObjPropStmt(String uriOfSub, String uriOfPred,
|
||||||
String uriOfObj, Authorization expectedAuthorization) {
|
String uriOfObj, Authorization expectedAuthorization) {
|
||||||
EditObjPropStmt whatToAuth = new EditObjPropStmt(uriOfSub, uriOfPred,
|
EditObjectPropertyStatement whatToAuth = new EditObjectPropertyStatement(
|
||||||
uriOfObj);
|
uriOfSub, uriOfPred, uriOfObj);
|
||||||
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
||||||
log.debug(dec);
|
log.debug(dec);
|
||||||
Assert.assertNotNull(dec);
|
Assert.assertNotNull(dec);
|
||||||
|
@ -289,8 +289,8 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an {@link EditDataPropStmt}, test it, and compare to expected
|
* Create an {@link EditDataPropertyStatement}, test it, and compare to
|
||||||
* results.
|
* expected results.
|
||||||
*/
|
*/
|
||||||
private void assertEditDataPropStmt(String individualURI,
|
private void assertEditDataPropStmt(String individualURI,
|
||||||
String datapropURI, String data, Authorization expectedAuthorization) {
|
String datapropURI, String data, Authorization expectedAuthorization) {
|
||||||
|
@ -299,7 +299,8 @@ public class SelfEditingPolicy_2_Test extends AbstractTestClass {
|
||||||
dps.setDatapropURI(datapropURI);
|
dps.setDatapropURI(datapropURI);
|
||||||
dps.setData(data);
|
dps.setData(data);
|
||||||
|
|
||||||
EditDataPropStmt whatToAuth = new EditDataPropStmt(dps);
|
EditDataPropertyStatement whatToAuth = new EditDataPropertyStatement(
|
||||||
|
dps);
|
||||||
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
PolicyDecision dec = policy.isAuthorized(ids, whatToAuth);
|
||||||
log.debug(dec);
|
log.debug(dec);
|
||||||
Assert.assertNotNull(dec);
|
Assert.assertNotNull(dec);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue