Merge branch 'maint-rel-1.6' into feature/orcid

This commit is contained in:
Jim Blake 2014-04-01 16:37:26 -04:00
commit b038902ee7
74 changed files with 2375 additions and 490 deletions

View file

@ -15,8 +15,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObje
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
@ -112,11 +110,9 @@ public class DisplayByRolePermission extends Permission {
* subject, its predicate, and its object.
*/
private boolean isAuthorized(DisplayObjectPropertyStatement action) {
ObjectPropertyStatement stmt = action.getObjectPropertyStatement();
String subjectUri = stmt.getSubjectURI();
String objectUri = stmt.getObjectURI();
Property op = (stmt.getProperty() != null)
? stmt.getProperty() : new Property(stmt.getPropertyURI());
String subjectUri = action.getSubjectUri();
String objectUri = action.getObjectUri();
Property op = action.getProperty();
return canDisplayResource(subjectUri)
&& canDisplayPredicate(op)
&& canDisplayResource(objectUri);

View file

@ -152,6 +152,7 @@ public class PermissionRegistry {
permissions.addAll(SimplePermission.getAllInstances());
permissions.addAll(createDisplayByRolePermissions(ctx));
permissions.addAll(createEditByRolePermissions(ctx));
permissions.addAll(createPublishByRolePermissions(ctx));
PermissionRegistry.createRegistry(ctx, permissions);
@ -203,5 +204,24 @@ public class PermissionRegistry {
public void contextDestroyed(ServletContextEvent sce) {
sce.getServletContext().removeAttribute(ATTRIBUTE_NAME);
}
/**
* There is no PublishByRolePermission for self-editors. They get the
* same rights as PUBLIC. Other permissions give them their self-editing
* privileges.
*/
private Collection<Permission> createPublishByRolePermissions(
ServletContext ctx) {
List<Permission> list = new ArrayList<Permission>();
list.add(new PublishByRolePermission("Admin", RoleLevel.DB_ADMIN,
ctx));
list.add(new PublishByRolePermission("Curator", RoleLevel.CURATOR,
ctx));
list.add(new PublishByRolePermission("Editor", RoleLevel.EDITOR,
ctx));
list.add(new PublishByRolePermission("Public", RoleLevel.PUBLIC,
ctx));
return list;
}
}
}

View file

@ -0,0 +1,133 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.auth.permissions;
import javax.servlet.ServletContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.publish.PublishDataProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishObjectProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
* Is the user authorized to publish properties that are marked as restricted to
* a certain "Role Level"?
*/
public class PublishByRolePermission extends Permission {
private static final Log log = LogFactory
.getLog(PublishByRolePermission.class);
public static final String NAMESPACE = "java:"
+ PublishByRolePermission.class.getName() + "#";
private final String roleName;
private final RoleLevel roleLevel;
private final ServletContext ctx;
public PublishByRolePermission(String roleName, RoleLevel roleLevel,
ServletContext ctx) {
super(NAMESPACE + roleName);
if (roleName == null) {
throw new NullPointerException("role may not be null.");
}
if (roleLevel == null) {
throw new NullPointerException("roleLevel may not be null.");
}
if (ctx == null) {
throw new NullPointerException("context may not be null.");
}
this.roleName = roleName;
this.roleLevel = roleLevel;
this.ctx = ctx;
}
@Override
public boolean isAuthorized(RequestedAction whatToAuth) {
boolean result;
if (whatToAuth instanceof PublishDataProperty) {
result = isAuthorized((PublishDataProperty) whatToAuth);
} else if (whatToAuth instanceof PublishObjectProperty) {
result = isAuthorized((PublishObjectProperty) whatToAuth);
} else if (whatToAuth instanceof PublishDataPropertyStatement) {
result = isAuthorized((PublishDataPropertyStatement) whatToAuth);
} else if (whatToAuth instanceof PublishObjectPropertyStatement) {
result = isAuthorized((PublishObjectPropertyStatement) whatToAuth);
} else {
result = false;
}
if (result) {
log.debug(this + " authorizes " + whatToAuth);
} else {
log.debug(this + " does not authorize " + whatToAuth);
}
return result;
}
/**
* The user may publish this data property if they are allowed to publish
* its predicate.
*/
private boolean isAuthorized(PublishDataProperty action) {
String predicateUri = action.getDataProperty().getURI();
return canPublishPredicate(new Property(predicateUri));
}
/**
* The user may publish this object property if they are allowed to publish
* its predicate.
*/
private boolean isAuthorized(PublishObjectProperty action) {
return canPublishPredicate(action.getObjectProperty());
}
/**
* The user may publish this data property if they are allowed to publish
* its subject and its predicate.
*/
private boolean isAuthorized(PublishDataPropertyStatement action) {
String subjectUri = action.getSubjectUri();
String predicateUri = action.getPredicateUri();
return canPublishResource(subjectUri)
&& canPublishPredicate(new Property(predicateUri));
}
/**
* The user may publish this data property if they are allowed to publish
* its subject, its predicate, and its object.
*/
private boolean isAuthorized(PublishObjectPropertyStatement action) {
String subjectUri = action.getSubjectUri();
Property predicate = action.getPredicate();
String objectUri = action.getObjectUri();
return canPublishResource(subjectUri) && canPublishPredicate(predicate)
&& canPublishResource(objectUri);
}
private boolean canPublishResource(String resourceUri) {
return PropertyRestrictionPolicyHelper.getBean(ctx).canPublishResource(
resourceUri, this.roleLevel);
}
private boolean canPublishPredicate(Property predicate) {
return PropertyRestrictionPolicyHelper.getBean(ctx)
.canPublishPredicate(predicate, this.roleLevel);
}
@Override
public String toString() {
return "PublishByRolePermission['" + roleName + "']";
}
}

View file

@ -95,7 +95,7 @@ public class DisplayRestrictedDataToSelfPolicy implements PolicyIface {
String subjectUri = stmt.getIndividualURI();
Property predicate = new Property(stmt.getDatapropURI());
if (canDisplayResource(subjectUri) && canDisplayPredicate(predicate)
&& isAboutAssociatedIndividual(individuals, stmt)) {
&& isAboutAssociatedIndividual(individuals, subjectUri)) {
return authorized("user may view DataPropertyStatement "
+ subjectUri + " ==> " + predicate.getURI());
} else {
@ -112,19 +112,17 @@ public class DisplayRestrictedDataToSelfPolicy implements PolicyIface {
*/
private PolicyDecision isAuthorized(DisplayObjectPropertyStatement action,
Collection<String> individuals) {
ObjectPropertyStatement stmt = action.getObjectPropertyStatement();
String subjectUri = stmt.getSubjectURI();
String predicateUri = stmt.getPropertyURI();
String objectUri = stmt.getObjectURI();
if (canDisplayResource(subjectUri) && canDisplayPredicate(new Property
(predicateUri))
String subjectUri = action.getSubjectUri();
Property predicate = action.getProperty();
String objectUri = action.getObjectUri();
if (canDisplayResource(subjectUri) && canDisplayPredicate(predicate)
&& canDisplayResource(objectUri)
&& isAboutAssociatedIndividual(individuals, stmt)) {
&& isAboutAssociatedIndividual(individuals, subjectUri, objectUri)) {
return authorized("user may view ObjectPropertyStatement "
+ subjectUri + " ==> " + predicateUri + " ==> " + objectUri);
+ subjectUri + " ==> " + predicate.getURI() + " ==> " + objectUri);
} else {
return defaultDecision("user may not view ObjectPropertyStatement "
+ subjectUri + " ==> " + predicateUri + " ==> " + objectUri);
+ subjectUri + " ==> " + predicate.getURI() + " ==> " + objectUri);
}
}
@ -151,9 +149,9 @@ public class DisplayRestrictedDataToSelfPolicy implements PolicyIface {
}
private boolean isAboutAssociatedIndividual(Collection<String> selves,
DataPropertyStatement stmt) {
String subjectUri) {
for (String self : selves) {
if (self.equals(stmt.getIndividualURI())) {
if (self.equals(subjectUri)) {
return true;
}
}
@ -161,10 +159,9 @@ public class DisplayRestrictedDataToSelfPolicy implements PolicyIface {
}
private boolean isAboutAssociatedIndividual(Collection<String> selves,
ObjectPropertyStatement stmt) {
String subjectUri, String objectUri) {
for (String self : selves) {
if (self.equals(stmt.getSubjectURI())
|| self.equals(stmt.getObjectURI())) {
if (self.equals(subjectUri) || self.equals(objectUri)) {
return true;
}
}

View file

@ -2,6 +2,8 @@
package edu.cornell.mannlib.vitro.webapp.auth.policy;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_URI;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
@ -26,6 +28,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPro
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator;
@ -125,8 +128,7 @@ public class PolicyHelper {
}
Resource subject = stmt.getSubject();
edu.cornell.mannlib.vitro.webapp.beans.Property predicate = new edu.cornell.mannlib.vitro.webapp.beans.Property(
stmt.getPredicate().getURI());
com.hp.hpl.jena.rdf.model.Property predicate = stmt.getPredicate();
RDFNode objectNode = stmt.getObject();
if ((subject == null) || (predicate == null) || (objectNode == null)) {
return false;
@ -134,8 +136,11 @@ public class PolicyHelper {
RequestedAction action;
if (objectNode.isResource()) {
Property property = new Property(predicate.getURI());
property.setDomainVClassURI(SOME_URI);
property.setRangeVClassURI(SOME_URI);
action = new AddObjectPropertyStatement(modelToBeModified,
subject.getURI(), predicate, objectNode.asResource()
subject.getURI(), property, objectNode.asResource()
.getURI());
} else {
action = new AddDataPropertyStatement(modelToBeModified,
@ -158,8 +163,7 @@ public class PolicyHelper {
}
Resource subject = stmt.getSubject();
edu.cornell.mannlib.vitro.webapp.beans.Property predicate = new edu.cornell.mannlib.vitro.webapp.beans.Property();
predicate.setURI(stmt.getPredicate().getURI());
com.hp.hpl.jena.rdf.model.Property predicate = stmt.getPredicate();
RDFNode objectNode = stmt.getObject();
if ((subject == null) || (predicate == null) || (objectNode == null)) {
return false;
@ -167,8 +171,11 @@ public class PolicyHelper {
RequestedAction action;
if (objectNode.isResource()) {
Property property = new Property(predicate.getURI());
property.setDomainVClassURI(SOME_URI);
property.setRangeVClassURI(SOME_URI);
action = new DropObjectPropertyStatement(modelToBeModified,
subject.getURI(), predicate, objectNode.asResource()
subject.getURI(), property, objectNode.asResource()
.getURI());
} else {
action = new DropDataPropertyStatement(modelToBeModified,

View file

@ -48,7 +48,6 @@ public class ServletPolicyList {
PolicyList policies = getPolicyList(sc);
if (!policies.contains(policy)) {
policies.add(policy);
log.info("Added policy: " + policy.getClass().getSimpleName());
log.debug("Added policy: " + policy.toString());
} else {
log.warn("Ignored attempt to add redundant policy.");
@ -67,7 +66,6 @@ public class ServletPolicyList {
PolicyList policies = getPolicyList(sc);
if (!policies.contains(policy)) {
policies.add(0, policy);
log.info("Added policy at front: " + policy.getClass().getSimpleName());
log.debug("Added policy at front: " + policy.toString());
} else {
log.warn("Ignored attempt to add redundant policy.");

View file

@ -37,8 +37,9 @@ public class PropertyRestrictionListener implements ChangeListener {
@Override
public void doDeleted(Object oldObj, EditProcessObject epo) {
Property p = (Property) oldObj;
if (eitherRoleChanged(p.getHiddenFromDisplayBelowRoleLevel(),
p.getProhibitedFromUpdateBelowRoleLevel(), null, null)) {
if (anyRoleChanged(p.getHiddenFromDisplayBelowRoleLevel(),
p.getProhibitedFromUpdateBelowRoleLevel(),
p.getHiddenFromPublishBelowRoleLevel(), null, null, null)) {
log.debug("rebuilding the PropertyRestrictionPolicyHelper after deletion");
createAndSetBean();
}
@ -50,9 +51,10 @@ public class PropertyRestrictionListener implements ChangeListener {
@Override
public void doInserted(Object newObj, EditProcessObject epo) {
Property p = (Property) newObj;
if (eitherRoleChanged(null, null,
if (anyRoleChanged(null, null, null,
p.getHiddenFromDisplayBelowRoleLevel(),
p.getProhibitedFromUpdateBelowRoleLevel())) {
p.getProhibitedFromUpdateBelowRoleLevel(),
p.getHiddenFromPublishBelowRoleLevel())) {
log.debug("rebuilding the PropertyRestrictionPolicyHelper after insertion");
createAndSetBean();
}
@ -65,20 +67,24 @@ public class PropertyRestrictionListener implements ChangeListener {
public void doUpdated(Object oldObj, Object newObj, EditProcessObject epo) {
Property oldP = (Property) oldObj;
Property newP = (Property) newObj;
if (eitherRoleChanged(oldP.getHiddenFromDisplayBelowRoleLevel(),
if (anyRoleChanged(oldP.getHiddenFromDisplayBelowRoleLevel(),
oldP.getProhibitedFromUpdateBelowRoleLevel(),
oldP.getHiddenFromPublishBelowRoleLevel(),
newP.getHiddenFromDisplayBelowRoleLevel(),
newP.getProhibitedFromUpdateBelowRoleLevel())) {
newP.getProhibitedFromUpdateBelowRoleLevel(),
newP.getHiddenFromPublishBelowRoleLevel())) {
log.debug("rebuilding the PropertyRestrictionPolicyHelper after update");
createAndSetBean();
}
}
private boolean eitherRoleChanged(RoleLevel oldDisplayRole,
RoleLevel oldUpdateRole, RoleLevel newDisplayRole,
RoleLevel newUpdateRole) {
private boolean anyRoleChanged(RoleLevel oldDisplayRole,
RoleLevel oldUpdateRole, RoleLevel oldPublishRole,
RoleLevel newDisplayRole, RoleLevel newUpdateRole,
RoleLevel newPublishRole) {
return (!isTheSame(oldDisplayRole, newDisplayRole))
|| (!isTheSame(oldUpdateRole, newUpdateRole));
|| (!isTheSame(oldUpdateRole, newUpdateRole))
|| (!isTheSame(oldPublishRole, newPublishRole));
}
private boolean isTheSame(RoleLevel oldRole, RoleLevel newRole) {

View file

@ -19,12 +19,6 @@ import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.QuerySolution;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
@ -46,10 +40,10 @@ import edu.cornell.mannlib.vitro.webapp.utils.ApplicationConfigurationOntologyUt
/**
* Assists the role-based policies in determining whether a property or resource
* may be displayed or modified.
* may be displayed, modified, or published in linked open data.
*
* There is a bean in the context that holds the current threshold role levels
* for displaying and modifying restricted properties.
* for displaying, modifying, or publishing restricted properties.
*
* Create this bean after the Jena model is in place in the context.
*
@ -119,6 +113,8 @@ public class PropertyRestrictionPolicyHelper {
new HashMap<Pair<String, Pair<String,String>>, RoleLevel>();
Map<Pair<String, Pair<String,String>>, RoleLevel> modifyThresholdMap =
new HashMap<Pair<String, Pair<String,String>>, RoleLevel>();
Map<Pair<String, Pair<String,String>>, RoleLevel> publishThresholdMap =
new HashMap<Pair<String, Pair<String,String>>, RoleLevel>();
OntModel union = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM,
ModelFactory.createUnion(displayModel, model));
@ -126,15 +122,14 @@ public class PropertyRestrictionPolicyHelper {
populateThresholdMap(union, displayThresholdMap,
VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
populateThresholdMap(
union,
modifyThresholdMap,
populateThresholdMap(union, modifyThresholdMap,
VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
populateThresholdMap(union, publishThresholdMap,
VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
PropertyRestrictionPolicyHelper bean = new PropertyRestrictionPolicyHelper(
PROHIBITED_NAMESPACES, PERMITTED_EXCEPTIONS,
displayThresholdMap, modifyThresholdMap, displayModel);
displayThresholdMap, modifyThresholdMap, publishThresholdMap);
return bean;
}
@ -209,9 +204,14 @@ public class PropertyRestrictionPolicyHelper {
} else if (VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT
.equals(propertyUri)) {
role = faux.getHiddenFromDisplayBelowRoleLevel();
} else if (VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT
.equals(propertyUri)) {
role = faux.getHiddenFromPublishBelowRoleLevel();
}
if (role != null) {
log.debug("Putting D:" + faux.getDomainVClassURI() + " P:" + faux.getURI() + " R:" + faux.getRangeVClassURI() + " ==> L:" + role);
log.debug("Putting D:" + faux.getDomainVClassURI() + " P:"
+ faux.getURI() + " R:" + faux.getRangeVClassURI()
+ " ==> L:" + role);
map.put(new Pair<String,Pair<String,String>>(
faux.getDomainVClassURI(), new Pair<String,String>(
faux.getURI(), faux.getRangeVClassURI())), role);
@ -251,6 +251,12 @@ public class PropertyRestrictionPolicyHelper {
*/
private final Map<Pair<String, Pair<String,String>>, RoleLevel> modifyThresholdMap;
/**
* These URIs can be published only if the user's role is at least as high as
* the threshold role.
*/
private final Map<Pair<String, Pair<String,String>>, RoleLevel> publishThresholdMap;
/**
* Store unmodifiable versions of the inputs.
@ -263,19 +269,23 @@ public class PropertyRestrictionPolicyHelper {
Collection<String> modifyExceptionsAllowedUris,
Map<Pair<String, Pair<String,String>>, RoleLevel> displayThresholdMap,
Map<Pair<String, Pair<String,String>>, RoleLevel> modifyThresholdMap,
Model displayModel) {
Map<Pair<String, Pair<String,String>>, RoleLevel> publishThresholdMap) {
this.modifyProhibitedNamespaces = unmodifiable(modifyProhibitedNamespaces);
this.modifyExceptionsAllowedUris = unmodifiable(modifyExceptionsAllowedUris);
this.displayThresholdMap = displayThresholdMap;
this.modifyThresholdMap = modifyThresholdMap;
// this.displayThresholdMap = unmodifiable(displayThresholdMap);
// this.modifyThresholdMap = unmodifiable(modifyThresholdMap);
this.publishThresholdMap = publishThresholdMap;
// TODO: why are these no longer unmodifiable? Brian changed during the
// TODO: ISF integration.
// this.displayThresholdMap = unmodifiable(displayThresholdMap);
// this.modifyThresholdMap = unmodifiable(modifyThresholdMap);
if (log.isDebugEnabled()) {
log.debug("prohibited: " + this.modifyProhibitedNamespaces);
log.debug("exceptions: " + this.modifyExceptionsAllowedUris);
log.debug("display thresholds: " + this.displayThresholdMap);
log.debug("modify thresholds: " + this.modifyThresholdMap);
log.debug("publish thresholds: " + this.publishThresholdMap);
}
}
@ -341,6 +351,22 @@ public class PropertyRestrictionPolicyHelper {
return true;
}
/**
* Any resource can be published.
*
* (Someday we may want to implement publish restrictions based on VClass.)
*/
@SuppressWarnings("unused")
public boolean canPublishResource(String resourceUri, RoleLevel userRole) {
if (resourceUri == null) {
log.debug("can't publish resource: resourceUri was null");
return false;
}
log.debug("can publish resource '" + resourceUri + "'");
return true;
}
/**
* If display of a predicate is restricted, the user's role must be at least
* as high as the restriction level.
@ -408,6 +434,33 @@ public class PropertyRestrictionPolicyHelper {
return false;
}
/**
* If publishing of a predicate is restricted, the user's role must be at least
* as high as the restriction level.
*/
public boolean canPublishPredicate(Property predicate, RoleLevel userRole) {
if (predicate == null) {
log.debug("can't publish predicate: predicate was null");
return false;
}
RoleLevel publishThreshold = getThreshold(predicate, publishThresholdMap);
if (isAuthorized(userRole, publishThreshold)) {
log.debug("can publish predicate: '" + predicate.getURI() + "', domain="
+ predicate.getDomainVClassURI() + ", range="
+ predicate.getRangeVClassURI() + ", userRole="
+ userRole + ", thresholdRole=" + publishThreshold);
return true;
}
log.debug("can't publish predicate: '" + predicate.getURI() + "', domain="
+ predicate.getDomainVClassURI() + ", range="
+ predicate.getRangeVClassURI() + ", userRole="
+ userRole + ", thresholdRole=" + publishThreshold);
return false;
}
private boolean isAuthorized(RoleLevel userRole, RoleLevel thresholdRole) {
if (userRole == null) {
return false;

View file

@ -3,27 +3,37 @@
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
/** Should we let the user see this ObjectPropertyStatement? */
public class DisplayObjectPropertyStatement extends RequestedAction {
private final ObjectPropertyStatement objectPropertyStatement;
private final String subjectUri;
private final ObjectProperty property;
private final String objectUri;
public DisplayObjectPropertyStatement(
ObjectPropertyStatement objectPropertyStatement) {
this.objectPropertyStatement = objectPropertyStatement;
public DisplayObjectPropertyStatement(String subjectUri,
ObjectProperty property, String objectUri) {
this.subjectUri = subjectUri;
this.property = property;
this.objectUri = objectUri;
}
public ObjectPropertyStatement getObjectPropertyStatement() {
return objectPropertyStatement;
public String getSubjectUri() {
return subjectUri;
}
public ObjectProperty getProperty() {
return property;
}
public String getObjectUri() {
return objectUri;
}
@Override
public String toString() {
return "DisplayObjectPropertyStatement["
+ objectPropertyStatement.getSubjectURI() + "==>"
+ objectPropertyStatement.getPropertyURI() + "==>"
+ objectPropertyStatement.getObjectURI() + "]";
return "DisplayObjectPropertyStatement[" + subjectUri + "==>"
+ property.getURI() + "==>" + objectUri + "]";
}
}

View file

@ -59,6 +59,10 @@ public abstract class AbstractDataPropertyStatementAction extends
public String[] getResourceUris() {
return new String[] {subjectUri};
}
public String dataValue() {
return dataValue;
}
@Override
public String toString() {

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
@ -17,23 +16,14 @@ public abstract class AbstractObjectPropertyStatementAction extends
private final Property predicate;
private final String objectUri;
public AbstractObjectPropertyStatementAction(OntModel ontModel, String subjectUri,
Property predicate, String objectUri) {
public AbstractObjectPropertyStatementAction(OntModel ontModel,
String subjectUri, Property predicate, String objectUri) {
super(ontModel);
this.subjectUri = subjectUri;
this.predicate = predicate;
this.objectUri = objectUri;
}
public AbstractObjectPropertyStatementAction(OntModel ontModel, ObjectPropertyStatement ops) {
super(ontModel);
this.subjectUri = (ops.getSubject() == null) ? ops.getSubjectURI()
: ops.getSubject().getURI();
this.predicate = (ops.getProperty());
this.objectUri = (ops.getObject() == null) ? ops.getObjectURI() : ops
.getObject().getURI();
}
public String getSubjectUri() {
return subjectUri;
}
@ -41,11 +31,12 @@ public abstract class AbstractObjectPropertyStatementAction extends
public String getObjectUri() {
return objectUri;
}
@Override
public Property getPredicate() {
return predicate;
return predicate;
}
@Override
public String getPredicateUri() {
return predicate.getURI();
@ -53,7 +44,7 @@ public abstract class AbstractObjectPropertyStatementAction extends
@Override
public String[] getResourceUris() {
return new String[] {subjectUri, objectUri};
return new String[] { subjectUri, objectUri };
}
@Override

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
@ -17,8 +16,4 @@ public class AddObjectPropertyStatement extends
super(ontModel, uriOfSub, predicate, uriOfObj);
}
public AddObjectPropertyStatement(OntModel ontModel,
ObjectPropertyStatement ops) {
super(ontModel, ops);
}
}

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
@ -17,9 +16,4 @@ public class DropObjectPropertyStatement extends
Property pred, String obj) {
super(ontModel, sub, pred, obj);
}
public DropObjectPropertyStatement(OntModel ontModel,
ObjectPropertyStatement ops) {
super(ontModel, ops);
}
}

View file

@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
@ -16,9 +15,4 @@ public class EditObjectPropertyStatement extends
Property keywordPred, String objectUri) {
super(ontModel, subjectUri, keywordPred, objectUri);
}
public EditObjectPropertyStatement(OntModel ontModel,
ObjectPropertyStatement ops) {
super(ontModel, ops);
}
}

View file

@ -0,0 +1,24 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
/** Should we allow the user to publish this DataProperty in Linked Open Data? */
public class PublishDataProperty extends RequestedAction {
private final DataProperty dataProperty;
public PublishDataProperty(DataProperty dataProperty) {
this.dataProperty = dataProperty;
}
public DataProperty getDataProperty() {
return dataProperty;
}
@Override
public String toString() {
return "PublishDataProperty[" + dataProperty + "]";
}
}

View file

@ -0,0 +1,26 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractDataPropertyStatementAction;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
/**
* Should we publish this DataPropertyStatement in a Linked Open Data request
* from the current user?
*/
public class PublishDataPropertyStatement extends
AbstractDataPropertyStatementAction {
public PublishDataPropertyStatement(OntModel ontModel, String subjectUri,
String predicateUri, String dataValue) {
super(ontModel, subjectUri, predicateUri, dataValue);
}
public PublishDataPropertyStatement(OntModel ontModel,
DataPropertyStatement dps) {
super(ontModel, dps);
}
}

View file

@ -0,0 +1,24 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
/** Should we allow the user to publish this ObjectProperty in Linked Open Data? */
public class PublishObjectProperty extends RequestedAction {
private final ObjectProperty objectProperty;
public PublishObjectProperty(ObjectProperty objectProperty) {
this.objectProperty = objectProperty;
}
public ObjectProperty getObjectProperty() {
return objectProperty;
}
@Override
public String toString() {
return "PublishObjectProperty[" + objectProperty.getLocalName() + "]";
}
}

View file

@ -0,0 +1,39 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish;
import com.hp.hpl.jena.ontology.OntModel;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractObjectPropertyStatementAction;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
* Should we publish this ObjectPropertyStatement in a Linked Open Data request
* from the current user?
*/
public class PublishObjectPropertyStatement extends
AbstractObjectPropertyStatementAction {
public PublishObjectPropertyStatement(OntModel ontModel, String subjectUri,
Property keywordPred, String objectUri) {
super(ontModel, subjectUri, keywordPred, objectUri);
}
/**
* We don't need to know range and domain because publishing never involves
* faux properties.
*/
public PublishObjectPropertyStatement(OntModel ontModel,
String subjectUri,
String predicateUri, String objectUri) {
this(ontModel, subjectUri, populateProperty(predicateUri), objectUri);
}
private static Property populateProperty(String predicateUri) {
Property prop = new Property(predicateUri);
prop.setDomainVClassURI(RequestActionConstants.SOME_URI);
prop.setRangeVClassURI(RequestActionConstants.SOME_URI);
return prop;
}
}

View file

@ -25,63 +25,80 @@ public class BaseResourceBean implements ResourceBean {
protected String localNameWithPrefix = null;
protected String pickListName = null;
// these will be phased in and used in the filters Brian C. has been setting up,
// with hiddenFromDisplay to control the level at which any class, individual, object property, or data property is displayed
// and prohibitedFromEditing to control when a control for editing is made available
protected RoleLevel hiddenFromDisplayBelowRoleLevel = null;
//protected RoleLevel prohibitedFromCreateBelowRoleLevel = null;
protected RoleLevel prohibitedFromUpdateBelowRoleLevel = null;
//protected RoleLevel prohibitedFromDeleteBelowRoleLevel = null;
protected RoleLevel hiddenFromPublishBelowRoleLevel = null;
public enum RoleLevel { PUBLIC("http://vitro.mannlib.cornell.edu/ns/vitro/role#public","public","public"),
SELF("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor","self-authenticated","self"),
EDITOR("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor","editor, curator, site administrator","editor"),
CURATOR("http://vitro.mannlib.cornell.edu/ns/vitro/role#curator","curator, site administrator","curator"),
DB_ADMIN("http://vitro.mannlib.cornell.edu/ns/vitro/role#dbAdmin","site administrator","siteAdmin"),
NOBODY("http://vitro.mannlib.cornell.edu/ns/vitro/role#nobody","root user","root");
private final String uri;
private final String label;
private final String shorthand;
RoleLevel(String uriStr,String labelStr, String shortStr) {
this.uri = uriStr;
this.label = labelStr;
this.shorthand = shortStr;
}
public String getURI() {
return uri;
}
public String getLabel() {
return label;
}
public enum RoleLevel {
PUBLIC("http://vitro.mannlib.cornell.edu/ns/vitro/role#public",
"all users, including public", "all users who can log in",
"public"),
SELF("http://vitro.mannlib.cornell.edu/ns/vitro/role#selfEditor",
"self-editor and above", "self-editor and above", "self"),
EDITOR("http://vitro.mannlib.cornell.edu/ns/vitro/role#editor",
"editor and above", "editor and above", "editor"),
CURATOR("http://vitro.mannlib.cornell.edu/ns/vitro/role#curator",
"curator and above", "curator and above", "curator"),
DB_ADMIN("http://vitro.mannlib.cornell.edu/ns/vitro/role#dbAdmin",
"site admin and root user", "site admin and root user",
"siteAdmin"),
NOBODY("http://vitro.mannlib.cornell.edu/ns/vitro/role#nobody",
"root user", "root user", "root");
private final String uri;
private final String displayLabel;
private final String updateLabel;
private final String shorthand;
private RoleLevel(String uri, String displayLabel, String updateLabel,
String shorthand) {
this.uri = uri;
this.displayLabel = displayLabel;
this.updateLabel = updateLabel;
this.shorthand = shorthand;
}
public String getURI() {
return uri;
}
public String getDisplayLabel() {
return displayLabel;
}
public String getUpdateLabel() {
return updateLabel;
}
public String getShorthand() {
return shorthand;
}
public static RoleLevel getRoleByUri(String uri2) {
if (uri2 == null)
return RoleLevel.values()[0];
for (RoleLevel role : RoleLevel.values()) {
if (role.uri.equals(uri2))
return role;
}
return RoleLevel.values()[0];
}
public String getShorthand() {
return shorthand;
}
public static RoleLevel getRoleByUri(String uri2) {
if( uri2 == null )
return RoleLevel.values()[0];
for( RoleLevel role : RoleLevel.values() ){
if( role.uri.equals( uri2 ) )
return role;
}
return RoleLevel.values()[0];
}
public static RoleLevel getRoleFromLoginStatus(HttpServletRequest req) {
UserAccount u = LoginStatusBean.getCurrentUser(req);
if (u == null) {
return PUBLIC;
}
Set<String> roles = u.getPermissionSetUris();
if (roles.contains(PermissionSets.URI_DBA)) {
return DB_ADMIN;
return DB_ADMIN;
} else if (roles.contains(PermissionSets.URI_CURATOR)) {
return CURATOR;
} else if (roles.contains(PermissionSets.URI_EDITOR)) {
@ -93,16 +110,19 @@ public class BaseResourceBean implements ResourceBean {
return SELF;
}
}
}
}
public boolean isAnonymous() {
@Override
public boolean isAnonymous() {
return (this.URI==null || VitroVocabulary.PSEUDO_BNODE_NS.equals(this.getNamespace()));
}
public String getURI() {
@Override
public String getURI() {
return URI;
}
public void setURI(String URI) {
@Override
public void setURI(String URI) {
if( this.localName != null || this.namespace != null)
buildLocalAndNS(URI);
else
@ -122,29 +142,34 @@ public class BaseResourceBean implements ResourceBean {
}
}
public String getNamespace() {
@Override
public String getNamespace() {
if( namespace == null && this.URI != null)
buildLocalAndNS(this.URI);
return namespace;
}
public void setNamespace(String namespace) {
@Override
public void setNamespace(String namespace) {
this.namespace = namespace;
if (namespace != null && localName != null ) {
this.URI = namespace + localName;
}
}
public String getLabel() {
@Override
public String getLabel() {
return getLocalName();
}
public String getLocalName() {
@Override
public String getLocalName() {
if( localName == null && this.URI != null)
buildLocalAndNS(this.URI);
return localName;
}
public void setLocalName(String localName) {
@Override
public void setLocalName(String localName) {
this.localName = localName;
if (namespace != null && localName != null) {
this.URI = namespace + localName;
@ -160,7 +185,8 @@ public class BaseResourceBean implements ResourceBean {
this.localNameWithPrefix = prefixedLocalName;
}
public String getPickListName() {
@Override
public String getPickListName() {
return pickListName==null ? getLocalName()==null ?
(URI==null ? "(no name)" : URI ): getLocalName() : pickListName;
}
@ -168,57 +194,51 @@ public class BaseResourceBean implements ResourceBean {
this.pickListName = pickListName;
}
public RoleLevel getHiddenFromDisplayBelowRoleLevel() {
@Override
public RoleLevel getHiddenFromDisplayBelowRoleLevel() {
return hiddenFromDisplayBelowRoleLevel;
}
public void setHiddenFromDisplayBelowRoleLevel(RoleLevel eR) {
@Override
public void setHiddenFromDisplayBelowRoleLevel(RoleLevel eR) {
hiddenFromDisplayBelowRoleLevel = eR;
}
public void setHiddenFromDisplayBelowRoleLevelUsingRoleUri(String roleUri) {
@Override
public void setHiddenFromDisplayBelowRoleLevelUsingRoleUri(String roleUri) {
hiddenFromDisplayBelowRoleLevel = BaseResourceBean.RoleLevel.getRoleByUri(roleUri);
}
/*
public RoleLevel getProhibitedFromCreateBelowRoleLevel() {
return prohibitedFromCreateBelowRoleLevel;
}
public void setProhibitedFromCreateBelowRoleLevel(RoleLevel eR) {
prohibitedFromCreateBelowRoleLevel = eR;
}
public void setProhibitedFromCreateBelowRoleLevelUsingRoleUri(String roleUri) {
prohibitedFromCreateBelowRoleLevel = BaseResourceBean.RoleLevel.getRoleByUri(roleUri);
}
*/
public RoleLevel getProhibitedFromUpdateBelowRoleLevel() {
@Override
public RoleLevel getProhibitedFromUpdateBelowRoleLevel() {
return prohibitedFromUpdateBelowRoleLevel;
}
public void setProhibitedFromUpdateBelowRoleLevel(RoleLevel eR) {
@Override
public void setProhibitedFromUpdateBelowRoleLevel(RoleLevel eR) {
prohibitedFromUpdateBelowRoleLevel = eR;
}
public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) {
@Override
public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) {
prohibitedFromUpdateBelowRoleLevel = BaseResourceBean.RoleLevel.getRoleByUri(roleUri);
}
/*
public RoleLevel getProhibitedFromDeleteBelowRoleLevel() {
return prohibitedFromDeleteBelowRoleLevel;
}
public void setProhibitedFromDeleteBelowRoleLevel(RoleLevel eR) {
prohibitedFromDeleteBelowRoleLevel = eR;
}
public void setProhibitedFromDeleteBelowRoleLevelUsingRoleUri(String roleUri) {
prohibitedFromDeleteBelowRoleLevel = BaseResourceBean.RoleLevel.getRoleByUri(roleUri);
}
*/
@Override
public RoleLevel getHiddenFromPublishBelowRoleLevel() {
return hiddenFromPublishBelowRoleLevel;
}
@Override
public void setHiddenFromPublishBelowRoleLevel(RoleLevel eR) {
hiddenFromPublishBelowRoleLevel = eR;
}
@Override
public void setHiddenFromPublishBelowRoleLevelUsingRoleUri(String roleUri) {
hiddenFromPublishBelowRoleLevel = BaseResourceBean.RoleLevel.getRoleByUri(roleUri);
}
@Override
public boolean equals(Object obj) {
if(obj == null )

View file

@ -633,6 +633,7 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
clone.setFunctional(this.getFunctional());
clone.setGroupURI(this.getGroupURI());
clone.setHiddenFromDisplayBelowRoleLevel(this.getHiddenFromDisplayBelowRoleLevel());
clone.setHiddenFromPublishBelowRoleLevel(this.getHiddenFromPublishBelowRoleLevel());
clone.setInverseFunctional(this.getInverseFunctional());
clone.setLabel(this.getLabel());
clone.setLocalName(this.getLocalName());

View file

@ -62,4 +62,13 @@ public class Ontology implements Comparable<Ontology>
return collator.compare(this.getName(), o2.getName());
}
@Override
public String toString() {
return "Ontology[myID=" + myID + ", myName=" + myName + ", myType="
+ myType + ", myPrefix=" + myPrefix + ", myNamespaceID="
+ myNamespaceID + ", myURI=" + myURI + ", myVClassesList="
+ myVClassesList + ", myPropsList=" + myPropsList
+ ", myEntitiesList=" + myEntitiesList + "]";
}
}

View file

@ -39,6 +39,12 @@ public interface ResourceBean {
public void setProhibitedFromUpdateBelowRoleLevelUsingRoleUri(String roleUri) ;
public RoleLevel getHiddenFromPublishBelowRoleLevel() ;
public void setHiddenFromPublishBelowRoleLevel(RoleLevel eR) ;
public void setHiddenFromPublishBelowRoleLevelUsingRoleUri(String roleUri) ;
public String getPickListName();
}

View file

@ -41,7 +41,7 @@ public class DatapropEditController extends BaseEditController {
VitroRequest vreq = new VitroRequest(request);
final int NUM_COLS=17;
final int NUM_COLS=18;
String datapropURI = request.getParameter("uri");
@ -73,6 +73,7 @@ public class DatapropEditController extends BaseEditController {
results.add("display limit"); // column 15
results.add("custom entry form"); // column 16
results.add("URI"); // column 17
results.add("publish level"); // column 18
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
@ -135,12 +136,16 @@ public class DatapropEditController extends BaseEditController {
String descriptionStr = (dp.getDescription() == null) ? "" : dp.getDescription(); // column 11
results.add(descriptionStr);
results.add(dp.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)" : dp.getHiddenFromDisplayBelowRoleLevel().getLabel()); // column 12
results.add(dp.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)" : dp.getProhibitedFromUpdateBelowRoleLevel().getLabel()); // column 13
results.add(dp.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)"
: dp.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel()); // column 12
results.add(dp.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)"
: dp.getProhibitedFromUpdateBelowRoleLevel().getUpdateLabel()); // column 13
results.add(String.valueOf(dp.getDisplayTier())); // column 14
results.add(String.valueOf(dp.getDisplayLimit())); // column 15
results.add(dp.getCustomEntryForm() == null ? "(unspecified)" : dp.getCustomEntryForm()); // column 16
results.add(dp.getURI() == null ? "" : dp.getURI()); // column 17
results.add(dp.getHiddenFromPublishBelowRoleLevel() == null ? "(unspecified)"
: dp.getHiddenFromPublishBelowRoleLevel().getDisplayLabel()); // column 18
request.setAttribute("results",results);
request.setAttribute("columncount",NUM_COLS);
request.setAttribute("suppressquery","true");

View file

@ -166,6 +166,7 @@ public class DatapropRetryController extends BaseEditController {
optionMap.put("HiddenFromDisplayBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getDisplayOptionsList(objectForEditing));
optionMap.put("ProhibitedFromUpdateBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getUpdateOptionsList(objectForEditing));
optionMap.put("HiddenFromPublishBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getPublishOptionsList(objectForEditing));
foo.setOptionLists(optionMap);

View file

@ -81,6 +81,8 @@ public class EntityEditController extends BaseEditController {
colCount++;
results.add("URI");
colCount++;
results.add("publish level");
colCount++;
String rName = null;
if (ent.getName() != null && ent.getName().length() > 0) {
@ -116,12 +118,16 @@ public class EntityEditController extends BaseEditController {
}
results.add(classStr);
results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" : ent.getHiddenFromDisplayBelowRoleLevel().getLabel());
results.add(ent.getProhibitedFromUpdateBelowRoleLevel() == null ? "unspecified" : ent.getProhibitedFromUpdateBelowRoleLevel().getLabel());
results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified"
: ent.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel());
results.add(ent.getProhibitedFromUpdateBelowRoleLevel() == null ? "unspecified"
: ent.getProhibitedFromUpdateBelowRoleLevel().getUpdateLabel());
String rModTime = (ent.getModTime()==null) ? "" : publicDateFormat.format(ent.getModTime());
results.add(rModTime);
results.add( (ent.getURI() == null) ? "[anonymous individual]" : ent.getURI() );
results.add(ent.getHiddenFromPublishBelowRoleLevel() == null ? "unspecified"
: ent.getHiddenFromPublishBelowRoleLevel().getDisplayLabel());
request.setAttribute("results",results);
request.setAttribute("columncount", colCount);
request.setAttribute("suppressquery","true");

View file

@ -170,6 +170,7 @@ public class EntityRetryController extends BaseEditController {
hash.put("HiddenFromDisplayBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getDisplayOptionsList(individualForEditing));
hash.put("ProhibitedFromUpdateBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getUpdateOptionsList(individualForEditing));
hash.put("HiddenFromPublishBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getPublishOptionsList(individualForEditing));
FormObject foo = new FormObject();
foo.setOptionLists(hash);

View file

@ -6,7 +6,6 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.servlet.RequestDispatcher;
@ -21,17 +20,14 @@ import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
public class PropertyEditController extends BaseEditController {
@ -43,7 +39,7 @@ public class PropertyEditController extends BaseEditController {
return;
}
final int NUM_COLS=24;
final int NUM_COLS=25;
VitroRequest vreq = new VitroRequest(request);
@ -81,6 +77,7 @@ public class PropertyEditController extends BaseEditController {
results.add("offer create new"); // column 22
results.add("sort direction"); // column 23
results.add("URI"); // column 24
results.add("publish level"); // column 25
results.add(p.getPickListName()); // column 1
@ -169,8 +166,10 @@ public class PropertyEditController extends BaseEditController {
String descriptionStr = (p.getDescription() == null) ? "" : p.getDescription();
results.add(descriptionStr); // column 15
results.add(p.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)" : p.getHiddenFromDisplayBelowRoleLevel().getLabel()); // column 16
results.add(p.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)" : p.getProhibitedFromUpdateBelowRoleLevel().getLabel()); // column 17
results.add(p.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)"
: p.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel()); // column 16
results.add(p.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)"
: p.getProhibitedFromUpdateBelowRoleLevel().getUpdateLabel()); // column 17
results.add("property: "+p.getDomainDisplayTier() + ", inverse: "+p.getRangeDisplayTier()); // column 18
@ -183,6 +182,8 @@ public class PropertyEditController extends BaseEditController {
results.add(p.getDomainEntitySortDirection() == null ? "ascending" : p.getDomainEntitySortDirection()); // column 23
results.add(p.getURI()); // column 24
results.add(p.getHiddenFromPublishBelowRoleLevel() == null ? "(unspecified)"
: p.getHiddenFromPublishBelowRoleLevel().getDisplayLabel()); // column 25
request.setAttribute("results",results);
request.setAttribute("columncount",NUM_COLS);
request.setAttribute("suppressquery","true");

View file

@ -151,6 +151,7 @@ public class PropertyRetryController extends BaseEditController {
optionMap.put("HiddenFromDisplayBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getDisplayOptionsList(propertyForEditing));
optionMap.put("ProhibitedFromUpdateBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getUpdateOptionsList(propertyForEditing));
optionMap.put("HiddenFromPublishBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getPublishOptionsList(propertyForEditing));
List groupOptList = FormUtils.makeOptionListFromBeans(request.getUnfilteredWebappDaoFactory().getPropertyGroupDao().getPublicGroups(true),"URI","Name", ((propertyForEditing.getGroupURI()==null) ? "" : propertyForEditing.getGroupURI()), null, (propertyForEditing.getGroupURI()!=null));
HashMap<String,Option> hashMap = new HashMap<String,Option>();

View file

@ -33,7 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
public class VclassEditController extends BaseEditController {
private static final Log log = LogFactory.getLog(VclassEditController.class.getName());
private static final int NUM_COLS = 13;
private static final int NUM_COLS = 14;
public void doPost (HttpServletRequest req, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTIONS)) {
@ -70,6 +70,7 @@ public class VclassEditController extends BaseEditController {
results.add("display rank"); // 11
results.add("custom entry form"); // 12
results.add("URI"); // 13
results.add("publish level"); // 14
String ontologyName = null;
if (vcl.getNamespace() != null) {
@ -107,8 +108,13 @@ public class VclassEditController extends BaseEditController {
commSb = new StringBuffer("no comments yet");
}
String hiddenFromDisplay = (vcl.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)" : vcl.getHiddenFromDisplayBelowRoleLevel().getLabel());
String ProhibitedFromUpdate = (vcl.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)" : vcl.getProhibitedFromUpdateBelowRoleLevel().getLabel());
String hiddenFromDisplay = (vcl.getHiddenFromDisplayBelowRoleLevel() == null ? "(unspecified)"
: vcl.getHiddenFromDisplayBelowRoleLevel().getDisplayLabel());
String ProhibitedFromUpdate = (vcl
.getProhibitedFromUpdateBelowRoleLevel() == null ? "(unspecified)"
: vcl.getProhibitedFromUpdateBelowRoleLevel().getUpdateLabel());
String hiddenFromPublish = (vcl.getHiddenFromPublishBelowRoleLevel() == null ? "(unspecified)"
: vcl.getHiddenFromPublishBelowRoleLevel().getDisplayLabel());
String customEntryForm = (vcl.getCustomEntryForm() == null ? "(unspecified)" : vcl.getCustomEntryForm());
@ -130,6 +136,7 @@ public class VclassEditController extends BaseEditController {
results.add(String.valueOf(vcl.getDisplayRank())); // 11
results.add(customEntryForm); // 12
results.add(uri); // 13
results.add(hiddenFromPublish); // 14
request.setAttribute("results", results);
request.setAttribute("columncount", NUM_COLS);
request.setAttribute("suppressquery", "true");

View file

@ -147,6 +147,7 @@ public class VclassRetryController extends BaseEditController {
optionMap.put("HiddenFromDisplayBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getDisplayOptionsList(vclassForEditing));
optionMap.put("ProhibitedFromUpdateBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getUpdateOptionsList(vclassForEditing));
optionMap.put("HiddenFromPublishBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getPublishOptionsList(vclassForEditing));
FormObject foo = new FormObject();
foo.setErrorMap(epo.getErrMsgMap());

View file

@ -23,7 +23,7 @@ public class RoleLevelOptionsSetup {
boolean someLevelSet=false;
Option publicOption = null;
for (BaseResourceBean.RoleLevel level : roles) {
Option option = new Option (level.getURI(),level.getLabel(),false);
Option option = new Option (level.getURI(),level.getDisplayLabel(),false);
if (level==BaseResourceBean.RoleLevel.PUBLIC) {
publicOption = option;
}
@ -50,7 +50,7 @@ public class RoleLevelOptionsSetup {
boolean someLevelSet=false;
Option publicOption = null;
for (BaseResourceBean.RoleLevel level : roles) {
Option option = new Option (level.getURI(),level.getLabel(),false);
Option option = new Option (level.getURI(),level.getUpdateLabel(),false);
if (level==BaseResourceBean.RoleLevel.PUBLIC) {
publicOption = option;
}
@ -68,4 +68,33 @@ public class RoleLevelOptionsSetup {
}
return prohibitedFromUpdateList;
}
public static List<Option> getPublishOptionsList(ResourceBean b) {
List<Option> hiddenFromPublishList = new LinkedList<Option>();
try {
BaseResourceBean.RoleLevel currentLevel = b.getHiddenFromPublishBelowRoleLevel();
BaseResourceBean.RoleLevel roles[] = BaseResourceBean.RoleLevel.values();
boolean someLevelSet=false;
Option publicOption = null;
for (BaseResourceBean.RoleLevel level : roles) {
Option option = new Option (level.getURI(),level.getDisplayLabel(),false);
if (level==BaseResourceBean.RoleLevel.PUBLIC) {
publicOption = option;
}
if (level==currentLevel) {
option.setSelected(true);
someLevelSet=true;
}
hiddenFromPublishList.add(option);
}
if (!someLevelSet) {
publicOption.setSelected(true);
}
} catch (Exception ex) {
log.error("cannot create HiddenFromPublishBelowRoleLevel options");
}
return hiddenFromPublishList;
}
}

View file

@ -2,6 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.controller.individual;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
@ -28,13 +29,11 @@ import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.publish.PublishObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RdfResponseValues;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
@ -61,7 +60,7 @@ import edu.cornell.mannlib.vitro.webapp.web.ContentType;
* Otherwise, show all triples, regardless of language.
*
* Filter the result based on the policy, removing any triples that should not
* be displayed to the public (or to the user, if logged in). Also remove any
* be published to the public (or to the user, if logged in). Also remove any
* objects which can only be reached by excluded triples.
*
* ----------------
@ -104,7 +103,6 @@ public class IndividualRdfAssembler {
this.individualUri = individualUri;
this.rdfFormat = rdfFormat;
String[] includes = vreq.getParameterValues("include");
this.richExportIncludes = (includes == null) ? new String[0] : includes;
@ -150,6 +148,11 @@ public class IndividualRdfAssembler {
m.add(runConstructQuery(String.format(
"CONSTRUCT { ?s ?predicate <%1$s> . } "
+ "WHERE { ?s ?predicate <%1$s> } ", individualUri)));
if (log.isDebugEnabled()) {
StringWriter sw = new StringWriter();
m.write(sw);
log.debug("Statements about '" + individualUri + "': " + sw);
}
return m;
}
@ -166,6 +169,16 @@ public class IndividualRdfAssembler {
+ "WHERE { <%1$s> ?predicate ?object ."
+ " ?object <%2$s> ?label . } ", individualUri,
RDFS.label)));
m.add(runConstructQuery(String.format(
"CONSTRUCT { ?subject <%2$s> ?type . } "
+ "WHERE { ?subject ?predicate <%1$s> ."
+ " ?subject <%2$s> ?type . } ", individualUri,
RDF.type)));
m.add(runConstructQuery(String.format(
"CONSTRUCT { ?subject <%2$s> ?label . } "
+ "WHERE { ?subject ?predicate <%1$s> ."
+ " ?subject <%2$s> ?label . } ", individualUri,
RDFS.label)));
return m;
}
@ -192,18 +205,17 @@ public class IndividualRdfAssembler {
String value = stmt.getObject().asLiteral().getString();
DataPropertyStatement dps = new DataPropertyStatementImpl(
subjectUri, predicateUri, value);
RequestedAction ddps = new DisplayDataPropertyStatement(dps);
if (!PolicyHelper.isAuthorizedForActions(vreq, ddps)) {
log.debug("not authorized: " + ddps);
RequestedAction pdps = new PublishDataPropertyStatement(o, dps);
if (!PolicyHelper.isAuthorizedForActions(vreq, pdps)) {
log.debug("not authorized: " + pdps);
stmts.remove();
}
} else if (stmt.getObject().isURIResource()) {
String objectUri = stmt.getObject().asResource().getURI();
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl(
RequestedAction pops = new PublishObjectPropertyStatement(o,
subjectUri, predicateUri, objectUri);
RequestedAction dops = new DisplayObjectPropertyStatement(ops);
if (!PolicyHelper.isAuthorizedForActions(vreq, dops)) {
log.debug("not authorized: " + dops);
if (!PolicyHelper.isAuthorizedForActions(vreq, pops)) {
log.debug("not authorized: " + pops);
stmts.remove();
}
} else {

View file

@ -54,11 +54,9 @@ public class VitroVocabulary {
public static final String DATAPROPERTY_ISEXTERNALID = vitroURI+"isExternalId";
public static final String HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"hiddenFromDisplayBelowRoleLevelAnnot";
//public static final String PROHIBITED_FROM_CREATE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromCreateBelowRoleLevelAnnot";
public static final String PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromUpdateBelowRoleLevelAnnot";
//public static final String PROHIBITED_FROM_DELETE_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"prohibitedFromDeleteBelowRoleLevelAnnot";
public static final String HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT = vitroURI+"hiddenFromPublishBelowRoleLevelAnnot";
public static final String MOST_SPECIFIC_TYPE = vitroURI + "mostSpecificType";
// roles

View file

@ -101,6 +101,11 @@ public class DataPropertyFiltering extends DataProperty {
return innerDataProperty.getProhibitedFromUpdateBelowRoleLevel();
}
@Override
public RoleLevel getHiddenFromPublishBelowRoleLevel() {
return innerDataProperty.getHiddenFromPublishBelowRoleLevel();
}
@Override
public String getLocalName() {
return innerDataProperty.getLocalName();
@ -196,6 +201,16 @@ public class DataPropertyFiltering extends DataProperty {
innerDataProperty.setProhibitedFromUpdateBelowRoleLevel(BaseResourceBean.RoleLevel.getRoleByUri(roleUri));
}
@Override
public void setHiddenFromPublishBelowRoleLevel(RoleLevel eR) {
innerDataProperty.setHiddenFromPublishBelowRoleLevel(eR);
}
@Override
public void setHiddenFromPublishBelowRoleLevelUsingRoleUri(String roleUri) {
innerDataProperty.setHiddenFromPublishBelowRoleLevel(BaseResourceBean.RoleLevel.getRoleByUri(roleUri));
}
@Override
public void setLocalName(String localName) {
innerDataProperty.setLocalName(localName);

View file

@ -449,6 +449,21 @@ public class IndividualFiltering implements Individual {
_innerIndividual.setProhibitedFromUpdateBelowRoleLevel(BaseResourceBean.RoleLevel.getRoleByUri(roleUri));
}
@Override
public RoleLevel getHiddenFromPublishBelowRoleLevel() {
return _innerIndividual.getHiddenFromPublishBelowRoleLevel();
}
@Override
public void setHiddenFromPublishBelowRoleLevel(RoleLevel eR) {
_innerIndividual.setHiddenFromPublishBelowRoleLevel(eR);
}
@Override
public void setHiddenFromPublishBelowRoleLevelUsingRoleUri(String roleUri) {
_innerIndividual.setHiddenFromPublishBelowRoleLevel(BaseResourceBean.RoleLevel.getRoleByUri(roleUri));
}
@Override
public boolean isAnonymous() {
return _innerIndividual.isAnonymous();

View file

@ -140,6 +140,11 @@ public class ObjectPropertyFiltering extends ObjectProperty {
return innerObjectProperty.getProhibitedFromUpdateBelowRoleLevel();
}
@Override
public RoleLevel getHiddenFromPublishBelowRoleLevel() {
return innerObjectProperty.getHiddenFromPublishBelowRoleLevel();
}
@Override
public boolean getInverseFunctional() {
return innerObjectProperty.getInverseFunctional();
@ -368,6 +373,16 @@ public class ObjectPropertyFiltering extends ObjectProperty {
innerObjectProperty.setProhibitedFromUpdateBelowRoleLevel(BaseResourceBean.RoleLevel.getRoleByUri(roleUri));
}
@Override
public void setHiddenFromPublishBelowRoleLevel(RoleLevel eR) {
innerObjectProperty.setHiddenFromPublishBelowRoleLevel(eR);
}
@Override
public void setHiddenFromPublishBelowRoleLevelUsingRoleUri(String roleUri) {
innerObjectProperty.setHiddenFromPublishBelowRoleLevel(BaseResourceBean.RoleLevel.getRoleByUri(roleUri));
}
@Override
public void setInverseFunctional(boolean inverseFunctional) {
innerObjectProperty.setInverseFunctional(inverseFunctional);

View file

@ -20,11 +20,13 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayData
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectPropertyStatement;
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.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
/**
* Filter the properties depending on what DisplayByRolePermission is on the
@ -117,7 +119,30 @@ public class FilterByRoleLevelPermission extends VitroFiltersImpl {
UnaryFunctor<ObjectPropertyStatement, Boolean> {
@Override
public Boolean fn(ObjectPropertyStatement ops) {
return checkAuthorization(new DisplayObjectPropertyStatement(ops));
String subjectUri = ops.getSubjectURI();
ObjectProperty predicate = getOrCreateProperty(ops);
String objectUri = ops.getObjectURI();
return checkAuthorization(new DisplayObjectPropertyStatement(
subjectUri, predicate, objectUri));
}
/**
* It would be nice if every ObjectPropertyStatement held a real
* ObjectProperty. If it doesn't, we do the next best thing, but it
* won't recognize any applicaable Faux properties.
*/
private ObjectProperty getOrCreateProperty(ObjectPropertyStatement ops) {
if (ops.getProperty() != null) {
return ops.getProperty();
}
if (ops.getPropertyURI() == null) {
return null;
}
ObjectProperty op = new ObjectProperty();
op.setURI(ops.getPropertyURI());
op.setDomainVClassURI(RequestActionConstants.SOME_URI);
op.setRangeVClassURI(RequestActionConstants.SOME_URI);
return op;
}
}

View file

@ -14,6 +14,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayData
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectPropertyStatement;
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.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
@ -88,7 +89,31 @@ public class HideFromDisplayByPolicyFilter extends VitroFiltersImpl {
UnaryFunctor<ObjectPropertyStatement, Boolean> {
@Override
public Boolean fn(ObjectPropertyStatement ops) {
return checkAuthorization(new DisplayObjectPropertyStatement(ops));
String subjectUri = ops.getSubjectURI();
ObjectProperty predicate = getOrCreateProperty(ops);
String objectUri = ops.getObjectURI();
return checkAuthorization(new DisplayObjectPropertyStatement(
subjectUri, predicate, objectUri));
}
/**
* It would be nice if every ObjectPropertyStatement held a real
* ObjectProperty. If it doesn't, we do the next best thing, but it
* won't recognize any applicaable Faux properties.
*/
private ObjectProperty getOrCreateProperty(ObjectPropertyStatement ops) {
if (ops.getProperty() != null) {
return ops.getProperty();
}
if (ops.getPropertyURI() == null) {
return null;
}
ObjectProperty op = new ObjectProperty();
op.setURI(ops.getPropertyURI());
op.setDomainVClassURI(RequestActionConstants.SOME_URI);
op.setRangeVClassURI(RequestActionConstants.SOME_URI);
return op;
}
}
}

View file

@ -235,6 +235,26 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
}
}
dp.setProhibitedFromUpdateBelowRoleLevel(prohibitedRoleLevel);//this might get set to null
//There might be multiple HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest
it = op.listProperties(HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
BaseResourceBean.RoleLevel publishRoleLevel = null;
while( it.hasNext() ){
Statement stmt = it.nextStatement();
RDFNode obj;
if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){
Resource res = obj.as(Resource.class);
if( res != null && res.getURI() != null ){
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
if( roleFromModel != null &&
(publishRoleLevel == null || roleFromModel.compareTo(publishRoleLevel) > 0 )){
publishRoleLevel = roleFromModel;
}
}
}
}
dp.setHiddenFromPublishBelowRoleLevel(publishRoleLevel);//this might get set to null
dp.setCustomEntryForm(getPropertyStringValue(op,PROPERTY_CUSTOMENTRYFORMANNOT));
dp.setExternalId( getOntModelSelector().getTBoxModel().contains(op, DATAPROPERTY_ISEXTERNALID, "TRUE") );
@ -504,6 +524,10 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
if (PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT != null && dtp.getProhibitedFromUpdateBelowRoleLevel() != null) { // only need to add if present
jDataprop.addProperty(PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(dtp.getProhibitedFromUpdateBelowRoleLevel().getURI()));
}
jDataprop.removeAll(HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
if (HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT != null && dtp.getHiddenFromPublishBelowRoleLevel() != null) { // only need to add if present
jDataprop.addProperty(HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(dtp.getHiddenFromPublishBelowRoleLevel().getURI()));
}
/*
if (dtp.isSelfEditProhibited()) { // only add the property if it's true
addPropertyBooleanValue(jDataprop, PROPERTY_SELFEDITPROHIBITEDANNOT, dtp.isSelfEditProhibited(), ontModel);
@ -570,6 +594,10 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
updatePropertyResourceURIValue(jDataprop,PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT,dtp.getProhibitedFromUpdateBelowRoleLevel().getURI(),ontModel);
}
if (dtp.getHiddenFromPublishBelowRoleLevel() != null) {
updatePropertyResourceURIValue(jDataprop,HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT,dtp.getHiddenFromPublishBelowRoleLevel().getURI(),ontModel);
}
if (dtp.getGroupURI() != null) {
updatePropertyResourceURIValue(jDataprop,PROPERTY_INPROPERTYGROUPANNOT,dtp.getGroupURI(),ontModel);
}

View file

@ -43,6 +43,7 @@ public class JenaBaseDaoCon {
protected AnnotationProperty HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty SEARCH_BOOST_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.SEARCH_BOOST_ANNOT);

View file

@ -190,7 +190,7 @@ public class JenaModelUtils {
// Perform possibly-redundant extraction to try ensure we don't miss
// individual axioms floating around. We still might miss things;
// this approach isn't perfect.
if (mode = AGGRESSIVE) {
if (mode == AGGRESSIVE) {
tboxModel.add(construct(dataset, namespace, graphURI, RDFS.subClassOf));
tboxModel.add(construct(dataset, namespace, graphURI, RDFS.subPropertyOf));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.equivalentClass));
@ -219,6 +219,8 @@ public class JenaModelUtils {
VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT)));
tboxModel.add(construct(dataset, namespace, graphURI, ResourceFactory.createResource(
VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT)));
tboxModel.add(construct(dataset, namespace, graphURI, ResourceFactory.createResource(
VitroVocabulary.HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT)));
tboxModel.add(construct(dataset, namespace, graphURI, ResourceFactory.createResource(
VitroVocabulary.DESCRIPTION_ANNOT)));
tboxModel.add(construct(dataset, namespace, graphURI, ResourceFactory.createResource(

View file

@ -202,6 +202,25 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
}
p.setProhibitedFromUpdateBelowRoleLevel(prohibitedRoleLevel); //this might get set to null
//There might be multiple HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest
it = op.listProperties(HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
BaseResourceBean.RoleLevel publishRoleLevel = null;
while( it.hasNext() ){
Statement stmt = it.nextStatement();
RDFNode obj;
if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){
Resource res = obj.as(Resource.class);
if( res != null && res.getURI() != null ){
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
if( roleFromModel != null &&
(publishRoleLevel == null || roleFromModel.compareTo(publishRoleLevel) > 0 )){
publishRoleLevel = roleFromModel;
}
}
}
}
p.setHiddenFromPublishBelowRoleLevel(publishRoleLevel); //this might get set to null
p.setCustomEntryForm(getPropertyStringValue(op,PROPERTY_CUSTOMENTRYFORMANNOT));
Boolean selectFromObj = getPropertyBooleanValue(op,PROPERTY_SELECTFROMEXISTINGANNOT);
p.setSelectFromExisting(selectFromObj==null ? true : selectFromObj);
@ -315,7 +334,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
"PREFIX config: <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" +
"PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n" +
"SELECT ?range ?rangeRoot ?label ?group ?customForm ?displayRank ?displayLevel " +
" ?updateLevel ?editLinkSuppressed ?addLinkSuppressed ?deleteLinkSuppressed \n" +
" ?updateLevel ?publishLevel ?editLinkSuppressed ?addLinkSuppressed ?deleteLinkSuppressed \n" +
" ?collateBySubclass ?displayLimit ?individualSortProperty \n" +
" ?entitySortDirection ?selectFromExisting ?offerCreateNew \n" +
" ?publicDescription ?stubDeletion \n" +
@ -341,6 +360,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
" OPTIONAL { ?configuration vitro:customEntryFormAnnot ?customForm } \n" +
" OPTIONAL { ?configuration vitro:hiddenFromDisplayBelowRoleLevelAnnot ?displayLevel } \n" +
" OPTIONAL { ?configuration vitro:prohibitedFromUpdateBelowRoleLevelAnnot ?updateLevel } \n" +
" OPTIONAL { ?configuration vitro:hiddenFromPublishBelowRoleLevelAnnot ?publishLevel } \n" +
" OPTIONAL { ?configuration <" + PROPERTY_COLLATEBYSUBCLASSANNOT.getURI() + "> ?collateBySubclass } \n" +
" OPTIONAL { ?configuration <" + DISPLAY_LIMIT.getURI() + "> ?displayLimit } \n" +
" OPTIONAL { ?configuration <" + PROPERTY_OBJECTINDIVIDUALSORTPROPERTY.getURI() + "> ?individualSortProperty } \n " +
@ -392,6 +412,12 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
BaseResourceBean.RoleLevel.getRoleByUri(
updateLevelRes.getURI()));
}
Resource publishLevelRes = qsoln.getResource("publishLevel");
if (publishLevelRes != null) {
op.setHiddenFromPublishBelowRoleLevel(
BaseResourceBean.RoleLevel.getRoleByUri(
publishLevelRes.getURI()));
}
Literal labelLit = qsoln.getLiteral("label");
if (labelLit != null) {
op.setDomainPublic(labelLit.getLexicalForm());
@ -739,6 +765,10 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
updatePropertyResourceURIValue(p, PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT, prop.getProhibitedFromUpdateBelowRoleLevel().getURI());
}
if (prop.getHiddenFromPublishBelowRoleLevel() != null) {
updatePropertyResourceURIValue(p, HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT, prop.getHiddenFromPublishBelowRoleLevel().getURI());
}
updatePropertyStringValue(p,PROPERTY_CUSTOMENTRYFORMANNOT,prop.getCustomEntryForm(),ontModel);
updatePropertyBooleanValue(p,PROPERTY_SELECTFROMEXISTINGANNOT,prop.getSelectFromExisting(),ontModel,JenaBaseDao.KEEP_ONLY_IF_FALSE);
updatePropertyBooleanValue(p,PROPERTY_OFFERCREATENEWOPTIONANNOT,prop.getOfferCreateNewOption(),ontModel,JenaBaseDao.KEEP_ONLY_IF_TRUE);

View file

@ -2,6 +2,8 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -28,10 +30,12 @@ public class OntologyDaoJena extends JenaBaseDao implements OntologyDao {
}
public static synchronized String adjustOntologyURI(String ontologyURI) {
if ( (ontologyURI.length()>1) && (ontologyURI.charAt(ontologyURI.length()-1)=='#') ) {
return ontologyURI.substring(0,ontologyURI.length()-1);
String uri = ontologyURI.trim();
int length = uri.length();
if ( (length>1) && (uri.charAt(length-1)=='#') ) {
return uri.substring(0,length-1);
} else {
return ontologyURI;
return uri;
}
}
@ -124,10 +128,14 @@ public class OntologyDaoJena extends JenaBaseDao implements OntologyDao {
}
public String insertNewOntology(Ontology ontology, OntModel ontModel) {
if (ontology != null && ontology.getURI() != null && ontology.getURI().length()>0) {
if (ontology == null) {
return null;
}
try {
String ontologyURI = adjustAndValidateOntologyURI(ontology.getURI());
ontModel.enterCriticalSection(Lock.WRITE);
try {
com.hp.hpl.jena.ontology.Ontology o = ontModel.createOntology(adjustOntologyURI(ontology.getURI()));
com.hp.hpl.jena.ontology.Ontology o = ontModel.createOntology(ontologyURI);
if (ontology.getName() != null && ontology.getName().length()>0) {
o.setLabel(ontology.getName(), getDefaultLanguage());
}
@ -138,12 +146,21 @@ public class OntologyDaoJena extends JenaBaseDao implements OntologyDao {
} finally {
ontModel.leaveCriticalSection();
}
} else {
return null;
} catch (URISyntaxException e) {
log.warn("Failed to insert new ontology: " + ontology, e);
throw new RuntimeException(e);
}
}
public void updateOntology(Ontology ontology) {
private String adjustAndValidateOntologyURI(String uri) throws URISyntaxException {
if (uri == null || uri.isEmpty()) {
throw new URISyntaxException(uri, "URI is empty");
}
String adjusted = adjustOntologyURI(uri);
return new URI(adjusted).toString();
}
public void updateOntology(Ontology ontology) {
updateOntology(ontology,getOntModel());
}

View file

@ -193,7 +193,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
} catch (Exception cce) {}
}
} catch (Exception e) {
log.error(e, e);
log.error("Failed to get super-properties for " + propertyURI, e);
} finally {
getOntModel().leaveCriticalSection();
}

View file

@ -984,6 +984,15 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
}
}
ontCls.removeAll(HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
if (HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT != null && cls.getHiddenFromPublishBelowRoleLevel() != null) { // only need to add if present
try {
ontCls.addProperty(HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(cls.getHiddenFromPublishBelowRoleLevel().getURI()));
} catch (Exception e) {
log.error("error adding HiddenFromPublishBelowRoleLevel annotation to class "+cls.getURI());
}
}
/* OPTIONAL annotation properties */
addPropertyStringValue(ontCls,PROPERTY_CUSTOMENTRYFORMANNOT,cls.getCustomEntryForm(),ontModel);
addPropertyStringValue(ontCls,PROPERTY_CUSTOMDISPLAYVIEWANNOT,cls.getCustomDisplayView(),ontModel);
@ -1025,6 +1034,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
updatePropertyResourceURIValue(ontCls,PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT,cls.getProhibitedFromUpdateBelowRoleLevel().getURI(),ontModel);
}
if (cls.getHiddenFromPublishBelowRoleLevel() != null) {
updatePropertyResourceURIValue(ontCls,HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT,cls.getHiddenFromPublishBelowRoleLevel().getURI(),ontModel);
}
updatePropertyStringValue(ontCls,PROPERTY_CUSTOMENTRYFORMANNOT,cls.getCustomEntryForm(),ontModel);
updatePropertyStringValue(ontCls,PROPERTY_CUSTOMDISPLAYVIEWANNOT,cls.getCustomDisplayView(),ontModel);
updatePropertyStringValue(ontCls,PROPERTY_CUSTOMSHORTVIEWANNOT,cls.getCustomShortView(),ontModel);

View file

@ -343,7 +343,7 @@ public class VClassJena extends VClass {
} else {
cls.getOntModel().enterCriticalSection(Lock.READ);
try {
//There might be multiple PROHIBITED_FROM_UPDATE_DISPLAY_ANNOT properties, only use the highest
//There might be multiple PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest
StmtIterator it = cls.listProperties(webappDaoFactory.getJenaBaseDao().PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
BaseResourceBean.RoleLevel prohibitedRoleLevel = null;
while( it.hasNext() ){
@ -369,6 +369,41 @@ public class VClassJena extends VClass {
}
}
@Override
public RoleLevel getHiddenFromPublishBelowRoleLevel() {
if (this.hiddenFromPublishBelowRoleLevel != null) {
return this.hiddenFromPublishBelowRoleLevel;
} else {
cls.getOntModel().enterCriticalSection(Lock.READ);
try {
//There might be multiple HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest
StmtIterator it = cls.listProperties(webappDaoFactory.getJenaBaseDao().HIDDEN_FROM_PUBLISH_BELOW_ROLE_LEVEL_ANNOT);
BaseResourceBean.RoleLevel publishRoleLevel = null;
while( it.hasNext() ){
Statement stmt = it.nextStatement();
RDFNode obj;
if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){
Resource res = obj.as(Resource.class);
if( res != null && res.getURI() != null ){
BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI());
if( roleFromModel != null &&
(publishRoleLevel == null || roleFromModel.compareTo(publishRoleLevel) > 0 )){
publishRoleLevel = roleFromModel;
}
}
}
}
setHiddenFromPublishBelowRoleLevel(publishRoleLevel); //this might get set to null
return this.hiddenFromPublishBelowRoleLevel;
} finally {
cls.getOntModel().leaveCriticalSection();
}
}
}
@Override
public boolean isUnion() {
return this.cls.isUnionClass();

View file

@ -3,9 +3,9 @@
package edu.cornell.mannlib.vitro.webapp.i18n.selection;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import javax.servlet.Filter;
@ -17,7 +17,6 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import org.apache.commons.collections.EnumerationUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -68,13 +67,12 @@ public class LocaleSelectionFilter implements Filter {
// ----------------------------------------------------------------------
/**
* Uses the selected Locale as the preferred Locale of the request.
* Uses the selected Locale as the only acceptable Locale of the request.
*/
private static class LocaleSelectionRequestWrapper extends
HttpServletRequestWrapper {
private final List<Locale> locales;
private final Locale selectedLocale;
@SuppressWarnings("unchecked")
public LocaleSelectionRequestWrapper(HttpServletRequest request,
Locale selectedLocale) {
super(request);
@ -87,18 +85,12 @@ public class LocaleSelectionFilter implements Filter {
"selectedLocale may not be null.");
}
Locale selectedLanguage = new Locale(selectedLocale.getLanguage());
locales = EnumerationUtils.toList(request.getLocales());
locales.remove(selectedLanguage);
locales.add(0, selectedLanguage);
locales.remove(selectedLocale);
locales.add(0, selectedLocale);
this.selectedLocale = selectedLocale;
}
@Override
public Locale getLocale() {
return locales.get(0);
return selectedLocale;
}
/**
@ -107,7 +99,7 @@ public class LocaleSelectionFilter implements Filter {
@SuppressWarnings("rawtypes")
@Override
public Enumeration getLocales() {
return Collections.enumeration(locales);
return Collections.enumeration(Arrays.asList(selectedLocale));
}
}

View file

@ -52,6 +52,7 @@ public abstract class SelectedLocale {
* <ul>
* <li>The forced Locale in the servlet context</li>
* <li>The selected Locale in the session</li>
* <li>The first of the selectable Locales</li>
* <li>null</li>
* </ul>
*/
@ -80,6 +81,17 @@ public abstract class SelectedLocale {
}
}
if (ctxInfo instanceof ContextSelectedLocale) {
List<Locale> selectableLocales = ((ContextSelectedLocale) ctxInfo)
.getSelectableLocales();
if (selectableLocales != null && !selectableLocales.isEmpty()) {
Locale defaultLocale = selectableLocales.get(0);
log.debug("Using first selectable locale as default: "
+ defaultLocale);
return defaultLocale;
}
}
return null;
}

View file

@ -3,7 +3,6 @@
package edu.cornell.mannlib.vitro.webapp.ontology.update;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -18,15 +17,17 @@ import java.util.List;
import javax.servlet.ServletContext;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openrdf.model.impl.URIImpl;
import com.hp.hpl.jena.iri.IRI;
import com.hp.hpl.jena.iri.IRIFactory;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
@ -234,6 +235,7 @@ public class KnowledgeBaseUpdater {
Model dedupeModel = dataset.getDefaultModel();
Model additions = jiu.renameBNodes(
anonModel, settings.getDefaultNamespace() + "n", dedupeModel);
additions = stripBadURIs(additions);
Model actualAdditions = ModelFactory.createDefaultModel();
StmtIterator stmtIt = additions.listStatements();
while (stmtIt.hasNext()) {
@ -249,7 +251,37 @@ public class KnowledgeBaseUpdater {
}
}
private Model stripBadURIs(Model additions) {
Model badURITriples = ModelFactory.createDefaultModel();
StmtIterator stmtIt = additions.listStatements();
while (stmtIt.hasNext()) {
String[] uris = new String[3];
Statement stmt = stmtIt.nextStatement();
if(stmt.getSubject().isURIResource()) {
uris[0] = stmt.getSubject().getURI();
}
uris[1] = stmt.getPredicate().getURI();
if(stmt.getObject().isURIResource()) {
uris[2] = ((Resource) stmt.getObject()).getURI();
}
for (int i = 0; i < 3; i++) {
String uri = uris[i];
if (uri != null) {
IRIFactory factory = IRIFactory.jenaImplementation();
IRI iri = factory.create(uri);
if (iri.hasViolation(false)) {
badURITriples.add(stmt);
log.error("Discarding added triple " + stmt + " because " +
"it includes one or more invalid URIs.");
break;
}
}
}
}
additions.remove(badURITriples);
return additions;
}
private List<AtomicOntologyChange> getAtomicOntologyChanges()
throws IOException {

View file

@ -14,9 +14,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAct
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.EditObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
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.ParamMap;
@ -33,9 +30,9 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
private final String editUrl;
private final String deleteUrl;
public ObjectPropertyStatementTemplateModel(String subjectUri, ObjectProperty predicate, String objectKey,
public ObjectPropertyStatementTemplateModel(String subjectUri, ObjectProperty property, String objectKey,
Map<String, String> data, String templateName, VitroRequest vreq) {
super(subjectUri, predicate, vreq);
super(subjectUri, property, vreq);
this.data = Collections.unmodifiableMap(new HashMap<String, String>(data));
this.objectUri = data.get(objectKey);
@ -43,15 +40,12 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
//to keep track of later
this.objectKey = objectKey;
ObjectPropertyStatement ops = new ObjectPropertyStatementImpl(subjectUri, property.getURI(), objectUri);
ops.setProperty(predicate);
// Do delete url first, since it is used in building edit url
this.deleteUrl = makeDeleteUrl(ops);
this.editUrl = makeEditUrl(ops);
this.deleteUrl = makeDeleteUrl();
this.editUrl = makeEditUrl();
}
private String makeDeleteUrl(ObjectPropertyStatement ops) {
private String makeDeleteUrl() {
// Is the delete link suppressed for this property?
if (property.isDeleteLinkSuppressed()) {
return "";
@ -87,11 +81,11 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
}
}
if (ops.getProperty()!= null && ops.getProperty().getDomainVClassURI() != null) {
params.put("domainUri", ops.getProperty().getDomainVClassURI());
if (property!= null && property.getDomainVClassURI() != null) {
params.put("domainUri", property.getDomainVClassURI());
}
if (ops.getProperty()!= null && ops.getProperty().getRangeVClassURI() != null) {
params.put("rangeUri", ops.getProperty().getRangeVClassURI());
if (property!= null && property.getRangeVClassURI() != null) {
params.put("rangeUri", property.getRangeVClassURI());
}
params.put("templateName", templateName);
@ -100,14 +94,14 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
return UrlBuilder.getUrl(EDIT_PATH, params);
}
private String makeEditUrl(ObjectPropertyStatement ops) {
private String makeEditUrl() {
// Is the edit link suppressed for this property?
if (property.isEditLinkSuppressed()) {
return "";
}
// Determine whether the statement can be edited
RequestedAction action = new EditObjectPropertyStatement(vreq.getJenaOntModel(), ops);
RequestedAction action = new EditObjectPropertyStatement(vreq.getJenaOntModel(), subjectUri, property, objectUri);
if ( ! PolicyHelper.isAuthorizedForActions(vreq, action) ) {
return "";
}
@ -125,11 +119,11 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
params.put("deleteProhibited", "prohibited");
}
if (ops.getProperty()!= null && ops.getProperty().getDomainVClassURI() != null) {
params.put("domainUri", ops.getProperty().getDomainVClassURI());
if (property!= null && property.getDomainVClassURI() != null) {
params.put("domainUri", property.getDomainVClassURI());
}
if (ops.getProperty()!= null && ops.getProperty().getRangeVClassURI() != null) {
params.put("rangeUri", ops.getProperty().getRangeVClassURI());
if (property!= null && property.getRangeVClassURI() != null) {
params.put("rangeUri", property.getRangeVClassURI());
}
params.putAll(UrlBuilder.getModelParams(vreq));

View file

@ -2,6 +2,9 @@
package edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_LITERAL;
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants.SOME_URI;
import java.util.ArrayList;
import java.util.List;
@ -10,9 +13,12 @@ import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayDataProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayDataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectProperty;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.display.DisplayObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
import edu.cornell.mannlib.vitro.webapp.beans.Property;
@ -38,11 +44,11 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
List<Property> propertyList = group.getPropertyList();
properties = new ArrayList<PropertyTemplateModel>(propertyList.size());
for (Property p : propertyList) {
if (p instanceof ObjectProperty) {
ObjectProperty op = (ObjectProperty) p;
RequestedAction dop = new DisplayObjectProperty(op);
if (!PolicyHelper.isAuthorizedForActions(vreq, dop)) {
if (!allowedToDisplay(vreq, op, subject)) {
continue;
}
ObjectPropertyTemplateModel tm = ObjectPropertyTemplateModel.getObjectPropertyTemplateModel(
@ -53,8 +59,7 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
} else if (p instanceof DataProperty){
DataProperty dp = (DataProperty) p;
RequestedAction dop = new DisplayDataProperty(dp);
if (!PolicyHelper.isAuthorizedForActions(vreq, dop)) {
if (!allowedToDisplay(vreq, dp, subject)) {
continue;
}
properties.add(new DataPropertyTemplateModel(dp, subject, vreq, editing, populatedDataPropertyList));
@ -64,7 +69,48 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
}
}
protected boolean isEmpty() {
/**
* See if the property is permitted in its own right. If not, the property
* statement might still be permitted to a self-editor.
*/
private boolean allowedToDisplay(VitroRequest vreq, ObjectProperty op,
Individual subject) {
RequestedAction dop = new DisplayObjectProperty(op);
if (PolicyHelper.isAuthorizedForActions(vreq, dop)) {
return true;
}
RequestedAction dops = new DisplayObjectPropertyStatement(
subject.getURI(), op, SOME_URI);
if (PolicyHelper.isAuthorizedForActions(vreq, dops)) {
return true;
}
return false;
}
/**
* See if the property is permitted in its own right. If not, the property
* statement might still be permitted to a self-editor.
*/
private boolean allowedToDisplay(VitroRequest vreq, DataProperty dp,
Individual subject) {
RequestedAction dop = new DisplayDataProperty(dp);
if (PolicyHelper.isAuthorizedForActions(vreq, dop)) {
return true;
}
DataPropertyStatementImpl dps = new DataPropertyStatementImpl(
subject.getURI(), dp.getURI(), SOME_LITERAL);
RequestedAction dops = new DisplayDataPropertyStatement(dps);
if (PolicyHelper.isAuthorizedForActions(vreq, dops)) {
return true;
}
return false;
}
protected boolean isEmpty() {
return properties.isEmpty();
}
@ -73,7 +119,8 @@ public class PropertyGroupTemplateModel extends BaseTemplateModel {
}
public String toString(){
@Override
public String toString(){
String ptmStr ="";
for( int i=0; i < properties.size() ; i ++ ){
PropertyTemplateModel ptm = properties.get(i);

View file

@ -85,13 +85,17 @@ public abstract class PropertyTemplateModel extends BaseTemplateModel {
verboseDisplay = new HashMap<String, Object>();
RoleLevel roleLevel = property.getHiddenFromDisplayBelowRoleLevel();
String roleLevelLabel = roleLevel != null ? roleLevel.getLabel() : "";
String roleLevelLabel = roleLevel != null ? roleLevel.getDisplayLabel() : "";
verboseDisplay.put("displayLevel", roleLevelLabel);
roleLevel = property.getProhibitedFromUpdateBelowRoleLevel();
roleLevelLabel = roleLevel != null ? roleLevel.getLabel() : "";
roleLevelLabel = roleLevel != null ? roleLevel.getUpdateLabel() : "";
verboseDisplay.put("updateLevel", roleLevelLabel);
roleLevel = property.getHiddenFromPublishBelowRoleLevel();
roleLevelLabel = roleLevel != null ? roleLevel.getDisplayLabel() : "";
verboseDisplay.put("publishLevel", roleLevelLabel);
verboseDisplay.put("localName", property.getLocalNameWithPrefix());
verboseDisplay.put("displayRank", getPropertyDisplayTier(property));