Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap the diagnostics bundle file content with StreamOutput #106

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.commonjava.indy.service.ui.jaxrs.diag;

import org.apache.commons.io.IOUtils;
import org.commonjava.indy.service.ui.client.diag.DiagnosticsServiceClient;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
Expand All @@ -27,6 +28,9 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;

import java.io.InputStream;

import static javax.ws.rs.core.MediaType.TEXT_PLAIN;

Expand Down Expand Up @@ -60,7 +64,7 @@ public Response getThreadDump()
@Produces( "application/zip" )
public Response getBundle()
{
return client.getBundle();
return streamBinContent( client.getBundle() );
}

@Operation( description = "Retrieve a ZIP-compressed file containing all repository definitions." )
Expand All @@ -71,7 +75,14 @@ public Response getBundle()
@Produces( "application/zip" )
public Response getRepoBundle()
{
return client.getRepoBundle();
return streamBinContent( client.getRepoBundle() );
}

private Response streamBinContent( final Response response )
{
final InputStream clientIn = response.readEntity( InputStream.class );
StreamingOutput out = output -> IOUtils.copy( clientIn, output );
return Response.status( response.getStatus() ).entity( out ).replaceAll( response.getHeaders() ).build();
}

}
Loading