@Test public void testValidAccessTeacher2() { setupCurrentUser(teacher2); Assert.assertTrue(validator.validate(EntityNames.PROGRAM, new HashSet<String>(Arrays.asList(program2.getEntityId()))).size() == 1); }
@Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.PROGRAM, entityType, ids)) { return new HashSet<String>(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria("body.staffId", "=", SecurityUtil.getSLIPrincipal().getEntity().getEntityId(), false)); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } addEndDateToQuery(nq, false); Set<String> validIds = new HashSet<String>(); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); for (Entity assoc : assocs) { validIds.add((String) assoc.getBody().get("programId")); } validIds.retainAll(ids); return validIds; }
GenericToProgramValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.PROGRAM, entityType, ids)) { return new HashSet<String>(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria("body.staffId", "=", SecurityUtil.getSLIPrincipal().getEntity().getEntityId(), false)); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } addEndDateToQuery(nq, false); Set<String> validIds = new HashSet<String>(); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); for (Entity assoc : assocs) { validIds.add((String) assoc.getBody().get("programId")); } validIds.retainAll(ids); return validIds; } }
GenericToProgramValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.PROGRAM, entityType, ids)) { return new HashSet<String>(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria("body.staffId", "=", SecurityUtil.getSLIPrincipal().getEntity().getEntityId(), false)); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } addEndDateToQuery(nq, false); Set<String> validIds = new HashSet<String>(); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); for (Entity assoc : assocs) { validIds.add((String) assoc.getBody().get("programId")); } validIds.retainAll(ids); return validIds; }  }
GenericToProgramValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.PROGRAM, entityType, ids)) { return new HashSet<String>(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria("body.staffId", "=", SecurityUtil.getSLIPrincipal().getEntity().getEntityId(), false)); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } addEndDateToQuery(nq, false); Set<String> validIds = new HashSet<String>(); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); for (Entity assoc : assocs) { validIds.add((String) assoc.getBody().get("programId")); } validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext(); }
GenericToProgramValidator extends AbstractContextValidator { @Override public Set<String> validate(String entityType, Set<String> ids) throws IllegalStateException { if (!areParametersValid(EntityNames.PROGRAM, entityType, ids)) { return new HashSet<String>(); } NeutralQuery nq = new NeutralQuery(new NeutralCriteria("body.staffId", "=", SecurityUtil.getSLIPrincipal().getEntity().getEntityId(), false)); if (SecurityUtil.getSLIPrincipal().isStudentAccessFlag()) { nq.addCriteria(new NeutralCriteria(ParameterConstants.STUDENT_RECORD_ACCESS, NeutralCriteria.OPERATOR_EQUAL, true)); } addEndDateToQuery(nq, false); Set<String> validIds = new HashSet<String>(); Iterable<Entity> assocs = getRepo().findAll(EntityNames.STAFF_PROGRAM_ASSOCIATION, nq); for (Entity assoc : assocs) { validIds.add((String) assoc.getBody().get("programId")); } validIds.retainAll(ids); return validIds; }  @Override boolean canValidate(String entityType, boolean isTransitive); @Override Set<String> validate(String entityType, Set<String> ids); @Override SecurityUtil.UserContext getContext();  }