target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testManyExtractedEntities() { Entity e = Mockito.mock(Entity.class); Mockito.when(mockRepo.findEach(Mockito.eq("student"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(e, e, e).iterator()); Map<String, DateTime> datedEdorgs = new HashMap<String, DateTime>(); datedEdorgs.put("LEA", DateTime.now()); Mockito.when(helper.fetchAllEdOrgsForStudent(Mockito.any(Entity.class))).thenReturn(datedEdorgs); extractor.extractEntities(null); Mockito.verify(mockExtractor, Mockito.times(3)).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("student"), Mockito.any(Predicate.class)); }
|
@Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgCache dummyCache); EntityToEdOrgCache getParentCache(); EntityToEdOrgDateCache getStudentDatedCache(); EntityToEdOrgDateCache getDiDateCache(); }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgCache dummyCache); EntityToEdOrgCache getParentCache(); EntityToEdOrgDateCache getStudentDatedCache(); EntityToEdOrgDateCache getDiDateCache(); }
|
@Test public void testNoExtractedEntities() { Entity e = Mockito.mock(Entity.class); Mockito.when(mockRepo.findEach(Mockito.eq("student"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(e).iterator()); extractor.extractEntities(null); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("student")); extractor.extractEntities(null); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("student")); }
|
@Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgCache dummyCache); EntityToEdOrgCache getParentCache(); EntityToEdOrgDateCache getStudentDatedCache(); EntityToEdOrgDateCache getDiDateCache(); }
|
StudentExtractor implements EntityExtract { @Override public void extractEntities(EntityToEdOrgCache dummyCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach(EntityNames.STUDENT, new NeutralQuery()); while (cursor.hasNext()) { Entity student = cursor.next(); buildStudentDatedCache(student); final Map<String, DateTime> datedEdOrgs = studentDatedCache.getEntriesById(student.getEntityId()); for (final String edOrg : map.getEdOrgs()) { if (datedEdOrgs.containsKey(edOrg)) { extractor.extractEntity(student, map.getExtractFileForEdOrg(edOrg), EntityNames.STUDENT, new Predicate<Entity>() { @Override public boolean apply(Entity input) { boolean shouldExtract = true; if (DATED_SUBDOCS.contains(input.getType())) { DateTime upToDate = datedEdOrgs.get(edOrg); shouldExtract = EntityDateHelper.shouldExtract(input, upToDate); } return shouldExtract; } }); Iterable<String> parents = helper.fetchCurrentParentsFromStudent(student); for (String parent : parents) { parentCache.addEntry(parent, edOrg); } } } List<Entity> sdias = student.getEmbeddedData().get("studentDisciplineIncidentAssociation"); if (sdias != null) { for (Entity sdia : sdias) { String did = (String) sdia.getBody().get("disciplineIncidentId"); Map<String, DateTime> edOrgsDate = studentDatedCache.getEntriesById(student.getEntityId()); for (Map.Entry<String, DateTime> entry : edOrgsDate.entrySet()) { diDateCache.addEntry(did, entry.getKey(), entry.getValue()); } } } } } StudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
ExtractorHelper helper, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgCache dummyCache); EntityToEdOrgCache getParentCache(); EntityToEdOrgDateCache getStudentDatedCache(); EntityToEdOrgDateCache getDiDateCache(); }
|
@Test public void testGetValue() { BSONObject field = new BasicBSONObject("field", "TEST1"); BSONObject entry = new BasicBSONObject("enum", field); BSONWritable entity = new BSONWritable(entry); EnumValueMapper<Testing> m = new EnumValueMapper<Testing>("enum.field", Testing.class); Writable value = m.getValue(entity); assertFalse(value instanceof NullWritable); assertTrue(value instanceof Text); assertEquals(((Text) value).toString(), Testing.TEST1.toString()); }
|
@Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } EnumValueMapper(String fieldName, Class<T> v); }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } EnumValueMapper(String fieldName, Class<T> v); @Override Writable getValue(BSONWritable entity); }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } EnumValueMapper(String fieldName, Class<T> v); @Override Writable getValue(BSONWritable entity); }
|
@Test public void testExtractOneEntity() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testExtractManyEntity() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity, mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor, Mockito.times(2)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testExtractNoEntityBecauseWrongDate() { entityBody.put(ParameterConstants.BEGIN_DATE, "2012-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testExtractNoEntityBecauseOfLEAMiss() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockEntity.getEntityId()).thenReturn("Staff2"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(null); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_PROGRAM_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffProgramAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_PROGRAM_ASSOCIATION, this.getClass().getName()); Iterator<Entity> spas = repo.findEach(EntityNames.STAFF_PROGRAM_ASSOCIATION, new NeutralQuery()); while (spas.hasNext()) { Entity spa = spas.next(); String staffId = (String) spa.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(spa, datedEdOrg.getValue())) { extractor.extractEntity(spa, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_PROGRAM_ASSOCIATION); } } } } StaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testBuildExtractFile() { Assert.assertTrue(factory.buildEdOrgExtractFile("bloop", "Bleep", "BLOO BLOO", null, null) != null); Assert.assertTrue(factory.buildEdOrgExtractFile("bloop", "Bleep", "BLOOB BLOO", null, null).getClass() == ExtractFile.class); }
|
public ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName, Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil) { File directory = new File(path, edOrg); directory.mkdirs(); return new ExtractFile(directory, archiveName, appPublicKeys, securityEventUtil); }
|
ExtractorFactory { public ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName, Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil) { File directory = new File(path, edOrg); directory.mkdirs(); return new ExtractFile(directory, archiveName, appPublicKeys, securityEventUtil); } }
|
ExtractorFactory { public ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName, Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil) { File directory = new File(path, edOrg); directory.mkdirs(); return new ExtractFile(directory, archiveName, appPublicKeys, securityEventUtil); } }
|
ExtractorFactory { public ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName, Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil) { File directory = new File(path, edOrg); directory.mkdirs(); return new ExtractFile(directory, archiveName, appPublicKeys, securityEventUtil); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
ExtractorFactory { public ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName, Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil) { File directory = new File(path, edOrg); directory.mkdirs(); return new ExtractFile(directory, archiveName, appPublicKeys, securityEventUtil); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
@Test public void testBuildAttendanceExtractor() { Assert.assertTrue(factory.buildAttendanceExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildAttendanceExtractor(null, null, null, null).getClass() == AttendanceExtractor.class); }
|
public EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new AttendanceExtractor(extractor, map, repo, edOrgExtractHelper); }
|
ExtractorFactory { public EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new AttendanceExtractor(extractor, map, repo, edOrgExtractHelper); } }
|
ExtractorFactory { public EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new AttendanceExtractor(extractor, map, repo, edOrgExtractHelper); } }
|
ExtractorFactory { public EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new AttendanceExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
ExtractorFactory { public EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new AttendanceExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
@Test public void testBuildStudentExtractor() { Assert.assertTrue(factory.buildStudentExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildStudentExtractor(null, null, null, null).getClass() == StudentExtractor.class); }
|
public StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentExtractor(extractor, map, repo, new ExtractorHelper(edOrgExtractHelper), edOrgExtractHelper); }
|
ExtractorFactory { public StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentExtractor(extractor, map, repo, new ExtractorHelper(edOrgExtractHelper), edOrgExtractHelper); } }
|
ExtractorFactory { public StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentExtractor(extractor, map, repo, new ExtractorHelper(edOrgExtractHelper), edOrgExtractHelper); } }
|
ExtractorFactory { public StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentExtractor(extractor, map, repo, new ExtractorHelper(edOrgExtractHelper), edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
ExtractorFactory { public StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentExtractor(extractor, map, repo, new ExtractorHelper(edOrgExtractHelper), edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
@Test public void testBuildStudentAssessmentExtractor() { Assert.assertTrue(factory.buildStudentAssessmentExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildStudentAssessmentExtractor(null, null, null, null).getClass() == StudentAssessmentExtractor.class); }
|
public EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentAssessmentExtractor(extractor, map, repo, edOrgExtractHelper); }
|
ExtractorFactory { public EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentAssessmentExtractor(extractor, map, repo, edOrgExtractHelper); } }
|
ExtractorFactory { public EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentAssessmentExtractor(extractor, map, repo, edOrgExtractHelper); } }
|
ExtractorFactory { public EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentAssessmentExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
ExtractorFactory { public EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StudentAssessmentExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
@Test public void testBuildStaffExtractor() { Assert.assertTrue(factory.buildStaffExtractor(null, null, null, null) != null); Assert.assertTrue(factory.buildStaffExtractor(null, null, null, null).getClass() == StaffExtractor.class); }
|
public EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StaffExtractor(extractor, map, repo, edOrgExtractHelper); }
|
ExtractorFactory { public EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StaffExtractor(extractor, map, repo, edOrgExtractHelper); } }
|
ExtractorFactory { public EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StaffExtractor(extractor, map, repo, edOrgExtractHelper); } }
|
ExtractorFactory { public EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StaffExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
ExtractorFactory { public EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper) { return new StaffExtractor(extractor, map, repo, edOrgExtractHelper); } StudentExtractor buildStudentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); YearlyTranscriptExtractor buildYearlyTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityExtract buildParentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); StaffEdorgAssignmentExtractor buildStaffAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStaffExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildTeacherSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildAttendanceExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); ExtractFile buildEdOrgExtractFile(String path, String edOrg, String archiveName,
Map<String, PublicKey> appPublicKeys, SecurityEventUtil securityEventUtil); EntityDatedExtract buildStaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); SectionEmbeddedDocsExtractor buildSectionExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache studentDatedCache, EdOrgExtractHelper edOrgExtractHelper, EntityToEdOrgDateCache staffDatedCache); EntityDatedExtract buildStaffProgramAssociationExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildCourseTranscriptExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EntityToEdOrgDateCache studentDatedCache); StudentGradebookEntryExtractor buildStudentGradebookEntryExtractor(EntityExtractor extractor, ExtractFileMap map,
Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); EntityDatedExtract buildStudentCompetencyExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository); EntityDatedExtract buildDisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository,
EntityToEdOrgDateCache entityCache); }
|
@Test public void testFetchCurrentParentsFromStudentNullChecks() { Map<String, List<Entity>> embeddedData = new HashMap<String, List<Entity>>(); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Mockito.when(mockEntity.getEmbeddedData()).thenReturn(embeddedData); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Entity parentAssoc1 = Mockito.mock(Entity.class); Entity parentAssoc2 = Mockito.mock(Entity.class); Map<String, Object> body = Mockito.mock(Map.class); Map<String, Object> body2 = Mockito.mock(Map.class); Mockito.when(parentAssoc1.getBody()).thenReturn(body); Mockito.when(parentAssoc2.getBody()).thenReturn(body2); List<Entity> parentAssociations = Arrays.asList(parentAssoc1, parentAssoc2); embeddedData.put(EntityNames.STUDENT_PARENT_ASSOCIATION, parentAssociations); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 0); Mockito.when(body.get(Mockito.eq(ParameterConstants.PARENT_ID))).thenReturn("ParentId123"); Mockito.when(body2.get(Mockito.eq(ParameterConstants.PARENT_ID))).thenReturn("ParentId456"); Assert.assertTrue(helper.fetchCurrentParentsFromStudent(mockEntity).size() == 2); }
|
public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; }
|
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } }
|
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } ExtractorHelper(); ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); }
|
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } ExtractorHelper(); ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); Map<String, DateTime> fetchAllEdOrgsForStudent(Entity student); Map<String, DateTime> updateEdorgToDateMap(Map<String, Object> entityBody, Map<String, DateTime> edOrgToDate,
String edOrgIdField, String beginDateField, String endDateField); void setDateHelper(DateHelper helper); Set<String> fetchCurrentParentsFromStudent(Entity student); Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache); EdOrgExtractHelper getEdOrgExtractHelper(); void setEdOrgExtractHelper(EdOrgExtractHelper edOrgExtractHelper); }
|
ExtractorHelper { public Set<String> fetchCurrentParentsFromStudent(Entity student) { Set<String> parents = new TreeSet<String>(); if (student.getEmbeddedData().containsKey(EntityNames.STUDENT_PARENT_ASSOCIATION)) { for (Entity assoc : student.getEmbeddedData().get(EntityNames.STUDENT_PARENT_ASSOCIATION)) { String parentId = (String) assoc.getBody().get(ParameterConstants.PARENT_ID); if (parentId != null) { parents.add(parentId); } } } return parents; } ExtractorHelper(); ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); Map<String, DateTime> fetchAllEdOrgsForStudent(Entity student); Map<String, DateTime> updateEdorgToDateMap(Map<String, Object> entityBody, Map<String, DateTime> edOrgToDate,
String edOrgIdField, String beginDateField, String endDateField); void setDateHelper(DateHelper helper); Set<String> fetchCurrentParentsFromStudent(Entity student); Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache); EdOrgExtractHelper getEdOrgExtractHelper(); void setEdOrgExtractHelper(EdOrgExtractHelper edOrgExtractHelper); }
|
@Test public void testGetValueNotFound() { BSONObject field = new BasicBSONObject("field", "Unknown"); BSONObject entry = new BasicBSONObject("enum", field); BSONWritable entity = new BSONWritable(entry); EnumValueMapper<Testing> m = new EnumValueMapper<Testing>("enum.field", Testing.class); Writable value = m.getValue(entity); assertTrue(value instanceof NullWritable); }
|
@Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } EnumValueMapper(String fieldName, Class<T> v); }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } EnumValueMapper(String fieldName, Class<T> v); @Override Writable getValue(BSONWritable entity); }
|
EnumValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { value = Enum.valueOf(enumClass, value).toString(); rval = new Text(value); } } catch (IllegalArgumentException e) { log.severe(String.format("Failed to convert value {%s} to Enum", value)); } return rval; } EnumValueMapper(String fieldName, Class<T> v); @Override Writable getValue(BSONWritable entity); }
|
@Test public void testBuildSubToParentEdOrgCache() { EntityToEdOrgCache cache = new EntityToEdOrgCache(); cache.addEntry("lea-1", "school-1"); cache.addEntry("lea-1", "school-2"); cache.addEntry("lea-1", "school-3"); cache.addEntry("lea-2", "school-4"); cache.addEntry("lea-2", "school-5"); cache.addEntry("lea-3", "school-6"); Map<String, Collection<String>> result = helper.buildSubToParentEdOrgCache(cache); Assert.assertEquals(6, result.keySet().size()); Assert.assertEquals(Sets.newHashSet("lea-1"), result.get("school-1")); Assert.assertEquals(Sets.newHashSet("lea-1"), result.get("school-2")); Assert.assertEquals(Sets.newHashSet("lea-1"), result.get("school-3")); Assert.assertEquals(Sets.newHashSet("lea-2"), result.get("school-4")); Assert.assertEquals(Sets.newHashSet("lea-2"), result.get("school-5")); Assert.assertEquals(Sets.newHashSet("lea-3"), result.get("school-6")); }
|
public Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache) { Map<String, String> result = new HashMap<String, String>(); HashMultimap<String, String> map = HashMultimap.create(); for(String lea : edOrgCache.getEntityIds()) { for (String child : edOrgCache.getEntriesById(lea)) { result.put(child, lea); map.put(child, lea); } } return map.asMap(); }
|
ExtractorHelper { public Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache) { Map<String, String> result = new HashMap<String, String>(); HashMultimap<String, String> map = HashMultimap.create(); for(String lea : edOrgCache.getEntityIds()) { for (String child : edOrgCache.getEntriesById(lea)) { result.put(child, lea); map.put(child, lea); } } return map.asMap(); } }
|
ExtractorHelper { public Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache) { Map<String, String> result = new HashMap<String, String>(); HashMultimap<String, String> map = HashMultimap.create(); for(String lea : edOrgCache.getEntityIds()) { for (String child : edOrgCache.getEntriesById(lea)) { result.put(child, lea); map.put(child, lea); } } return map.asMap(); } ExtractorHelper(); ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); }
|
ExtractorHelper { public Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache) { Map<String, String> result = new HashMap<String, String>(); HashMultimap<String, String> map = HashMultimap.create(); for(String lea : edOrgCache.getEntityIds()) { for (String child : edOrgCache.getEntriesById(lea)) { result.put(child, lea); map.put(child, lea); } } return map.asMap(); } ExtractorHelper(); ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); Map<String, DateTime> fetchAllEdOrgsForStudent(Entity student); Map<String, DateTime> updateEdorgToDateMap(Map<String, Object> entityBody, Map<String, DateTime> edOrgToDate,
String edOrgIdField, String beginDateField, String endDateField); void setDateHelper(DateHelper helper); Set<String> fetchCurrentParentsFromStudent(Entity student); Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache); EdOrgExtractHelper getEdOrgExtractHelper(); void setEdOrgExtractHelper(EdOrgExtractHelper edOrgExtractHelper); }
|
ExtractorHelper { public Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache) { Map<String, String> result = new HashMap<String, String>(); HashMultimap<String, String> map = HashMultimap.create(); for(String lea : edOrgCache.getEntityIds()) { for (String child : edOrgCache.getEntriesById(lea)) { result.put(child, lea); map.put(child, lea); } } return map.asMap(); } ExtractorHelper(); ExtractorHelper(EdOrgExtractHelper edOrgExtractHelper); Map<String, DateTime> fetchAllEdOrgsForStudent(Entity student); Map<String, DateTime> updateEdorgToDateMap(Map<String, Object> entityBody, Map<String, DateTime> edOrgToDate,
String edOrgIdField, String beginDateField, String endDateField); void setDateHelper(DateHelper helper); Set<String> fetchCurrentParentsFromStudent(Entity student); Map<String, Collection<String>> buildSubToParentEdOrgCache(EntityToEdOrgCache edOrgCache); EdOrgExtractHelper getEdOrgExtractHelper(); void setEdOrgExtractHelper(EdOrgExtractHelper edOrgExtractHelper); }
|
@Test public void testExtractOneEntity() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testExtractManyEntity() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity, mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor, Mockito.times(2)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testExtractNoEntityBecauseWrongDate() { entityBody.put(ParameterConstants.BEGIN_DATE, "2012-05-01"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION), Mockito.eq(new NeutralQuery()))) .thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testExtractNoEntityBecauseOfLEAMiss() { entityBody.put(ParameterConstants.BEGIN_DATE, "2010-05-01"); Mockito.when(mockEntity.getEntityId()).thenReturn("Staff2"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(null); extractor.extractEntities(staffToLeaCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STAFF_COHORT_ASSOCIATION)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
StaffCohortAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache staffDatedCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STAFF_COHORT_ASSOCIATION, this.getClass().getName()); Iterator<Entity> scas = repo.findEach(EntityNames.STAFF_COHORT_ASSOCIATION, new NeutralQuery()); while (scas.hasNext()) { Entity sca = scas.next(); String staffId = (String) sca.getBody().get(ParameterConstants.STAFF_ID); Map<String, DateTime> edOrgs = staffDatedCache.getEntriesById(staffId); for (Map.Entry<String, DateTime> datedEdOrg : edOrgs.entrySet()) { if (EntityDateHelper.shouldExtract(sca, datedEdOrg.getValue())) { extractor.extractEntity(sca, map.getExtractFileForEdOrg(datedEdOrg.getKey()), EntityNames.STAFF_COHORT_ASSOCIATION); } } } } StaffCohortAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache staffDatedCache); }
|
@Test public void testWriteOneAttendance() { Mockito.when(mockRepo.findEach(Mockito.eq("attendance"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity).iterator()); entityBody.put("studentId", "student"); entityBody.put(ParameterConstants.SCHOOL_YEAR, "2010-2011"); extractor.extractEntities(mockCache); Mockito.verify(mockExtractor).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq("attendance")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
@Test public void testWriteManyAttendances() { Mockito.when(mockRepo.findEach(Mockito.eq("attendance"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity, mockEntity, mockEntity).iterator()); entityBody.put("studentId", "student"); entityBody.put(ParameterConstants.SCHOOL_YEAR, "2010-2011"); extractor.extractEntities(mockCache); Mockito.verify(mockExtractor, Mockito.times(3)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq("attendance")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
@Test public void testWriteNoAttendances() { Mockito.when(mockRepo.findEach(Mockito.eq("attendance"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity, mockEntity, mockEntity).iterator()); entityBody.put("studentId", "student"); entityBody.put(ParameterConstants.SCHOOL_YEAR, "2010-2011"); Mockito.when(mockCache.getEntriesById("student")).thenReturn(new HashMap<String, DateTime>()); extractor.extractEntities(mockCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq("attendance")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
@Test public void testWriteFutureAttendances() { Mockito.when(mockRepo.findEach(Mockito.eq("attendance"), Mockito.eq(new NeutralQuery()))).thenReturn( Arrays.asList(mockEntity, mockEntity, mockEntity).iterator()); entityBody.put("studentId", "student"); entityBody.put(ParameterConstants.SCHOOL_YEAR, "3010-3011"); extractor.extractEntities(mockCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq("attendance")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
AttendanceExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.ATTENDANCE, this.getClass().getName()); Iterator<Entity> attendances = repo.findEach("attendance", new NeutralQuery()); while (attendances.hasNext()) { Entity attendance = attendances.next(); Map<String, DateTime> studentEdOrgDate = studentCache.getEntriesById((String) attendance.getBody().get("studentId")); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (EntityDateHelper.shouldExtract(attendance, upToDate)) { extractor.extractEntity(attendance, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.ATTENDANCE); } } } } AttendanceExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo,
EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache studentCache); }
|
@Test public void testTwoLeasOneStudent() { Map<String, DateTime> edOrgDate = new HashMap<String, DateTime>(); edOrgDate.put("LEA-1", DateTime.now()); edOrgDate.put("LEA-2", DateTime.now()); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-1"))).thenReturn(edOrgDate); Entity e = Mockito.mock(Entity.class); Map entityBody = new HashMap<String, Object>(); entityBody.put("studentId", "student-1"); entityBody.put(ParameterConstants.ENTRY_DATE, "2013-01-01"); Mockito.when(e.getBody()).thenReturn(entityBody); Mockito.when(e.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Mockito.when(mockRepo.findEach(Mockito.eq("studentSchoolAssociation"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e).iterator()); ssaExtractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(2)).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("studentSchoolAssociation")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
@Test public void testGetValue() { BSONObject field = new BasicBSONObject("field", 1.312D); BSONObject entry = new BasicBSONObject("double", field); BSONWritable entity = new BSONWritable(entry); DoubleValueMapper mapper = new DoubleValueMapper("double.field"); Writable value = mapper.getValue(entity); assertFalse(value instanceof NullWritable); assertTrue(value instanceof DoubleWritable); assertEquals(((DoubleWritable) value).get(), 1.312D, 0.05); }
|
@Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); @Override Writable getValue(BSONWritable entity); }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); @Override Writable getValue(BSONWritable entity); }
|
@Test public void testOneStudentOneLea() { Map<String, DateTime> edOrgDate = new HashMap<String, DateTime>(); edOrgDate.put("LEA-1", DateTime.now()); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-1"))).thenReturn(edOrgDate); Entity e = Mockito.mock(Entity.class); Map entityBody = new HashMap<String, Object>(); entityBody.put("studentId", "student-1"); entityBody.put(ParameterConstants.ENTRY_DATE, "2013-01-01"); Mockito.when(e.getBody()).thenReturn(entityBody); Mockito.when(e.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Mockito.when(mockRepo.findEach(Mockito.eq("studentSchoolAssociation"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e).iterator()); ssaExtractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(1)).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("studentSchoolAssociation")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
@Test public void testTwoStudentsOneLea() { Map<String, DateTime> edOrgDate = new HashMap<String, DateTime>(); edOrgDate.put("LEA-1", DateTime.now()); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-1"))).thenReturn(edOrgDate); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-2"))).thenReturn(edOrgDate); Entity e1 = Mockito.mock(Entity.class); Map entityBody1 = new HashMap<String, Object>(); entityBody1.put("studentId", "student-1"); entityBody1.put(ParameterConstants.ENTRY_DATE, "2013-01-01"); Mockito.when(e1.getBody()).thenReturn(entityBody1); Mockito.when(e1.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Entity e2 = Mockito.mock(Entity.class); Map entityBody2 = new HashMap<String, Object>(); entityBody2.put("studentId", "student-2"); entityBody2.put(ParameterConstants.ENTRY_DATE, "2013-01-01"); Mockito.when(e2.getBody()).thenReturn(entityBody2); Mockito.when(e2.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Mockito.when(mockRepo.findEach(Mockito.eq("studentSchoolAssociation"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e1, e2).iterator()); ssaExtractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(2)).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("studentSchoolAssociation")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
@Test public void testNonCurrentDate() { Map<String, DateTime> edOrgDate = new HashMap<String, DateTime>(); edOrgDate.put("LEA-1", DateTime.now()); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-1"))).thenReturn(edOrgDate); Mockito.when(mockStudentCache.getEntriesById(Mockito.eq("student-2"))).thenReturn(edOrgDate); Entity e1 = Mockito.mock(Entity.class); Map entityBody1 = new HashMap<String, Object>(); entityBody1.put("studentId", "student-1"); entityBody1.put(ParameterConstants.ENTRY_DATE, "2013-01-01"); Mockito.when(e1.getBody()).thenReturn(entityBody1); Mockito.when(e1.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Entity e2 = Mockito.mock(Entity.class); Map entityBody2 = new HashMap<String, Object>(); entityBody2.put("studentId", "student-2"); entityBody2.put(ParameterConstants.ENTRY_DATE, "3000-01-01"); Mockito.when(e2.getBody()).thenReturn(entityBody2); Mockito.when(e2.getType()).thenReturn(EntityNames.STUDENT_SCHOOL_ASSOCIATION); Mockito.when(mockRepo.findEach(Mockito.eq("studentSchoolAssociation"), Mockito.eq(new NeutralQuery()))).thenReturn(Arrays.asList(e1, e2).iterator()); ssaExtractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(1)).extractEntity(Mockito.any(Entity.class), Mockito.any(ExtractFile.class), Mockito.eq("studentSchoolAssociation")); }
|
@Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
StudentSchoolAssociationExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache studentDateCache) { helper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_SCHOOL_ASSOCIATION, this.getClass().getName()); Iterator<Entity> cursor = repo.findEach("studentSchoolAssociation", new NeutralQuery()); while(cursor.hasNext()) { Entity ssa = cursor.next(); Map<String, DateTime> studentEdOrgDate = studentDateCache.getEntriesById((String) ssa.getBody().get(ParameterConstants.STUDENT_ID)); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(ssa, upToDate)) { extractor.extractEntity(ssa, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_SCHOOL_ASSOCIATION); } } } } StudentSchoolAssociationExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper helper); @Override void extractEntities(EntityToEdOrgDateCache studentDateCache); }
|
@Test public void testExtractDisciplineIncidentAndAction() { Entity da1 = createDisciplineAction("2009-01-01"); Entity da2 = createDisciplineAction("2010-02-13"); Mockito.when(repo.findEach(Mockito.eq("disciplineAction"), Mockito.any(NeutralQuery.class))).thenReturn(Arrays.asList(da1, da2).listIterator(0)); Entity di1 = createDisciplineIncident("2000-02-01"); Entity di2 = createDisciplineIncident("2011-02-01"); Mockito.when(repo.findEach(Mockito.eq("disciplineIncident"), Mockito.any(NeutralQuery.class))).thenReturn(Arrays.asList(di1, di2).listIterator(0)); EntityToEdOrgDateCache diCache = new EntityToEdOrgDateCache(); diCache.addEntry("marker", LEA2, DateTime.parse("2010-02-12", DateHelper.getDateTimeFormat())); diCache.addEntry(DI_ID, LEA2, DateTime.parse("2010-02-12", DateHelper.getDateTimeFormat())); disc.extractEntities(diCache); Mockito.verify(ex, Mockito.times(1)).extractEntity(Mockito.eq(da1), Mockito.any(ExtractFile.class), Mockito.eq("disciplineAction")); Mockito.verify(ex, Mockito.never()).extractEntity(Mockito.eq(da2), Mockito.any(ExtractFile.class), Mockito.eq("disciplineAction")); Mockito.verify(ex, Mockito.times(1)).extractEntity(Mockito.eq(di1), Mockito.any(ExtractFile.class), Mockito.eq("disciplineIncident")); Mockito.verify(ex, Mockito.never()).extractEntity(Mockito.eq(di2), Mockito.any(ExtractFile.class), Mockito.eq("disciplineIncident")); }
|
@Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId(); Map<String, DateTime> edorgDate = diCache.getEntriesById(id); Set<String> edOrgs = new HashSet<String>(); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } return edOrgs; } }); extract(EntityNames.DISCIPLINE_ACTION, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { Set<String> edOrgs = new HashSet<String>(); List<String> students = (List<String>) input.getBody().get("studentId"); for (String student : students) { Map<String, DateTime> edorgDate = studentCache.getEntriesById(student); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } } return edOrgs; } }); }
|
DisciplineExtractor implements EntityDatedExtract { @Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId(); Map<String, DateTime> edorgDate = diCache.getEntriesById(id); Set<String> edOrgs = new HashSet<String>(); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } return edOrgs; } }); extract(EntityNames.DISCIPLINE_ACTION, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { Set<String> edOrgs = new HashSet<String>(); List<String> students = (List<String>) input.getBody().get("studentId"); for (String student : students) { Map<String, DateTime> edorgDate = studentCache.getEntriesById(student); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } } return edOrgs; } }); } }
|
DisciplineExtractor implements EntityDatedExtract { @Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId(); Map<String, DateTime> edorgDate = diCache.getEntriesById(id); Set<String> edOrgs = new HashSet<String>(); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } return edOrgs; } }); extract(EntityNames.DISCIPLINE_ACTION, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { Set<String> edOrgs = new HashSet<String>(); List<String> students = (List<String>) input.getBody().get("studentId"); for (String student : students) { Map<String, DateTime> edorgDate = studentCache.getEntriesById(student); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } } return edOrgs; } }); } DisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository, EntityToEdOrgDateCache studentCache); }
|
DisciplineExtractor implements EntityDatedExtract { @Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId(); Map<String, DateTime> edorgDate = diCache.getEntriesById(id); Set<String> edOrgs = new HashSet<String>(); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } return edOrgs; } }); extract(EntityNames.DISCIPLINE_ACTION, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { Set<String> edOrgs = new HashSet<String>(); List<String> students = (List<String>) input.getBody().get("studentId"); for (String student : students) { Map<String, DateTime> edorgDate = studentCache.getEntriesById(student); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } } return edOrgs; } }); } DisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository, EntityToEdOrgDateCache studentCache); @Override @SuppressWarnings("unchecked") void extractEntities(final EntityToEdOrgDateCache diCache); }
|
DisciplineExtractor implements EntityDatedExtract { @Override @SuppressWarnings("unchecked") public void extractEntities(final EntityToEdOrgDateCache diCache) { extract(EntityNames.DISCIPLINE_INCIDENT, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { String id = input.getEntityId(); Map<String, DateTime> edorgDate = diCache.getEntriesById(id); Set<String> edOrgs = new HashSet<String>(); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } return edOrgs; } }); extract(EntityNames.DISCIPLINE_ACTION, new Function<Entity, Set<String>>() { @Override public Set<String> apply(Entity input) { Set<String> edOrgs = new HashSet<String>(); List<String> students = (List<String>) input.getBody().get("studentId"); for (String student : students) { Map<String, DateTime> edorgDate = studentCache.getEntriesById(student); for (Map.Entry<String, DateTime> entry: edorgDate.entrySet()) { DateTime upToDate = entry.getValue(); if (shouldExtract(input, upToDate)) { edOrgs.add(entry.getKey()); } } } return edOrgs; } }); } DisciplineExtractor(EntityExtractor entityExtractor, ExtractFileMap extractFileMap, Repository<Entity> repository, EntityToEdOrgDateCache studentCache); @Override @SuppressWarnings("unchecked") void extractEntities(final EntityToEdOrgDateCache diCache); }
|
@Test public void testWriteOneEntity() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity).iterator()); entityBody.put(ParameterConstants.STUDENT_ID, "student"); extractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
@Test public void testWriteManyEntities() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity, mockEntity, mockEntity).iterator()); entityBody.put(ParameterConstants.STUDENT_ID, "student"); extractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(3)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
@Test public void testWriteSomeEntities() { Entity saEntity = Mockito.mock(Entity.class); Map<String, Object> saEntityBody = new HashMap<String, Object>(); saEntityBody.put("administrationDate", "3000-12-21"); saEntityBody.put(ParameterConstants.STUDENT_ID, "student"); Mockito.when(saEntity.getBody()).thenReturn(saEntityBody); Mockito.when(saEntity.getType()).thenReturn(EntityNames.STUDENT_ASSESSMENT); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity, saEntity).iterator()); entityBody.put(ParameterConstants.STUDENT_ID, "student"); extractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.times(1)).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); Mockito.verify(mockExtractor, Mockito.times(0)).extractEntity(Mockito.eq(saEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
@Test public void testExtractNoEntityBecauseOfLEAMiss() { Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(null); extractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
@Test public void testExtractNoEntityBecauseOfIdMiss() { entityBody.put(ParameterConstants.STUDENT_ID, "STUDENT1"); Mockito.when(mockRepo.findEach(Mockito.eq(EntityNames.STUDENT_ASSESSMENT), Mockito.eq(new NeutralQuery()))) .thenReturn( Arrays.asList(mockEntity).iterator()); Mockito.when(mockMap.getExtractFileForEdOrg("LEA")).thenReturn(mockFile); extractor.extractEntities(mockStudentCache); Mockito.verify(mockExtractor, Mockito.never()).extractEntity(Mockito.eq(mockEntity), Mockito.eq(mockFile), Mockito.eq(EntityNames.STUDENT_ASSESSMENT)); }
|
@Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
StudentAssessmentExtractor implements EntityDatedExtract { @Override public void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache) { edOrgExtractHelper.logSecurityEvent(map.getEdOrgs(), EntityNames.STUDENT_ASSESSMENT, this.getClass().getName()); Iterator<Entity> assessments = repo.findEach(EntityNames.STUDENT_ASSESSMENT, new NeutralQuery()); while (assessments.hasNext()) { Entity assessment = assessments.next(); String studentId = (String) assessment.getBody().get(ParameterConstants.STUDENT_ID); Map<String, DateTime> studentEdOrgDate = entityToEdOrgDateCache.getEntriesById(studentId); for (Map.Entry<String, DateTime> entry: studentEdOrgDate.entrySet()) { DateTime upToDate = entry.getValue(); if(EntityDateHelper.shouldExtract(assessment, upToDate)) { extractor.extractEntity(assessment, map.getExtractFileForEdOrg(entry.getKey()), EntityNames.STUDENT_ASSESSMENT); } } } } StudentAssessmentExtractor(EntityExtractor extractor, ExtractFileMap map, Repository<Entity> repo, EdOrgExtractHelper edOrgExtractHelper); @Override void extractEntities(EntityToEdOrgDateCache entityToEdOrgDateCache); }
|
@Test public void testAudit() { SecurityEvent securityEvent = new SecurityEvent(); securityEvent.setClassName(this.getClass().getName()); securityEvent.setLogMessage("Test Message"); securityEvent.setLogLevel(LogLevelType.TYPE_TRACE); audit(securityEvent); Mockito.verify(mockedEntityRepository, times(1)).create(any(String.class), any(Map.class), any(Map.class), any(String.class)); }
|
public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } }
|
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } }
|
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } @Autowired LogUtil(@Qualifier("secondaryRepo") Repository<Entity> repo); }
|
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } @Autowired LogUtil(@Qualifier("secondaryRepo") Repository<Entity> repo); static void audit(SecurityEvent event); static Repository<Entity> getEntityRepository(); static void setEntityRepository(Repository<Entity> entityRepository); }
|
LogUtil { public static void audit(SecurityEvent event) { if (entityRepository != null) { Map<String, Object> metadata = new HashMap<String, Object>(); metadata.put("tenantId", event.getTenantId()); entityRepository.create("securityEvent", event.getProperties(), metadata, "securityEvent"); } else { LOG.error("Could not log SecurityEvent to the database."); } switch (event.getLogLevel()) { case TYPE_DEBUG: LOG.debug(event.toString()); break; case TYPE_WARN: LOG.warn(event.toString()); break; case TYPE_INFO: LOG.info(event.toString()); break; case TYPE_ERROR: LOG.error(event.toString()); break; case TYPE_TRACE: LOG.trace(event.toString()); break; default: LOG.info(event.toString()); break; } } @Autowired LogUtil(@Qualifier("secondaryRepo") Repository<Entity> repo); static void audit(SecurityEvent event); static Repository<Entity> getEntityRepository(); static void setEntityRepository(Repository<Entity> entityRepository); }
|
@Test public void testValueNotFound() { BSONObject field = new BasicBSONObject("field", 1.312D); BSONObject entry = new BasicBSONObject("double", field); BSONWritable entity = new BSONWritable(entry); DoubleValueMapper mapper = new DoubleValueMapper("double.missing_field"); Writable value = mapper.getValue(entity); assertTrue(value instanceof NullWritable); }
|
@Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); @Override Writable getValue(BSONWritable entity); }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); @Override Writable getValue(BSONWritable entity); }
|
@Test public void generateArchiveTest() throws Exception { String fileName = archiveFile.getFileName(testApp); archiveFile.generateArchive(); TarArchiveInputStream tarInputStream = null; List<String> names = new ArrayList<String>(); File decryptedFile = null; try { decryptedFile = decrypt(new File(fileName)); tarInputStream = new TarArchiveInputStream(new FileInputStream(decryptedFile)); TarArchiveEntry entry = null; while((entry = tarInputStream.getNextTarEntry())!= null) { names.add(entry.getName()); } } finally { IOUtils.closeQuietly(tarInputStream); } Assert.assertEquals(2, names.size()); Assert.assertTrue("Student extract file not found", names.get(1).contains("student")); Assert.assertTrue("Metadata file not found", names.get(0).contains("metadata")); FileUtils.deleteQuietly(decryptedFile); }
|
public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_INFO, app, BEMessageCode.BE_SE_CODE_0022, app); event.setTargetEdOrgList(edorg); audit(event); multiOutputStream.addStream(getAppStream(app)); } tarArchiveOutputStream = new TarArchiveOutputStream(multiOutputStream); archiveFile(tarArchiveOutputStream, manifestFile.getFile()); File errors = errorFile.getFile(); if (errors != null) { archiveFile(tarArchiveOutputStream, errors); } for (JsonFileWriter dataFile : dataFiles.values()) { File df = dataFile.getFile(); if (df != null && df.exists()) { archiveFile(tarArchiveOutputStream, df); } } } catch (Exception e) { SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_ERROR, BEMessageCode.BE_SE_CODE_0023); event.setTargetEdOrgList(edorg); audit(event); LOG.error("Error writing to tar file: {}", e.getMessage()); success = false; for(File archiveFile : archiveFiles.values()){ FileUtils.deleteQuietly(archiveFile); } } finally { IOUtils.closeQuietly(tarArchiveOutputStream); FileUtils.deleteQuietly(tempDir); } return success; }
|
ExtractFile { public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_INFO, app, BEMessageCode.BE_SE_CODE_0022, app); event.setTargetEdOrgList(edorg); audit(event); multiOutputStream.addStream(getAppStream(app)); } tarArchiveOutputStream = new TarArchiveOutputStream(multiOutputStream); archiveFile(tarArchiveOutputStream, manifestFile.getFile()); File errors = errorFile.getFile(); if (errors != null) { archiveFile(tarArchiveOutputStream, errors); } for (JsonFileWriter dataFile : dataFiles.values()) { File df = dataFile.getFile(); if (df != null && df.exists()) { archiveFile(tarArchiveOutputStream, df); } } } catch (Exception e) { SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_ERROR, BEMessageCode.BE_SE_CODE_0023); event.setTargetEdOrgList(edorg); audit(event); LOG.error("Error writing to tar file: {}", e.getMessage()); success = false; for(File archiveFile : archiveFiles.values()){ FileUtils.deleteQuietly(archiveFile); } } finally { IOUtils.closeQuietly(tarArchiveOutputStream); FileUtils.deleteQuietly(tempDir); } return success; } }
|
ExtractFile { public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_INFO, app, BEMessageCode.BE_SE_CODE_0022, app); event.setTargetEdOrgList(edorg); audit(event); multiOutputStream.addStream(getAppStream(app)); } tarArchiveOutputStream = new TarArchiveOutputStream(multiOutputStream); archiveFile(tarArchiveOutputStream, manifestFile.getFile()); File errors = errorFile.getFile(); if (errors != null) { archiveFile(tarArchiveOutputStream, errors); } for (JsonFileWriter dataFile : dataFiles.values()) { File df = dataFile.getFile(); if (df != null && df.exists()) { archiveFile(tarArchiveOutputStream, df); } } } catch (Exception e) { SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_ERROR, BEMessageCode.BE_SE_CODE_0023); event.setTargetEdOrgList(edorg); audit(event); LOG.error("Error writing to tar file: {}", e.getMessage()); success = false; for(File archiveFile : archiveFiles.values()){ FileUtils.deleteQuietly(archiveFile); } } finally { IOUtils.closeQuietly(tarArchiveOutputStream); FileUtils.deleteQuietly(tempDir); } return success; } ExtractFile(File parentDir, String archiveName, Map<String, PublicKey> clientKeys, SecurityEventUtil securityEventUtil); }
|
ExtractFile { public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_INFO, app, BEMessageCode.BE_SE_CODE_0022, app); event.setTargetEdOrgList(edorg); audit(event); multiOutputStream.addStream(getAppStream(app)); } tarArchiveOutputStream = new TarArchiveOutputStream(multiOutputStream); archiveFile(tarArchiveOutputStream, manifestFile.getFile()); File errors = errorFile.getFile(); if (errors != null) { archiveFile(tarArchiveOutputStream, errors); } for (JsonFileWriter dataFile : dataFiles.values()) { File df = dataFile.getFile(); if (df != null && df.exists()) { archiveFile(tarArchiveOutputStream, df); } } } catch (Exception e) { SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_ERROR, BEMessageCode.BE_SE_CODE_0023); event.setTargetEdOrgList(edorg); audit(event); LOG.error("Error writing to tar file: {}", e.getMessage()); success = false; for(File archiveFile : archiveFiles.values()){ FileUtils.deleteQuietly(archiveFile); } } finally { IOUtils.closeQuietly(tarArchiveOutputStream); FileUtils.deleteQuietly(tempDir); } return success; } ExtractFile(File parentDir, String archiveName, Map<String, PublicKey> clientKeys, SecurityEventUtil securityEventUtil); JsonFileWriter getDataFileEntry(String filePrefix); void closeWriters(); ManifestFile getManifestFile(); ErrorFile getErrorLogger(); boolean generateArchive(); boolean finalizeExtraction(DateTime startTime); String getFileName(String appId); Map<String, File> getArchiveFiles(); Map<String, PublicKey> getClientKeys(); void setClientKeys(Map<String, PublicKey> clientKeys); String getEdorg(); void setEdorg(String edorg); }
|
ExtractFile { public boolean generateArchive() { boolean success = true; TarArchiveOutputStream tarArchiveOutputStream = null; MultiOutputStream multiOutputStream = new MultiOutputStream(); try { for(String app : clientKeys.keySet()){ SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_INFO, app, BEMessageCode.BE_SE_CODE_0022, app); event.setTargetEdOrgList(edorg); audit(event); multiOutputStream.addStream(getAppStream(app)); } tarArchiveOutputStream = new TarArchiveOutputStream(multiOutputStream); archiveFile(tarArchiveOutputStream, manifestFile.getFile()); File errors = errorFile.getFile(); if (errors != null) { archiveFile(tarArchiveOutputStream, errors); } for (JsonFileWriter dataFile : dataFiles.values()) { File df = dataFile.getFile(); if (df != null && df.exists()) { archiveFile(tarArchiveOutputStream, df); } } } catch (Exception e) { SecurityEvent event = securityEventUtil.createSecurityEvent(this.getClass().getName(), "Writing extract file to the file system", LogLevelType.TYPE_ERROR, BEMessageCode.BE_SE_CODE_0023); event.setTargetEdOrgList(edorg); audit(event); LOG.error("Error writing to tar file: {}", e.getMessage()); success = false; for(File archiveFile : archiveFiles.values()){ FileUtils.deleteQuietly(archiveFile); } } finally { IOUtils.closeQuietly(tarArchiveOutputStream); FileUtils.deleteQuietly(tempDir); } return success; } ExtractFile(File parentDir, String archiveName, Map<String, PublicKey> clientKeys, SecurityEventUtil securityEventUtil); JsonFileWriter getDataFileEntry(String filePrefix); void closeWriters(); ManifestFile getManifestFile(); ErrorFile getErrorLogger(); boolean generateArchive(); boolean finalizeExtraction(DateTime startTime); String getFileName(String appId); Map<String, File> getArchiveFiles(); Map<String, PublicKey> getClientKeys(); void setClientKeys(Map<String, PublicKey> clientKeys); String getEdorg(); void setEdorg(String edorg); }
|
@Test public void testErrorFile() throws IOException { File parentDir = new File("./"); parentDir.deleteOnExit(); ErrorFile error = new ErrorFile(parentDir); for (int i=0; i < 3; i++) { Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenReturn("TYPE" + i); error.logEntityError(entity); } Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenReturn("TYPE0"); error.logEntityError(entity); File result = error.getFile(); assertNotNull(result); String errorString = FileUtils.readFileToString(result); assertTrue(errorString.contains("2 errors occurred for entity type TYPE0\n")); assertTrue(errorString.contains("1 errors occurred for entity type TYPE1\n")); assertTrue(errorString.contains("1 errors occurred for entity type TYPE2\n")); }
|
public ErrorFile(File parent) { errorFile = new File(parent, ERROR_FILE_NAME); }
|
ErrorFile { public ErrorFile(File parent) { errorFile = new File(parent, ERROR_FILE_NAME); } }
|
ErrorFile { public ErrorFile(File parent) { errorFile = new File(parent, ERROR_FILE_NAME); } ErrorFile(File parent); }
|
ErrorFile { public ErrorFile(File parent) { errorFile = new File(parent, ERROR_FILE_NAME); } ErrorFile(File parent); void logEntityError(Entity entity); File getFile(); }
|
ErrorFile { public ErrorFile(File parent) { errorFile = new File(parent, ERROR_FILE_NAME); } ErrorFile(File parent); void logEntityError(Entity entity); File getFile(); static final String ERROR_FILE_NAME; }
|
@Test public void testWrite() { ExtractFile archiveFile = Mockito.mock(ExtractFile.class); JsonFileWriter jsonFile = Mockito.mock(JsonFileWriter.class); Mockito.when(archiveFile.getDataFileEntry(Mockito.anyString())).thenReturn(jsonFile); Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenReturn("teacher"); writer.write(entity, archiveFile); Mockito.verify(jsonWriter1, Mockito.times(1)).write(Mockito.any(Entity.class), Mockito.any(JsonFileWriter.class), Mockito.any(ErrorFile.class)); Mockito.verify(jsonWriter2, Mockito.times(1)).write(Mockito.any(Entity.class), Mockito.any(JsonFileWriter.class), Mockito.any(ErrorFile.class)); }
|
public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } Entity write(Entity entity, ExtractFile archiveFile); void writeDeleteFile(Entity entity, ExtractFile archiveFile); void setWriters(DefaultHashMap<String, EntityWriter> writers); void setMultiFileEntities(Map<String, String> multiFileEntities); void setEntities(Map<String, String> entities); }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } Entity write(Entity entity, ExtractFile archiveFile); void writeDeleteFile(Entity entity, ExtractFile archiveFile); void setWriters(DefaultHashMap<String, EntityWriter> writers); void setMultiFileEntities(Map<String, String> multiFileEntities); void setEntities(Map<String, String> entities); }
|
@Test public void testWriteDefault() { ExtractFile archiveFile = Mockito.mock(ExtractFile.class); JsonFileWriter jsonFile = Mockito.mock(JsonFileWriter.class); Mockito.when(archiveFile.getDataFileEntry(Mockito.anyString())).thenReturn(jsonFile); Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenReturn("student"); writer.write(entity, archiveFile); Mockito.verify(defaultWriter, Mockito.times(1)).write(Mockito.any(Entity.class), Mockito.any(JsonFileWriter.class), Mockito.any(ErrorFile.class)); Mockito.verify(jsonWriter1, Mockito.times(0)).write(Mockito.any(Entity.class), Mockito.any(JsonFileWriter.class), Mockito.any(ErrorFile.class)); Mockito.verify(jsonWriter2, Mockito.times(0)).write(Mockito.any(Entity.class), Mockito.any(JsonFileWriter.class), Mockito.any(ErrorFile.class)); }
|
public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } Entity write(Entity entity, ExtractFile archiveFile); void writeDeleteFile(Entity entity, ExtractFile archiveFile); void setWriters(DefaultHashMap<String, EntityWriter> writers); void setMultiFileEntities(Map<String, String> multiFileEntities); void setEntities(Map<String, String> entities); }
|
EntityWriterManager { public Entity write(Entity entity, ExtractFile archiveFile) { writeEntityFile(entity, archiveFile); writerCollectionFile(entity, archiveFile); return entity; } Entity write(Entity entity, ExtractFile archiveFile); void writeDeleteFile(Entity entity, ExtractFile archiveFile); void setWriters(DefaultHashMap<String, EntityWriter> writers); void setMultiFileEntities(Map<String, String> multiFileEntities); void setEntities(Map<String, String> entities); }
|
@Test public void testWrite() { JsonFileWriter file = Mockito.mock(JsonFileWriter.class); ErrorFile errorFile = Mockito.mock(ErrorFile.class); Entity entity = Mockito.mock(Entity.class); Entity check = writer.write(entity, file, errorFile); Assert.assertEquals(treatedEntity, check); try { Mockito.verify(file, Mockito.times(1)).write(treatedEntity); } catch (IOException e) { Assert.fail(); } }
|
public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); Entity write(Entity entity, JsonFileWriter file, ErrorFile errors); }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); Entity write(Entity entity, JsonFileWriter file, ErrorFile errors); }
|
@Test public void testIOException() throws IOException { JsonFileWriter file = Mockito.mock(JsonFileWriter.class); Mockito.doThrow(new IOException("Mock IOException")).when(file).write(Mockito.any(Entity.class)); ErrorFile errorFile = Mockito.mock(ErrorFile.class); Entity entity = Mockito.mock(Entity.class); Mockito.when(entity.getType()).thenReturn("MOCK_ENTITY_TYPE"); writer.write(entity, file, errorFile); Mockito.verify(errorFile).logEntityError(entity); Mockito.doThrow(Mockito.mock(JsonProcessingException.class)).when(file).write(Mockito.any(Entity.class)); writer.write(entity, file, errorFile); Mockito.verify(errorFile, Mockito.times(2)).logEntityError(entity); }
|
public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); Entity write(Entity entity, JsonFileWriter file, ErrorFile errors); }
|
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); Entity write(Entity entity, JsonFileWriter file, ErrorFile errors); }
|
@Test public void testGetSampleExtract() throws Exception { injector.setEducatorContext(); ResponseImpl res = (ResponseImpl) bulkExtract.get(req); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")); assertTrue(headers.containsKey("last-modified")); String header = (String) headers.getFirst("content-disposition"); assertNotNull(header); assertTrue(header.startsWith("attachment")); assertTrue(header.indexOf("sample-extract.tar") > 0); Object entity = res.getEntity(); assertNotNull(entity); StreamingOutput out = (StreamingOutput) entity; File file = new File("out.zip"); FileOutputStream os = new FileOutputStream(file); out.write(os); os.flush(); assertTrue(file.exists()); assertEquals(798669192L, FileUtils.checksumCRC32(file)); FileUtils.deleteQuietly(file); }
|
@GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) public Response get(@Context HttpServletRequest request) throws Exception { LOG.info("Received request to stream sample bulk extract..."); logSecurityEvent("Received request to stream sample bulk extract"); validateRequestCertificate(request); final InputStream is = this.getClass().getResourceAsStream("/bulkExtractSampleData/" + SAMPLED_FILE_NAME); StreamingOutput out = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { int n; byte[] buffer = new byte[1024]; while ((n = is.read(buffer)) > -1) { output.write(buffer, 0, n); } } }; ResponseBuilder builder = Response.ok(out); builder.header("content-disposition", "attachment; filename = " + SAMPLED_FILE_NAME); builder.header("last-modified", "Not Specified"); logSecurityEvent("Successful request to stream sample bulk extract"); return builder.build(); }
|
BulkExtract { @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) public Response get(@Context HttpServletRequest request) throws Exception { LOG.info("Received request to stream sample bulk extract..."); logSecurityEvent("Received request to stream sample bulk extract"); validateRequestCertificate(request); final InputStream is = this.getClass().getResourceAsStream("/bulkExtractSampleData/" + SAMPLED_FILE_NAME); StreamingOutput out = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { int n; byte[] buffer = new byte[1024]; while ((n = is.read(buffer)) > -1) { output.write(buffer, 0, n); } } }; ResponseBuilder builder = Response.ok(out); builder.header("content-disposition", "attachment; filename = " + SAMPLED_FILE_NAME); builder.header("last-modified", "Not Specified"); logSecurityEvent("Successful request to stream sample bulk extract"); return builder.build(); } }
|
BulkExtract { @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) public Response get(@Context HttpServletRequest request) throws Exception { LOG.info("Received request to stream sample bulk extract..."); logSecurityEvent("Received request to stream sample bulk extract"); validateRequestCertificate(request); final InputStream is = this.getClass().getResourceAsStream("/bulkExtractSampleData/" + SAMPLED_FILE_NAME); StreamingOutput out = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { int n; byte[] buffer = new byte[1024]; while ((n = is.read(buffer)) > -1) { output.write(buffer, 0, n); } } }; ResponseBuilder builder = Response.ok(out); builder.header("content-disposition", "attachment; filename = " + SAMPLED_FILE_NAME); builder.header("last-modified", "Not Specified"); logSecurityEvent("Successful request to stream sample bulk extract"); return builder.build(); } }
|
BulkExtract { @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) public Response get(@Context HttpServletRequest request) throws Exception { LOG.info("Received request to stream sample bulk extract..."); logSecurityEvent("Received request to stream sample bulk extract"); validateRequestCertificate(request); final InputStream is = this.getClass().getResourceAsStream("/bulkExtractSampleData/" + SAMPLED_FILE_NAME); StreamingOutput out = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { int n; byte[] buffer = new byte[1024]; while ((n = is.read(buffer)) > -1) { output.write(buffer, 0, n); } } }; ResponseBuilder builder = Response.ok(out); builder.header("content-disposition", "attachment; filename = " + SAMPLED_FILE_NAME); builder.header("last-modified", "Not Specified"); logSecurityEvent("Successful request to stream sample bulk extract"); return builder.build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) public Response get(@Context HttpServletRequest request) throws Exception { LOG.info("Received request to stream sample bulk extract..."); logSecurityEvent("Received request to stream sample bulk extract"); validateRequestCertificate(request); final InputStream is = this.getClass().getResourceAsStream("/bulkExtractSampleData/" + SAMPLED_FILE_NAME); StreamingOutput out = new StreamingOutput() { @Override public void write(OutputStream output) throws IOException, WebApplicationException { int n; byte[] buffer = new byte[1024]; while ((n = is.read(buffer)) > -1) { output.write(buffer, 0, n); } } }; ResponseBuilder builder = Response.ok(out); builder.header("content-disposition", "attachment; filename = " + SAMPLED_FILE_NAME); builder.header("last-modified", "Not Specified"); logSecurityEvent("Successful request to stream sample bulk extract"); return builder.build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testGetExtractResponse() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockBulkExtractEntity(null); HttpRequestContext context = new HttpRequestContextAdapter() { @Override public String getMethod() { return "GET"; } }; Response res = bulkExtract.getEdOrgExtractResponse(context, null, null); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")); assertTrue(headers.containsKey("last-modified")); String header = (String) headers.getFirst("content-disposition"); assertNotNull(header); assertTrue(header.startsWith("attachment")); assertTrue(header.indexOf(INPUT_FILE_NAME) > 0); Object entity = res.getEntity(); assertNotNull(entity); StreamingOutput out = (StreamingOutput) entity; ByteArrayOutputStream os = new ByteArrayOutputStream(); out.write(os); os.flush(); byte[] responseData = os.toByteArray(); String s = new String(responseData); assertEquals(BULK_DATA, s); }
|
Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testHeadTenant() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockBulkExtractEntity(null); HttpRequestContext context = new HttpRequestContextAdapter() { @Override public String getMethod() { return "HEAD"; } }; Response res = bulkExtract.getEdOrgExtractResponse(context, null, null); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")); assertTrue(headers.containsKey("last-modified")); String header = (String) headers.getFirst("content-disposition"); assertNotNull(header); assertTrue(header.startsWith("attachment")); assertTrue(header.indexOf(INPUT_FILE_NAME) > 0); Object entity = res.getEntity(); assertNull(entity); }
|
Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testRange() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockBulkExtractEntity(null); HttpRequestContext failureContext = Mockito.mock(HttpRequestContext.class); Mockito.when(failureContext.getMethod()).thenReturn("HEAD"); Mockito.when(failureContext.getHeaderValue("Range")).thenReturn("bytes=0"); Response failureRes = bulkExtract.getEdOrgExtractResponse(failureContext, null, null); assertEquals(416, failureRes.getStatus()); HttpRequestContext validContext = Mockito.mock(HttpRequestContext.class); Mockito.when(validContext.getMethod()).thenReturn("HEAD"); Mockito.when(validContext.getHeaderValue("Range")).thenReturn("bytes=0-5"); Response validRes = bulkExtract.getEdOrgExtractResponse(validContext, null, null); assertEquals(200, validRes.getStatus()); HttpRequestContext multiRangeContext = Mockito.mock(HttpRequestContext.class); Mockito.when(multiRangeContext.getMethod()).thenReturn("HEAD"); Mockito.when(multiRangeContext.getHeaderValue("Range")).thenReturn("bytes=0-5,6-10"); Response multiRangeRes = bulkExtract.getEdOrgExtractResponse(validContext, null, null); assertEquals(200, multiRangeRes.getStatus()); }
|
Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testGetValueNotDouble() { BSONObject field = new BasicBSONObject("field", "Bob"); BSONObject entry = new BasicBSONObject("double", field); BSONWritable entity = new BSONWritable(entry); DoubleValueMapper mapper = new DoubleValueMapper("double.field"); Writable value = mapper.getValue(entity); assertTrue(value instanceof NullWritable); }
|
@Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); @Override Writable getValue(BSONWritable entity); }
|
DoubleValueMapper extends ValueMapper { @Override public Writable getValue(BSONWritable entity) { Writable rval = NullWritable.get(); String value = null; try { value = BSONUtilities.getValue(entity, fieldName); if (value != null) { rval = new DoubleWritable(Double.parseDouble(value.toString())); } } catch (NumberFormatException e) { log.severe(String.format("Failed to convert value {%s} to Double", value)); } return rval; } DoubleValueMapper(String fieldName); @Override Writable getValue(BSONWritable entity); }
|
@Test public void testFailedEvaluatePreconditions() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockBulkExtractEntity(null); HttpRequestContext context = new HttpRequestContextAdapter() { @Override public ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag) { return Responses.preconditionFailed(); } }; Response res = bulkExtract.getEdOrgExtractResponse(context, null, null); assertEquals(412, res.getStatus()); }
|
Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { Response getEdOrgExtractResponse(final HttpRequestContext req, final String edOrgId, final String deltaDate) { ExtractFile ef = getEdOrgExtractFile(edOrgId, deltaDate); if (ef == null) { return Response.status(Status.NOT_FOUND).build(); } return fileResource.getFileResponse(req, ef, ef.getLastModified()); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testGetDelta() throws Exception { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); mockAppAuth(); Map<String, Object> body = new HashMap<String, Object>(); File f = File.createTempFile("bulkExtract", ".tar"); try { body.put(BulkExtract.BULK_EXTRACT_FILE_PATH, f.getAbsolutePath()); body.put(BulkExtract.BULK_EXTRACT_DATE, ISODateTimeFormat.dateTime().parseDateTime("2013-04-22T11:00:00.000Z").toDate()); Entity e = new MongoEntity("bulkExtractEntity", body); final DateTime d = ISODateTimeFormat.dateTime().parseDateTime("2013-03-31T11:00:00.000Z"); when( mockMongoEntityRepository.findOne(eq(BulkExtract.BULK_EXTRACT_FILES), argThat(new BaseMatcher<NeutralQuery>() { @Override public boolean matches(Object arg0) { NeutralQuery query = (NeutralQuery) arg0; return query.getCriteria().contains( new NeutralCriteria("date", NeutralCriteria.OPERATOR_EQUAL, d.toDate())) && query.getCriteria().contains( new NeutralCriteria("edorg", NeutralCriteria.OPERATOR_EQUAL, "Midvale")); } @Override public void describeTo(Description arg0) { } }))).thenReturn(e); Response r = bulkExtract.getDelta(req, CONTEXT, "Midvale", "2013-03-31T11:00:00.000Z"); assertEquals(200, r.getStatus()); Response notExisting = bulkExtract.getDelta(req, CONTEXT, "Midvale", "2013-04-01T11:00:00.000Z"); assertEquals(404, notExisting.getStatus()); } finally { f.delete(); } }
|
@GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testSEADelta() throws Exception { String edOrgId = "Midvale"; Map<String, Object> edOrgBody = new HashMap<String, Object>(); List<String> orgCategory = new ArrayList<String>(); orgCategory.add("State Education Agency"); edOrgBody.put("organizationCategories", orgCategory); Entity edOrg = new MongoEntity(EntityNames.EDUCATION_ORGANIZATION, edOrgId, edOrgBody, null); when(edOrgHelper.byId(edOrgId)).thenReturn(edOrg); when(edOrgHelper.isSEA(edOrg)).thenReturn(true); DateTime d = ISODateTimeFormat.dateTime().parseDateTime("2013-05-14T11:00:00.000Z"); Date date = d.toDate(); mockBulkExtractEntity(date); Mockito.when(edOrgHelper.getDirectChildLEAsOfEdOrg(edOrg)).thenReturn(Arrays.asList("lea123")); Set<String> lea = new HashSet<String>(); lea.add("lea123"); Mockito.when(mockValidator.validate(EntityNames.EDUCATION_ORGANIZATION, lea)).thenReturn(lea); Map<String, Object> authBody = new HashMap<String, Object>(); authBody.put("applicationId", "App1"); authBody.put(ApplicationAuthorizationResource.EDORG_IDS, ApplicationAuthorizationResourceTest.getAuthList("lea123")); Entity mockAppAuth = Mockito.mock(Entity.class); Mockito.when(mockAppAuth.getBody()).thenReturn(authBody); Mockito.when(mockMongoEntityRepository.findOne(eq("applicationAuthorization"), Mockito.any(NeutralQuery.class))) .thenReturn(mockAppAuth); Response res = bulkExtract.getPublicDelta(req, CONTEXT, "2013-05-14T11:00:00.000Z"); assertEquals(200, res.getStatus()); }
|
@GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }
|
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("date") String date) { logSecurityEvent("Received request to stream public delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta public bulk extract at date {}", date); if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testAppIsNotAuthorizedForLea() throws Exception { injector.setEducatorContext(); Map<String, Object> body = new HashMap<String, Object>(); body.put("isBulkExtract", true); body.put("authorized_ed_orgs", Arrays.asList("ONE")); body.put("public_key", "KEY"); Entity mockEntity = Mockito.mock(Entity.class); when(mockEntity.getBody()).thenReturn(body); when(mockEntity.getEntityId()).thenReturn("App1"); when(mockMongoEntityRepository.findOne(eq("application"), Mockito.any(NeutralQuery.class))).thenReturn( mockEntity); Map<String, Object> authBody = new HashMap<String, Object>(); authBody.put("applicationId", "App1"); authBody.put(ApplicationAuthorizationResource.EDORG_IDS, ApplicationAuthorizationResourceTest.getAuthList("TWO")); Entity mockAuth = Mockito.mock(Entity.class); when(mockAuth.getBody()).thenReturn(authBody); when(mockMongoEntityRepository.findOne(eq("applicationAuthorization"), Mockito.any(NeutralQuery.class))) .thenReturn(mockAuth); bulkExtract.getEdOrgExtract(CONTEXT, req, "BLEEP"); }
|
@GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testAppIsNotAuthorizedForDeltaLea() throws Exception { injector.setEducatorContext(); Map<String, Object> body = new HashMap<String, Object>(); body.put("isBulkExtract", true); body.put("authorized_ed_orgs", Arrays.asList("ONE")); body.put("public_key", "KEY"); Entity mockEntity = Mockito.mock(Entity.class); when(mockEntity.getBody()).thenReturn(body); when(mockEntity.getEntityId()).thenReturn("App1"); when(mockMongoEntityRepository.findOne(eq("application"), Mockito.any(NeutralQuery.class))).thenReturn( mockEntity); Map<String, Object> authBody = new HashMap<String, Object>(); authBody.put("applicationId", "App1"); authBody.put(ApplicationAuthorizationResource.EDORG_IDS, ApplicationAuthorizationResourceTest.getAuthList("TWO")); Entity mockAuth = Mockito.mock(Entity.class); when(mockAuth.getBody()).thenReturn(authBody); when(mockMongoEntityRepository.findOne(eq("applicationAuthorization"), Mockito.any(NeutralQuery.class))) .thenReturn(mockAuth); bulkExtract.getDelta(req, CONTEXT, "BLEEP", "2012-12-21"); }
|
@GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testAppAuthIsEmpty() throws Exception { injector.setEducatorContext(); Map<String, Object> body = new HashMap<String, Object>(); body.put("isBulkExtract", true); body.put("authorized_ed_orgs", Arrays.asList("ONE")); body.put("public_key", "KEY"); Entity mockEntity = Mockito.mock(Entity.class); when(mockEntity.getBody()).thenReturn(body); when(mockEntity.getEntityId()).thenReturn("App1"); when(mockMongoEntityRepository.findOne(eq("application"), Mockito.any(NeutralQuery.class))).thenReturn( mockEntity); Map<String, Object> authBody = new HashMap<String, Object>(); authBody.put("applicationId", "App1"); authBody.put(ApplicationAuthorizationResource.EDORG_IDS, ApplicationAuthorizationResourceTest.getAuthList()); Entity mockAuth = Mockito.mock(Entity.class); when(mockAuth.getBody()).thenReturn(authBody); when(mockMongoEntityRepository.findOne(eq("applicationAuthorization"), Mockito.any(NeutralQuery.class))) .thenReturn(mockAuth); bulkExtract.getEdOrgExtract(CONTEXT, req, "BLEEP"); }
|
@GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testAppHasNoAuthorizedEdorgs() throws Exception { injector.setEducatorContext(); Map<String, Object> body = new HashMap<String, Object>(); body.put("isBulkExtract", true); body.put("authorized_ed_orgs", Arrays.asList()); body.put("public_key", "KEY"); Entity mockEntity = Mockito.mock(Entity.class); when(mockEntity.getBody()).thenReturn(body); when(mockEntity.getEntityId()).thenReturn("App1"); when(mockMongoEntityRepository.findOne(eq("application"), Mockito.any(NeutralQuery.class))).thenReturn( mockEntity); bulkExtract.getEdOrgExtract(CONTEXT, req, "BLEEP"); }
|
@GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testUserNotInLEA() throws Exception { injector.setEducatorContext(); Mockito.when(mockValidator.validate(eq(EntityNames.EDUCATION_ORGANIZATION), Mockito.any(Set.class))) .thenReturn(Collections.EMPTY_SET); bulkExtract.getEdOrgExtract(CONTEXT, req, "BLEEP"); }
|
@GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testGetSLEAListFalseAppAuth() throws Exception { injector.setEducatorContext(); Entity mockEntity = mockApplicationEntity(); mockEntity.getBody().put("isBulkExtract", false); bulkExtract.getBulkExtractList(req, CONTEXT); }
|
@GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test(expected = AccessDeniedException.class) public void testGetSLEAListCheckUserAssociatedSLEAsFailure() throws Exception { injector.setEducatorContext(); mockApplicationEntity(); bulkExtract.getBulkExtractList(req, CONTEXT); }
|
@GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testToBSON() { IdFieldEmittableKey key = new IdFieldEmittableKey("test.id.key.field"); key.setId(new Text("1234")); BSONObject bson = key.toBSON(); assertNotNull(bson); assertTrue(bson.containsField("test.id.key.field")); Object obj = bson.get("test.id.key.field"); assertNotNull(obj); assertTrue(obj instanceof String); String val = (String) obj; assertEquals(val, "1234"); }
|
@Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; }
|
IdFieldEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; } }
|
IdFieldEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); }
|
IdFieldEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
IdFieldEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject rval = new BasicBSONObject(); rval.put(getIdField().toString(), getId().toString()); return rval; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
@Test() public void testGetLEAListNoUserAssociatedLEAs() throws Exception { injector.setEducatorContext(); mockApplicationEntity(); Mockito.when(edOrgHelper.getUserEdorgs(Mockito.any(Entity.class))).thenReturn(Arrays.asList("123")); Response res = bulkExtract.getBulkExtractList(req, CONTEXT); assertEquals(404, res.getStatus()); }
|
@GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context) throws Exception { LOG.info("Received request for list of links for all edOrgs and public data for this user/app"); logSecurityEvent("Received request for list of links for all edOrgs and public data for this user/app"); validateRequestAndApplicationAuthorization(request); logSecurityEvent("Successful request for list of links for all edOrgs and public data for this user/app"); return getPublicAndEdOrgListResponse(context); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testNullDeltaDate() { try { bulkExtract.getDelta(req, CONTEXT, "Midgar", null); fail("Should have thrown exception for null date"); } catch (IllegalArgumentException e) { assertTrue(!e.getMessage().isEmpty()); } }
|
@GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getDelta(@Context HttpServletRequest request, @Context HttpContext context, @PathParam("edOrgId") String edOrgId, @PathParam("date") String date) { logSecurityEvent("Received request to stream Edorg delta bulk extract data"); if (deltasEnabled) { LOG.info("Retrieving delta bulk extract for {}, at date {}", edOrgId, date); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed delta request, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } if (date == null || date.isEmpty()) { logSecurityEvent("Failed delta request, missing date"); throw new IllegalArgumentException("date cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, date); } logSecurityEvent("Failed request for Edorg delta bulk extract data"); return Response.status(404).build(); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testEdOrgFullExtract() throws IOException, ParseException { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); Entity mockedEntity = mockBulkExtractEntity(null); Mockito.when(edOrgHelper.byId(eq("ONE"))).thenReturn(mockedEntity); Map<String, Object> authBody = new HashMap<String, Object>(); authBody.put("applicationId", "App1"); authBody.put(ApplicationAuthorizationResource.EDORG_IDS, ApplicationAuthorizationResourceTest.getAuthList("ONE")); Entity mockAppAuth = Mockito.mock(Entity.class); Mockito.when(mockAppAuth.getBody()).thenReturn(authBody); Mockito.when(mockMongoEntityRepository.findOne(eq("applicationAuthorization"), Mockito.any(NeutralQuery.class))) .thenReturn(mockAppAuth); Response res = bulkExtract.getEdOrgExtract(CONTEXT, req, "ONE"); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")); assertTrue(headers.containsKey("last-modified")); String header = (String) headers.getFirst("content-disposition"); assertNotNull(header); assertTrue(header.startsWith("attachment")); assertTrue(header.indexOf(INPUT_FILE_NAME) > 0); Object entity = res.getEntity(); assertNotNull(entity); StreamingOutput out = (StreamingOutput) entity; ByteArrayOutputStream os = new ByteArrayOutputStream(); out.write(os); os.flush(); byte[] responseData = os.toByteArray(); String s = new String(responseData); assertEquals(BULK_DATA, s); }
|
@GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId) { logSecurityEvent("Received request to stream Edorg data"); if (edOrgId == null || edOrgId.isEmpty()) { logSecurityEvent("Failed request to stream edOrg data, missing edOrgId"); throw new IllegalArgumentException("edOrgId cannot be missing"); } validateRequestCertificate(request); validateCanAccessEdOrgExtract(edOrgId); return getEdOrgExtractResponse(context.getRequest(), edOrgId, null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testPublicExtract() throws IOException, ParseException { injector.setOauthAuthenticationWithEducationRole(); mockApplicationEntity(); Entity mockedEntity = mockBulkExtractEntity(null); Mockito.when(edOrgHelper.byId(eq("ONE"))).thenReturn(mockedEntity); Response res = bulkExtract.getPublicExtract(CONTEXT, req); assertEquals(200, res.getStatus()); MultivaluedMap<String, Object> headers = res.getMetadata(); assertNotNull(headers); assertTrue(headers.containsKey("content-disposition")); assertTrue(headers.containsKey("last-modified")); String header = (String) headers.getFirst("content-disposition"); assertNotNull(header); assertTrue(header.startsWith("attachment")); assertTrue(header.indexOf(INPUT_FILE_NAME) > 0); Object entity = res.getEntity(); assertNotNull(entity); StreamingOutput out = (StreamingOutput) entity; ByteArrayOutputStream os = new ByteArrayOutputStream(); out.write(os); os.flush(); byte[] responseData = os.toByteArray(); String s = new String(responseData); assertEquals(BULK_DATA, s); }
|
@GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request) { logSecurityEvent("Received request to stream public data"); validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), null); }
|
BulkExtract { @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request) { logSecurityEvent("Received request to stream public data"); validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), null); } }
|
BulkExtract { @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request) { logSecurityEvent("Received request to stream public data"); validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), null); } }
|
BulkExtract { @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request) { logSecurityEvent("Received request to stream public data"); validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); }
|
BulkExtract { @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) public Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request) { logSecurityEvent("Received request to stream public data"); validateRequestCertificate(request); return getPublicExtractResponse(context.getRequest(), null); } @GET @Path("extract") @RightsAllowed({ Right.BULK_EXTRACT }) Response get(@Context HttpServletRequest request); @GET @Path("extract/{edOrgId}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getEdOrgExtract(@Context HttpContext context, @Context HttpServletRequest request, @PathParam("edOrgId") String edOrgId); @GET @Path("extract/public") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicExtract(@Context HttpContext context, @Context HttpServletRequest request); @GET @Path("extract/list") @RightsAllowed({ Right.BULK_EXTRACT }) Response getBulkExtractList(@Context HttpServletRequest request, @Context HttpContext context); @GET @Path("extract/{edOrgId}/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("edOrgId") String edOrgId, @PathParam("date") String date); @GET @Path("extract/public/delta/{date}") @RightsAllowed({ Right.BULK_EXTRACT }) Response getPublicDelta(@Context HttpServletRequest request, @Context HttpContext context,
@PathParam("date") String date); Repository<Entity> getMongoEntityRepository(); void setMongoEntityRepository(Repository<Entity> mongoEntityRepository); void setEdorgValidator(GenericToEdOrgValidator validator); void setFileResource(FileResource fileResource); static final String BULK_EXTRACT_FILES; static final String BULK_EXTRACT_FILE_PATH; static final String BULK_EXTRACT_DATE; static final DateTimeFormatter DATE_TIME_FORMATTER; }
|
@Test public void testGetApiVersionSolo() { String version = "foo"; String uriPath = version + "/bar"; UriInfo uriInfo = mock(UriInfo.class); when(uriInfo.getPath()).thenReturn(uriPath); assertTrue(ResourceUtil.getApiVersion(uriInfo).equals(version)); }
|
public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } static String getApiVersion(final UriInfo uriInfo); @Deprecated static List<EmbeddedLink> getSelfLink(final UriInfo uriInfo, final String userId, final EntityDefinition defn); static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId,
final EntityDefinition defn); static EmbeddedLink getCustomLink(final UriInfo uriInfo, final String entityId, final EntityDefinition defn); @Deprecated static List<EmbeddedLink> getAssociationsLinks(final EntityDefinitionStore entityDefs,
final EntityDefinition defn, final String id, final UriInfo uriInfo); static List<EmbeddedLink> getLinks(final EntityDefinitionStore entityDefs, final EntityDefinition defn,
final EntityBody entityBody, final UriInfo uriInfo); static List<EmbeddedLink> getAggregateLink(final UriInfo uriInfo); static void putValue(MultivaluedMap<String, String> queryParameters, String key, String value); static void putValue(MultivaluedMap<String, String> queryParameters, String key, int value); static Map<String, String> convertToMap(Map<String, List<String>> map); static URI getURI(UriInfo uriInfo, String... paths); static String getVersionedUriString(UriInfo uriInfo, String... paths); static SLIPrincipal getSLIPrincipalFromSecurityContext(); static String getLinkName(String resourceName, String referenceName, String referenceField,
boolean isReferenceEntity); }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } static String getApiVersion(final UriInfo uriInfo); @Deprecated static List<EmbeddedLink> getSelfLink(final UriInfo uriInfo, final String userId, final EntityDefinition defn); static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId,
final EntityDefinition defn); static EmbeddedLink getCustomLink(final UriInfo uriInfo, final String entityId, final EntityDefinition defn); @Deprecated static List<EmbeddedLink> getAssociationsLinks(final EntityDefinitionStore entityDefs,
final EntityDefinition defn, final String id, final UriInfo uriInfo); static List<EmbeddedLink> getLinks(final EntityDefinitionStore entityDefs, final EntityDefinition defn,
final EntityBody entityBody, final UriInfo uriInfo); static List<EmbeddedLink> getAggregateLink(final UriInfo uriInfo); static void putValue(MultivaluedMap<String, String> queryParameters, String key, String value); static void putValue(MultivaluedMap<String, String> queryParameters, String key, int value); static Map<String, String> convertToMap(Map<String, List<String>> map); static URI getURI(UriInfo uriInfo, String... paths); static String getVersionedUriString(UriInfo uriInfo, String... paths); static SLIPrincipal getSLIPrincipalFromSecurityContext(); static String getLinkName(String resourceName, String referenceName, String referenceField,
boolean isReferenceEntity); }
|
@Test public void testGetApiVersionNothingElse() { String version = "foo"; UriInfo uriInfo = mock(UriInfo.class); when(uriInfo.getPath()).thenReturn(version); assertTrue(ResourceUtil.getApiVersion(uriInfo).equals(version)); }
|
public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } static String getApiVersion(final UriInfo uriInfo); @Deprecated static List<EmbeddedLink> getSelfLink(final UriInfo uriInfo, final String userId, final EntityDefinition defn); static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId,
final EntityDefinition defn); static EmbeddedLink getCustomLink(final UriInfo uriInfo, final String entityId, final EntityDefinition defn); @Deprecated static List<EmbeddedLink> getAssociationsLinks(final EntityDefinitionStore entityDefs,
final EntityDefinition defn, final String id, final UriInfo uriInfo); static List<EmbeddedLink> getLinks(final EntityDefinitionStore entityDefs, final EntityDefinition defn,
final EntityBody entityBody, final UriInfo uriInfo); static List<EmbeddedLink> getAggregateLink(final UriInfo uriInfo); static void putValue(MultivaluedMap<String, String> queryParameters, String key, String value); static void putValue(MultivaluedMap<String, String> queryParameters, String key, int value); static Map<String, String> convertToMap(Map<String, List<String>> map); static URI getURI(UriInfo uriInfo, String... paths); static String getVersionedUriString(UriInfo uriInfo, String... paths); static SLIPrincipal getSLIPrincipalFromSecurityContext(); static String getLinkName(String resourceName, String referenceName, String referenceField,
boolean isReferenceEntity); }
|
ResourceUtil { public static String getApiVersion(final UriInfo uriInfo) { if (uriInfo != null) { String uriPath = uriInfo.getPath(); if (uriPath != null) { int indexOfSlash = uriPath.indexOf("/"); if (indexOfSlash >= 0) { String version = uriPath.substring(0, indexOfSlash); return version; } else { return uriPath; } } } return null; } static String getApiVersion(final UriInfo uriInfo); @Deprecated static List<EmbeddedLink> getSelfLink(final UriInfo uriInfo, final String userId, final EntityDefinition defn); static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId,
final EntityDefinition defn); static EmbeddedLink getCustomLink(final UriInfo uriInfo, final String entityId, final EntityDefinition defn); @Deprecated static List<EmbeddedLink> getAssociationsLinks(final EntityDefinitionStore entityDefs,
final EntityDefinition defn, final String id, final UriInfo uriInfo); static List<EmbeddedLink> getLinks(final EntityDefinitionStore entityDefs, final EntityDefinition defn,
final EntityBody entityBody, final UriInfo uriInfo); static List<EmbeddedLink> getAggregateLink(final UriInfo uriInfo); static void putValue(MultivaluedMap<String, String> queryParameters, String key, String value); static void putValue(MultivaluedMap<String, String> queryParameters, String key, int value); static Map<String, String> convertToMap(Map<String, List<String>> map); static URI getURI(UriInfo uriInfo, String... paths); static String getVersionedUriString(UriInfo uriInfo, String... paths); static SLIPrincipal getSLIPrincipalFromSecurityContext(); static String getLinkName(String resourceName, String referenceName, String referenceField,
boolean isReferenceEntity); }
|
@Test public void testGetApiVersionLinked() { String version = "bar"; String uriPath = version + "/foo"; UriInfo uriInfo = mock(UriInfo.class); when(uriInfo.getPath()).thenReturn(uriPath); when(uriInfo.getBaseUriBuilder()).thenReturn(this.createUriBuilder()); EntityDefinition defn = mock(EntityDefinition.class); String resourceName = "baz"; when(defn.getResourceName()).thenReturn(resourceName); String entityId = "entityId"; PathConstants.TEMP_MAP.put(resourceName, resourceName); EmbeddedLink embeddedLink = ResourceUtil.getSelfLinkForEntity(uriInfo, entityId, defn); String href = embeddedLink.getHref(); assertTrue(href.contains(version + "/" + resourceName + "/" + entityId)); }
|
public static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId, final EntityDefinition defn) { return new EmbeddedLink(ResourceConstants.SELF, getURI(uriInfo, getApiVersion(uriInfo), PathConstants.TEMP_MAP.get(defn.getResourceName()), entityId).toString()); }
|
ResourceUtil { public static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId, final EntityDefinition defn) { return new EmbeddedLink(ResourceConstants.SELF, getURI(uriInfo, getApiVersion(uriInfo), PathConstants.TEMP_MAP.get(defn.getResourceName()), entityId).toString()); } }
|
ResourceUtil { public static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId, final EntityDefinition defn) { return new EmbeddedLink(ResourceConstants.SELF, getURI(uriInfo, getApiVersion(uriInfo), PathConstants.TEMP_MAP.get(defn.getResourceName()), entityId).toString()); } }
|
ResourceUtil { public static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId, final EntityDefinition defn) { return new EmbeddedLink(ResourceConstants.SELF, getURI(uriInfo, getApiVersion(uriInfo), PathConstants.TEMP_MAP.get(defn.getResourceName()), entityId).toString()); } static String getApiVersion(final UriInfo uriInfo); @Deprecated static List<EmbeddedLink> getSelfLink(final UriInfo uriInfo, final String userId, final EntityDefinition defn); static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId,
final EntityDefinition defn); static EmbeddedLink getCustomLink(final UriInfo uriInfo, final String entityId, final EntityDefinition defn); @Deprecated static List<EmbeddedLink> getAssociationsLinks(final EntityDefinitionStore entityDefs,
final EntityDefinition defn, final String id, final UriInfo uriInfo); static List<EmbeddedLink> getLinks(final EntityDefinitionStore entityDefs, final EntityDefinition defn,
final EntityBody entityBody, final UriInfo uriInfo); static List<EmbeddedLink> getAggregateLink(final UriInfo uriInfo); static void putValue(MultivaluedMap<String, String> queryParameters, String key, String value); static void putValue(MultivaluedMap<String, String> queryParameters, String key, int value); static Map<String, String> convertToMap(Map<String, List<String>> map); static URI getURI(UriInfo uriInfo, String... paths); static String getVersionedUriString(UriInfo uriInfo, String... paths); static SLIPrincipal getSLIPrincipalFromSecurityContext(); static String getLinkName(String resourceName, String referenceName, String referenceField,
boolean isReferenceEntity); }
|
ResourceUtil { public static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId, final EntityDefinition defn) { return new EmbeddedLink(ResourceConstants.SELF, getURI(uriInfo, getApiVersion(uriInfo), PathConstants.TEMP_MAP.get(defn.getResourceName()), entityId).toString()); } static String getApiVersion(final UriInfo uriInfo); @Deprecated static List<EmbeddedLink> getSelfLink(final UriInfo uriInfo, final String userId, final EntityDefinition defn); static EmbeddedLink getSelfLinkForEntity(final UriInfo uriInfo, final String entityId,
final EntityDefinition defn); static EmbeddedLink getCustomLink(final UriInfo uriInfo, final String entityId, final EntityDefinition defn); @Deprecated static List<EmbeddedLink> getAssociationsLinks(final EntityDefinitionStore entityDefs,
final EntityDefinition defn, final String id, final UriInfo uriInfo); static List<EmbeddedLink> getLinks(final EntityDefinitionStore entityDefs, final EntityDefinition defn,
final EntityBody entityBody, final UriInfo uriInfo); static List<EmbeddedLink> getAggregateLink(final UriInfo uriInfo); static void putValue(MultivaluedMap<String, String> queryParameters, String key, String value); static void putValue(MultivaluedMap<String, String> queryParameters, String key, int value); static Map<String, String> convertToMap(Map<String, List<String>> map); static URI getURI(UriInfo uriInfo, String... paths); static String getVersionedUriString(UriInfo uriInfo, String... paths); static SLIPrincipal getSLIPrincipalFromSecurityContext(); static String getLinkName(String resourceName, String referenceName, String referenceField,
boolean isReferenceEntity); }
|
@Test public void shouldVerifyMissingFieldReturnsFalse() { EntityBody entity = new EntityBody(); NeutralQuery query = new NeutralQuery(); query.addCriteria(new NeutralCriteria("foo", NeutralCriteria.CRITERIA_EXISTS, true)); boolean result = eval.entitySatisfiesDateQuery(entity, query); Assert.assertEquals("Should match", false, result); }
|
public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query); }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query); }
|
@Test public void shouldVerifyOrQueryReturnsFalse(){ EntityBody entity = new EntityBody(); entity.put("date", "2005"); NeutralQuery query = new NeutralQuery(); query.addOrQuery(createQuery(new NeutralCriteria("date",NeutralCriteria.CRITERIA_GT,"2007"))); boolean result = eval.entitySatisfiesDateQuery(entity, query); Assert.assertEquals("Should match", false, result); }
|
public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query); }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query); }
|
@Test public void shouldVerifyOrQueryReturnsTrue(){ EntityBody entity = new EntityBody(); entity.put("date", "2005"); NeutralQuery query = new NeutralQuery(); query.addOrQuery(createQuery(new NeutralCriteria("date",NeutralCriteria.CRITERIA_GT,"2007"))); query.addOrQuery(createQuery(new NeutralCriteria("date",NeutralCriteria.CRITERIA_GT,"2001"))); boolean result = eval.entitySatisfiesDateQuery(entity, query); Assert.assertEquals("Should match", true, result); }
|
public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query); }
|
InProcessDateQueryEvaluator { public boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query) { for (NeutralCriteria andCriteria : query.getCriteria()) { String fieldName = andCriteria.getKey(); String operator = andCriteria.getOperator(); if (NeutralCriteria.CRITERIA_EXISTS.equals(operator)) { boolean shouldExist = (Boolean) andCriteria.getValue(); Object actualValue = entity.get(fieldName); if (shouldExist && actualValue == null) { return false; } else if (!shouldExist && actualValue != null) { return false; } } else { String fieldValue = (String) entity.get(fieldName); if (fieldValue == null) { return false; } String expectedValue = (String) andCriteria.getValue(); int comparison = fieldValue.compareTo(expectedValue); if (NeutralCriteria.CRITERIA_LT.equals(operator)) { if (comparison >= 0) { return false; } } else if (NeutralCriteria.CRITERIA_LTE.equals(operator)) { if (comparison > 0) { return false; } } else if (NeutralCriteria.CRITERIA_GT.equals(operator)) { if (comparison <= 0) { return false; } } else if (NeutralCriteria.CRITERIA_GTE.equals(operator)) { if (comparison < 0) { return false; } } } } if (query.getOrQueries().size() > 0) { for (NeutralQuery orQuery : query.getOrQueries()) { if (entitySatisfiesDateQuery(entity, orQuery)) { return true; } } return false; } else { return true; } } boolean entitySatisfiesDateQuery(EntityBody entity, NeutralQuery query); }
|
@Test public void testGetIdField() { IdFieldEmittableKey key = new IdFieldEmittableKey("test.id.key.field"); assertEquals(key.getIdField().toString(), "test.id.key.field"); }
|
public Text getIdField() { return super.getFieldName(); }
|
IdFieldEmittableKey extends EmittableKey { public Text getIdField() { return super.getFieldName(); } }
|
IdFieldEmittableKey extends EmittableKey { public Text getIdField() { return super.getFieldName(); } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); }
|
IdFieldEmittableKey extends EmittableKey { public Text getIdField() { return super.getFieldName(); } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
IdFieldEmittableKey extends EmittableKey { public Text getIdField() { return super.getFieldName(); } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
@Test public void testSessionEmails() throws Exception { buildWithEmailType(Arrays.asList("Work")); Map<String, Object> response = (Map<String, Object>) resource.sessionCheck(); assertEquals("[email protected]", response.get("email")); buildWithEmailType(Arrays.asList("Organization")); response = (Map<String, Object>) resource.sessionCheck(); assertEquals("[email protected]", response.get("email")); buildWithEmailType(Arrays.asList("Organization", "Work", "Other")); response = (Map<String, Object>) resource.sessionCheck(); assertEquals("[email protected]", response.get("email")); buildWithEmailType(Arrays.asList("Organization", "Other")); response = (Map<String, Object>) resource.sessionCheck(); assertEquals("[email protected]", response.get("email")); EntityBody body = new EntityBody(); body.put("name", new ArrayList<String>()); Entity e = Mockito.mock(Entity.class); Mockito.when(e.getBody()).thenReturn(body); injector.setCustomContext("MerpTest", "Merp Test", "IL", Arrays.asList(SecureRoleRightAccessImpl.EDUCATOR), e, "merpmerpmerp"); response = (Map<String, Object>) resource.sessionCheck(); assertNull(response.get("email")); }
|
@GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; }
|
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; } }
|
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; } }
|
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; } @GET @Path("logout") Map<String, Object> logoutUser(@Context HttpHeaders headers, @Context UriInfo uriInfo); @GET @Path("debug") SecurityContext sessionDebug(); @GET @Path("check") Object sessionCheck(); }
|
SecuritySessionResource { @GET @Path("check") public Object sessionCheck() { final Map<String, Object> sessionDetails = new TreeMap<String, Object>(); if (isAuthenticated(SecurityContextHolder.getContext())) { sessionDetails.put("authenticated", true); SLIPrincipal principal = (SLIPrincipal) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); sessionDetails.put("user_id", principal.getId()); sessionDetails.put("full_name", principal.getName()); sessionDetails.put("granted_authorities", principal.getRoles()); sessionDetails.put("realm", principal.getRealm()); sessionDetails.put("edOrg", principal.getEdOrg()); sessionDetails.put("edOrgId", principal.getEdOrgId()); sessionDetails.put("sliRoles", principal.getRoles()); sessionDetails.put("tenantId", principal.getTenantId()); sessionDetails.put("external_id", principal.getExternalId()); sessionDetails.put("email", getUserEmail(principal)); sessionDetails.put("rights", SecurityContextHolder.getContext().getAuthentication().getAuthorities()); sessionDetails.put("selfRights", principal.getSelfRights()); sessionDetails.put("adminRealmAuthenticated", principal.isAdminRealmAuthenticated()); sessionDetails.put("isAdminUser", principal.isAdminUser()); sessionDetails.put("userType", principal.getEntity().getType()); sessionDetails.put("edOrgRoles", principal.getEdOrgRoles()); sessionDetails.put("edOrgRights", principal.getEdOrgRights()); if (principal.getFirstName() != null) { sessionDetails.put("first_name", principal.getFirstName()); } if (principal.getLastName() != null) { sessionDetails.put("last_name", principal.getLastName()); } if (principal.getVendor() != null) { sessionDetails.put("vendor", principal.getVendor()); } } else { sessionDetails.put("authenticated", false); sessionDetails.put("redirect_user", realmPage); } return sessionDetails; } @GET @Path("logout") Map<String, Object> logoutUser(@Context HttpHeaders headers, @Context UriInfo uriInfo); @GET @Path("debug") SecurityContext sessionDebug(); @GET @Path("check") Object sessionCheck(); }
|
@Test public void testAddClientRole() throws Exception { try { resource.updateRealm("-1", null, null); assertFalse(false); } catch (IllegalArgumentException e) { assertTrue(true); } UriInfo uriInfo = ResourceTestUtil.buildMockUriInfo(""); Response res = resource.updateRealm("1234", mapping, uriInfo); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); idp.put(RealmResource.SOURCE_ID, "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); res = resource.updateRealm("1234", mapping, uriInfo); Assert.assertEquals(204, res.getStatus()); idp.remove(RealmResource.SOURCE_ID); }
|
@PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); static final String REALM; static final String ED_ORG; static final String RESPONSE; static final String NAME; static final String UNIQUE_IDENTIFIER; static final String IDP_ID; static final String ARTIFACT_RESOLUTION_ENDPOINT; static final String SOURCE_ID; static final String IDP; }
|
@Test public void testvalidateArtifactResolution() { Response res = resource.validateArtifactResolution(null, null); Assert.assertNull(res); res = resource.validateArtifactResolution("", ""); Assert.assertNull(res); res = resource.validateArtifactResolution("testEndpoint", "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); Assert.assertNull(res); res = resource.validateArtifactResolution("", "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution("testEndpoint", ""); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution(null, "ccf4f3895f6e37896e7511ed1d991b1d96f04ac1"); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution("tesetEndpoint", null); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); res = resource.validateArtifactResolution("tesetEndpoint", "ccf4f3895f6e37896e7511ed1d991b1d96f"); Assert.assertEquals(Status.BAD_REQUEST.getStatusCode(), res.getStatus()); }
|
protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); }
|
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); } }
|
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); } }
|
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); }
|
RealmResource { protected Response validateArtifactResolution(String artifactResolutionEndpoint, String sourceId) { if (artifactResolutionEndpoint == null && sourceId == null) { return null; } Map<String, String> res = new HashMap<String, String>(); if (artifactResolutionEndpoint != null && sourceId != null) { if ((artifactResolutionEndpoint.isEmpty() && sourceId.isEmpty()) || (sourceId.length() == SOURCEID_LENGTH && !artifactResolutionEndpoint.isEmpty())) { return null; } else { res.put(RESPONSE, "Source id needs to be 40 characters long"); } } else { res.put(RESPONSE, "artifactResolutionEndpoint and sourceId need to be present together."); } return Response.status(Status.BAD_REQUEST).entity(res).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); static final String REALM; static final String ED_ORG; static final String RESPONSE; static final String NAME; static final String UNIQUE_IDENTIFIER; static final String IDP_ID; static final String ARTIFACT_RESOLUTION_ENDPOINT; static final String SOURCE_ID; static final String IDP; }
|
@Test public void testGetMappingsFound() throws Exception { Response res = resource.readRealm("1234"); Assert.assertEquals(Response.Status.OK.getStatusCode(), res.getStatus()); Assert.assertNotNull(res.getEntity()); }
|
@GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); static final String REALM; static final String ED_ORG; static final String RESPONSE; static final String NAME; static final String UNIQUE_IDENTIFIER; static final String IDP_ID; static final String ARTIFACT_RESOLUTION_ENDPOINT; static final String SOURCE_ID; static final String IDP; }
|
@Test public void testGetMappingsNotFound() throws Exception { Response res = resource.readRealm("-1"); Assert.assertEquals(Response.Status.OK.getStatusCode(), res.getStatus()); Assert.assertNull(res.getEntity()); }
|
@GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); }
|
RealmResource { @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) public Response readRealm(@PathParam("realmId") String realmId) { EntityBody result = service.get(realmId); return Response.ok(result).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); static final String REALM; static final String ED_ORG; static final String RESPONSE; static final String NAME; static final String UNIQUE_IDENTIFIER; static final String IDP_ID; static final String ARTIFACT_RESOLUTION_ENDPOINT; static final String SOURCE_ID; static final String IDP; }
|
@Test public void testUpdateOtherEdOrgRealm() { EntityBody temp = new EntityBody(); temp.put("foo", "foo"); UriInfo uriInfo = null; Response res = resource.updateRealm("other-realm", temp, uriInfo); Assert.assertEquals(403, res.getStatus()); }
|
@PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); }
|
RealmResource { @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) public Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm, @Context final UriInfo uriInfo) { if (updatedRealm == null) { throw new IllegalArgumentException("Updated Realm was null"); } EntityBody oldRealm = service.get(realmId); if (!canEditCurrentRealm(updatedRealm) || oldRealm.get(ED_ORG) != null && !oldRealm.get(ED_ORG).equals(SecurityUtil.getEdOrg())) { EntityBody body = new EntityBody(); body.put(RESPONSE, "You are not authorized to update this realm."); return Response.status(Status.FORBIDDEN).entity(body).build(); } Response validateUniqueness = validateUniqueId(realmId, (String) updatedRealm.get(UNIQUE_IDENTIFIER), (String) updatedRealm.get(NAME), getIdpId(updatedRealm)); if (validateUniqueness != null) { return validateUniqueness; } Map<String, Object> idp = (Map<String, Object>) updatedRealm.get(IDP); Response validateArtifactResolution = validateArtifactResolution((String) idp.get(ARTIFACT_RESOLUTION_ENDPOINT), (String) idp.get(SOURCE_ID)); if (validateArtifactResolution != null) { LOG.debug("Invalid artifact resolution information"); return validateArtifactResolution; } updatedRealm.put("tenantId", SecurityUtil.getTenantId()); updatedRealm.put(ED_ORG, SecurityUtil.getEdOrg()); if (service.update(realmId, updatedRealm, false)) { logSecurityEvent(uriInfo, oldRealm, updatedRealm); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); void setService(EntityService service); @PUT @Path("{realmId}") @Consumes("application/json") @RightsAllowed({ Right.CRUD_REALM }) Response updateRealm(@PathParam("realmId") String realmId, EntityBody updatedRealm,
@Context final UriInfo uriInfo); @DELETE @Path("{realmId}") @RightsAllowed({ Right.CRUD_REALM }) Response deleteRealm(@PathParam("realmId") String realmId, @Context final UriInfo uriInfo); @POST @RightsAllowed({ Right.CRUD_REALM }) Response createRealm(EntityBody newRealm, @Context final UriInfo uriInfo); @GET @Path("{realmId}") @RightsAllowed({ Right.ADMIN_ACCESS }) Response readRealm(@PathParam("realmId") String realmId); @GET @RightsAllowed({ Right.ADMIN_ACCESS }) Response getRealms(@QueryParam(REALM) @DefaultValue("") String realm, @Context UriInfo info); static final String REALM; static final String ED_ORG; static final String RESPONSE; static final String NAME; static final String UNIQUE_IDENTIFIER; static final String IDP_ID; static final String ARTIFACT_RESOLUTION_ENDPOINT; static final String SOURCE_ID; static final String IDP; }
|
@SuppressWarnings("unchecked") @Test public void getMetadataTest() { Response response = resource.getMetadata(); Assert.assertNotNull(response); Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus()); Assert.assertNotNull(response.getEntity()); Exception exception = null; try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader((String) response.getEntity())); org.w3c.dom.Document doc = db.parse(is); DOMBuilder builder = new DOMBuilder(); org.jdom.Document jdomDocument = builder.build(doc); Iterator<org.jdom.Element> itr = jdomDocument.getDescendants(new ElementFilter()); while (itr.hasNext()) { org.jdom.Element el = itr.next(); if(el.getName().equals("X509Certificate")) { Assert.assertNotNull(el.getText()); } } } catch (ParserConfigurationException e) { exception = e; } catch (SAXException e) { exception = e; } catch (IOException e) { exception = e; } Assert.assertNull(exception); }
|
@GET @Path("metadata") @Produces({ "text/xml" }) public Response getMetadata() { if (!metadata.isEmpty()) { return Response.ok(metadata).build(); } return Response.status(Response.Status.NOT_FOUND).build(); }
|
SamlFederationResource { @GET @Path("metadata") @Produces({ "text/xml" }) public Response getMetadata() { if (!metadata.isEmpty()) { return Response.ok(metadata).build(); } return Response.status(Response.Status.NOT_FOUND).build(); } }
|
SamlFederationResource { @GET @Path("metadata") @Produces({ "text/xml" }) public Response getMetadata() { if (!metadata.isEmpty()) { return Response.ok(metadata).build(); } return Response.status(Response.Status.NOT_FOUND).build(); } }
|
SamlFederationResource { @GET @Path("metadata") @Produces({ "text/xml" }) public Response getMetadata() { if (!metadata.isEmpty()) { return Response.ok(metadata).build(); } return Response.status(Response.Status.NOT_FOUND).build(); } @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); }
|
SamlFederationResource { @GET @Path("metadata") @Produces({ "text/xml" }) public Response getMetadata() { if (!metadata.isEmpty()) { return Response.ok(metadata).build(); } return Response.status(Response.Status.NOT_FOUND).build(); } @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); static SimpleDateFormat ft; }
|
@Test (expected= APIAccessDeniedException.class) public void processArtifactBindingInvalidRequest() { setRealm(false); HttpServletRequest request = Mockito.mock(HttpServletRequest.class); UriInfo uriInfo = Mockito.mock(UriInfo.class); Mockito.when(request.getParameter("RelayState")).thenReturn("My Realm"); resource.processArtifactBinding(request, uriInfo); }
|
@GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); static SimpleDateFormat ft; }
|
@Test public void processArtifactBindingInvalidCondition() throws URISyntaxException { setRealm(false); HttpServletRequest request = Mockito.mock(HttpServletRequest.class); UriInfo uriInfo = Mockito.mock(UriInfo.class); URI uri = new URI(issuerString); Mockito.when(uriInfo.getRequestUri()).thenReturn(uri); Mockito.when(uriInfo.getAbsolutePath()).thenReturn(uri); Mockito.when(request.getParameter("SAMLart")).thenReturn("AAQAAjh3bwgbBZ+LiIx3/RVwDGy0aRUu+xxuNtTZVbFofgZZVCKJQwQNQ7Q="); Mockito.when(request.getParameter("RelayState")).thenReturn("My Realm"); List<Assertion> assertions = new ArrayList<Assertion>(); DateTimeFormatter fmt = DateTimeFormat.forPattern("MM/dd/yyyy"); DateTime datetime = DateTime.now(); datetime = datetime.plusMonths(2) ; Assertion assertion = createAssertion(datetime.toString(fmt), "01/10/2011", issuerString); assertions.add(assertion); Mockito.when(samlHelper.getAssertion(Mockito.any(org.opensaml.saml2.core.Response.class), Mockito.any(KeyStore.PrivateKeyEntry.class))).thenReturn(assertion); expectedException.expect(APIAccessDeniedException.class); expectedException.expectMessage("Authorization could not be verified."); resource.processArtifactBinding(request, uriInfo); Mockito.when(assertion.getSubject()).thenReturn(null); resource.processArtifactBinding(request, uriInfo); assertions.clear(); assertions.add(createAssertion("01/10/2011", datetime.toString(fmt), issuerString)); resource.processArtifactBinding(request, uriInfo); }
|
@GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); }
|
SamlFederationResource { @GET @Path("sso/artifact") public Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String artifact = request.getParameter("SAMLart"); String realmId = request.getParameter("RelayState"); if (artifact == null) { throw new APIAccessDeniedException("No artifact provided by the IdP"); } String artifactUrl = samlHelper.getArtifactUrl(realmId, artifact); ArtifactResolve artifactResolve = artifactBindingHelper.generateArtifactResolveRequest(artifact, dsPKEntry, artifactUrl); Envelope soapEnvelope = artifactBindingHelper.generateSOAPEnvelope(artifactResolve); XMLObject response = soapHelper.sendSOAPCommunication(soapEnvelope, artifactUrl, clientCertPKEntry); ArtifactResponse artifactResponse = (ArtifactResponse)((EnvelopeImpl) response).getBody().getUnknownXMLObjects().get(0); org.opensaml.saml2.core.Response samlResponse = (org.opensaml.saml2.core.Response) artifactResponse.getMessage(); return processSAMLResponse(samlResponse, uriInfo); } @GET @Path("metadata") @Produces({ "text/xml" }) Response getMetadata(); @POST @Path("sso/post") Response processPostBinding(@FormParam("SAMLResponse") String postData, @Context UriInfo uriInfo); @GET @Path("sso/artifact") Response processArtifactBinding(@Context HttpServletRequest request, @Context UriInfo uriInfo); static SimpleDateFormat ft; }
|
@Test public void testValidCreate() throws URISyntaxException { setRealms(REALM_ID); EntityBody body = getValidRoleDoc(); mockGetRealmId(); Mockito.when(service.create(body)).thenReturn("new-role-id"); Response res = resource.createCustomRole(body, getMockUriInfo()); Assert.assertEquals(201, res.getStatus()); }
|
@POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testToString() { IdFieldEmittableKey key = new IdFieldEmittableKey("test.id.key.field"); key.setId(new Text("1234")); assertEquals(key.toString(), "IdFieldEmittableKey [test.id.key.field=1234]"); }
|
@Override public String toString() { return "IdFieldEmittableKey [" + getIdField() + "=" + getId().toString() + "]"; }
|
IdFieldEmittableKey extends EmittableKey { @Override public String toString() { return "IdFieldEmittableKey [" + getIdField() + "=" + getId().toString() + "]"; } }
|
IdFieldEmittableKey extends EmittableKey { @Override public String toString() { return "IdFieldEmittableKey [" + getIdField() + "=" + getId().toString() + "]"; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); }
|
IdFieldEmittableKey extends EmittableKey { @Override public String toString() { return "IdFieldEmittableKey [" + getIdField() + "=" + getId().toString() + "]"; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
IdFieldEmittableKey extends EmittableKey { @Override public String toString() { return "IdFieldEmittableKey [" + getIdField() + "=" + getId().toString() + "]"; } IdFieldEmittableKey(); IdFieldEmittableKey(final String mongoFieldName); Text getIdField(); Text getId(); void setId(final Text value); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
@Test public void testValidUpdate() { setRealms(REALM_ID); EntityBody body = getValidRoleDoc(); mockGetRealmId(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); body.put("roles", new ArrayList<Map<String, List<String>>>()); Mockito.when(service.update(id, body, false)).thenReturn(true); Response res = resource.updateCustomRole(id, body, uriInfo); Assert.assertEquals(204, res.getStatus()); }
|
@PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testReadAll() { setRealms(REALM_ID); EntityBody body = getValidRoleDoc(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); mockGetRealmId(); Entity mockEntity = Mockito.mock(Entity.class); Mockito.when(mockEntity.getEntityId()).thenReturn("mock-id"); Mockito.when(service.get("mock-id")).thenReturn(body); NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, new HashSet<String>(Arrays.asList(REALM_ID)))); Mockito.when(repo.findAllIds("customRole", customRoleQuery)).thenReturn(Arrays.asList("mock-id")); Response res = resource.readAll(uriInfo, ""); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(Arrays.asList(body), res.getEntity()); }
|
@GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testReadAllWithBadRealmIdParam() { setRealms(REALM_ID); EntityBody body = getValidRoleDoc(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); mockGetRealmId(); Entity mockEntity = Mockito.mock(Entity.class); Mockito.when(mockEntity.getEntityId()).thenReturn("mock-id"); Mockito.when(service.get("mock-id")).thenReturn(body); NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, REALM_ID)); Mockito.when(repo.findAllIds("customRole", customRoleQuery)).thenReturn(Arrays.asList("mock-id")); Response res = resource.readAll(uriInfo, "BAD_REALM_ID"); Assert.assertEquals(400, res.getStatus()); }
|
@GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testReadAllWithMultipleRealmsAndNoRealmIdParam() { setRealms(REALM_ID, "REALM2"); EntityBody body = getValidRoleDoc(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); mockGetRealmId(); Entity mockEntity = Mockito.mock(Entity.class); Mockito.when(mockEntity.getEntityId()).thenReturn("mock-id"); Mockito.when(service.get("mock-id")).thenReturn(body); NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, new HashSet<String>(Arrays.asList(REALM_ID, "REALM2")))); Mockito.when(repo.findAllIds("customRole", customRoleQuery)).thenReturn(Arrays.asList("mock-id")); Response res = resource.readAll(uriInfo, ""); Assert.assertEquals(200, res.getStatus()); }
|
@GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testReadAllWithMultipleRealmsAndValidRealmIdParam() { setRealms(REALM_ID, "REALM2"); EntityBody body = getValidRoleDoc(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); mockGetRealmId(); Entity mockEntity = Mockito.mock(Entity.class); Mockito.when(mockEntity.getEntityId()).thenReturn("mock-id"); Mockito.when(service.get("mock-id")).thenReturn(body); NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, new HashSet<String>(Arrays.asList(REALM_ID)))); Mockito.when(repo.findAllIds("customRole", customRoleQuery)).thenReturn(Arrays.asList("mock-id")); Response res = resource.readAll(uriInfo, REALM_ID); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(Arrays.asList(body), res.getEntity()); }
|
@GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @GET @RightsAllowed({Right.CRUD_ROLE }) public Response readAll(@Context final UriInfo uriInfo, @DefaultValue("") @QueryParam("realmId") String realmId) { if (uriInfo.getQueryParameters() != null) { String defaultsOnly = uriInfo.getQueryParameters().getFirst("defaultsOnly"); if (defaultsOnly != null && Boolean.valueOf(defaultsOnly).booleanValue()) { return Response.ok(roleInitializer.getDefaultRoles()).build(); } } List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(); Set<String> myRealms = realmHelper.getAssociatedRealmIds(); Set<String> realmsToQuery = null; if (!realmId.isEmpty() && !myRealms.contains(realmId)) { return buildBadRequest(ERROR_INVALID_REALM_ID + ": '" + realmId + "'"); } else { if (realmId.isEmpty()) { realmsToQuery = myRealms; } else { realmsToQuery = new HashSet<String>(); realmsToQuery.add(realmId); } } NeutralQuery customRoleQuery = new NeutralQuery(); customRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.CRITERIA_IN, realmsToQuery)); Iterable<String> customRoles = repo.findAllIds("customRole", customRoleQuery); for (String id : customRoles) { EntityBody result = service.get(id); results.add(result); } return Response.ok(results).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testReadAccessible() { setRealms(REALM_ID); EntityBody body = getValidRoleDoc(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); mockGetRealmId(); Response res = resource.read(id, uriInfo); Assert.assertEquals(200, res.getStatus()); Assert.assertEquals(body, res.getEntity()); }
|
@GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testReadInaccessible() { String inaccessibleId = "inaccessible-id"; EntityBody body = getValidRoleDoc(); body.put("realmId", "BAD-REALM"); Mockito.when(service.get(inaccessibleId)).thenReturn(body); Response res = resource.read(inaccessibleId, uriInfo); Assert.assertEquals(403, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_FORBIDDEN, res.getEntity()); }
|
@GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response read(@PathParam("id") String id, @Context final UriInfo uriInfo) { EntityBody customRole = service.get(id); String realmId = (String)customRole.get("realmId"); if (!realmHelper.getAssociatedRealmIds().contains(realmId)) { auditSecEvent(uriInfo, "Failed to read custom role with id: " + id + " wrong tenant + realm combination.",realmId); return Response.status(Status.FORBIDDEN).entity(ERROR_FORBIDDEN).build(); } return Response.ok(customRole).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testUpdateWithDuplicateRoles() { EntityBody body = getRoleDocWithDuplicateRole(); body.put("customRights", Arrays.asList(new String[] {"Something", "Else"})); mockGetRealmId(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); Mockito.when(service.update(id, body, false)).thenReturn(true); Response res = resource.updateCustomRole(id, body, uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_DUPLICATE_ROLE + ": 'Role1'", res.getEntity()); }
|
@PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testUpdateWithInvalidRight() { EntityBody body = getRoleDocWithInvalidRight(); body.put("customRights", Arrays.asList(new String[] {"Something", "Else"})); mockGetRealmId(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); Mockito.when(service.update(id, body, false)).thenReturn(true); Response res = resource.updateCustomRole(id, body, uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_INVALID_RIGHT + ": 'RIGHT_TO_REMAIN_SILENT'", res.getEntity()); }
|
@PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testUpdateWithInvalidRealmId() { EntityBody body = getRoleDocWithInvalidRealm(); body.put("customRights", Arrays.asList(new String[] {"Something", "Else"})); mockGetRealmId(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); Mockito.when(service.update(id, body, false)).thenReturn(true); Response res = resource.updateCustomRole(id, body, uriInfo); Assert.assertEquals(403, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_INVALID_REALM, res.getEntity()); }
|
@PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testToBSON() { TenantAndIdEmittableKey key = new TenantAndIdEmittableKey("meta.data.tenantId", "test.id.key.field"); key.setTenantId(new Text("Midgar")); key.setId(new Text("1234")); BSONObject bson = key.toBSON(); assertNotNull(bson); assertTrue(bson.containsField("meta.data.tenantId")); Object obj = bson.get("meta.data.tenantId"); assertNotNull(obj); assertTrue(obj instanceof String); String val = (String) obj; assertEquals(val, "Midgar"); assertTrue(bson.containsField("test.id.key.field")); obj = bson.get("test.id.key.field"); assertNotNull(obj); assertTrue(obj instanceof String); val = (String) obj; assertEquals(val, "1234"); }
|
@Override public BSONObject toBSON() { BSONObject bson = new BasicBSONObject(); bson.put(getTenantIdField().toString(), getTenantId().toString()); bson.put(getIdField().toString(), getId().toString()); return bson; }
|
TenantAndIdEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject bson = new BasicBSONObject(); bson.put(getTenantIdField().toString(), getTenantId().toString()); bson.put(getIdField().toString(), getId().toString()); return bson; } }
|
TenantAndIdEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject bson = new BasicBSONObject(); bson.put(getTenantIdField().toString(), getTenantId().toString()); bson.put(getIdField().toString(), getId().toString()); return bson; } TenantAndIdEmittableKey(); TenantAndIdEmittableKey(final String tenantIdFieldName, final String idFieldName); }
|
TenantAndIdEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject bson = new BasicBSONObject(); bson.put(getTenantIdField().toString(), getTenantId().toString()); bson.put(getIdField().toString(), getId().toString()); return bson; } TenantAndIdEmittableKey(); TenantAndIdEmittableKey(final String tenantIdFieldName, final String idFieldName); Text getTenantId(); void setTenantId(final Text id); Text getTenantIdField(); Text getId(); void setId(final Text id); Text getIdField(); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
TenantAndIdEmittableKey extends EmittableKey { @Override public BSONObject toBSON() { BSONObject bson = new BasicBSONObject(); bson.put(getTenantIdField().toString(), getTenantId().toString()); bson.put(getIdField().toString(), getId().toString()); return bson; } TenantAndIdEmittableKey(); TenantAndIdEmittableKey(final String tenantIdFieldName, final String idFieldName); Text getTenantId(); void setTenantId(final Text id); Text getTenantIdField(); Text getId(); void setId(final Text id); Text getIdField(); @Override void readFields(DataInput data); @Override void write(DataOutput data); @Override String toString(); @Override BSONObject toBSON(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(EmittableKey other); }
|
@Test public void testUpdateWithDuplicateRights() { EntityBody body = getRoleDocWithDuplicateRights(); body.put("customRights", Arrays.asList(new String[] {"Something", "Else"})); mockGetRealmId(); String id = "old-id"; Mockito.when(service.get(id)).thenReturn((EntityBody) body.clone()); Mockito.when(service.update(id, body, false)).thenReturn(true); Response res = resource.updateCustomRole(id, body, uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_DUPLICATE_RIGHTS + ": 'WRITE_GENERAL'", res.getEntity()); }
|
@PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) public Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo) { Response res = validateRights(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",null); return res; } res = validateUniqueRoles(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",null); return res; } res = validateValidRealm(updated); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",null); return res; } EntityBody oldRealm = service.get(id); String oldRealmId = (String) oldRealm.get("realmId"); String updatedRealmId = (String) updated.get("realmId"); if (!updatedRealmId.equals(oldRealmId)) { auditSecEvent(uriInfo, "Failed to update realmId { from: " + oldRealmId + ", to: " + updatedRealmId + " } for role with id:" + id, oldRealmId); return buildBadRequest(ERROR_CHANGING_REALM_ID + ": '" + oldRealmId + "' -> '" + updatedRealmId + "'"); } if (service.update(id, updated, false)) { auditSecEvent(uriInfo, "Updated role with id:" + id,oldRealmId); this.sessions.clear(); return Response.status(Status.NO_CONTENT).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testCreateWithDuplicateRoles() { EntityBody body = getRoleDocWithDuplicateRole(); mockGetRealmId(); Mockito.when(service.create(body)).thenReturn("new-role-id"); Response res = resource.createCustomRole(body, uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_DUPLICATE_ROLE + ": 'Role1'", res.getEntity()); }
|
@POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testCreateWithInvalidRight() { EntityBody body = getRoleDocWithInvalidRight(); mockGetRealmId(); Mockito.when(service.create(body)).thenReturn("new-role-id"); Response res = resource.createCustomRole(body, uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_INVALID_RIGHT + ": 'RIGHT_TO_REMAIN_SILENT'", res.getEntity()); }
|
@POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testCreateWithInvalidRealmId() { EntityBody body = getRoleDocWithInvalidRealm(); mockGetRealmId(); Mockito.when(service.create(body)).thenReturn("new-role-id"); Response res = resource.createCustomRole(body, uriInfo); Assert.assertEquals(403, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_INVALID_REALM, res.getEntity()); }
|
@POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testCreateWithDuplicateRights() { EntityBody body = getRoleDocWithDuplicateRights(); mockGetRealmId(); Mockito.when(service.create(body)).thenReturn("new-role-id"); Response res = resource.createCustomRole(body, uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_DUPLICATE_RIGHTS + ": 'WRITE_GENERAL'", res.getEntity()); }
|
@POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testCreateDuplicate() { setRealms(REALM_ID); NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, REALM_ID)); Entity mockEntity = Mockito.mock(Entity.class); Mockito.when(mockEntity.getEntityId()).thenReturn("fake-id"); Mockito.when(repo.findOne(CustomRoleResource.RESOURCE_NAME, existingCustomRoleQuery)).thenReturn(mockEntity); mockGetRealmId(); Response res = resource.createCustomRole(getValidRoleDoc(), uriInfo); Assert.assertEquals(400, res.getStatus()); Assert.assertEquals(CustomRoleResource.ERROR_MULTIPLE_DOCS + ": Realm '867-5309'", res.getEntity()); }
|
@POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); }
|
CustomRoleResource { @POST @RightsAllowed({Right.CRUD_ROLE }) public Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo) { String realmId = (String) newCustomRole.get("realmId"); Response res = validateRights(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role rights validation failed.",realmId); return res; } res = validateUniqueRoles(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role unique roles check failed.",realmId); return res; } res = validateValidRealm(newCustomRole); if (res != null) { auditSecEvent(uriInfo, "Failed to create custom role invalid realm specified.",realmId); return res; } NeutralQuery existingCustomRoleQuery = new NeutralQuery(); existingCustomRoleQuery.addCriteria(new NeutralCriteria("realmId", NeutralCriteria.OPERATOR_EQUAL, realmId)); Entity existingRoleDoc = repo.findOne(RESOURCE_NAME, existingCustomRoleQuery); if (existingRoleDoc != null) { auditSecEvent(uriInfo, "Failed to create custom role Already exists.",realmId); return buildBadRequest(ERROR_MULTIPLE_DOCS + ": Realm '" + realmId + "'"); } String id = service.create(newCustomRole); if (id != null) { String uri = uriToString(uriInfo) + "/" + id; auditSecEvent(uriInfo, "Created custom role with id: " + id,realmId); this.sessions.clear(); return Response.status(Status.CREATED).header("Location", uri).build(); } return Response.status(Status.BAD_REQUEST).build(); } @PostConstruct void init(); @GET @RightsAllowed({Right.CRUD_ROLE }) Response readAll(@Context final UriInfo uriInfo,
@DefaultValue("") @QueryParam("realmId") String realmId); @GET @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response read(@PathParam("id") String id, @Context final UriInfo uriInfo); @POST @RightsAllowed({Right.CRUD_ROLE }) Response createCustomRole(EntityBody newCustomRole, @Context final UriInfo uriInfo); @PUT @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response updateCustomRole(@PathParam("id") String id, EntityBody updated, @Context final UriInfo uriInfo); @DELETE @Path("{id}") @RightsAllowed({Right.CRUD_ROLE }) Response deleteCustomRole(@PathParam("id") String id, @Context final UriInfo uriInfo); static final String RESOURCE_NAME; }
|
@Test public void testBadData() { Response response = resource.provision(new HashMap<String, String>(), null); assertEquals(response.getStatus(), Status.BAD_REQUEST.getStatusCode()); }
|
@POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); @POST @RightsAllowed({Right.INGEST_DATA }) Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo); Response createEdOrg(final String orgId); }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); @POST @RightsAllowed({Right.INGEST_DATA }) Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo); Response createEdOrg(final String orgId); static final String STATE_EDUCATION_AGENCY; static final String STATE_EDORG_ID; static final String EDORG_INSTITUTION_NAME; static final String ADDRESSES; static final String ADDRESS_STREET; static final String ADDRESS_CITY; static final String ADDRESS_STATE_ABRV; static final String ADDRESS_POSTAL_CODE; static final String CATEGORIES; static final String PRELOAD_FILES_ID; }
|
@SuppressWarnings("unchecked") @Test public void testProvision() { Map<String, String> requestBody = new HashMap<String, String>(); requestBody.put(OnboardingResource.STATE_EDORG_ID, "TestOrg"); requestBody.put(ResourceConstants.ENTITY_METADATA_TENANT_ID, "12345"); requestBody.put(OnboardingResource.PRELOAD_FILES_ID, "small_sample_dataset"); LandingZoneInfo landingZone = new LandingZoneInfo("LANDING ZONE", "INGESTION SERVER"); Map<String, String> tenantBody = new HashMap<String, String>(); tenantBody.put("landingZone", "LANDING ZONE"); tenantBody.put("ingestionServer", "INGESTION SERVER"); try { when(mockTenantResource.createLandingZone(Mockito.anyString(), Mockito.eq("TestOrg"), Mockito.anyBoolean())).thenReturn(landingZone); } catch (TenantResourceCreationException e) { Assert.fail(e.getMessage()); } Response res = resource.provision(requestBody, null); assertTrue(Status.fromStatusCode(res.getStatus()) == Status.CREATED); Map<String, String> result = (Map<String, String>) res.getEntity(); assertNotNull(result.get("landingZone")); Assert.assertEquals("LANDING ZONE", result.get("landingZone")); assertNotNull(result.get("serverName")); Assert.assertEquals("landingZone", result.get("serverName")); res = resource.provision(requestBody, null); assertEquals(Status.CREATED, Status.fromStatusCode(res.getStatus())); }
|
@POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); @POST @RightsAllowed({Right.INGEST_DATA }) Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo); Response createEdOrg(final String orgId); }
|
OnboardingResource { @POST @RightsAllowed({Right.INGEST_DATA }) public Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo) { String orgId = reqBody.get(STATE_EDORG_ID); if (orgId == null) { return Response.status(Status.BAD_REQUEST).entity("Missing required " + STATE_EDORG_ID).build(); } Response r = createEdOrg(orgId); return r; } @Autowired OnboardingResource(@Value("${sli.landingZone.server}") String landingZoneServer); @POST @RightsAllowed({Right.INGEST_DATA }) Response provision(Map<String, String> reqBody, @Context final UriInfo uriInfo); Response createEdOrg(final String orgId); static final String STATE_EDUCATION_AGENCY; static final String STATE_EDORG_ID; static final String EDORG_INSTITUTION_NAME; static final String ADDRESSES; static final String ADDRESS_STREET; static final String ADDRESS_CITY; static final String ADDRESS_STATE_ABRV; static final String ADDRESS_POSTAL_CODE; static final String CATEGORIES; static final String PRELOAD_FILES_ID; }
|
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testGetApps() { ResponseImpl resp = (ResponseImpl) resource.getApplications(""); List<Map> list = (List<Map>) resp.getEntity(); List<String> names = new ArrayList<String>(); for (Map map : list) { String name = (String) map.get("name"); names.add(name); } Assert.assertTrue(names.contains("MyApp")); }
|
@GET @RightsAllowed(any = true) public Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter) { List<EntityBody> results = new ArrayList<EntityBody>(); NeutralQuery query = new NeutralQuery(0); for (Entity result : repo.findAll("application", query)) { if (appValidator.isAuthorizedForApp(result, SecurityUtil.getSLIPrincipal())) { EntityBody body = new EntityBody(result.getBody()); if (!shouldFilterApp(result, adminFilter)) { filterAttributes(body); results.add(body); } } } return Response.status(Status.OK).entity(results).build(); }
|
ApprovedApplicationResource { @GET @RightsAllowed(any = true) public Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter) { List<EntityBody> results = new ArrayList<EntityBody>(); NeutralQuery query = new NeutralQuery(0); for (Entity result : repo.findAll("application", query)) { if (appValidator.isAuthorizedForApp(result, SecurityUtil.getSLIPrincipal())) { EntityBody body = new EntityBody(result.getBody()); if (!shouldFilterApp(result, adminFilter)) { filterAttributes(body); results.add(body); } } } return Response.status(Status.OK).entity(results).build(); } }
|
ApprovedApplicationResource { @GET @RightsAllowed(any = true) public Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter) { List<EntityBody> results = new ArrayList<EntityBody>(); NeutralQuery query = new NeutralQuery(0); for (Entity result : repo.findAll("application", query)) { if (appValidator.isAuthorizedForApp(result, SecurityUtil.getSLIPrincipal())) { EntityBody body = new EntityBody(result.getBody()); if (!shouldFilterApp(result, adminFilter)) { filterAttributes(body); results.add(body); } } } return Response.status(Status.OK).entity(results).build(); } }
|
ApprovedApplicationResource { @GET @RightsAllowed(any = true) public Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter) { List<EntityBody> results = new ArrayList<EntityBody>(); NeutralQuery query = new NeutralQuery(0); for (Entity result : repo.findAll("application", query)) { if (appValidator.isAuthorizedForApp(result, SecurityUtil.getSLIPrincipal())) { EntityBody body = new EntityBody(result.getBody()); if (!shouldFilterApp(result, adminFilter)) { filterAttributes(body); results.add(body); } } } return Response.status(Status.OK).entity(results).build(); } @GET @RightsAllowed(any = true) Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter); }
|
ApprovedApplicationResource { @GET @RightsAllowed(any = true) public Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter) { List<EntityBody> results = new ArrayList<EntityBody>(); NeutralQuery query = new NeutralQuery(0); for (Entity result : repo.findAll("application", query)) { if (appValidator.isAuthorizedForApp(result, SecurityUtil.getSLIPrincipal())) { EntityBody body = new EntityBody(result.getBody()); if (!shouldFilterApp(result, adminFilter)) { filterAttributes(body); results.add(body); } } } return Response.status(Status.OK).entity(results).build(); } @GET @RightsAllowed(any = true) Response getApplications(@DefaultValue("") @QueryParam("is_admin") String adminFilter); static final String RESOURCE_NAME; }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.