diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBrowseCommand.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBrowseCommand.java index 9186572858..6a4d0d9983 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBrowseCommand.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitBrowseCommand.java @@ -65,6 +65,9 @@ import java.util.Collections; import java.util.List; import java.util.Map; +import static sonia.scm.ContextEntry.ContextBuilder.entity; +import static sonia.scm.NotFoundException.notFound; + //~--- JDK imports ------------------------------------------------------------ /** @@ -128,10 +131,11 @@ public class GitBrowseCommand extends AbstractGitCommand if (Util.isNotEmpty(request.getRevision())) { logger.error("could not find revision {}", request.getRevision()); + throw notFound(entity("Revision", request.getRevision()).in(this.repository)); } else if (logger.isWarnEnabled()) { - logger.warn("coul not find head of repository, empty?"); + logger.warn("could not find head of repository, empty?"); } result = new BrowserResult(Constants.HEAD, createEmtpyRoot()); diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java index bdbb87f2aa..cae62ad362 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitLogCommand.java @@ -79,6 +79,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand */ private static final Logger logger = LoggerFactory.getLogger(GitLogCommand.class); + public static final String REVISION = "Revision"; //~--- constructors --------------------------------------------------------- @@ -143,6 +144,10 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand { logger.error("could not open repository", ex); } + catch (NullPointerException e) + { + throw notFound(entity(REVISION, revision).in(this.repository)); + } finally { IOUtil.close(converter); @@ -208,7 +213,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) { ancestorId = repository.resolve(request.getAncestorChangeset()); if (ancestorId == null) { - throw notFound(entity("Revision", request.getAncestorChangeset()).in(this.repository)); + throw notFound(entity(REVISION, request.getAncestorChangeset()).in(this.repository)); } } @@ -250,7 +255,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand } } } else if (ancestorId != null) { - throw notFound(entity("Revision", request.getBranch()).in(this.repository)); + throw notFound(entity(REVISION, request.getBranch()).in(this.repository)); } if (branch != null) { @@ -267,7 +272,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand } catch (MissingObjectException e) { - throw notFound(entity("Revision", e.getObjectId().getName()).in(repository)); + throw notFound(entity(REVISION, e.getObjectId().getName()).in(repository)); } catch (NotFoundException e) { diff --git a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/SourceRootResource.java b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/SourceRootResource.java index d507a59f14..b5091a8b5f 100644 --- a/scm-webapp/src/main/java/sonia/scm/api/v2/resources/SourceRootResource.java +++ b/scm-webapp/src/main/java/sonia/scm/api/v2/resources/SourceRootResource.java @@ -15,6 +15,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import java.io.IOException; +import static sonia.scm.ContextEntry.ContextBuilder.entity; +import static sonia.scm.NotFoundException.notFound; + public class SourceRootResource { private final RepositoryServiceFactory serviceFactory; @@ -62,7 +65,7 @@ public class SourceRootResource { if (browserResult != null) { return Response.ok(browserResultToFileObjectDtoMapper.map(browserResult, namespaceAndName)).build(); } else { - return Response.status(Response.Status.NOT_FOUND).build(); + throw notFound(entity("sources", path).in(namespaceAndName)); } } }