From 1aef7ddcb756d3d539f39afdf235d3213c352866 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 23 Jun 2011 16:17:46 +0000 Subject: [PATCH] NIHVIVO-2720 Add methods to PolicyHelper to check authorization for adding or dropping Jena statements, or entire Jena models. --- .../requestedAction/propstmt/AddDataPropStmt.java | 9 +++++++++ .../requestedAction/propstmt/DropDataPropStmt.java | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/AddDataPropStmt.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/AddDataPropStmt.java index 4f7ed015c..ef2170321 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/AddDataPropStmt.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/AddDataPropStmt.java @@ -2,6 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt; +import com.hp.hpl.jena.rdf.model.Literal; + /** Should we allow the user to add this DataPropertyStatement? */ public class AddDataPropStmt extends AbstractDataPropertyAction { protected String data; @@ -15,6 +17,13 @@ public class AddDataPropStmt extends AbstractDataPropertyAction { this.lang = lang; } + public AddDataPropStmt(String subjectUri, String predicateUri, Literal literal) { + super(subjectUri, predicateUri); + this.data= literal.getValue().toString(); + this.dataType = literal.getDatatypeURI(); + this.lang = literal.getLanguage(); + } + public String getData() { return data; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/DropDataPropStmt.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/DropDataPropStmt.java index 685b84c37..44af36e89 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/DropDataPropStmt.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/auth/requestedAction/propstmt/DropDataPropStmt.java @@ -2,6 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt; +import com.hp.hpl.jena.rdf.model.Literal; + import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl; @@ -23,7 +25,15 @@ public class DropDataPropStmt extends AbstractDataPropertyAction { dataPropStmt.setData(data); } - public String data(){ return dataPropStmt.getData(); } + public DropDataPropStmt(String subjectUri, String predicateUri, Literal data) { + super(subjectUri, predicateUri); + dataPropStmt = new DataPropertyStatementImpl(); + dataPropStmt.setIndividualURI(subjectUri); + dataPropStmt.setDatapropURI(predicateUri); + dataPropStmt.setData(data.getValue().toString()); + } + + public String data(){ return dataPropStmt.getData(); } public String lang(){ return dataPropStmt.getLanguage(); } public String datatype(){return dataPropStmt.getDatatypeURI(); }