aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-07-29 17:57:45 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-07-29 17:57:45 +0200
commitfda851f0c161b80b026bdfc398e8dca4f149399e (patch)
tree49e15160fe70856c7fb69084a38be86b84e11f48 /server
parentbcf61c2c5d7fb06009c86c9e10d0611c61ce41e3 (diff)
downloadsonarqube-fda851f0c161b80b026bdfc398e8dca4f149399e.tar.gz
sonarqube-fda851f0c161b80b026bdfc398e8dca4f149399e.zip
SONAR-6652 WS system/db_migration_status add MIGRATION_REQUIRED status
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationJsonWriter.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java5
3 files changed, 10 insertions, 9 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationJsonWriter.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationJsonWriter.java
index 567d06800f5..ea4ef58ab8e 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationJsonWriter.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationJsonWriter.java
@@ -23,7 +23,6 @@ package org.sonar.server.platform.ws;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.db.version.DatabaseMigration;
-import static org.sonar.db.version.DatabaseMigration.Status.NONE;
import static org.sonar.db.version.DatabaseMigration.Status.RUNNING;
public class DbMigrationJsonWriter {
@@ -36,10 +35,11 @@ public class DbMigrationJsonWriter {
static final String STATUS_MIGRATION_RUNNING = "MIGRATION_RUNNING";
static final String STATUS_MIGRATION_FAILED = "MIGRATION_FAILED";
static final String STATUS_MIGRATION_SUCCEEDED = "MIGRATION_SUCCEEDED";
+ static final String STATUS_MIGRATION_REQUIRED = "MIGRATION_REQUIRED";
static final String UNSUPPORTED_DATABASE_MIGRATION_STATUS = "Unsupported DatabaseMigration status";
static final String MESSAGE_NO_MIGRATION_ON_EMBEDDED_DATABASE = "Upgrade is not supported on embedded database.";
- static final String MESSAGE_MIGRATION_NEEDED = "Database migration is required. DB migration can be started using WS /api/system/migrate_db.";
+ static final String MESSAGE_MIGRATION_REQUIRED = "Database migration is required. DB migration can be started using WS /api/system/migrate_db.";
static final String MESSAGE_STATUS_NONE = "Database is up-to-date, no migration needed.";
static final String MESSAGE_STATUS_RUNNING = "Database migration is running.";
static final String MESSAGE_STATUS_SUCCEEDED = "Migration succeeded.";
@@ -72,10 +72,10 @@ public class DbMigrationJsonWriter {
.endObject();
}
- static void writeMigrationNeededResponse(JsonWriter json) {
+ static void writeMigrationRequiredResponse(JsonWriter json) {
json.beginObject()
- .prop(FIELD_STATE, statusToJson(NONE))
- .prop(FIELD_MESSAGE, MESSAGE_MIGRATION_NEEDED)
+ .prop(FIELD_STATE, STATUS_MIGRATION_REQUIRED)
+ .prop(FIELD_MESSAGE, MESSAGE_MIGRATION_REQUIRED)
.endObject();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java
index 0710c1ed472..1fb2ecb86f2 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java
@@ -32,7 +32,7 @@ import org.sonar.db.version.DatabaseVersion;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.UNSUPPORTED_DATABASE_MIGRATION_STATUS;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.statusDescription;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.write;
-import static org.sonar.server.platform.ws.DbMigrationJsonWriter.writeMigrationNeededResponse;
+import static org.sonar.server.platform.ws.DbMigrationJsonWriter.writeMigrationRequiredResponse;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.writeNotSupportedResponse;
/**
@@ -79,7 +79,7 @@ public class DbMigrationStatusAction implements SystemWsAction {
write(json, databaseMigration);
break;
case NONE:
- writeMigrationNeededResponse(json);
+ writeMigrationRequiredResponse(json);
break;
default:
throw new IllegalArgumentException(UNSUPPORTED_DATABASE_MIGRATION_STATUS);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java
index 81153c39368..e0d3c432240 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java
@@ -44,12 +44,13 @@ import static org.sonar.db.version.DatabaseMigration.Status.FAILED;
import static org.sonar.db.version.DatabaseMigration.Status.NONE;
import static org.sonar.db.version.DatabaseMigration.Status.RUNNING;
import static org.sonar.db.version.DatabaseMigration.Status.SUCCEEDED;
-import static org.sonar.server.platform.ws.DbMigrationJsonWriter.MESSAGE_MIGRATION_NEEDED;
+import static org.sonar.server.platform.ws.DbMigrationJsonWriter.MESSAGE_MIGRATION_REQUIRED;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.MESSAGE_NO_MIGRATION_ON_EMBEDDED_DATABASE;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.MESSAGE_STATUS_NONE;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.MESSAGE_STATUS_RUNNING;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.MESSAGE_STATUS_SUCCEEDED;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.STATUS_MIGRATION_FAILED;
+import static org.sonar.server.platform.ws.DbMigrationJsonWriter.STATUS_MIGRATION_REQUIRED;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.STATUS_MIGRATION_RUNNING;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.STATUS_MIGRATION_SUCCEEDED;
import static org.sonar.server.platform.ws.DbMigrationJsonWriter.STATUS_NOT_SUPPORTED;
@@ -190,7 +191,7 @@ public class DbMigrationStatusActionTest {
underTest.handle(request, response);
- assertJson(response.outputAsString()).isSimilarTo(expectedResponse(STATUS_NO_MIGRATION, MESSAGE_MIGRATION_NEEDED));
+ assertJson(response.outputAsString()).isSimilarTo(expectedResponse(STATUS_MIGRATION_REQUIRED, MESSAGE_MIGRATION_REQUIRED));
}
private static String failedMsg(@Nullable String t) {