Merge branch 'maint-rel-1.6' into develop
This commit is contained in:
commit
50e55b62ef
54 changed files with 1977 additions and 250 deletions
|
@ -15,7 +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;
|
||||
|
||||
|
|
|
@ -134,6 +134,7 @@ public class PermissionRegistry {
|
|||
permissions.addAll(SimplePermission.getAllInstances());
|
||||
permissions.addAll(createDisplayByRolePermissions(ctx));
|
||||
permissions.addAll(createEditByRolePermissions(ctx));
|
||||
permissions.addAll(createPublishByRolePermissions(ctx));
|
||||
|
||||
PermissionRegistry.createRegistry(ctx, permissions);
|
||||
|
||||
|
@ -185,5 +186,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 + "']";
|
||||
}
|
||||
|
||||
}
|
|
@ -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.");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,6 +204,9 @@ 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);
|
||||
|
@ -251,6 +249,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 +267,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 +349,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 +432,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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt;
|
|||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||
|
||||
|
@ -17,23 +18,31 @@ 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) {
|
||||
public AbstractObjectPropertyStatementAction(OntModel ontModel,
|
||||
ObjectPropertyStatement ops) {
|
||||
super(ontModel);
|
||||
this.subjectUri = (ops.getSubject() == null) ? ops.getSubjectURI()
|
||||
: ops.getSubject().getURI();
|
||||
this.predicate = (ops.getProperty());
|
||||
this.predicate = (ops.getProperty() == null) ? createProperty(ops
|
||||
.getPropertyURI()) : ops.getProperty();
|
||||
this.objectUri = (ops.getObject() == null) ? ops.getObjectURI() : ops
|
||||
.getObject().getURI();
|
||||
}
|
||||
|
||||
private ObjectProperty createProperty(String propertyURI) {
|
||||
ObjectProperty op = new ObjectProperty();
|
||||
op.setURI(propertyURI);
|
||||
return op;
|
||||
}
|
||||
|
||||
public String getSubjectUri() {
|
||||
return subjectUri;
|
||||
}
|
||||
|
@ -41,11 +50,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 +63,7 @@ public abstract class AbstractObjectPropertyStatementAction extends
|
|||
|
||||
@Override
|
||||
public String[] getResourceUris() {
|
||||
return new String[] {subjectUri, objectUri};
|
||||
return new String[] { subjectUri, objectUri };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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() + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* $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.AbstractObjectPropertyStatementAction;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
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);
|
||||
}
|
||||
|
||||
public PublishObjectPropertyStatement(OntModel ontModel,
|
||||
ObjectPropertyStatement ops) {
|
||||
super(ontModel, ops);
|
||||
}
|
||||
|
||||
}
|
|
@ -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 )
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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>();
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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,9 +29,9 @@ 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;
|
||||
|
@ -61,7 +62,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 +105,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 +150,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 +171,15 @@ 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 +206,18 @@ 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(
|
||||
subjectUri, predicateUri, objectUri);
|
||||
RequestedAction dops = new DisplayObjectPropertyStatement(ops);
|
||||
if (!PolicyHelper.isAuthorizedForActions(vreq, dops)) {
|
||||
log.debug("not authorized: " + dops);
|
||||
RequestedAction pops = new PublishObjectPropertyStatement(o, ops);
|
||||
if (!PolicyHelper.isAuthorizedForActions(vreq, pops)) {
|
||||
log.debug("not authorized: " + pops);
|
||||
stmts.remove();
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue