Skip to content

Commit

Permalink
Merge pull request #105 from ligangty/1.0.x
Browse files Browse the repository at this point in the history
Add back diagnostics bundle addon
  • Loading branch information
ligangty authored Nov 27, 2023
2 parents 8deac8b + 01148c9 commit ea54598
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
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();
}

}
4 changes: 2 additions & 2 deletions src/main/webui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
<li><a class="fa" href="#/nfc">Not-Found Cache</a></li>
<li><a class="fa" href="#/cache/delete">Delete Metadata</a></li>
<li class="divider"></li>
<li ng-repeat="addon in addon_navs"><a class="fa" href="#{{addon.route}}">{{addon.name}}</a>
</li>
<li><a class="fa" href="/api/diag/bundle">Diagnostic Bundle</a></li>
<li ng-repeat="addon in addon_navs"><a class="fa" href="#{{addon.route}}">{{addon.name}}</a></li>
</ul>
</li>
<li class="dropdown" ng-if="username">
Expand Down

0 comments on commit ea54598

Please sign in to comment.