mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
Correct usage of RepositoryNotFoundException
This commit is contained in:
@@ -61,4 +61,8 @@ public class RepositoryNotFoundException extends NotFoundException
|
||||
public RepositoryNotFoundException(String repositoryId) {
|
||||
super("repository", repositoryId);
|
||||
}
|
||||
|
||||
public RepositoryNotFoundException(NamespaceAndName namespaceAndName) {
|
||||
super("repository", namespaceAndName.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,9 +208,7 @@ public final class RepositoryServiceFactory
|
||||
|
||||
if (repository == null)
|
||||
{
|
||||
String msg = "could not find a repository with namespace/name " + namespaceAndName;
|
||||
|
||||
throw new RepositoryNotFoundException(msg);
|
||||
throw new RepositoryNotFoundException(namespaceAndName);
|
||||
}
|
||||
|
||||
return create(repository);
|
||||
|
||||
@@ -210,8 +210,9 @@ public class PermissionRootResource {
|
||||
* @throws RepositoryNotFoundException if the repository does not exists
|
||||
*/
|
||||
private Repository load(String namespace, String name) throws RepositoryNotFoundException {
|
||||
return Optional.ofNullable(manager.get(new NamespaceAndName(namespace, name)))
|
||||
.orElseThrow(() -> new RepositoryNotFoundException(name));
|
||||
NamespaceAndName namespaceAndName = new NamespaceAndName(namespace, name);
|
||||
return Optional.ofNullable(manager.get(namespaceAndName))
|
||||
.orElseThrow(() -> new RepositoryNotFoundException(namespaceAndName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,8 +61,7 @@ public final class HealthChecker {
|
||||
Repository repository = repositoryManager.get(id);
|
||||
|
||||
if (repository == null) {
|
||||
throw new RepositoryNotFoundException(
|
||||
"could not find repository with id ".concat(id));
|
||||
throw new RepositoryNotFoundException(id);
|
||||
}
|
||||
|
||||
doCheck(repository);
|
||||
|
||||
Reference in New Issue
Block a user