Cleanup smells

This commit is contained in:
René Pfeuffer
2018-09-14 12:11:07 +02:00
parent cd344664aa
commit 37ea231340
4 changed files with 10 additions and 12 deletions

View File

@@ -44,8 +44,8 @@ import sonia.scm.NotFoundException;
public class RepositoryNotFoundException extends NotFoundException public class RepositoryNotFoundException extends NotFoundException
{ {
/** Field description */
private static final long serialVersionUID = -6583078808900520166L; private static final long serialVersionUID = -6583078808900520166L;
private static final String TYPE_REPOSITORY = "repository";
//~--- constructors --------------------------------------------------------- //~--- constructors ---------------------------------------------------------
@@ -55,14 +55,14 @@ public class RepositoryNotFoundException extends NotFoundException
* *
*/ */
public RepositoryNotFoundException(Repository repository) { public RepositoryNotFoundException(Repository repository) {
super("repository", repository.getName() + "/" + repository.getNamespace()); super(TYPE_REPOSITORY, repository.getName() + "/" + repository.getNamespace());
} }
public RepositoryNotFoundException(String repositoryId) { public RepositoryNotFoundException(String repositoryId) {
super("repository", repositoryId); super(TYPE_REPOSITORY, repositoryId);
} }
public RepositoryNotFoundException(NamespaceAndName namespaceAndName) { public RepositoryNotFoundException(NamespaceAndName namespaceAndName) {
super("repository", namespaceAndName.toString()); super(TYPE_REPOSITORY, namespaceAndName.toString());
} }
} }

View File

@@ -363,7 +363,7 @@ public final class RepositoryService implements Closeable {
public Stream<ScmProtocol> getSupportedProtocols() { public Stream<ScmProtocol> getSupportedProtocols() {
return protocolProviders.stream() return protocolProviders.stream()
.filter(provider -> provider.getType().equals(getRepository().getType())) .filter(protocolProvider -> protocolProvider.getType().equals(getRepository().getType()))
.map(this::createProviderInstanceForRepository); .map(this::createProviderInstanceForRepository);
} }

View File

@@ -44,7 +44,7 @@ public abstract class InitializingHttpScmProtocolWrapper implements ScmProtocolP
if (!repository.getType().equals(getType())) { if (!repository.getType().equals(getType())) {
throw new IllegalArgumentException("cannot handle repository with type " + repository.getType() + " with protocol for type " + getType()); throw new IllegalArgumentException("cannot handle repository with type " + repository.getType() + " with protocol for type " + getType());
} }
return new ProtocolWrapper(repository); return new ProtocolWrapper(repository, computeBasePath());
} }
private String computeBasePath() { private String computeBasePath() {
@@ -70,8 +70,8 @@ public abstract class InitializingHttpScmProtocolWrapper implements ScmProtocolP
private class ProtocolWrapper extends HttpScmProtocol { private class ProtocolWrapper extends HttpScmProtocol {
public ProtocolWrapper(Repository repository) { public ProtocolWrapper(Repository repository, String basePath) {
super(repository, computeBasePath()); super(repository, basePath);
} }
@Override @Override

View File

@@ -29,8 +29,6 @@ public abstract class RepositoryToRepositoryDtoMapper extends BaseMapper<Reposit
private ResourceLinks resourceLinks; private ResourceLinks resourceLinks;
@Inject @Inject
private RepositoryServiceFactory serviceFactory; private RepositoryServiceFactory serviceFactory;
@Inject
private ScmPathInfoStore scmPathInfoStore;
abstract HealthCheckFailureDto toDto(HealthCheckFailure failure); abstract HealthCheckFailureDto toDto(HealthCheckFailure failure);
@@ -47,7 +45,7 @@ public abstract class RepositoryToRepositoryDtoMapper extends BaseMapper<Reposit
try (RepositoryService repositoryService = serviceFactory.create(repository)) { try (RepositoryService repositoryService = serviceFactory.create(repository)) {
if (RepositoryPermissions.pull(repository).isPermitted()) { if (RepositoryPermissions.pull(repository).isPermitted()) {
List<Link> protocolLinks = repositoryService.getSupportedProtocols() List<Link> protocolLinks = repositoryService.getSupportedProtocols()
.map(protocol -> createProtocolLink(protocol, repository)) .map(this::createProtocolLink)
.collect(toList()); .collect(toList());
linksBuilder.array(protocolLinks); linksBuilder.array(protocolLinks);
} }
@@ -63,7 +61,7 @@ public abstract class RepositoryToRepositoryDtoMapper extends BaseMapper<Reposit
target.add(linksBuilder.build()); target.add(linksBuilder.build());
} }
private Link createProtocolLink(ScmProtocol protocol, Repository repository) { private Link createProtocolLink(ScmProtocol protocol) {
return Link.linkBuilder("protocol", protocol.getUrl()).withName(protocol.getType()).build(); return Link.linkBuilder("protocol", protocol.getUrl()).withName(protocol.getType()).build();
} }
} }