@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; }