Remove dead code

This commit is contained in:
René Pfeuffer
2018-11-23 13:16:18 +01:00
parent 8b8240319b
commit aa596af880
7 changed files with 11 additions and 38 deletions

View File

@@ -86,7 +86,7 @@ public abstract class AbstractSimpleRepositoryHandler<C extends RepositoryConfig
@Override
public Repository create(Repository repository) {
File directory = repositoryLocationResolver.getNativeDirectory(repository);
File directory = initialRepositoryLocationResolver.getDefaultNativeDirectory(repository);
if (directory != null && directory.exists()) {
throw new AlreadyExistsException(repository);
}
@@ -161,11 +161,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends RepositoryConfig
return directory;
}
@Override
public File getInitialBaseDirectory() {
return initialRepositoryLocationResolver.getBaseDirectory();
}
@Override
public String getVersionInformation() {
return DEFAULT_VERSION_INFORMATION;

View File

@@ -30,15 +30,16 @@ public class InitialRepositoryLocationResolver {
this.context = context;
}
File getBaseDirectory() {
return new File(context.getBaseDirectory(), DEFAULT_REPOSITORY_PATH);
}
File getDefaultDirectory(Repository repository) {
String initialRepoFolder = getRelativeRepositoryPath(repository);
return new File(context.getBaseDirectory(), initialRepoFolder);
}
File getDefaultNativeDirectory(Repository repository) {
String initialRepoFolder = getRelativeRepositoryPath(repository);
return new File(context.getBaseDirectory(), initialRepoFolder + "/data");
}
public String getRelativeRepositoryPath(Repository repository) {
return DEFAULT_REPOSITORY_PATH + File.separator + repository.getId();
}

View File

@@ -11,10 +11,7 @@ import java.nio.file.Path;
public interface PathBasedRepositoryDAO extends RepositoryDAO {
/**
* get the current path of the repository or create it
*
* @param repository
* @return the current path of the repository
* Get the current path of the repository. This works for existing repositories only, not for repositories that should be created.
*/
Path getPath(Repository repository) ;
}

View File

@@ -48,10 +48,4 @@ public interface RepositoryDirectoryHandler extends RepositoryHandler {
* @return the current directory of the given repository
*/
File getDirectory(Repository repository);
/**
* get the initial directory of all repositories
* @return the initial directory of all repositories
*/
File getInitialBaseDirectory();
}

View File

@@ -153,7 +153,10 @@ public class XmlRepositoryDAO
return context
.getBaseDirectory()
.toPath()
.resolve(findExistingRepositoryPath(repository).map(RepositoryPath::getPath).orElse(initialRepositoryLocationResolver.getRelativeRepositoryPath(repository)));
.resolve(
findExistingRepositoryPath(repository)
.map(RepositoryPath::getPath)
.orElseThrow(() -> new InternalRepositoryException(repository, "could not find base directory for repository")));
}
@Override

View File

@@ -104,19 +104,6 @@ public class XmlRepositoryDAOTest {
assertThat(path.toString()).isEqualTo("/tmp/path");
}
@Test
public void shouldGetPathForNewRepository() {
when(db.getPaths()).thenReturn(emptyList());
InitialRepositoryLocationResolver initialRepositoryLocationResolver = new InitialRepositoryLocationResolver(context);
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, initialRepositoryLocationResolver, context);
Repository newRepository = new Repository("id", "new", null, null);
Path path = dao.getPath(newRepository);
assertThat(path.toString()).isEqualTo(context.getBaseDirectory().getPath() + "/" + InitialRepositoryLocationResolver.DEFAULT_REPOSITORY_PATH + "/id");
}
@Test
public void shouldFindRepositoryForRelativePath() {
new File(context.getBaseDirectory(), "relative/path/data").mkdirs();

View File

@@ -33,10 +33,6 @@ public class HgHookCallbackServletTest {
String path = "/tmp/hg/12345";
when(request.getParameter(PARAM_REPOSITORYPATH)).thenReturn(path);
File file = new File(path);
when(handler.getInitialBaseDirectory()).thenReturn(file);
servlet.doPost(request, response);
verify(response, never()).sendError(anyInt());