mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 00:09:47 +01:00
improve bundle/unbundle api, by using ByteSource and ByteSink
This commit is contained in:
@@ -35,6 +35,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.io.ByteSink;
|
||||
import com.google.common.io.Closeables;
|
||||
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
@@ -52,13 +53,12 @@ import static com.google.common.base.Preconditions.*;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra <sebastian.sdorra@triology.de>
|
||||
* @author Sebastian Sdorra <s.sdorra@gmail.com>
|
||||
*/
|
||||
public class SvnBundleCommand extends AbstractSvnCommand
|
||||
implements BundleCommand
|
||||
@@ -90,14 +90,14 @@ public class SvnBundleCommand extends AbstractSvnCommand
|
||||
* @throws SVNException
|
||||
*/
|
||||
private static void dump(SVNAdminClient adminClient, File repository,
|
||||
File target)
|
||||
ByteSink target)
|
||||
throws SVNException, IOException
|
||||
{
|
||||
OutputStream outputStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
outputStream = new FileOutputStream(target);
|
||||
outputStream = target.openBufferedStream();
|
||||
adminClient.doDump(repository, outputStream, SVNRevision.create(-1l),
|
||||
SVNRevision.HEAD, false, false);
|
||||
}
|
||||
@@ -122,7 +122,8 @@ public class SvnBundleCommand extends AbstractSvnCommand
|
||||
public BundleResponse bundle(BundleCommandRequest request)
|
||||
throws IOException, RepositoryException
|
||||
{
|
||||
File archive = checkNotNull(request.getArchive(), "archive is required");
|
||||
ByteSink archive = checkNotNull(request.getArchive(),
|
||||
"archive is required");
|
||||
|
||||
SVNClientManager clientManager = null;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Closeables;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -53,13 +54,12 @@ import static com.google.common.base.Preconditions.*;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra <sebastian.sdorra@triology.de>
|
||||
* @author Sebastian Sdorra <s.sdorra@gmail.com>
|
||||
*/
|
||||
public class SvnUnbundleCommand extends AbstractSvnCommand
|
||||
implements UnbundleCommand
|
||||
@@ -99,7 +99,8 @@ public class SvnUnbundleCommand extends AbstractSvnCommand
|
||||
public UnbundleResponse unbundle(UnbundleCommandRequest request)
|
||||
throws IOException
|
||||
{
|
||||
File archive = checkNotNull(request.getArchive(), "archive is required");
|
||||
ByteSource archive = checkNotNull(request.getArchive(),
|
||||
"archive is required");
|
||||
|
||||
logger.debug("archive repository {} to {}", context.getDirectory(),
|
||||
archive);
|
||||
@@ -137,14 +138,15 @@ public class SvnUnbundleCommand extends AbstractSvnCommand
|
||||
* @throws IOException
|
||||
* @throws SVNException
|
||||
*/
|
||||
private void restore(SVNAdminClient adminClient, File dump, File repository)
|
||||
private void restore(SVNAdminClient adminClient, ByteSource dump,
|
||||
File repository)
|
||||
throws SVNException, IOException
|
||||
{
|
||||
InputStream inputStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
inputStream = new FileInputStream(dump);
|
||||
inputStream = dump.openBufferedStream();
|
||||
adminClient.doLoad(repository, inputStream);
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user