/** * If asynchronous processing was requested, queries the monitor URI. * * @return the last Response received from the Batch service */ public Response poll() { if (monitor != null) { response = WebClient.create(monitor). header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt). type(RESTHeaders.multipartMixedWith(boundary.substring(2))).get(); } return response; }
/** * If asynchronous processing was requested, queries the monitor URI. * * @return the last Response received from the Batch service */ public Response poll() { if (monitor != null) { response = WebClient.create(monitor). header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt). type(RESTHeaders.multipartMixedWith(boundary.substring(2))).get(); } return response; }
@Override public Response batch() { MediaType mediaType = MediaType.valueOf(messageContext.getHttpServletRequest().getContentType()); String boundary = mediaType.getParameters().get(RESTHeaders.BOUNDARY_PARAMETER); Batch batch = batchDAO.find(boundary); if (batch == null) { throw new NotFoundException("Batch " + boundary); } if (batch.getResults() == null) { return Response.accepted(). type(RESTHeaders.multipartMixedWith(boundary)). header(HttpHeaders.RETRY_AFTER, 5). header(HttpHeaders.LOCATION, uriInfo.getAbsolutePathBuilder().build()). build(); } Response response = Response.ok(batch.getResults()). type(RESTHeaders.multipartMixedWith(boundary)). build(); batchDAO.delete(boundary); return response; } }
@Override public Response deleteExecutions(final ExecDeleteQuery query) { List<BatchResponseItem> batchResponseItems = getExecutableLogic().deleteExecutions( query.getKey(), query.getStartedBefore(), query.getStartedAfter(), query.getEndedBefore(), query.getEndedAfter()); String boundary = "deleteExecutions_" + SecureRandomUtils.generateRandomUUID().toString(); return Response.ok(BatchPayloadGenerator.generate( batchResponseItems, SyncopeConstants.DOUBLE_DASH + boundary)). type(RESTHeaders.multipartMixedWith(boundary)). build(); }
/** * Sends the current request, with items accumulated by invoking methods on proxies obtained via * {@link #getService(java.lang.Class)}, to the Batch service, and awaits for a synchronous or asynchronous * response, depending on the {@code async} parameter. * It also clears out the accumulated items, in case of reuse of this instance for subsequent requests. * * @param async whether asynchronous Batch process is requested, or not * @return batch response */ public BatchResponse commit(final boolean async) { String boundary = "--batch_" + UUID.randomUUID().toString(); WebClient webClient = WebClient.create(bcfb.getAddress()).path("batch"). header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt). type(RESTHeaders.multipartMixedWith(boundary.substring(2))); if (async) { webClient.header(RESTHeaders.PREFER, Preference.RESPOND_ASYNC); } String body = BatchPayloadGenerator.generate(bcfb.getBatchRequestItems(), boundary); LOG.debug("Batch request body:\n{}", body); initBatchClientFactoryBean(); return new BatchResponse(boundary, jwt, webClient.post(body)); } }
/** * Sends the current request, with items accumulated by invoking methods on proxies obtained via * {@link #getService(java.lang.Class)}, to the Batch service, and awaits for a synchronous or asynchronous * response, depending on the {@code async} parameter. * It also clears out the accumulated items, in case of reuse of this instance for subsequent requests. * * @param async whether asynchronous Batch process is requested, or not * @return batch response */ public BatchResponse commit(final boolean async) { String boundary = "--batch_" + UUID.randomUUID().toString(); WebClient webClient = WebClient.create(bcfb.getAddress()).path("batch"). header(HttpHeaders.AUTHORIZATION, "Bearer " + jwt). type(RESTHeaders.multipartMixedWith(boundary.substring(2))); if (async) { webClient.header(RESTHeaders.PREFER, Preference.RESPOND_ASYNC); } String body = BatchPayloadGenerator.generate(bcfb.getBatchRequestItems(), boundary); LOG.debug("Batch request body:\n{}", body); initBatchClientFactoryBean(); return new BatchResponse(boundary, jwt, webClient.post(body)); } }
header(RESTHeaders.PREFERENCE_APPLIED, getPreference().toString()). header(HttpHeaders.LOCATION, uriInfo.getAbsolutePathBuilder().build()). type(RESTHeaders.multipartMixedWith(boundary)). build(); } else {
return Response.ok(BatchPayloadGenerator.generate( batchResponseItems, SyncopeConstants.DOUBLE_DASH + boundary)). type(RESTHeaders.multipartMixedWith(boundary)). build();
return Response.ok(BatchPayloadGenerator.generate( batchResponseItems, SyncopeConstants.DOUBLE_DASH + boundary)). type(RESTHeaders.multipartMixedWith(boundary)). build();