Merge branch 'develop' of https://github.com/vivo-project/VIVO into develop

This commit is contained in:
tworrall 2013-10-03 13:14:08 -04:00
commit 33b83179a7
9 changed files with 147 additions and 129 deletions

View file

@ -9,14 +9,13 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.specialrelationships.Relatio
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPropertyStatementAction; 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 * Does the requested action involve a change to an Advising Relationship that
* is authorized to modify? * the self-editor is authorized to modify?
*/ */
public class AdvisingRelationshipChecker extends RelationshipChecker { 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 private static final String URI_ADVISING_RELATIONSHIP_TYPE = NS_CORE
+ "AdvisingRelationship"; + "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; 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 * 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 * 1) is an Advisor in that Relationship
*/ */
@ -47,7 +47,8 @@ public class AdvisingRelationshipChecker extends RelationshipChecker {
} }
private List<String> getUrisOfAdvisors(String resourceUri) { 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) { private PolicyDecision authorizedAdvisor(String resourceUri) {

View file

@ -13,12 +13,8 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
* is authorized to modify? * is authorized to modify?
*/ */
public class CourseChecker extends RelationshipChecker { 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_COURSE_TYPE = NS_CORE + "Course";
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE private static final String URI_TEACHER_ROLE_TYPE = NS_CORE + "TeacherRole";
+ "relatedRole";
private static final String URI_TEACHER_ROLE_OF_PROPERTY = NS_CORE
+ "teacherRoleOf";
private final String[] resourceUris; private final String[] resourceUris;
@ -49,8 +45,8 @@ public class CourseChecker extends RelationshipChecker {
} }
private List<String> getUrisOfTeachers(String resourceUri) { private List<String> getUrisOfTeachers(String resourceUri) {
return getObjectsOfLinkedProperty(resourceUri, return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES,
URI_RELATED_ROLE_PROPERTY, URI_TEACHER_ROLE_OF_PROPERTY); URI_TEACHER_ROLE_TYPE, URI_INHERES_IN);
} }
private PolicyDecision authorizedTeacher(String resourceUri) { private PolicyDecision authorizedTeacher(String resourceUri) {

View file

@ -13,14 +13,11 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
* authorized to modify? * authorized to modify?
*/ */
public class GrantChecker extends RelationshipChecker { 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_GRANT_TYPE = NS_CORE + "Grant";
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE private static final String URI_PI_ROLE_TYPE = NS_CORE
+ "relatedRole"; + "PrincipalInvestigatorRole";
private static final String URI_PRINCIPAL_INVESTIGATOR_OF_PROPERTY = NS_CORE private static final String URI_CO_PI_ROLE_TYPE = NS_CORE
+ "principalInvestigatorRoleOf"; + "CoPrincipalInvestigatorRole";
private static final String URI_CO_PRINCIPAL_INVESTIGATOR_OF_PROPERTY = NS_CORE
+ "co-PrincipalInvestigatorRoleOf";
private final String[] resourceUris; private final String[] resourceUris;
@ -58,15 +55,13 @@ public class GrantChecker extends RelationshipChecker {
} }
private List<String> getUrisOfPrincipalInvestigators(String resourceUri) { private List<String> getUrisOfPrincipalInvestigators(String resourceUri) {
return getObjectsOfLinkedProperty(resourceUri, return getObjectsThroughLinkingNode(resourceUri, URI_RELATES,
URI_RELATED_ROLE_PROPERTY, URI_PI_ROLE_TYPE, URI_INHERES_IN);
URI_PRINCIPAL_INVESTIGATOR_OF_PROPERTY);
} }
private List<String> getUrisOfCoPrincipalInvestigators(String resourceUri) { private List<String> getUrisOfCoPrincipalInvestigators(String resourceUri) {
return getObjectsOfLinkedProperty(resourceUri, return getObjectsThroughLinkingNode(resourceUri, URI_RELATES,
URI_RELATED_ROLE_PROPERTY, URI_CO_PI_ROLE_TYPE, URI_INHERES_IN);
URI_CO_PRINCIPAL_INVESTIGATOR_OF_PROPERTY);
} }
private PolicyDecision authorizedPI(String resourceUri) { private PolicyDecision authorizedPI(String resourceUri) {

View file

@ -9,47 +9,42 @@ import edu.cornell.mannlib.vitro.webapp.auth.policy.specialrelationships.Relatio
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPropertyStatementAction; import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPropertyStatementAction;
/** /**
* Does the requested action involve a change to an Information Resource that * Does the requested action involve a change to an Info Content Entity that the
* the self-editor is authorized to modify? * self-editor is authorized to modify?
*/ */
public class InformationResourceChecker extends RelationshipChecker { public class InfoContentEntityChecker extends RelationshipChecker {
private static final String NS_CORE = "http://vivoweb.org/ontology/core#"; private static final String URI_INFO_CONTENT_TYPE = NS_OBO + "IAO_0000030";
private static final String URI_INFORMATION_RESOURCE_TYPE = NS_CORE
+ "InformationResource";
private static final String URI_EDITOR_PROPERTY = "http://purl.org/ontology/bibo/editor";
private static final String URI_FEATURES_PROPERTY = NS_CORE + "features"; private static final String URI_FEATURES_PROPERTY = NS_CORE + "features";
private static final String URI_IN_AUTHORSHIP_PROPERTY = NS_CORE private static final String URI_AUTHORSHIP_TYPE = NS_CORE + "Authorship";
+ "informationResourceInAuthorship"; private static final String URI_EDITORSHIP_TYPE = NS_CORE + "Editorship";
private static final String URI_LINKED_AUTHOR_PROPERTY = NS_CORE
+ "linkedAuthor";
private final String[] resourceUris; private final String[] resourceUris;
public InformationResourceChecker(AbstractPropertyStatementAction action) { public InfoContentEntityChecker(AbstractPropertyStatementAction action) {
super(action.getOntModel()); super(action.getOntModel());
this.resourceUris = action.getResourceUris(); this.resourceUris = action.getResourceUris();
} }
/** /**
* A self-editor is authorized to add, edit, or delete a statement if the * 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: * 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) { public PolicyDecision isAuthorized(List<String> userUris) {
for (String resourceUri : resourceUris) { for (String resourceUri : resourceUris) {
if (isInformationResource(resourceUri)) { if (isInfoContentEntity(resourceUri)) {
if (anyUrisInCommon(userUris, getUrisOfEditors(resourceUri))) {
return authorizedEditor(resourceUri);
}
if (anyUrisInCommon(userUris, getUrisOfAuthors(resourceUri))) { if (anyUrisInCommon(userUris, getUrisOfAuthors(resourceUri))) {
return authorizedAuthor(resourceUri); return authorizedAuthor(resourceUri);
} }
if (anyUrisInCommon(userUris, getUrisOfEditors(resourceUri))) {
return authorizedEditor(resourceUri);
}
if (anyUrisInCommon(userUris, getUrisOfFeatured(resourceUri))) { if (anyUrisInCommon(userUris, getUrisOfFeatured(resourceUri))) {
return authorizedFeatured(resourceUri); return authorizedFeatured(resourceUri);
} }
@ -58,16 +53,16 @@ public class InformationResourceChecker extends RelationshipChecker {
return null; return null;
} }
// ---------------------------------------------------------------------- private boolean isInfoContentEntity(String resourceUri) {
// methods for InformationResource return isResourceOfType(resourceUri, URI_INFO_CONTENT_TYPE);
// ----------------------------------------------------------------------
private boolean isInformationResource(String resourceUri) {
return isResourceOfType(resourceUri, URI_INFORMATION_RESOURCE_TYPE);
} }
private List<String> getUrisOfEditors(String resourceUri) { 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) { private List<String> getUrisOfFeatured(String resourceUri) {
@ -75,8 +70,11 @@ public class InformationResourceChecker extends RelationshipChecker {
} }
private List<String> getUrisOfAuthors(String resourceUri) { private List<String> getUrisOfAuthors(String resourceUri) {
return getObjectsOfLinkedProperty(resourceUri, List<String> allRelatedUris = getObjectsThroughLinkingNode(resourceUri,
URI_IN_AUTHORSHIP_PROPERTY, URI_LINKED_AUTHOR_PROPERTY); 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) { private PolicyDecision authorizedEditor(String uri) {

View file

@ -13,13 +13,10 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
* self-editor is authorized to modify? * self-editor is authorized to modify?
*/ */
public class PresentationChecker extends RelationshipChecker { 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 private static final String URI_PRESENTATION_TYPE = NS_CORE
+ "Presentation"; + "Presentation";
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE private static final String URI_PRESENTER_ROLE_TYPE = NS_CORE
+ "relatedRole"; + "PresenterRole";
private static final String URI_PRESENTER_ROLE_OF_PROPERTY = NS_CORE
+ "presenterRoleOf";
private final String[] resourceUris; private final String[] resourceUris;
@ -50,8 +47,8 @@ public class PresentationChecker extends RelationshipChecker {
} }
private List<String> getUrisOfPresenters(String resourceUri) { private List<String> getUrisOfPresenters(String resourceUri) {
return getObjectsOfLinkedProperty(resourceUri, return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES,
URI_RELATED_ROLE_PROPERTY, URI_PRESENTER_ROLE_OF_PROPERTY); URI_PRESENTER_ROLE_TYPE, URI_INHERES_IN);
} }
private PolicyDecision authorizedPresenter(String resourceUri) { private PolicyDecision authorizedPresenter(String resourceUri) {

View file

@ -13,13 +13,12 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AbstractPr
* self-editor is authorized to modify? * self-editor is authorized to modify?
*/ */
public class ProjectOrServiceChecker extends RelationshipChecker { 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_PROJECT_TYPE = NS_CORE + "Project";
private static final String URI_SERVICE_TYPE = NS_CORE + "Service"; private static final String URI_SERVICE_TYPE = NS_CORE + "Service";
private static final String URI_RELATED_ROLE_PROPERTY = NS_CORE private static final String URI_CLINICAL_ROLE_TYPE = NS_CORE
+ "relatedRole"; + "ClinicalRole";
private static final String URI_CLINICAL_ROLE_OF_PROPERTY = NS_CORE private static final String URI_CONTRIBUTING_ROLE_PROPERTY = NS_CORE
+ "clinicalRoleOf"; + "contributingRole";
private final String[] resourceUris; private final String[] resourceUris;
@ -37,9 +36,15 @@ public class ProjectOrServiceChecker extends RelationshipChecker {
*/ */
public PolicyDecision isAuthorized(List<String> userUris) { public PolicyDecision isAuthorized(List<String> userUris) {
for (String resourceUri : resourceUris) { for (String resourceUri : resourceUris) {
if (isProject(resourceUri) || isService(resourceUri)) { if (isProject(resourceUri)) {
if (anyUrisInCommon(userUris, if (anyUrisInCommon(userUris,
getUrisOfClinicalAgents(resourceUri))) { getClinicalAgentsOfProject(resourceUri))) {
return authorizedClinicalAgent(resourceUri);
}
}
if (isService(resourceUri)) {
if (anyUrisInCommon(userUris,
getClinicalAgentsOfService(resourceUri))) {
return authorizedClinicalAgent(resourceUri); return authorizedClinicalAgent(resourceUri);
} }
} }
@ -55,9 +60,15 @@ public class ProjectOrServiceChecker extends RelationshipChecker {
return isResourceOfType(resourceUri, URI_SERVICE_TYPE); return isResourceOfType(resourceUri, URI_SERVICE_TYPE);
} }
private List<String> getUrisOfClinicalAgents(String resourceUri) { private List<String> getClinicalAgentsOfProject(String resourceUri) {
return getObjectsOfLinkedProperty(resourceUri, return getObjectsThroughLinkingNode(resourceUri, URI_REALIZES,
URI_RELATED_ROLE_PROPERTY, URI_CLINICAL_ROLE_OF_PROPERTY); 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) { private PolicyDecision authorizedClinicalAgent(String resourceUri) {

View file

@ -86,7 +86,7 @@ public class SelfEditorRelationshipPolicy extends AbstractRelationshipPolicy
private PolicyDecision checkRelationships(List<String> userUris, private PolicyDecision checkRelationships(List<String> userUris,
AbstractPropertyStatementAction action) { AbstractPropertyStatementAction action) {
PolicyDecision decision = new InformationResourceChecker(action) PolicyDecision decision = new InfoContentEntityChecker(action)
.isAuthorized(userUris); .isAuthorized(userUris);
if (decision == null) { if (decision == null) {
decision = new GrantChecker(action).isAuthorized(userUris); decision = new GrantChecker(action).isAuthorized(userUris);
@ -101,6 +101,9 @@ public class SelfEditorRelationshipPolicy extends AbstractRelationshipPolicy
if (decision == null) { if (decision == null) {
decision = new CourseChecker(action).isAuthorized(userUris); decision = new CourseChecker(action).isAuthorized(userUris);
} }
if (decision == null) {
decision = new AdvisingRelationshipChecker(action).isAuthorized(userUris);
}
if (decision == null) { if (decision == null) {
decision = userNotAuthorizedToStatement(); decision = userNotAuthorizedToStatement();
} }

View file

@ -44,7 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
/** /**
* Check the relationships in the SelfEditorRelationshipPolicy. * 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 * 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 * configurable relationships, then we'll be able to make more general tests as
* well. * well.
@ -153,7 +153,6 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
@Before @Before
public void setLogging() { public void setLogging() {
// setLoggerLevel(this.getClass(), Level.DEBUG); // setLoggerLevel(this.getClass(), Level.DEBUG);
// setLoggerLevel(InformationResourceEditingPolicy.class, Level.DEBUG);
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -221,18 +220,18 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// InformationResource tests // InfoContentEntity tests
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@Test @Test
public void dataPropSubjectIsInfoResourceButNobodyIsSelfEditing() { public void dataPropSubjectIsIceButNobodyIsSelfEditing() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action));
} }
@Test @Test
public void dataPropSubjectIsInfoResourceButNoAuthorsOrEditorsOrFeatured() { public void dataPropSubjectIsIceButNoAuthorsOrEditorsOrFeatured() {
action = new AddDataPropertyStatement(ontModel, URI_NOBODY_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_NOBODY_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
@ -240,28 +239,28 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void dataPropSubjectIsInfoResourceButWrongAuthor() { public void dataPropSubjectIsIceButWrongAuthor() {
action = new AddDataPropertyStatement(ontModel, URI_BOZO_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_BOZO_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropSubjectIsInfoResourceButWrongEditor() { public void dataPropSubjectIsIceButWrongEditor() {
action = new AddDataPropertyStatement(ontModel, URI_BOZO_EDITED_IT, action = new AddDataPropertyStatement(ontModel, URI_BOZO_EDITED_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropSubjectIsInfoResourceButWrongFeatured() { public void dataPropSubjectIsIceButWrongFeatured() {
action = new AddDataPropertyStatement(ontModel, action = new AddDataPropertyStatement(ontModel,
URI_BOZO_FEATURED_IN_IT, URI_PERMITTED_PREDICATE); URI_BOZO_FEATURED_IN_IT, URI_PERMITTED_PREDICATE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void dataPropSubjectIsInfoResourceWithSelfEditingAuthor() { public void dataPropSubjectIsIceWithSelfEditingAuthor() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_WROTE_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
@ -269,7 +268,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void dataPropSubjectIsInfoResourceWithSelfEditingEditor() { public void dataPropSubjectIsIceWithSelfEditingEditor() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_EDITED_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
@ -277,7 +276,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void dataPropSubjectIsInfoResourceWithSelfEditingFeatured() { public void dataPropSubjectIsIceWithSelfEditingFeatured() {
action = new AddDataPropertyStatement(ontModel, URI_JOE_FEATURED_IN_IT, action = new AddDataPropertyStatement(ontModel, URI_JOE_FEATURED_IN_IT,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
@ -285,14 +284,14 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropSubjectIsInfoResourceButNobodyIsSelfEditing() { public void objectPropSubjectIsIceButNobodyIsSelfEditing() {
action = new AddObjectPropertyStatement(ontModel, URI_JOE_EDITED_IT, action = new AddObjectPropertyStatement(ontModel, URI_JOE_EDITED_IT,
PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idNobody, action));
} }
@Test @Test
public void objectPropSubjectIsInfoResourceButNoAuthorsOrEditorsOrFeatured() { public void objectPropSubjectIsIceButNoAuthorsOrEditorsOrFeatured() {
action = new AddObjectPropertyStatement(ontModel, URI_NOBODY_WROTE_IT, action = new AddObjectPropertyStatement(ontModel, URI_NOBODY_WROTE_IT,
PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
@ -300,21 +299,21 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropSubjectIsInfoResourceButWrongAuthor() { public void objectPropSubjectIsIceButWrongAuthor() {
action = new AddObjectPropertyStatement(ontModel, URI_BOZO_WROTE_IT, action = new AddObjectPropertyStatement(ontModel, URI_BOZO_WROTE_IT,
PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void objectPropSubjectIsInfoResourceButWrongEditor() { public void objectPropSubjectIsIceButWrongEditor() {
action = new AddObjectPropertyStatement(ontModel, URI_BOZO_EDITED_IT, action = new AddObjectPropertyStatement(ontModel, URI_BOZO_EDITED_IT,
PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void objectPropSubjectIsInfoResourceButWrongFeatured() { public void objectPropSubjectIsIceButWrongFeatured() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_BOZO_FEATURED_IN_IT, PERMITTED_PREDICATE, URI_BOZO_FEATURED_IN_IT, PERMITTED_PREDICATE,
URI_PERMITTED_RESOURCE); URI_PERMITTED_RESOURCE);
@ -322,7 +321,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropSubjectIsInfoResourceWithSelfEditingAuthor() { public void objectPropSubjectIsIceWithSelfEditingAuthor() {
action = new AddObjectPropertyStatement(ontModel, URI_JOE_WROTE_IT, action = new AddObjectPropertyStatement(ontModel, URI_JOE_WROTE_IT,
PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
@ -330,7 +329,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropSubjectIsInfoResourceWithSelfEditingEditor() { public void objectPropSubjectIsIceWithSelfEditingEditor() {
action = new AddObjectPropertyStatement(ontModel, URI_JOE_EDITED_IT, action = new AddObjectPropertyStatement(ontModel, URI_JOE_EDITED_IT,
PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE); PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE);
assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action)); assertDecision(AUTHORIZED, policy.isAuthorized(idJoe, action));
@ -338,7 +337,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropSubjectIsInfoResourceWithSelfEditingFeatured() { public void objectPropSubjectIsIceWithSelfEditingFeatured() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_JOE_FEATURED_IN_IT, PERMITTED_PREDICATE, URI_JOE_FEATURED_IN_IT, PERMITTED_PREDICATE,
URI_PERMITTED_RESOURCE); URI_PERMITTED_RESOURCE);
@ -347,7 +346,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourcebutNobodyIsSelfEditing() { public void objectPropObjectIsIcebutNobodyIsSelfEditing() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_JOE_EDITED_IT); URI_JOE_EDITED_IT);
@ -355,7 +354,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceButNoAuthorsOrEditors() { public void objectPropObjectIsIceButNoAuthorsOrEditors() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_NOBODY_WROTE_IT); URI_NOBODY_WROTE_IT);
@ -364,7 +363,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceButWrongAuthor() { public void objectPropObjectIsIceButWrongAuthor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_BOZO_WROTE_IT); URI_BOZO_WROTE_IT);
@ -372,7 +371,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceButWrongEditor() { public void objectPropObjectIsIceButWrongEditor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_BOZO_EDITED_IT); URI_BOZO_EDITED_IT);
@ -380,7 +379,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceButWrongFeatured() { public void objectPropObjectIsIceButWrongFeatured() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_BOZO_FEATURED_IN_IT); URI_BOZO_FEATURED_IN_IT);
@ -388,7 +387,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceWithSelfEditingAuthor() { public void objectPropObjectIsIceWithSelfEditingAuthor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_JOE_WROTE_IT); URI_JOE_WROTE_IT);
@ -397,7 +396,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceWithSelfEditingEditor() { public void objectPropObjectIsIceWithSelfEditingEditor() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_JOE_EDITED_IT); URI_JOE_EDITED_IT);
@ -406,7 +405,7 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
} }
@Test @Test
public void objectPropObjectIsInfoResourceWithSelfEditingFeatured() { public void objectPropObjectIsIceWithSelfEditingFeatured() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_JOE_FEATURED_IN_IT); URI_JOE_FEATURED_IN_IT);
@ -419,14 +418,14 @@ public class SelfEditorRelationshipPolicyTest extends AbstractTestClass {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@Test @Test
public void dataPropSubjectIsNotInfoResource() { public void dataPropSubjectIsNotIce() {
action = new AddDataPropertyStatement(ontModel, URI_PERMITTED_RESOURCE, action = new AddDataPropertyStatement(ontModel, URI_PERMITTED_RESOURCE,
URI_PERMITTED_PREDICATE); URI_PERMITTED_PREDICATE);
assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action)); assertDecision(INCONCLUSIVE, policy.isAuthorized(idJoe, action));
} }
@Test @Test
public void objectPropNeitherSubjectOrObjectIsInfoResource() { public void objectPropNeitherSubjectOrObjectIsIce() {
action = new AddObjectPropertyStatement(ontModel, action = new AddObjectPropertyStatement(ontModel,
URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE, URI_PERMITTED_RESOURCE, PERMITTED_PREDICATE,
URI_PERMITTED_RESOURCE); URI_PERMITTED_RESOURCE);

View file

@ -6,9 +6,11 @@
@prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix bib: <http://purl.org/ontology/bibo/> . @prefix bib: <http://purl.org/ontology/bibo/> .
@prefix core: <http://vivoweb.org/ontology/core#> . @prefix core: <http://vivoweb.org/ontology/core#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix mydomain: <http://vivo.mydomain.edu/individual/> . @prefix mydomain: <http://vivo.mydomain.edu/individual/> .
### This file is for the test InformationResourceEditingPolicyTest.java.
### This file contains data for SelfEditorRelationshipPolicyTest.java.
# #
# Bozo # Bozo
@ -21,8 +23,8 @@ mydomain:bozo
rdfs:label "Person, Bozo" ; rdfs:label "Person, Bozo" ;
foaf:firstName "Bozo" ; foaf:firstName "Bozo" ;
foaf:lastName "Person" ; foaf:lastName "Person" ;
core:editorOf mydomain:bozoEditedIt ; core:relatedBy mydomain:authorshipBozo ;
core:authorInAuthorship mydomain:authorshipBozo ; core:relatedBy mydomain:editorshipBozo ;
. .
# #
@ -36,16 +38,16 @@ mydomain:joe
rdfs:label "Person, Joe" ; rdfs:label "Person, Joe" ;
foaf:firstName "Joe" ; foaf:firstName "Joe" ;
foaf:lastName "Person" ; foaf:lastName "Person" ;
core:editorOf mydomain:joeEditedIt ; core:relatedBy mydomain:authorshipJoe ;
core:authorInAuthorship mydomain:authorshipJoe ; core:relatedBy mydomain:editorshipJoe ;
. .
# #
# info resource with no author or editor # info content entity with no author or editor
# #
mydomain:nobodyWroteIt mydomain:nobodyWroteIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;
@ -53,45 +55,53 @@ mydomain:nobodyWroteIt
. .
# #
# info resource with Bozo as author # info content entity with Bozo as author
# #
mydomain:bozoWroteIt mydomain:bozoWroteIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;
rdfs:label "Bozo is author" ; rdfs:label "Bozo is author" ;
core:informationResourceInAuthorship mydomain:authorshipBozo ; core:relatedBy mydomain:authorshipBozo ;
. .
mydomain:authorshipBozo mydomain:authorshipBozo
a core:Authorship ; a core:Authorship ;
a core:Relationship ; a core:Relationship ;
a owl:Thing ; a owl:Thing ;
core:linkedInformationResource mydomain:bozoWroteIt ; core:relates mydomain:bozoWroteIt ;
core:linkedAuthor mydomain:bozo ; core:relates mydomain:bozo ;
. .
# #
# info resource with Bozo as editor # info content entity with Bozo as editor
# #
mydomain:bozoEditedIt mydomain:bozoEditedIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;
rdfs:label "Bozo is editor" ; 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 mydomain:bozoFeaturedInIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;
@ -100,45 +110,53 @@ mydomain:bozoFeaturedInIt
. .
# #
# info resource with Joe as author # info content entity with Joe as author
# #
mydomain:joeWroteIt mydomain:joeWroteIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;
rdfs:label "Joe is author" ; rdfs:label "Joe is author" ;
core:informationResourceInAuthorship mydomain:authorshipJoe ; core:relatedBy mydomain:authorshipJoe ;
. .
mydomain:authorshipJoe mydomain:authorshipJoe
a core:Authorship ; a core:Authorship ;
a core:Relationship ; a core:Relationship ;
a owl:Thing ; a owl:Thing ;
core:linkedInformationResource mydomain:joeWroteIt ; core:relates mydomain:joeWroteIt ;
core:linkedAuthor mydomain:joe ; core:relates mydomain:joe ;
. .
# #
# info resource with Joe as editor # info content entity with Joe as editor
# #
mydomain:joeEditedIt mydomain:joeEditedIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;
rdfs:label "Joe is editor" ; 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 mydomain:joeFeaturedInIt
a core:BlogPosting ; a core:BlogPosting ;
a core:InformationResource ; a obo:IAO_0000030 ;
a bib:Article ; a bib:Article ;
a bib:Document ; a bib:Document ;
a owl:Thing ; a owl:Thing ;