Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: private javax.ws.rs.core.Response batchProcessAndStream(final javax.ws.rs.core.UriInfo uriInfo, final javax.ws.rs.core.HttpHeaders httpHeaders, final javax.servlet.http.HttpServletRequest req, final java.io.InputStream body)
        private Response BatchProcessAndStream(UriInfo uriInfo, HttpHeaders httpHeaders, HttpServletRequest req, Stream body)
        {
            try
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final javax.ws.rs.core.StreamingOutput stream = output ->
                StreamingOutput stream = _output =>
                {
                    try
                    {
                        ServletOutputStream servletOutputStream = new ServletOutputStreamAnonymousInnerClass(this);
                        (new StreamingBatchOperations(_webServer)).readAndExecuteOperations(uriInfo, httpHeaders, req, body, servletOutputStream);
                        _representationWriteHandler.onRepresentationWritten();
                    }
                    catch (Exception e)
                    {
                        _logger.warn("Error executing batch request ", e);
                    }
                    finally
                    {
                        _representationWriteHandler.onRepresentationFinal();
                    }
                };
                return(Response.ok(stream).type(HttpHeaderUtils.mediaTypeWithCharsetUtf8(MediaType.APPLICATION_JSON_TYPE)).build());
            }
            catch (Exception e)
            {
                return(_output.serverError(e));
            }
        }
Exemplo n.º 2
0
        private Response BatchProcess(UriInfo uriInfo, HttpHeaders httpHeaders, HttpServletRequest req, Stream body)
        {
            try
            {
                NonStreamingBatchOperations batchOperations = new NonStreamingBatchOperations(_webServer);
                BatchOperationResults       results         = batchOperations.PerformBatchJobs(uriInfo, httpHeaders, req, body);

                Response res = Response.ok().entity(results.ToJSON()).type(HttpHeaderUtils.mediaTypeWithCharsetUtf8(MediaType.APPLICATION_JSON_TYPE)).build();
                _representationWriteHandler.onRepresentationWritten();
                return(res);
            }
            catch (Exception e)
            {
                return(_output.serverError(e));
            }
            finally
            {
                _representationWriteHandler.onRepresentationFinal();
            }
        }
Exemplo n.º 3
0
 protected internal virtual Response Response(Response.ResponseBuilder response, Representation representation)
 {
     return(FormatRepresentation(response, representation).type(HttpHeaderUtils.mediaTypeWithCharsetUtf8(MediaType)).build());
 }