mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26:16 +01:00
Add raw stream result to cat command
This commit is contained in:
@@ -37,22 +37,21 @@ package sonia.scm.repository.api;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
import sonia.scm.repository.spi.CatCommand;
|
||||
import sonia.scm.repository.spi.CatCommandRequest;
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Shows the content of a file in the {@link Repository}.<br />
|
||||
* <br />
|
||||
@@ -106,23 +105,31 @@ public final class CatCommandBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes the content of the given file to the outputstream.
|
||||
* Passes the content of the given file to the output stream.
|
||||
*
|
||||
* @param outputStream outputstream for the content
|
||||
* @param outputStream output stream for the content
|
||||
* @param path file path
|
||||
*
|
||||
* @return {@code this}
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public CatCommandBuilder retriveContent(OutputStream outputStream,
|
||||
String path)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
public void retriveContent(OutputStream outputStream, String path) throws IOException, RepositoryException {
|
||||
getCatResult(outputStream, path);
|
||||
}
|
||||
|
||||
return this;
|
||||
/**
|
||||
* Returns an output stream with the file content.
|
||||
*
|
||||
* @param path file path
|
||||
*/
|
||||
public InputStream getStream(String path) throws IOException, RepositoryException {
|
||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
|
||||
"path is required");
|
||||
|
||||
CatCommandRequest requestClone = request.clone();
|
||||
|
||||
requestClone.setPath(path);
|
||||
|
||||
logger.debug("create cat stream for {}", requestClone);
|
||||
|
||||
return catCommand.getCatResultStream(requestClone);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
@@ -37,11 +37,12 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import sonia.scm.repository.RepositoryException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -50,16 +51,7 @@ import java.io.OutputStream;
|
||||
public interface CatCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param output
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public void getCatResult(CatCommandRequest request, OutputStream output)
|
||||
throws IOException, RepositoryException;
|
||||
void getCatResult(CatCommandRequest request, OutputStream output) throws IOException, RepositoryException;
|
||||
|
||||
InputStream getCatResultStream(CatCommandRequest request) throws IOException, RepositoryException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user