Skip to content

The Unified and Autonomous Development Platform

Fix the issue that server setup does not complete

robin shen7de22926c5d0
diff --git a/core/src/main/java/com/gitplex/server/GitPlex.java b/core/src/main/java/com/gitplex/server/GitPlex.java
index a1b9000326..2f82ff3257 100644
--- a/core/src/main/java/com/gitplex/server/GitPlex.java
+++ b/core/src/main/java/com/gitplex/server/GitPlex.java
@@ -103,7 +103,7 @@ public class GitPlex extends AbstractPlugin implements Serializable {
logger.warn("Please set up the server at " + guessServerUrl());
initStage = new InitStage("Server Setup", manualConfigs);
- initStage.waitFor();
+ initStage.waitForFinish();
// clear session in order to pick up changes made in interactive setup
dao.getSession().clear();
@@ -154,11 +154,7 @@ public class GitPlex extends AbstractPlugin implements Serializable {
* cloned initStage, or <tt>null</tt> if system initialization is completed
*/
public @Nullable InitStage getInitStage() {
- if (initStage != null) {
- return initStage.clone();
- } else {
- return null;
- }
+ return initStage;
}
public boolean isReady() {
diff --git a/core/src/main/java/com/gitplex/server/util/init/InitStage.java b/core/src/main/java/com/gitplex/server/util/init/InitStage.java
index 97dd26448c..61e47988b0 100644
--- a/core/src/main/java/com/gitplex/server/util/init/InitStage.java
+++ b/core/src/main/java/com/gitplex/server/util/init/InitStage.java
@@ -4,8 +4,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.lang3.SerializationUtils;
-
@SuppressWarnings("serial")
public class InitStage implements Serializable, Cloneable {
@@ -30,7 +28,7 @@ public class InitStage implements Serializable, Cloneable {
return manualConfigs;
}
- public synchronized void waitFor() {
+ public synchronized void waitForFinish() {
if (!manualConfigs.isEmpty()) {
try {
wait();
@@ -40,54 +38,10 @@ public class InitStage implements Serializable, Cloneable {
}
}
- @Override
- public synchronized InitStage clone() {
- if (!manualConfigs.isEmpty()) {
- List<ManualConfig> clonedConfigs = new ArrayList<ManualConfig>();
- for (ManualConfig each: manualConfigs)
- clonedConfigs.add(SerializationUtils.clone(each));
-
- final ManualConfig lastConfig = clonedConfigs.remove(clonedConfigs.size()-1);
-
- clonedConfigs.add(new ManualConfig(lastConfig.getMessage(), lastConfig.getSetting()) {
-
- @Override
- public Skippable getSkippable() {
- final Skippable skippable = lastConfig.getSkippable();
- if (skippable != null) {
- return new Skippable() {
-
- @Override
- public void skip() {
- skippable.skip();
- synchronized (InitStage.this) {
- message = "Please wait...";
- InitStage.this.manualConfigs.clear();
- InitStage.this.notify();
- }
- }
-
- };
- } else {
- return null;
- }
- }
-
- @Override
- public void complete() {
- lastConfig.complete();
- synchronized (InitStage.this) {
- message = "Please wait...";
- InitStage.this.manualConfigs.clear();
- InitStage.this.notify();
- }
- }
-
- });
-
- return new InitStage(message, clonedConfigs);
- } else {
- return new InitStage(message);
- }
+ public synchronized void finished() {
+ message = "Please wait...";
+ manualConfigs.clear();
+ notify();
}
+
}
diff --git a/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java b/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java
index db55d2445d..1d5cd68c1c 100644
--- a/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java
+++ b/web/src/main/java/com/gitplex/server/web/page/init/ServerInitPage.java
@@ -3,6 +3,7 @@ package com.gitplex.server.web.page.init;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang3.SerializationUtils;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
@@ -16,6 +17,7 @@ import com.gitplex.server.model.Account;
import com.gitplex.server.security.SecurityUtils;
import com.gitplex.server.util.init.InitStage;
import com.gitplex.server.util.init.ManualConfig;
+import com.gitplex.server.util.init.Skippable;
import com.gitplex.server.web.WebSession;
import com.gitplex.server.web.component.wizard.ManualConfigStep;
import com.gitplex.server.web.component.wizard.Wizard;
@@ -27,8 +29,52 @@ public class ServerInitPage extends BasePage {
private InitStage initStage;
public ServerInitPage() {
- initStage = GitPlex.getInstance().getInitStage();
- if (initStage == null) {
+ InitStage initStage = GitPlex.getInstance().getInitStage();
+ if (initStage != null) {
+ if (!initStage.getManualConfigs().isEmpty()) {
+ List<ManualConfig> clonedConfigs = new ArrayList<ManualConfig>();
+ for (ManualConfig each: initStage.getManualConfigs())
+ clonedConfigs.add(SerializationUtils.clone(each));
+
+ final ManualConfig lastConfig = clonedConfigs.remove(clonedConfigs.size()-1);
+
+ clonedConfigs.add(new ManualConfig(lastConfig.getMessage(), lastConfig.getSetting()) {
+
+ @Override
+ public Skippable getSkippable() {
+ final Skippable skippable = lastConfig.getSkippable();
+ if (skippable != null) {
+ return new Skippable() {
+
+ @Override
+ public void skip() {
+ skippable.skip();
+ InitStage initStage = GitPlex.getInstance().getInitStage();
+ if (initStage != null)
+ initStage.finished();
+ }
+
+ };
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void complete() {
+ lastConfig.complete();
+ InitStage initStage = GitPlex.getInstance().getInitStage();
+ if (initStage != null)
+ initStage.finished();
+ }
+
+ });
+
+ this.initStage = new InitStage(initStage.getMessage(), clonedConfigs);
+ } else {
+ this.initStage = new InitStage(initStage.getMessage());
+ }
+ } else {
continueToOriginalDestination();
throw new RestartResponseException(getApplication().getHomePage());