mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
Create migration module only if necessary
This commit is contained in:
@@ -2,21 +2,22 @@ package sonia.scm.update;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.servlet.GuiceServletContextListener;
|
||||
import sonia.scm.update.repository.XmlRepositoryV1UpdateStep;
|
||||
|
||||
public class MigrationWizardContextListener extends GuiceServletContextListener {
|
||||
|
||||
private final Injector injector;
|
||||
private final Injector bootstrapInjector;
|
||||
|
||||
public MigrationWizardContextListener(Injector bootstrapInjector) {
|
||||
this.injector = bootstrapInjector.createChildInjector(new MigrationWizardModule());
|
||||
this.bootstrapInjector = bootstrapInjector;
|
||||
}
|
||||
|
||||
public boolean wizardNecessary() {
|
||||
return injector.getInstance(MigrationWizardServlet.class).wizardNecessary();
|
||||
return !bootstrapInjector.getInstance(XmlRepositoryV1UpdateStep.class).getRepositoriesWithoutMigrationStrategies().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Injector getInjector() {
|
||||
return injector;
|
||||
return bootstrapInjector.createChildInjector(new MigrationWizardModule());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,17 +44,13 @@ class MigrationWizardServlet extends HttpServlet {
|
||||
this.migrationStrategyDao = migrationStrategyDao;
|
||||
}
|
||||
|
||||
public boolean wizardNecessary() {
|
||||
return !repositoryV1UpdateStep.getRepositoriesWithoutMigrationStrategies().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
|
||||
List<RepositoryLineEntry> repositoryLineEntries = getRepositoryLineEntries();
|
||||
doGet(req, resp, repositoryLineEntries);
|
||||
}
|
||||
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp, List<RepositoryLineEntry> repositoryLineEntries) {
|
||||
private void doGet(HttpServletRequest req, HttpServletResponse resp, List<RepositoryLineEntry> repositoryLineEntries) {
|
||||
HashMap<String, Object> model = new HashMap<>();
|
||||
|
||||
model.put("contextPath", req.getContextPath());
|
||||
@@ -77,7 +73,6 @@ class MigrationWizardServlet extends HttpServlet {
|
||||
String id = repositoryLineEntry.getId();
|
||||
String namespace = req.getParameter("namespace-" + id);
|
||||
String name = req.getParameter("name-" + id);
|
||||
String strategy = req.getParameter("strategy-" + id);
|
||||
repositoryLineEntry.setNamespace(namespace);
|
||||
repositoryLineEntry.setName(name);
|
||||
|
||||
|
||||
@@ -157,7 +157,6 @@ class MigrationWizardServletTest {
|
||||
);
|
||||
doReturn("invalid namespace").when(request).getParameter("namespace-id");
|
||||
doReturn("invalid name").when(request).getParameter("name-id");
|
||||
doReturn("COPY").when(request).getParameter("strategy-id");
|
||||
|
||||
servlet.doPost(request, response);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user