improve handling of exceptions

This commit is contained in:
Sebastian Sdorra
2012-06-12 14:17:15 +02:00
parent 94f46d587e
commit 491b26c4ed
10 changed files with 106 additions and 8 deletions

View File

@@ -43,11 +43,13 @@ import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BlameCommand;
import sonia.scm.repository.spi.BlameCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Serializable;
/**
@@ -105,8 +107,12 @@ public final class BlameCommandBuilder
* @return changeset informations by line for the given file
*
* @throws IllegalArgumentException if the path is null or empty
*
* @throws IOException
* @throws RepositoryException
*/
public BlameResult getBlameResult(String path)
throws IOException, RepositoryException
{
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
"path is required");

View File

@@ -41,11 +41,13 @@ import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.BrowseCommand;
import sonia.scm.repository.spi.BrowseCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Serializable;
/**
@@ -103,8 +105,12 @@ public final class BrowseCommandBuilder
*
*
* @return files for the given parameters
*
* @throws IOException
* @throws RepositoryException
*/
public BrowserResult getBrowserResult()
throws IOException, RepositoryException
{
BrowserResult result = null;

View File

@@ -40,12 +40,14 @@ import com.google.common.base.Strings;
import com.google.common.io.Closeables;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.CatCommand;
import sonia.scm.repository.spi.CatCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
@@ -89,9 +91,13 @@ public final class CatCommandBuilder
* @param path file path
*
* @return {@code this}
*
* @throws IOException
* @throws RepositoryException
*/
public CatCommandBuilder retriveContent(OutputStream outputStream,
String path)
throws IOException, RepositoryException
{
getCatResult(outputStream, path);
@@ -105,8 +111,11 @@ public final class CatCommandBuilder
*
* @param path file path
* @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;
ByteArrayOutputStream baos = null;
@@ -150,8 +159,12 @@ public final class CatCommandBuilder
*
* @param outputStream the outputstream for the content
* @param path path of the file
*
* @throws IOException
* @throws RepositoryException
*/
private void getCatResult(OutputStream outputStream, String path)
throws IOException, RepositoryException
{
Preconditions.checkNotNull(outputStream, "OutputStream is required");
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),

View File

@@ -38,12 +38,14 @@ package sonia.scm.repository.api;
import com.google.common.base.Preconditions;
import com.google.common.io.Closeables;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.DiffCommand;
import sonia.scm.repository.spi.DiffCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
@@ -80,8 +82,12 @@ public final class DiffCommandBuilder
* @param outputStream outputstream for the difference
*
* @return {@code this}
*
* @throws IOException
* @throws RepositoryException
*/
public DiffCommandBuilder retriveContent(OutputStream outputStream)
throws IOException, RepositoryException
{
getDiffResult(outputStream);
@@ -94,8 +100,11 @@ public final class DiffCommandBuilder
* Returns the content of the difference as string.
*
* @return content of the difference
*
* @throws IOException
* @throws RepositoryException
*/
public String getContent()
public String getContent() throws IOException, RepositoryException
{
String content = null;
ByteArrayOutputStream baos = null;
@@ -154,8 +163,12 @@ public final class DiffCommandBuilder
*
* @param outputStream
* @param path
*
* @throws IOException
* @throws RepositoryException
*/
private void getDiffResult(OutputStream outputStream)
throws IOException, RepositoryException
{
Preconditions.checkNotNull(outputStream, "OutputStream is required");
Preconditions.checkArgument(request.isValid(),

View File

@@ -43,11 +43,13 @@ import sonia.scm.cache.CacheManager;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.LogCommand;
import sonia.scm.repository.spi.LogCommandRequest;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Serializable;
/**
@@ -160,8 +162,12 @@ public final class LogCommandBuilder
* @param id id of the {@link Changeset}
*
* @return the {@link Changeset} with the given id or null
*
* @throws IOException
* @throws RepositoryException
*/
public Changeset getChangeset(String id)
throws IOException, RepositoryException
{
Changeset changeset = null;
@@ -198,8 +204,12 @@ public final class LogCommandBuilder
*
*
* @return all changesets with the given parameters
*
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets()
throws IOException, RepositoryException
{
ChangesetPagingResult cpr = null;

View File

@@ -36,6 +36,11 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
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
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public BlameResult getBlameResult(BlameCommandRequest request);
public BlameResult getBlameResult(BlameCommandRequest request)
throws IOException, RepositoryException;
}

View File

@@ -36,6 +36,11 @@ package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
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
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public BrowserResult getBrowserResult(BrowseCommandRequest request);
public BrowserResult getBrowserResult(BrowseCommandRequest request)
throws IOException, RepositoryException;
}

View File

@@ -33,8 +33,13 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
/**
@@ -51,6 +56,10 @@ public interface CatCommand
*
* @param request
* @param output
*
* @throws IOException
* @throws RepositoryException
*/
public void getCatResult(CatCommandRequest request, OutputStream output);
public void getCatResult(CatCommandRequest request, OutputStream output)
throws IOException, RepositoryException;
}

View File

@@ -33,8 +33,13 @@
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.RepositoryException;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
/**
@@ -51,6 +56,11 @@ public interface DiffCommand
*
* @param request
* @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;
}

View File

@@ -37,6 +37,11 @@ package sonia.scm.repository.spi;
import sonia.scm.repository.Changeset;
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
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public Changeset getChangeset(String id);
public Changeset getChangeset(String id)
throws IOException, RepositoryException;
/**
* Method description
@@ -63,6 +72,10 @@ public interface LogCommand
* @param request
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(LogCommandRequest request);
public ChangesetPagingResult getChangesets(LogCommandRequest request)
throws IOException, RepositoryException;
}