Merge branch 'develop' of https://github.com/vivo-project/VIVO into develop
This commit is contained in:
commit
33b83179a7
9 changed files with 147 additions and 129 deletions
|
@ -9,14 +9,13 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.specialrelationships.Relatio
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPropertyStatementAction;
|
||||
|
||||
/**
|
||||
* Does the requested action involve a change to an Advising Relationship that the self-editor
|
||||
* is authorized to modify?
|
||||
* Does the requested action involve a change to an Advising Relationship that
|
||||
* the self-editor is authorized to modify?
|
||||
*/
|
||||
public class AdvisingRelationshipChecker extends RelationshipChecker {
|
||||
private static final String NS_CORE = "http://vivoweb.org/ontology/core#";
|
||||
private static final String URI_ADVISING_RELATIONSHIP_TYPE = NS_CORE
|
||||
+ "AdvisingRelationship";
|
||||
private static final String URI_ADVISOR_PROPERTY = NS_CORE + "advisor";
|
||||
private static final String URI_ADVISOR_ROLE = NS_CORE + "AdvisorRole";
|
||||
|
||||
private final String[] resourceUris;
|
||||
|
||||
|
@ -27,7 +26,8 @@ public class AdvisingRelationshipChecker extends RelationshipChecker {
|
|||
|
||||
/**
|
||||
* A self-editor is authorized to add, edit, or delete a statement if the
|
||||
* subject or object refers to an Advising Relationship, and if the self-editor:
|
||||
* subject or object refers to an Advising Relationship, and if the
|
||||
* self-editor:
|
||||
*
|
||||
* 1) is an Advisor in that Relationship
|
||||
*/
|
||||
|
@ -47,7 +47,8 @@ public class AdvisingRelationshipChecker extends RelationshipChecker {
|
|||
}
|
||||
|
||||
private List<String> getUrisOfAdvisors(String resourceUri) {
|
||||
return getObjectsOfProperty(resourceUri, URI_ADVISOR_PROPERTY);
|
||||
return getObjectsThroughLinkingNode(resourceUri, URI_RELATES,
|
||||
URI_ADVISOR_ROLE, URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private PolicyDecision authorizedAdvisor(String resourceUri) {
|
||||
|
|
|
@ -13,12 +13,8 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
|
|||
* is authorized to modify?
|
||||
*/
|
||||
public class CourseChecker extends RelationshipChecker {
|
||||
private static final String NS_CORE = "http://vivoweb.org/ontology/core#";
|
||||
private static final String URI_COURSE_TYPE = NS_CORE + "Course";
|
||||
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE
|
||||
+ "relatedRole";
|
||||
private static final String URI_TEACHER_ROLE_OF_PROPERTY = NS_CORE
|
||||
+ "teacherRoleOf";
|
||||
private static final String URI_TEACHER_ROLE_TYPE = NS_CORE + "TeacherRole";
|
||||
|
||||
private final String[] resourceUris;
|
||||
|
||||
|
@ -49,8 +45,8 @@ public class CourseChecker extends RelationshipChecker {
|
|||
}
|
||||
|
||||
private List<String> getUrisOfTeachers(String resourceUri) {
|
||||
return getObjectsOfLinkedProperty(resourceUri,
|
||||
URI_RELATED_ROLE_PROPERTY, URI_TEACHER_ROLE_OF_PROPERTY);
|
||||
return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES,
|
||||
URI_TEACHER_ROLE_TYPE, URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private PolicyDecision authorizedTeacher(String resourceUri) {
|
||||
|
|
|
@ -13,14 +13,11 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
|
|||
* authorized to modify?
|
||||
*/
|
||||
public class GrantChecker extends RelationshipChecker {
|
||||
private static final String NS_CORE = "http://vivoweb.org/ontology/core#";
|
||||
private static final String URI_GRANT_TYPE = NS_CORE + "Grant";
|
||||
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE
|
||||
+ "relatedRole";
|
||||
private static final String URI_PRINCIPAL_INVESTIGATOR_OF_PROPERTY = NS_CORE
|
||||
+ "principalInvestigatorRoleOf";
|
||||
private static final String URI_CO_PRINCIPAL_INVESTIGATOR_OF_PROPERTY = NS_CORE
|
||||
+ "co-PrincipalInvestigatorRoleOf";
|
||||
private static final String URI_PI_ROLE_TYPE = NS_CORE
|
||||
+ "PrincipalInvestigatorRole";
|
||||
private static final String URI_CO_PI_ROLE_TYPE = NS_CORE
|
||||
+ "CoPrincipalInvestigatorRole";
|
||||
|
||||
private final String[] resourceUris;
|
||||
|
||||
|
@ -58,15 +55,13 @@ public class GrantChecker extends RelationshipChecker {
|
|||
}
|
||||
|
||||
private List<String> getUrisOfPrincipalInvestigators(String resourceUri) {
|
||||
return getObjectsOfLinkedProperty(resourceUri,
|
||||
URI_RELATED_ROLE_PROPERTY,
|
||||
URI_PRINCIPAL_INVESTIGATOR_OF_PROPERTY);
|
||||
return getObjectsThroughLinkingNode(resourceUri, URI_RELATES,
|
||||
URI_PI_ROLE_TYPE, URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private List<String> getUrisOfCoPrincipalInvestigators(String resourceUri) {
|
||||
return getObjectsOfLinkedProperty(resourceUri,
|
||||
URI_RELATED_ROLE_PROPERTY,
|
||||
URI_CO_PRINCIPAL_INVESTIGATOR_OF_PROPERTY);
|
||||
return getObjectsThroughLinkingNode(resourceUri, URI_RELATES,
|
||||
URI_CO_PI_ROLE_TYPE, URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private PolicyDecision authorizedPI(String resourceUri) {
|
||||
|
|
|
@ -9,47 +9,42 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.specialrelationships.Relatio
|
|||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPropertyStatementAction;
|
||||
|
||||
/**
|
||||
* Does the requested action involve a change to an Information Resource that
|
||||
* the self-editor is authorized to modify?
|
||||
* Does the requested action involve a change to an Info Content Entity that the
|
||||
* self-editor is authorized to modify?
|
||||
*/
|
||||
public class InformationResourceChecker extends RelationshipChecker {
|
||||
private static final String NS_CORE = "http://vivoweb.org/ontology/core#";
|
||||
private static final String URI_INFORMATION_RESOURCE_TYPE = NS_CORE
|
||||
+ "InformationResource";
|
||||
private static final String URI_EDITOR_PROPERTY = "http://purl.org/ontology/bibo/editor";
|
||||
public class InfoContentEntityChecker extends RelationshipChecker {
|
||||
private static final String URI_INFO_CONTENT_TYPE = NS_OBO + "IAO_0000030";
|
||||
private static final String URI_FEATURES_PROPERTY = NS_CORE + "features";
|
||||
private static final String URI_IN_AUTHORSHIP_PROPERTY = NS_CORE
|
||||
+ "informationResourceInAuthorship";
|
||||
private static final String URI_LINKED_AUTHOR_PROPERTY = NS_CORE
|
||||
+ "linkedAuthor";
|
||||
private static final String URI_AUTHORSHIP_TYPE = NS_CORE + "Authorship";
|
||||
private static final String URI_EDITORSHIP_TYPE = NS_CORE + "Editorship";
|
||||
|
||||
private final String[] resourceUris;
|
||||
|
||||
public InformationResourceChecker(AbstractPropertyStatementAction action) {
|
||||
public InfoContentEntityChecker(AbstractPropertyStatementAction action) {
|
||||
super(action.getOntModel());
|
||||
this.resourceUris = action.getResourceUris();
|
||||
}
|
||||
|
||||
/**
|
||||
* A self-editor is authorized to add, edit, or delete a statement if the
|
||||
* subject or object refers to an Information Resource, and if the
|
||||
* subject or object refers to an Info Content Entity, and if the
|
||||
* self-editor:
|
||||
*
|
||||
* 1) is an Author of that Information Resource
|
||||
* 1) is an Author of that Info Content Entity,
|
||||
*
|
||||
* 2) is an Editor of that Information Resource, or
|
||||
* 2) is an Editor of that Info Content Entity, or
|
||||
*
|
||||
* 3) is Featured in that Information Resource.
|
||||
* 3) is Featured in that Info Content Entity.
|
||||
*/
|
||||
public PolicyDecision isAuthorized(List<String> userUris) {
|
||||
for (String resourceUri : resourceUris) {
|
||||
if (isInformationResource(resourceUri)) {
|
||||
if (anyUrisInCommon(userUris, getUrisOfEditors(resourceUri))) {
|
||||
return authorizedEditor(resourceUri);
|
||||
}
|
||||
if (isInfoContentEntity(resourceUri)) {
|
||||
if (anyUrisInCommon(userUris, getUrisOfAuthors(resourceUri))) {
|
||||
return authorizedAuthor(resourceUri);
|
||||
}
|
||||
if (anyUrisInCommon(userUris, getUrisOfEditors(resourceUri))) {
|
||||
return authorizedEditor(resourceUri);
|
||||
}
|
||||
if (anyUrisInCommon(userUris, getUrisOfFeatured(resourceUri))) {
|
||||
return authorizedFeatured(resourceUri);
|
||||
}
|
||||
|
@ -58,16 +53,16 @@ public class InformationResourceChecker extends RelationshipChecker {
|
|||
return null;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// methods for InformationResource
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private boolean isInformationResource(String resourceUri) {
|
||||
return isResourceOfType(resourceUri, URI_INFORMATION_RESOURCE_TYPE);
|
||||
private boolean isInfoContentEntity(String resourceUri) {
|
||||
return isResourceOfType(resourceUri, URI_INFO_CONTENT_TYPE);
|
||||
}
|
||||
|
||||
private List<String> getUrisOfEditors(String resourceUri) {
|
||||
return getObjectsOfProperty(resourceUri, URI_EDITOR_PROPERTY);
|
||||
List<String> allRelatedUris = getObjectsThroughLinkingNode(resourceUri,
|
||||
URI_RELATED_BY, URI_EDITORSHIP_TYPE, URI_RELATES);
|
||||
// The editorship relates to the editors and to the resource itself.
|
||||
allRelatedUris.remove(resourceUri);
|
||||
return allRelatedUris;
|
||||
}
|
||||
|
||||
private List<String> getUrisOfFeatured(String resourceUri) {
|
||||
|
@ -75,8 +70,11 @@ public class InformationResourceChecker extends RelationshipChecker {
|
|||
}
|
||||
|
||||
private List<String> getUrisOfAuthors(String resourceUri) {
|
||||
return getObjectsOfLinkedProperty(resourceUri,
|
||||
URI_IN_AUTHORSHIP_PROPERTY, URI_LINKED_AUTHOR_PROPERTY);
|
||||
List<String> allRelatedUris = getObjectsThroughLinkingNode(resourceUri,
|
||||
URI_RELATED_BY, URI_AUTHORSHIP_TYPE, URI_RELATES);
|
||||
// The authorship relates to the authors and to the resource itself.
|
||||
allRelatedUris.remove(resourceUri);
|
||||
return allRelatedUris;
|
||||
}
|
||||
|
||||
private PolicyDecision authorizedEditor(String uri) {
|
|
@ -13,13 +13,10 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
|
|||
* self-editor is authorized to modify?
|
||||
*/
|
||||
public class PresentationChecker extends RelationshipChecker {
|
||||
private static final String NS_CORE = "http://vivoweb.org/ontology/core#";
|
||||
private static final String URI_PRESENTATION_TYPE = NS_CORE
|
||||
+ "Presentation";
|
||||
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE
|
||||
+ "relatedRole";
|
||||
private static final String URI_PRESENTER_ROLE_OF_PROPERTY = NS_CORE
|
||||
+ "presenterRoleOf";
|
||||
private static final String URI_PRESENTER_ROLE_TYPE = NS_CORE
|
||||
+ "PresenterRole";
|
||||
|
||||
private final String[] resourceUris;
|
||||
|
||||
|
@ -50,8 +47,8 @@ public class PresentationChecker extends RelationshipChecker {
|
|||
}
|
||||
|
||||
private List<String> getUrisOfPresenters(String resourceUri) {
|
||||
return getObjectsOfLinkedProperty(resourceUri,
|
||||
URI_RELATED_ROLE_PROPERTY, URI_PRESENTER_ROLE_OF_PROPERTY);
|
||||
return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES,
|
||||
URI_PRESENTER_ROLE_TYPE, URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private PolicyDecision authorizedPresenter(String resourceUri) {
|
||||
|
|
|
@ -13,13 +13,12 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
|
|||
* self-editor is authorized to modify?
|
||||
*/
|
||||
public class ProjectOrServiceChecker extends RelationshipChecker {
|
||||
private static final String NS_CORE = "http://vivoweb.org/ontology/core#";
|
||||
private static final String URI_PROJECT_TYPE = NS_CORE + "Project";
|
||||
private static final String URI_SERVICE_TYPE = NS_CORE + "Service";
|
||||
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE
|
||||
+ "relatedRole";
|
||||
private static final String URI_CLINICAL_ROLE_OF_PROPERTY = NS_CORE
|
||||
+ "clinicalRoleOf";
|
||||
private static final String URI_CLINICAL_ROLE_TYPE = NS_CORE
|
||||
+ "ClinicalRole";
|
||||
private static final String URI_CONTRIBUTING_ROLE_PROPERTY = NS_CORE
|
||||
+ "contributingRole";
|
||||
|
||||
private final String[] resourceUris;
|
||||
|
||||
|
@ -37,9 +36,15 @@ public class ProjectOrServiceChecker extends RelationshipChecker {
|
|||
*/
|
||||
public PolicyDecision isAuthorized(List<String> userUris) {
|
||||
for (String resourceUri : resourceUris) {
|
||||
if (isProject(resourceUri) || isService(resourceUri)) {
|
||||
if (isProject(resourceUri)) {
|
||||
if (anyUrisInCommon(userUris,
|
||||
getUrisOfClinicalAgents(resourceUri))) {
|
||||
getClinicalAgentsOfProject(resourceUri))) {
|
||||
return authorizedClinicalAgent(resourceUri);
|
||||
}
|
||||
}
|
||||
if (isService(resourceUri)) {
|
||||
if (anyUrisInCommon(userUris,
|
||||
getClinicalAgentsOfService(resourceUri))) {
|
||||
return authorizedClinicalAgent(resourceUri);
|
||||
}
|
||||
}
|
||||
|
@ -55,9 +60,15 @@ public class ProjectOrServiceChecker extends RelationshipChecker {
|
|||
return isResourceOfType(resourceUri, URI_SERVICE_TYPE);
|
||||
}
|
||||
|
||||
private List<String> getUrisOfClinicalAgents(String resourceUri) {
|
||||
return getObjectsOfLinkedProperty(resourceUri,
|
||||
URI_RELATED_ROLE_PROPERTY, URI_CLINICAL_ROLE_OF_PROPERTY);
|
||||
private List<String> getClinicalAgentsOfProject(String resourceUri) {
|
||||
return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES,
|
||||
URI_CLINICAL_ROLE_TYPE, URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private List<String> getClinicalAgentsOfService(String resourceUri) {
|
||||
return getObjectsThroughLinkingNode(resourceUri,
|
||||
URI_CONTRIBUTING_ROLE_PROPERTY, URI_CLINICAL_ROLE_TYPE,
|
||||
URI_INHERES_IN);
|
||||
}
|
||||
|
||||
private PolicyDecision authorizedClinicalAgent(String resourceUri) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public class SelfEditorRelationshipPolicy extends AbstractRelationshipPolicy
|
|||
private PolicyDecision checkRelationships(List<String> userUris,
|
||||
AbstractPropertyStatementAction action) {
|
||||
|
||||
PolicyDecision decision = new InformationResourceChecker(action)
|
||||
PolicyDecision decision = new InfoContentEntityChecker(action)
|
||||
.isAuthorized(userUris);
|
||||
if (decision == null) {
|
||||
decision = new GrantChecker(action).isAuthorized(userUris);
|
||||
|
@ -101,6 +101,9 @@ public class SelfEditorRelationshipPolicy extends AbstractRelationshipPolicy
|
|||
if (decision == null) {
|
||||
decision = new CourseChecker(action).isAuthorized(userUris);
|
||||
}
|
||||
if (decision == null) {
|
||||
decision = new AdvisingRelationshipChecker(action).isAuthorized(userUris);
|
||||
}
|
||||
if (decision == null) {
|
||||
decision = userNotAuthorizedToStatement();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue