mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
improve handling of exceptions
This commit is contained in:
@@ -43,11 +43,13 @@ import sonia.scm.cache.Cache;
|
|||||||
import sonia.scm.cache.CacheManager;
|
import sonia.scm.cache.CacheManager;
|
||||||
import sonia.scm.repository.BlameResult;
|
import sonia.scm.repository.BlameResult;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.spi.BlameCommand;
|
import sonia.scm.repository.spi.BlameCommand;
|
||||||
import sonia.scm.repository.spi.BlameCommandRequest;
|
import sonia.scm.repository.spi.BlameCommandRequest;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,8 +107,12 @@ public final class BlameCommandBuilder
|
|||||||
* @return changeset informations by line for the given file
|
* @return changeset informations by line for the given file
|
||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if the path is null or empty
|
* @throws IllegalArgumentException if the path is null or empty
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public BlameResult getBlameResult(String path)
|
public BlameResult getBlameResult(String path)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
|
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
|
||||||
"path is required");
|
"path is required");
|
||||||
|
|||||||
@@ -41,11 +41,13 @@ import sonia.scm.cache.Cache;
|
|||||||
import sonia.scm.cache.CacheManager;
|
import sonia.scm.cache.CacheManager;
|
||||||
import sonia.scm.repository.BrowserResult;
|
import sonia.scm.repository.BrowserResult;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.spi.BrowseCommand;
|
import sonia.scm.repository.spi.BrowseCommand;
|
||||||
import sonia.scm.repository.spi.BrowseCommandRequest;
|
import sonia.scm.repository.spi.BrowseCommandRequest;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,8 +105,12 @@ public final class BrowseCommandBuilder
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return files for the given parameters
|
* @return files for the given parameters
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public BrowserResult getBrowserResult()
|
public BrowserResult getBrowserResult()
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
BrowserResult result = null;
|
BrowserResult result = null;
|
||||||
|
|
||||||
|
|||||||
@@ -40,12 +40,14 @@ import com.google.common.base.Strings;
|
|||||||
import com.google.common.io.Closeables;
|
import com.google.common.io.Closeables;
|
||||||
|
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.spi.CatCommand;
|
import sonia.scm.repository.spi.CatCommand;
|
||||||
import sonia.scm.repository.spi.CatCommandRequest;
|
import sonia.scm.repository.spi.CatCommandRequest;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,9 +91,13 @@ public final class CatCommandBuilder
|
|||||||
* @param path file path
|
* @param path file path
|
||||||
*
|
*
|
||||||
* @return {@code this}
|
* @return {@code this}
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public CatCommandBuilder retriveContent(OutputStream outputStream,
|
public CatCommandBuilder retriveContent(OutputStream outputStream,
|
||||||
String path)
|
String path)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
getCatResult(outputStream, path);
|
getCatResult(outputStream, path);
|
||||||
|
|
||||||
@@ -105,8 +111,11 @@ public final class CatCommandBuilder
|
|||||||
*
|
*
|
||||||
* @param path file path
|
* @param path file path
|
||||||
* @return content of the file
|
* @return content of the file
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public String getContent(String path)
|
public String getContent(String path) throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
String content = null;
|
String content = null;
|
||||||
ByteArrayOutputStream baos = null;
|
ByteArrayOutputStream baos = null;
|
||||||
@@ -150,8 +159,12 @@ public final class CatCommandBuilder
|
|||||||
*
|
*
|
||||||
* @param outputStream the outputstream for the content
|
* @param outputStream the outputstream for the content
|
||||||
* @param path path of the file
|
* @param path path of the file
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
private void getCatResult(OutputStream outputStream, String path)
|
private void getCatResult(OutputStream outputStream, String path)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Preconditions.checkNotNull(outputStream, "OutputStream is required");
|
Preconditions.checkNotNull(outputStream, "OutputStream is required");
|
||||||
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
|
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
|
||||||
|
|||||||
@@ -38,12 +38,14 @@ package sonia.scm.repository.api;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.Closeables;
|
import com.google.common.io.Closeables;
|
||||||
|
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.spi.DiffCommand;
|
import sonia.scm.repository.spi.DiffCommand;
|
||||||
import sonia.scm.repository.spi.DiffCommandRequest;
|
import sonia.scm.repository.spi.DiffCommandRequest;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,8 +82,12 @@ public final class DiffCommandBuilder
|
|||||||
* @param outputStream outputstream for the difference
|
* @param outputStream outputstream for the difference
|
||||||
*
|
*
|
||||||
* @return {@code this}
|
* @return {@code this}
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public DiffCommandBuilder retriveContent(OutputStream outputStream)
|
public DiffCommandBuilder retriveContent(OutputStream outputStream)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
getDiffResult(outputStream);
|
getDiffResult(outputStream);
|
||||||
|
|
||||||
@@ -94,8 +100,11 @@ public final class DiffCommandBuilder
|
|||||||
* Returns the content of the difference as string.
|
* Returns the content of the difference as string.
|
||||||
*
|
*
|
||||||
* @return content of the difference
|
* @return content of the difference
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public String getContent()
|
public String getContent() throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
String content = null;
|
String content = null;
|
||||||
ByteArrayOutputStream baos = null;
|
ByteArrayOutputStream baos = null;
|
||||||
@@ -154,8 +163,12 @@ public final class DiffCommandBuilder
|
|||||||
*
|
*
|
||||||
* @param outputStream
|
* @param outputStream
|
||||||
* @param path
|
* @param path
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
private void getDiffResult(OutputStream outputStream)
|
private void getDiffResult(OutputStream outputStream)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Preconditions.checkNotNull(outputStream, "OutputStream is required");
|
Preconditions.checkNotNull(outputStream, "OutputStream is required");
|
||||||
Preconditions.checkArgument(request.isValid(),
|
Preconditions.checkArgument(request.isValid(),
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ import sonia.scm.cache.CacheManager;
|
|||||||
import sonia.scm.repository.Changeset;
|
import sonia.scm.repository.Changeset;
|
||||||
import sonia.scm.repository.ChangesetPagingResult;
|
import sonia.scm.repository.ChangesetPagingResult;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.spi.LogCommand;
|
import sonia.scm.repository.spi.LogCommand;
|
||||||
import sonia.scm.repository.spi.LogCommandRequest;
|
import sonia.scm.repository.spi.LogCommandRequest;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,8 +162,12 @@ public final class LogCommandBuilder
|
|||||||
* @param id id of the {@link Changeset}
|
* @param id id of the {@link Changeset}
|
||||||
*
|
*
|
||||||
* @return the {@link Changeset} with the given id or null
|
* @return the {@link Changeset} with the given id or null
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public Changeset getChangeset(String id)
|
public Changeset getChangeset(String id)
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
Changeset changeset = null;
|
Changeset changeset = null;
|
||||||
|
|
||||||
@@ -198,8 +204,12 @@ public final class LogCommandBuilder
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @return all changesets with the given parameters
|
* @return all changesets with the given parameters
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public ChangesetPagingResult getChangesets()
|
public ChangesetPagingResult getChangesets()
|
||||||
|
throws IOException, RepositoryException
|
||||||
{
|
{
|
||||||
ChangesetPagingResult cpr = null;
|
ChangesetPagingResult cpr = null;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ package sonia.scm.repository.spi;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.repository.BlameResult;
|
import sonia.scm.repository.BlameResult;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -52,6 +57,10 @@ public interface BlameCommand
|
|||||||
* @param request
|
* @param request
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public BlameResult getBlameResult(BlameCommandRequest request);
|
public BlameResult getBlameResult(BlameCommandRequest request)
|
||||||
|
throws IOException, RepositoryException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ package sonia.scm.repository.spi;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.repository.BrowserResult;
|
import sonia.scm.repository.BrowserResult;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -52,6 +57,10 @@ public interface BrowseCommand
|
|||||||
* @param request
|
* @param request
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public BrowserResult getBrowserResult(BrowseCommandRequest request);
|
public BrowserResult getBrowserResult(BrowseCommandRequest request)
|
||||||
|
throws IOException, RepositoryException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,13 @@
|
|||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +56,10 @@ public interface CatCommand
|
|||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param output
|
* @param output
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public void getCatResult(CatCommandRequest request, OutputStream output);
|
public void getCatResult(CatCommandRequest request, OutputStream output)
|
||||||
|
throws IOException, RepositoryException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,13 @@
|
|||||||
|
|
||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +56,11 @@ public interface DiffCommand
|
|||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @param output
|
* @param output
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RuntimeException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public void getDiffResult(DiffCommandRequest request, OutputStream output);
|
public void getDiffResult(DiffCommandRequest request, OutputStream output)
|
||||||
|
throws IOException, RepositoryException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ package sonia.scm.repository.spi;
|
|||||||
|
|
||||||
import sonia.scm.repository.Changeset;
|
import sonia.scm.repository.Changeset;
|
||||||
import sonia.scm.repository.ChangesetPagingResult;
|
import sonia.scm.repository.ChangesetPagingResult;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -53,8 +58,12 @@ public interface LogCommand
|
|||||||
* @param id
|
* @param id
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public Changeset getChangeset(String id);
|
public Changeset getChangeset(String id)
|
||||||
|
throws IOException, RepositoryException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
@@ -63,6 +72,10 @@ public interface LogCommand
|
|||||||
* @param request
|
* @param request
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* @throws RepositoryException
|
||||||
*/
|
*/
|
||||||
public ChangesetPagingResult getChangesets(LogCommandRequest request);
|
public ChangesetPagingResult getChangesets(LogCommandRequest request)
|
||||||
|
throws IOException, RepositoryException;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user