Move constant to interface

This commit is contained in:
René Pfeuffer
2019-06-03 13:47:05 +02:00
parent e8c37f3a50
commit 6244713970
9 changed files with 12 additions and 14 deletions

View File

@@ -59,9 +59,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends RepositoryConfig
public static final String DEFAULT_VERSION_INFORMATION = "unknown";
public static final String DOT = ".";
public static final String REPOSITORIES_NATIVE_DIRECTORY = "data";
/**
* the logger for AbstractSimpleRepositoryHandler
*/

View File

@@ -42,6 +42,8 @@ import java.io.File;
*/
public interface RepositoryDirectoryHandler extends RepositoryHandler {
String REPOSITORIES_NATIVE_DIRECTORY = "data";
/**
* Get the current directory of the repository for the given id.
* @return the current directory of the given repository

View File

@@ -117,6 +117,6 @@ public class GitRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
initRepository();
File path = repositoryHandler.getDirectory(repository.getId());
assertEquals(repoPath.toString() + File.separator + AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
assertEquals(repoPath.toString() + File.separator + RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
}
}

View File

@@ -96,6 +96,6 @@ public class HgRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
initRepository();
File path = repositoryHandler.getDirectory(repository.getId());
assertEquals(repoPath.toString() + File.separator + AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
assertEquals(repoPath.toString() + File.separator + RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
}
}

View File

@@ -112,6 +112,6 @@ public class SvnRepositoryHandlerTest extends SimpleRepositoryHandlerTestBase {
initRepository();
File path = repositoryHandler.getDirectory(repository.getId());
assertEquals(repoPath.toString()+File.separator+ AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
assertEquals(repoPath.toString()+File.separator+ RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY, path.getAbsolutePath());
}
}

View File

@@ -113,7 +113,7 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
File repoDirectory = new File(baseDirectory, repository.getId());
repoPath = repoDirectory.toPath();
// when(repoDao.getPath(repository.getId())).thenReturn(repoPath);
return new File(repoDirectory, AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
return new File(repoDirectory, RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
}
protected File baseDirectory;

View File

@@ -1,7 +1,7 @@
package sonia.scm.repository.update;
import sonia.scm.SCMContextProvider;
import sonia.scm.repository.AbstractSimpleRepositoryHandler;
import sonia.scm.repository.RepositoryDirectoryHandler;
import sonia.scm.repository.RepositoryLocationResolver;
import javax.inject.Inject;
@@ -22,7 +22,7 @@ class CopyMigrationStrategy extends BaseMigrationStrategy {
public Path migrate(String id, String name, String type) {
Path repositoryBasePath = locationResolver.forClass(Path.class).getLocation(id);
Path targetDataPath = repositoryBasePath
.resolve(AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
.resolve(RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
Path sourceDataPath = getSourceDataPath(name, type);
copyData(sourceDataPath, targetDataPath);
return repositoryBasePath;

View File

@@ -1,10 +1,9 @@
package sonia.scm.repository.update;
import sonia.scm.SCMContextProvider;
import sonia.scm.repository.AbstractSimpleRepositoryHandler;
import sonia.scm.repository.RepositoryDirectoryHandler;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -19,7 +18,7 @@ class InlineMigrationStrategy extends BaseMigrationStrategy {
public Path migrate(String id, String name, String type) {
Path repositoryBasePath = getSourceDataPath(name, type);
Path targetDataPath = repositoryBasePath
.resolve(AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
.resolve(RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
moveData(repositoryBasePath, targetDataPath);
return repositoryBasePath;
}

View File

@@ -3,7 +3,7 @@ package sonia.scm.repository.update;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.SCMContextProvider;
import sonia.scm.repository.AbstractSimpleRepositoryHandler;
import sonia.scm.repository.RepositoryDirectoryHandler;
import sonia.scm.repository.RepositoryLocationResolver;
import javax.inject.Inject;
@@ -30,7 +30,7 @@ class MoveMigrationStrategy extends BaseMigrationStrategy {
public Path migrate(String id, String name, String type) {
Path repositoryBasePath = locationResolver.forClass(Path.class).getLocation(id);
Path targetDataPath = repositoryBasePath
.resolve(AbstractSimpleRepositoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
.resolve(RepositoryDirectoryHandler.REPOSITORIES_NATIVE_DIRECTORY);
Path sourceDataPath = getSourceDataPath(name, type);
moveData(sourceDataPath, targetDataPath);
deleteOldDataDir(getTypeDependentPath(type), name);