NIHVIVO-1332 Add edit and delete links for data property statements
This commit is contained in:
parent
e5b43812f1
commit
c51f65c2ab
10 changed files with 116 additions and 47 deletions
|
@ -26,14 +26,13 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
import com.hp.hpl.jena.ontology.OntModel;
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord;
|
import edu.cornell.mannlib.vitro.webapp.controller.TabEntitiesController.PageRecord;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.SelectListGenerator;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.SelectListGenerator;
|
||||||
|
@ -202,13 +201,13 @@ public class JSONServlet extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getDataPropertyValue(Individual ind, DataProperty dp, WebappDaoFactory wdf){
|
String getDataPropertyValue(Individual ind, DataProperty dp, WebappDaoFactory wdf){
|
||||||
List<DataPropertyStatement> stmts = wdf.getDataPropertyStatementDao()
|
List<Literal> values = wdf.getDataPropertyStatementDao()
|
||||||
.getDataPropertyStatementsForIndividualByProperty(ind, dp);
|
.getDataPropertyValuesForIndividualByProperty(ind, dp);
|
||||||
if( stmts == null || stmts.isEmpty() )
|
if( values == null || values.isEmpty() )
|
||||||
return "";
|
return "";
|
||||||
else{
|
else{
|
||||||
if( stmts.get(0) != null )
|
if( values.get(0) != null )
|
||||||
return stmts.get(0).getData();
|
return values.get(0).getLexicalForm();
|
||||||
else
|
else
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
Individual individual = null;
|
Individual individual = null;
|
||||||
try {
|
try {
|
||||||
individual = getEntityFromRequest(vreq);
|
individual = getIndividualFromRequest(vreq);
|
||||||
} catch (Throwable th) {
|
} catch (Throwable th) {
|
||||||
return doHelp();
|
return doHelp();
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
@return null on failure.
|
@return null on failure.
|
||||||
*/
|
*/
|
||||||
public static Individual getEntityFromRequest(VitroRequest vreq) {
|
public static Individual getIndividualFromRequest(VitroRequest vreq) {
|
||||||
String netIdStr = null;
|
String netIdStr = null;
|
||||||
Individual entity = null;
|
Individual entity = null;
|
||||||
IndividualDao iwDao = vreq.getWebappDaoFactory().getIndividualDao();
|
IndividualDao iwDao = vreq.getWebappDaoFactory().getIndividualDao();
|
||||||
|
|
|
@ -5,6 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.dao;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
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;
|
||||||
|
@ -38,7 +40,7 @@ public interface DataPropertyStatementDao {
|
||||||
|
|
||||||
int insertNewDataPropertyStatement(DataPropertyStatement dataPropertyStatement );
|
int insertNewDataPropertyStatement(DataPropertyStatement dataPropertyStatement );
|
||||||
|
|
||||||
List<DataPropertyStatement> getDataPropertyStatementsForIndividualByProperty(Individual subject, DataProperty property);
|
List<Literal> getDataPropertyValuesForIndividualByProperty(Individual subject, DataProperty property);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,17 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
package edu.cornell.mannlib.vitro.webapp.dao.filtering;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.*;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
|
||||||
import net.sf.jga.fn.UnaryFunctor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
|
|
||||||
class DataPropertyStatementDaoFiltering extends BaseFiltering implements DataPropertyStatementDao{
|
class DataPropertyStatementDaoFiltering extends BaseFiltering implements DataPropertyStatementDao{
|
||||||
final DataPropertyStatementDao innerDataPropertyStatementDao;
|
final DataPropertyStatementDao innerDataPropertyStatementDao;
|
||||||
final VitroFilters filters;
|
final VitroFilters filters;
|
||||||
|
@ -92,8 +95,8 @@ class DataPropertyStatementDaoFiltering extends BaseFiltering implements DataPro
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// RY What about filtering?
|
// RY What about filtering?
|
||||||
public List<DataPropertyStatement> getDataPropertyStatementsForIndividualByProperty(Individual subject, DataProperty property) {
|
public List<Literal> getDataPropertyValuesForIndividualByProperty(Individual subject, DataProperty property) {
|
||||||
return innerDataPropertyStatementDao.getDataPropertyStatementsForIndividualByProperty(subject, property);
|
return innerDataPropertyStatementDao.getDataPropertyValuesForIndividualByProperty(subject, property);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -289,7 +289,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
/*
|
/*
|
||||||
* SPARQL-based method for getting the individual's values for a single data property.
|
* SPARQL-based method for getting the individual's values for a single data property.
|
||||||
*/
|
*/
|
||||||
public List<DataPropertyStatement> getDataPropertyStatementsForIndividualByProperty(Individual subject, DataProperty property) {
|
public List<Literal> getDataPropertyValuesForIndividualByProperty(Individual subject, DataProperty property) {
|
||||||
log.debug("dataPropertyValueQueryString:\n" + dataPropertyValueQueryString);
|
log.debug("dataPropertyValueQueryString:\n" + dataPropertyValueQueryString);
|
||||||
log.debug("dataPropertyValueQuery:\n" + dataPropertyValueQuery);
|
log.debug("dataPropertyValueQuery:\n" + dataPropertyValueQuery);
|
||||||
|
|
||||||
|
@ -301,8 +301,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
bindings.add("property", ResourceFactory.createResource(propertyUri));
|
bindings.add("property", ResourceFactory.createResource(propertyUri));
|
||||||
|
|
||||||
// Run the SPARQL query to get the properties
|
// Run the SPARQL query to get the properties
|
||||||
List<DataPropertyStatement> statements =
|
List<Literal> values = new ArrayList<Literal>();
|
||||||
new ArrayList<DataPropertyStatement>();
|
|
||||||
DatasetWrapper w = dwf.getDatasetWrapper();
|
DatasetWrapper w = dwf.getDatasetWrapper();
|
||||||
Dataset dataset = w.getDataset();
|
Dataset dataset = w.getDataset();
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||||
|
@ -314,14 +313,12 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
QuerySolution sol = results.next();
|
QuerySolution sol = results.next();
|
||||||
Literal value = sol.getLiteral("value");
|
Literal value = sol.getLiteral("value");
|
||||||
DataPropertyStatement dps = new DataPropertyStatementImpl(
|
values.add(value);
|
||||||
subjectUri, propertyUri, value.getLexicalForm());
|
|
||||||
statements.add(dps);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
dataset.getLock().leaveCriticalSection();
|
dataset.getLock().leaveCriticalSection();
|
||||||
w.close();
|
w.close();
|
||||||
}
|
}
|
||||||
return statements;
|
return values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,37 +2,103 @@
|
||||||
|
|
||||||
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.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;
|
||||||
|
|
||||||
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
|
|
||||||
|
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.EditDataPropStmt;
|
||||||
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.controller.freemarker.UrlBuilder;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||||
|
|
||||||
public class DataPropertyStatementTemplateModel extends BaseTemplateModel {
|
public class DataPropertyStatementTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(DataPropertyStatementTemplateModel.class);
|
private static final Log log = LogFactory.getLog(DataPropertyStatementTemplateModel.class);
|
||||||
|
private static final String EDIT_PATH = "edit/editDatapropStmtRequestDispatch.jsp";
|
||||||
|
|
||||||
private DataPropertyStatement statement;
|
private static enum EditAccess {
|
||||||
private EditingPolicyHelper policyHelper;
|
EDIT, DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
DataPropertyStatementTemplateModel(DataPropertyStatement statement, EditingPolicyHelper policyHelper) {
|
private Literal value;
|
||||||
this.statement = statement;
|
|
||||||
this.policyHelper = policyHelper;
|
// Used for editing
|
||||||
|
private String subjectUri = null;
|
||||||
|
private String propertyUri = null;
|
||||||
|
private List<EditAccess> editAccessList = null;
|
||||||
|
private String dataPropHash = null;
|
||||||
|
|
||||||
|
DataPropertyStatementTemplateModel(String subjectUri, String propertyUri,
|
||||||
|
Literal value2, EditingPolicyHelper policyHelper) {
|
||||||
|
|
||||||
|
this.value = value2;
|
||||||
|
|
||||||
|
if (policyHelper != null) {
|
||||||
|
this.subjectUri = subjectUri;
|
||||||
|
this.propertyUri = propertyUri;
|
||||||
|
|
||||||
|
DataPropertyStatement dps = new DataPropertyStatementImpl(subjectUri, propertyUri, value.getLexicalForm());
|
||||||
|
// Language and datatype are needed to get the correct hash value
|
||||||
|
dps.setLanguage(value.getLanguage());
|
||||||
|
dps.setDatatypeURI(value.getDatatypeURI());
|
||||||
|
this.dataPropHash = String.valueOf(RdfLiteralHash.makeRdfLiteralHash(dps));
|
||||||
|
|
||||||
|
editAccessList = new ArrayList<EditAccess>();
|
||||||
|
|
||||||
|
// Determine whether the statement can be edited
|
||||||
|
RequestedAction action = new EditDataPropStmt(dps);
|
||||||
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
|
editAccessList.add(EditAccess.EDIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine whether the statement can be deleted
|
||||||
|
action = new DropDataPropStmt(dps);
|
||||||
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
|
editAccessList.add(EditAccess.DELETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Access methods for templates */
|
/* Access methods for templates */
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return statement.getData();
|
return value.getLexicalForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEditUrl() {
|
public String getEditUrl() {
|
||||||
String editUrl = "";
|
String editUrl = "";
|
||||||
|
if (editAccessList.contains(EditAccess.EDIT)) {
|
||||||
|
ParamMap params = new ParamMap(
|
||||||
|
"subjectUri", subjectUri,
|
||||||
|
"predicateUri", propertyUri,
|
||||||
|
"datapropKey", dataPropHash);
|
||||||
|
if (! editAccessList.contains(EditAccess.DELETE)) {
|
||||||
|
params.put("deleteProhibited", "prohibited");
|
||||||
|
}
|
||||||
|
editUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||||
|
}
|
||||||
return editUrl;
|
return editUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDeleteUrl() {
|
public String getDeleteUrl() {
|
||||||
String deleteUrl = "";
|
String deleteUrl = "";
|
||||||
|
if (editAccessList.contains(EditAccess.DELETE)) {
|
||||||
|
ParamMap params = new ParamMap(
|
||||||
|
"subjectUri", subjectUri,
|
||||||
|
"predicateUri", propertyUri,
|
||||||
|
"datapropKey", dataPropHash,
|
||||||
|
"cmd", "delete");
|
||||||
|
deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||||
|
}
|
||||||
return deleteUrl;
|
return deleteUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,12 @@ 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;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.Authorization;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.PolicyDecision;
|
|
||||||
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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
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.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;
|
||||||
|
@ -38,18 +37,17 @@ public class DataPropertyTemplateModel extends PropertyTemplateModel {
|
||||||
// Determine whether a new statement can be added
|
// Determine whether a new statement can be added
|
||||||
if (policyHelper != null) {
|
if (policyHelper != null) {
|
||||||
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
|
RequestedAction action = new AddDataPropStmt(subjectUri, propertyUri,RequestActionConstants.SOME_LITERAL, null, null);
|
||||||
PolicyDecision decision = policyHelper.getPolicyDecision(action);
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
if( decision != null && decision.getAuthorized() == Authorization.AUTHORIZED ) {
|
|
||||||
addAccess = true;
|
addAccess = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the data property statements via a sparql query
|
// Get the data property statements via a sparql query
|
||||||
DataPropertyStatementDao dpDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
|
DataPropertyStatementDao dpDao = vreq.getWebappDaoFactory().getDataPropertyStatementDao();
|
||||||
List<DataPropertyStatement> dpStatements = dpDao.getDataPropertyStatementsForIndividualByProperty(subject, dp);
|
List<Literal> values = dpDao.getDataPropertyValuesForIndividualByProperty(subject, dp);
|
||||||
statements = new ArrayList<DataPropertyStatementTemplateModel>(dpStatements.size());
|
statements = new ArrayList<DataPropertyStatementTemplateModel>(values.size());
|
||||||
for (DataPropertyStatement dps : dpStatements) {
|
for (Literal value : values) {
|
||||||
statements.add(new DataPropertyStatementTemplateModel(dps, policyHelper));
|
statements.add(new DataPropertyStatementTemplateModel(subjectUri, propertyUri, value, policyHelper));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.identifier.ServletIdentifierBundleF
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyList;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyList;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.RequestPolicyList;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.RequestPolicyList;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||||
|
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;
|
||||||
|
@ -52,7 +53,13 @@ public class EditingPolicyHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PolicyDecision getPolicyDecision(RequestedAction action) {
|
protected boolean isAuthorizedAction(RequestedAction action) {
|
||||||
|
PolicyDecision decision = getPolicyDecision(action);
|
||||||
|
return (decision != null && decision.getAuthorized() == Authorization.AUTHORIZED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PolicyDecision getPolicyDecision(RequestedAction action) {
|
||||||
return policy.isAuthorized(ids, action);
|
return policy.isAuthorized(ids, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,15 +55,13 @@ public class ObjectPropertyStatementTemplateModel extends BaseTemplateModel {
|
||||||
|
|
||||||
// Determine whether the statement can be edited
|
// Determine whether the statement can be edited
|
||||||
RequestedAction action = new EditObjPropStmt(objectPropertyStatement);
|
RequestedAction action = new EditObjPropStmt(objectPropertyStatement);
|
||||||
PolicyDecision decision = policyHelper.getPolicyDecision(action);
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
if (decision != null && decision.getAuthorized() == Authorization.AUTHORIZED) {
|
|
||||||
editAccessList.add(EditAccess.EDIT);
|
editAccessList.add(EditAccess.EDIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the statement can be deleted
|
// Determine whether the statement can be deleted
|
||||||
action = new DropObjectPropStmt(subjectUri, propertyUri, objectUri);
|
action = new DropObjectPropStmt(subjectUri, propertyUri, objectUri);
|
||||||
decision = policyHelper.getPolicyDecision(action);
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
if (decision != null && decision.getAuthorized() == Authorization.AUTHORIZED) {
|
|
||||||
editAccessList.add(EditAccess.DELETE);
|
editAccessList.add(EditAccess.DELETE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,8 +88,7 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
// Determine whether a new statement can be added
|
// Determine whether a new statement can be added
|
||||||
if (policyHelper != null) {
|
if (policyHelper != null) {
|
||||||
RequestedAction action = new AddObjectPropStmt(subjectUri, propertyUri, RequestActionConstants.SOME_URI);
|
RequestedAction action = new AddObjectPropStmt(subjectUri, propertyUri, RequestActionConstants.SOME_URI);
|
||||||
PolicyDecision decision = policyHelper.getPolicyDecision(action);
|
if (policyHelper.isAuthorizedAction(action)) {
|
||||||
if( decision != null && decision.getAuthorized() == Authorization.AUTHORIZED ) {
|
|
||||||
addAccess = true;
|
addAccess = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue