mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
First step to make name and namespace editable in migration
This commit is contained in:
@@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
@@ -65,8 +66,13 @@ class MigrationWizardServlet extends HttpServlet {
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
||||
resp.setStatus(200);
|
||||
|
||||
req.getParameterMap().forEach(
|
||||
(name, strategy) -> migrationStrategyDao.set(name, MigrationStrategy.valueOf(strategy[0]))
|
||||
Arrays.stream(req.getParameterValues("ids")).forEach(
|
||||
id -> {
|
||||
String strategy = req.getParameter("strategy-" + id);
|
||||
String namespace = req.getParameter("namespace-" + id);
|
||||
String name = req.getParameter("name-" + id);
|
||||
migrationStrategyDao.set(id, MigrationStrategy.valueOf(strategy), namespace, name);
|
||||
}
|
||||
);
|
||||
|
||||
MustacheFactory mf = new DefaultMustacheFactory();
|
||||
|
||||
@@ -23,8 +23,8 @@ public class MigrationStrategyDao {
|
||||
return plan.get(id);
|
||||
}
|
||||
|
||||
public void set(String repositoryId, MigrationStrategy strategy) {
|
||||
plan.set(repositoryId, strategy);
|
||||
public void set(String repositoryId, MigrationStrategy strategy, String newNamespace, String newName) {
|
||||
plan.set(repositoryId, strategy, newNamespace, newName);
|
||||
store.set(plan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,12 @@ class RepositoryMigrationPlan {
|
||||
.map(RepositoryEntry::getDataMigrationStrategy);
|
||||
}
|
||||
|
||||
public void set(String repositoryId, MigrationStrategy strategy) {
|
||||
public void set(String repositoryId, MigrationStrategy strategy, String newNamespace, String newName) {
|
||||
Optional<RepositoryEntry> entry = findEntry(repositoryId);
|
||||
if (entry.isPresent()) {
|
||||
entry.get().setStrategy(strategy);
|
||||
entry.get().setNewNamespace(newNamespace);
|
||||
entry.get().setNewName(newName);
|
||||
} else {
|
||||
entries.add(new RepositoryEntry(repositoryId, strategy));
|
||||
}
|
||||
@@ -49,6 +51,8 @@ class RepositoryMigrationPlan {
|
||||
|
||||
private String repositoryId;
|
||||
private MigrationStrategy dataMigrationStrategy;
|
||||
private String newNamespace;
|
||||
private String newName;
|
||||
|
||||
RepositoryEntry() {
|
||||
}
|
||||
@@ -62,8 +66,24 @@ class RepositoryMigrationPlan {
|
||||
return dataMigrationStrategy;
|
||||
}
|
||||
|
||||
public String getNewNamespace() {
|
||||
return newNamespace;
|
||||
}
|
||||
|
||||
public String getNewName() {
|
||||
return newName;
|
||||
}
|
||||
|
||||
private void setStrategy(MigrationStrategy strategy) {
|
||||
this.dataMigrationStrategy = strategy;
|
||||
}
|
||||
|
||||
private void setNewNamespace(String newNamespace) {
|
||||
this.newNamespace = newNamespace;
|
||||
}
|
||||
|
||||
private void setNewName(String newName) {
|
||||
this.newName = newName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user