mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
Remove dead code
This commit is contained in:
@@ -87,11 +87,6 @@ public abstract class AbstractSimpleRepositoryHandler<C extends RepositoryConfig
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createResourcePath(Repository repository) {
|
||||
return "/" + getType().getName() + "/" + repository.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Repository repository) {
|
||||
}
|
||||
|
||||
@@ -50,17 +50,6 @@ public interface RepositoryHandler
|
||||
extends Handler<Repository>
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the resource path for the given {@link Repository}.
|
||||
* The resource path is part of the {@link Repository} url.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param repository given {@link Repository}
|
||||
* @return resource path of the {@link Repository}
|
||||
*/
|
||||
public String createResourcePath(Repository repository);
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
||||
@@ -185,7 +185,7 @@ public class XmlRepositoryDAO
|
||||
|
||||
@Override
|
||||
public Repository getRepositoryForDirectory(File path) {
|
||||
for (RepositoryPath p : db.getPaths()) {
|
||||
for (RepositoryPath p : db.values()) {
|
||||
if (toRealPath(path.toPath()).startsWith(toRealPath(context.getBaseDirectory().toPath().resolve(p.getPath())))) {
|
||||
return p.getRepository();
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class XmlRepositoryDAO
|
||||
}
|
||||
|
||||
private Optional<RepositoryPath> findExistingRepositoryPath(Repository repository) {
|
||||
return db.getPaths().stream()
|
||||
return db.values().stream()
|
||||
.filter(repoPath -> repoPath.getId().equals(repository.getId()))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
@@ -98,16 +98,6 @@ public class XmlRepositoryDatabase implements XmlDatabase<RepositoryPath> {
|
||||
return get(id) != null;
|
||||
}
|
||||
|
||||
public boolean contains(Repository repository)
|
||||
{
|
||||
return repositoryPathMap.containsKey(createKey(repository));
|
||||
}
|
||||
|
||||
public void remove(Repository repository)
|
||||
{
|
||||
repositoryPathMap.remove(createKey(repository));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryPath remove(String id)
|
||||
{
|
||||
@@ -129,11 +119,6 @@ public class XmlRepositoryDatabase implements XmlDatabase<RepositoryPath> {
|
||||
return repositoryPathMap.values();
|
||||
}
|
||||
|
||||
public Collection<RepositoryPath> getPaths() {
|
||||
return repositoryPathMap.values();
|
||||
}
|
||||
|
||||
|
||||
public Repository get(NamespaceAndName namespaceAndName) {
|
||||
RepositoryPath repositoryPath = repositoryPathMap.get(createKey(namespaceAndName));
|
||||
if (repositoryPath != null) {
|
||||
|
||||
@@ -79,7 +79,7 @@ public class XmlRepositoryMapAdapter extends XmlAdapter<XmlRepositoryList, Map<S
|
||||
}
|
||||
}
|
||||
} catch (JAXBException ex) {
|
||||
throw new StoreException("failed to marshall repository database", ex);
|
||||
throw new StoreException("failed to marshal repository database", ex);
|
||||
}
|
||||
|
||||
return repositoryPaths;
|
||||
@@ -105,7 +105,7 @@ public class XmlRepositoryMapAdapter extends XmlAdapter<XmlRepositoryList, Map<S
|
||||
repositoryPathMap.put(XmlRepositoryDatabase.createKey(repository), repositoryPath);
|
||||
}
|
||||
} catch (JAXBException ex) {
|
||||
throw new StoreException("failed to unmarshall object", ex);
|
||||
throw new StoreException("failed to unmarshal object", ex);
|
||||
}
|
||||
return repositoryPathMap;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class XmlRepositoryDAOTest {
|
||||
public void modifyShouldStoreChangedRepository() {
|
||||
Repository oldRepository = new Repository("id", "old", null, null);
|
||||
RepositoryPath repositoryPath = new RepositoryPath("/path", "id", oldRepository);
|
||||
when(db.getPaths()).thenReturn(asList(repositoryPath));
|
||||
when(db.values()).thenReturn(asList(repositoryPath));
|
||||
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, new InitialRepositoryLocationResolver(context), fileSystem, context);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class XmlRepositoryDAOTest {
|
||||
public void shouldGetPathInBaseDirectoryForRelativePath() {
|
||||
Repository existingRepository = new Repository("id", "old", null, null);
|
||||
RepositoryPath repositoryPath = new RepositoryPath("path", "id", existingRepository);
|
||||
when(db.getPaths()).thenReturn(asList(repositoryPath));
|
||||
when(db.values()).thenReturn(asList(repositoryPath));
|
||||
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, new InitialRepositoryLocationResolver(context), fileSystem, context);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class XmlRepositoryDAOTest {
|
||||
public void shouldGetPathInBaseDirectoryForAbsolutePath() {
|
||||
Repository existingRepository = new Repository("id", "old", null, null);
|
||||
RepositoryPath repositoryPath = new RepositoryPath("/tmp/path", "id", existingRepository);
|
||||
when(db.getPaths()).thenReturn(asList(repositoryPath));
|
||||
when(db.values()).thenReturn(asList(repositoryPath));
|
||||
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, new InitialRepositoryLocationResolver(context), fileSystem, context);
|
||||
|
||||
@@ -112,7 +112,7 @@ public class XmlRepositoryDAOTest {
|
||||
new File(context.getBaseDirectory(), "relative/path/data").mkdirs();
|
||||
Repository existingRepository = new Repository("id", "old", null, null);
|
||||
RepositoryPath repositoryPath = new RepositoryPath("relative/path", "id", existingRepository);
|
||||
when(db.getPaths()).thenReturn(asList(repositoryPath));
|
||||
when(db.values()).thenReturn(asList(repositoryPath));
|
||||
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, new InitialRepositoryLocationResolver(context), fileSystem, context);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class XmlRepositoryDAOTest {
|
||||
Repository existingRepository = new Repository("id", "old", null, null);
|
||||
File folder = temporaryFolder.newFolder("somewhere", "data");
|
||||
RepositoryPath repositoryPath = new RepositoryPath(folder.getParent(), "id", existingRepository);
|
||||
when(db.getPaths()).thenReturn(asList(repositoryPath));
|
||||
when(db.values()).thenReturn(asList(repositoryPath));
|
||||
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, new InitialRepositoryLocationResolver(context), fileSystem, context);
|
||||
|
||||
@@ -142,7 +142,7 @@ public class XmlRepositoryDAOTest {
|
||||
File link = new File(folder.getParentFile().getParentFile(), "link");
|
||||
Files.createSymbolicLink(link.toPath(), folder.getParentFile().toPath());
|
||||
RepositoryPath repositoryPath = new RepositoryPath(new File(link, "data").getPath(), "id", existingRepository);
|
||||
when(db.getPaths()).thenReturn(asList(repositoryPath));
|
||||
when(db.values()).thenReturn(asList(repositoryPath));
|
||||
|
||||
XmlRepositoryDAO dao = new XmlRepositoryDAO(storeFactory, new InitialRepositoryLocationResolver(context), fileSystem, context);
|
||||
|
||||
|
||||
@@ -70,17 +70,6 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
|
||||
createRepository();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateResourcePath() {
|
||||
createRepository();
|
||||
|
||||
String path = handler.createResourcePath(repository);
|
||||
|
||||
assertNotNull(path);
|
||||
assertTrue(path.trim().length() > 0);
|
||||
assertTrue(path.contains(repository.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postSetUp() throws IOException, RepositoryPathNotFoundException {
|
||||
InMemoryConfigurationStoreFactory storeFactory = new InMemoryConfigurationStoreFactory();
|
||||
@@ -96,7 +85,7 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
|
||||
}
|
||||
}
|
||||
|
||||
private Repository createRepository() {
|
||||
private void createRepository() {
|
||||
File nativeRepoDirectory = initRepository();
|
||||
|
||||
handler.create(repository);
|
||||
@@ -105,8 +94,6 @@ public abstract class SimpleRepositoryHandlerTestBase extends AbstractTestBase {
|
||||
assertTrue(nativeRepoDirectory.exists());
|
||||
assertTrue(nativeRepoDirectory.isDirectory());
|
||||
checkDirectory(nativeRepoDirectory);
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
protected File initRepository() {
|
||||
|
||||
Reference in New Issue
Block a user