From b9bf8bb27c50aede9893ab6a6d2459adfa4e2a11 Mon Sep 17 00:00:00 2001 From: j2blake Date: Thu, 3 Oct 2013 11:52:40 -0400 Subject: [PATCH] VIVO-308 Revise SelfEditorRelationshipPolicy to fit the ISF Change the RelationshipChecker classes, and update the unit tests. --- .../policy/AdvisingRelationshipChecker.java | 13 ++-- .../vivo/auth/policy/CourseChecker.java | 10 +-- .../vivo/auth/policy/GrantChecker.java | 21 +++--- ...ker.java => InfoContentEntityChecker.java} | 56 +++++++-------- .../vivo/auth/policy/PresentationChecker.java | 11 ++- .../auth/policy/ProjectOrServiceChecker.java | 31 +++++--- .../policy/SelfEditorRelationshipPolicy.java | 5 +- .../SelfEditorRelationshipPolicyTest.java | 57 ++++++++------- .../SelfEditorRelationshipPolicyTest.n3 | 72 ++++++++++++------- 9 files changed, 147 insertions(+), 129 deletions(-) rename src/edu/cornell/mannlib/vivo/auth/policy/{InformationResourceChecker.java => InfoContentEntityChecker.java} (55%) diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/AdvisingRelationshipChecker.java b/src/edu/cornell/mannlib/vivo/auth/policy/AdvisingRelationshipChecker.java index a75f5c38..41ed2fec 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/AdvisingRelationshipChecker.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/AdvisingRelationshipChecker.java @@ -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 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) { diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/CourseChecker.java b/src/edu/cornell/mannlib/vivo/auth/policy/CourseChecker.java index e952ef94..8a66e70a 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/CourseChecker.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/CourseChecker.java @@ -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 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) { diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/GrantChecker.java b/src/edu/cornell/mannlib/vivo/auth/policy/GrantChecker.java index 365175d8..608974bc 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/GrantChecker.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/GrantChecker.java @@ -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 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 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) { diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/InformationResourceChecker.java b/src/edu/cornell/mannlib/vivo/auth/policy/InfoContentEntityChecker.java similarity index 55% rename from src/edu/cornell/mannlib/vivo/auth/policy/InformationResourceChecker.java rename to src/edu/cornell/mannlib/vivo/auth/policy/InfoContentEntityChecker.java index 3f31816d..1805e231 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/InformationResourceChecker.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/InfoContentEntityChecker.java @@ -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 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 getUrisOfEditors(String resourceUri) { - return getObjectsOfProperty(resourceUri, URI_EDITOR_PROPERTY); + List 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 getUrisOfFeatured(String resourceUri) { @@ -75,8 +70,11 @@ public class InformationResourceChecker extends RelationshipChecker { } private List getUrisOfAuthors(String resourceUri) { - return getObjectsOfLinkedProperty(resourceUri, - URI_IN_AUTHORSHIP_PROPERTY, URI_LINKED_AUTHOR_PROPERTY); + List 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) { diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/PresentationChecker.java b/src/edu/cornell/mannlib/vivo/auth/policy/PresentationChecker.java index 662b7604..d17a5300 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/PresentationChecker.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/PresentationChecker.java @@ -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 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) { diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/ProjectOrServiceChecker.java b/src/edu/cornell/mannlib/vivo/auth/policy/ProjectOrServiceChecker.java index 3f2e9dcd..ed0b5670 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/ProjectOrServiceChecker.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/ProjectOrServiceChecker.java @@ -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 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 getUrisOfClinicalAgents(String resourceUri) { - return getObjectsOfLinkedProperty(resourceUri, - URI_RELATED_ROLE_PROPERTY, URI_CLINICAL_ROLE_OF_PROPERTY); + private List getClinicalAgentsOfProject(String resourceUri) { + return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES, + URI_CLINICAL_ROLE_TYPE, URI_INHERES_IN); + } + + private List getClinicalAgentsOfService(String resourceUri) { + return getObjectsThroughLinkingNode(resourceUri, + URI_CONTRIBUTING_ROLE_PROPERTY, URI_CLINICAL_ROLE_TYPE, + URI_INHERES_IN); } private PolicyDecision authorizedClinicalAgent(String resourceUri) { diff --git a/src/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicy.java b/src/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicy.java index 9ac81ea7..fad81997 100644 --- a/src/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicy.java +++ b/src/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicy.java @@ -86,7 +86,7 @@ public class SelfEditorRelationshipPolicy extends AbstractRelationshipPolicy private PolicyDecision checkRelationships(List 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(); } diff --git a/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.java b/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.java index 855dd32d..d3f9863d 100644 --- a/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.java +++ b/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.java @@ -44,7 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; /** * Check the relationships in the SelfEditorRelationshipPolicy. * - * This only checks the relationships that deal with InformationResources. + * This only checks the relationships that deal with InfoContentEntitys. * Testing the others seems too redundant. If we generalize this to use * configurable relationships, then we'll be able to make more general tests as * well. @@ -153,7 +153,6 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { @Before public void setLogging() { // setLoggerLevel(this.getClass(), Level.DEBUG); - // setLoggerLevel(InformationResourceEditingPolicy.class, Level.DEBUG); } // ---------------------------------------------------------------------- @@ -221,18 +220,18 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } // ---------------------------------------------------------------------- - // InformationResource tests + // InfoContentEntity tests // ---------------------------------------------------------------------- @Test - public void dataPropSubjectIsInfoResourceButNobodyIsSelfEditing() { + public void dataPropSubjectIsIceButNobodyIsSelfEditing() { action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT, URI_PERMITTED_PREDICATE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action)); } @Test - public void dataPropSubjectIsInfoResourceButNoAuthorsOrEditorsOrFeatured() { + public void dataPropSubjectIsIceButNoAuthorsOrEditorsOrFeatured() { action = new AddDataPropertyStatement(ontModel, URI_NOBODY_WROTE_IT, URI_PERMITTED_PREDICATE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); @@ -240,28 +239,28 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void dataPropSubjectIsInfoResourceButWrongAuthor() { + public void dataPropSubjectIsIceButWrongAuthor() { action = new AddDataPropertyStatement(ontModel, URI_BOZO_WROTE_IT, URI_PERMITTED_PREDICATE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); } @Test - public void dataPropSubjectIsInfoResourceButWrongEditor() { + public void dataPropSubjectIsIceButWrongEditor() { action = new AddDataPropertyStatement(ontModel, URI_BOZO_EDITED_IT, URI_PERMITTED_PREDICATE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); } @Test - public void dataPropSubjectIsInfoResourceButWrongFeatured() { + public void dataPropSubjectIsIceButWrongFeatured() { action = new AddDataPropertyStatement(ontModel, URI_BOZO_FEATURED_IN_IT, URI_PERMITTED_PREDICATE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); } @Test - public void dataPropSubjectIsInfoResourceWithSelfEditingAuthor() { + public void dataPropSubjectIsIceWithSelfEditingAuthor() { action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT, URI_PERMITTED_PREDICATE); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); @@ -269,7 +268,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void dataPropSubjectIsInfoResourceWithSelfEditingEditor() { + public void dataPropSubjectIsIceWithSelfEditingEditor() { action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT, URI_PERMITTED_PREDICATE); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); @@ -277,7 +276,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void dataPropSubjectIsInfoResourceWithSelfEditingFeatured() { + public void dataPropSubjectIsIceWithSelfEditingFeatured() { action = new AddDataPropertyStatement(ontModel, URI_JOE_FEATURED_IN_IT, URI_PERMITTED_PREDICATE); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); @@ -285,14 +284,14 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropSubjectIsInfoResourceButNobodyIsSelfEditing() { + public void objectPropSubjectIsIceButNobodyIsSelfEditing() { action = new AddObjectPropertyStatement(ontModel, URI_JOE_EDITED_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action)); } @Test - public void objectPropSubjectIsInfoResourceButNoAuthorsOrEditorsOrFeatured() { + public void objectPropSubjectIsIceButNoAuthorsOrEditorsOrFeatured() { action = new AddObjectPropertyStatement(ontModel, URI_NOBODY_WROTE_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); @@ -300,21 +299,21 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropSubjectIsInfoResourceButWrongAuthor() { + public void objectPropSubjectIsIceButWrongAuthor() { action = new AddObjectPropertyStatement(ontModel, URI_BOZO_WROTE_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); } @Test - public void objectPropSubjectIsInfoResourceButWrongEditor() { + public void objectPropSubjectIsIceButWrongEditor() { action = new AddObjectPropertyStatement(ontModel, URI_BOZO_EDITED_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); } @Test - public void objectPropSubjectIsInfoResourceButWrongFeatured() { + public void objectPropSubjectIsIceButWrongFeatured() { action = new AddObjectPropertyStatement(ontModel, URI_BOZO_FEATURED_IN_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); @@ -322,7 +321,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropSubjectIsInfoResourceWithSelfEditingAuthor() { + public void objectPropSubjectIsIceWithSelfEditingAuthor() { action = new AddObjectPropertyStatement(ontModel, URI_JOE_WROTE_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); @@ -330,7 +329,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropSubjectIsInfoResourceWithSelfEditingEditor() { + public void objectPropSubjectIsIceWithSelfEditingEditor() { action = new AddObjectPropertyStatement(ontModel, URI_JOE_EDITED_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); @@ -338,7 +337,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropSubjectIsInfoResourceWithSelfEditingFeatured() { + public void objectPropSubjectIsIceWithSelfEditingFeatured() { action = new AddObjectPropertyStatement(ontModel, URI_JOE_FEATURED_IN_IT, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); @@ -347,7 +346,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourcebutNobodyIsSelfEditing() { + public void objectPropObjectIsIcebutNobodyIsSelfEditing() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_EDITED_IT); @@ -355,7 +354,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceButNoAuthorsOrEditors() { + public void objectPropObjectIsIceButNoAuthorsOrEditors() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_NOBODY_WROTE_IT); @@ -364,7 +363,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceButWrongAuthor() { + public void objectPropObjectIsIceButWrongAuthor() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_BOZO_WROTE_IT); @@ -372,7 +371,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceButWrongEditor() { + public void objectPropObjectIsIceButWrongEditor() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_BOZO_EDITED_IT); @@ -380,7 +379,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceButWrongFeatured() { + public void objectPropObjectIsIceButWrongFeatured() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_BOZO_FEATURED_IN_IT); @@ -388,7 +387,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceWithSelfEditingAuthor() { + public void objectPropObjectIsIceWithSelfEditingAuthor() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_WROTE_IT); @@ -397,7 +396,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceWithSelfEditingEditor() { + public void objectPropObjectIsIceWithSelfEditingEditor() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_EDITED_IT); @@ -406,7 +405,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { } @Test - public void objectPropObjectIsInfoResourceWithSelfEditingFeatured() { + public void objectPropObjectIsIceWithSelfEditingFeatured() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_JOE_FEATURED_IN_IT); @@ -419,14 +418,14 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass { // ---------------------------------------------------------------------- @Test - public void dataPropSubjectIsNotInfoResource() { + public void dataPropSubjectIsNotIce() { action = new AddDataPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, URI_PERMITTED_PREDICATE); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); } @Test - public void objectPropNeitherSubjectOrObjectIsInfoResource() { + public void objectPropNeitherSubjectOrObjectIsIce() { action = new AddObjectPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); diff --git a/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.n3 b/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.n3 index 39be6f57..87d36aa4 100644 --- a/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.n3 +++ b/test/edu/cornell/mannlib/vivo/auth/policy/SelfEditorRelationshipPolicyTest.n3 @@ -6,9 +6,11 @@ @prefix foaf: . @prefix bib: . @prefix core: . +@prefix obo: . @prefix mydomain: . -### This file is for the test InformationResourceEditingPolicyTest.java. + +### This file contains data for SelfEditorRelationshipPolicyTest.java. # # Bozo @@ -21,8 +23,8 @@ mydomain:bozo rdfs:label "Person, Bozo" ; foaf:firstName "Bozo" ; foaf:lastName "Person" ; - core:editorOf mydomain:bozoEditedIt ; - core:authorInAuthorship mydomain:authorshipBozo ; + core:relatedBy mydomain:authorshipBozo ; + core:relatedBy mydomain:editorshipBozo ; . # @@ -36,16 +38,16 @@ mydomain:joe rdfs:label "Person, Joe" ; foaf:firstName "Joe" ; foaf:lastName "Person" ; - core:editorOf mydomain:joeEditedIt ; - core:authorInAuthorship mydomain:authorshipJoe ; + core:relatedBy mydomain:authorshipJoe ; + core:relatedBy mydomain:editorshipJoe ; . # -# info resource with no author or editor +# info content entity with no author or editor # mydomain:nobodyWroteIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ; @@ -53,45 +55,53 @@ mydomain:nobodyWroteIt . # -# info resource with Bozo as author +# info content entity with Bozo as author # mydomain:bozoWroteIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ; rdfs:label "Bozo is author" ; - core:informationResourceInAuthorship mydomain:authorshipBozo ; + core:relatedBy mydomain:authorshipBozo ; . mydomain:authorshipBozo a core:Authorship ; a core:Relationship ; a owl:Thing ; - core:linkedInformationResource mydomain:bozoWroteIt ; - core:linkedAuthor mydomain:bozo ; + core:relates mydomain:bozoWroteIt ; + core:relates mydomain:bozo ; . # -# info resource with Bozo as editor +# info content entity with Bozo as editor # mydomain:bozoEditedIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ; rdfs:label "Bozo is editor" ; - bib:editor mydomain:bozo ; + core:relatedBy mydomain:editorshipBozo ; + . + +mydomain:editorshipBozo + a core:Editorship ; + a core:Relationship ; + a owl:Thing ; + core:relates mydomain:bozoEditedIt ; + core:relates mydomain:bozo ; . # -# info resource with Bozo featured +# info content entity with Bozo featured # mydomain:bozoFeaturedInIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ; @@ -100,45 +110,53 @@ mydomain:bozoFeaturedInIt . # -# info resource with Joe as author +# info content entity with Joe as author # mydomain:joeWroteIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ; rdfs:label "Joe is author" ; - core:informationResourceInAuthorship mydomain:authorshipJoe ; + core:relatedBy mydomain:authorshipJoe ; . mydomain:authorshipJoe a core:Authorship ; a core:Relationship ; a owl:Thing ; - core:linkedInformationResource mydomain:joeWroteIt ; - core:linkedAuthor mydomain:joe ; + core:relates mydomain:joeWroteIt ; + core:relates mydomain:joe ; . # -# info resource with Joe as editor +# info content entity with Joe as editor # mydomain:joeEditedIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ; rdfs:label "Joe is editor" ; - bib:editor mydomain:joe ; + core:relatedBy mydomain:editorshipJoe ; + . + +mydomain:editorshipJoe + a core:Editorship ; + a core:Relationship ; + a owl:Thing ; + core:relates mydomain:joeEditedIt ; + core:relates mydomain:joe ; . # -# info resource with Joe featured +# info content entity with Joe featured # mydomain:joeFeaturedInIt a core:BlogPosting ; - a core:InformationResource ; + a obo:IAO_0000030 ; a bib:Article ; a bib:Document ; a owl:Thing ;