aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-11-26 04:17:17 +0700
committerGravatar Alexander Alexeev2016-11-26 04:17:17 +0700
commit46a040d6ff07e2581ae461ac60d2abc736cc7c6d (patch)
tree13bd27c1c12b6846e780a54cc87e7a7b17639d0b
parent55b09a6a3bc4a21201189d855e140308f05016fb (diff)
status constants
-rw-r--r--juick-api/src/main/java/com/juick/api/controllers/Notifications.java2
-rw-r--r--juick-crosspost/src/main/java/com/juick/components/controllers/StatusController.java3
-rw-r--r--juick-notifications/src/main/java/com/juick/components/controllers/StatusController.java3
-rw-r--r--juick-server/src/main/java/com/juick/server/helpers/Status.java17
-rw-r--r--juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java2
-rw-r--r--juick-xmpp-bot/src/main/java/com/juick/components/controllers/StatusController.java6
-rw-r--r--juick-xmpp-ft/src/main/java/com/juick/components/controllers/StatusController.java6
-rw-r--r--juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java4
8 files changed, 23 insertions, 20 deletions
diff --git a/juick-api/src/main/java/com/juick/api/controllers/Notifications.java b/juick-api/src/main/java/com/juick/api/controllers/Notifications.java
index 0d0d0965..c3529645 100644
--- a/juick-api/src/main/java/com/juick/api/controllers/Notifications.java
+++ b/juick-api/src/main/java/com/juick/api/controllers/Notifications.java
@@ -133,6 +133,6 @@ public class Notifications {
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT);
TokensList list = mapper.readValue(requestBody, TokensList.class);
list.getTokens().forEach(t -> pushQueriesService.deleteAPNSToken(t));
- return new Status("ok");
+ return Status.OK;
}
}
diff --git a/juick-crosspost/src/main/java/com/juick/components/controllers/StatusController.java b/juick-crosspost/src/main/java/com/juick/components/controllers/StatusController.java
index 348cfed1..3d8636fc 100644
--- a/juick-crosspost/src/main/java/com/juick/components/controllers/StatusController.java
+++ b/juick-crosspost/src/main/java/com/juick/components/controllers/StatusController.java
@@ -21,7 +21,6 @@ public class StatusController {
@RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Status status() {
- String status = crosspost != null ? "OK" : "Fail";
- return new Status(status);
+ return crosspost != null ? Status.OK : Status.FAIL;
}
}
diff --git a/juick-notifications/src/main/java/com/juick/components/controllers/StatusController.java b/juick-notifications/src/main/java/com/juick/components/controllers/StatusController.java
index 50d73de6..05bd9b45 100644
--- a/juick-notifications/src/main/java/com/juick/components/controllers/StatusController.java
+++ b/juick-notifications/src/main/java/com/juick/components/controllers/StatusController.java
@@ -21,7 +21,6 @@ public class StatusController {
@RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Status status() {
- String status = push != null ? "OK" : "Fail";
- return new Status(status);
+ return push != null ? Status.OK : Status.FAIL;
}
}
diff --git a/juick-server/src/main/java/com/juick/server/helpers/Status.java b/juick-server/src/main/java/com/juick/server/helpers/Status.java
index f68baae5..3c344193 100644
--- a/juick-server/src/main/java/com/juick/server/helpers/Status.java
+++ b/juick-server/src/main/java/com/juick/server/helpers/Status.java
@@ -6,9 +6,17 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* Created by vitalyster on 25.07.2016.
*/
public class Status {
- private String value;
+ private final String value;
- public Status(String value) {
+ public static final Status OK = new Status("ok");
+ public static final Status FAIL = new Status("Fail");
+ public static final Status ERROR = new Status("Error");
+
+ public static Status getStatus(final String stringStatus) {
+ return new Status(stringStatus);
+ }
+
+ private Status(String value) {
this.value = value;
}
@@ -16,4 +24,9 @@ public class Status {
public String getValue() {
return value;
}
+
+ @Override
+ public String toString() {
+ return "value = " + value;
+ }
}
diff --git a/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java b/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java
index 2f57b0b6..21572637 100644
--- a/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java
+++ b/juick-ws/src/main/java/com/juick/ws/controllers/ApiController.java
@@ -20,6 +20,6 @@ public class ApiController {
@RequestMapping(value = "/api/status", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Status status() {
- return new Status(String.valueOf(wsHandler.getClients().size()));
+ return Status.getStatus(String.valueOf(wsHandler.getClients().size()));
}
}
diff --git a/juick-xmpp-bot/src/main/java/com/juick/components/controllers/StatusController.java b/juick-xmpp-bot/src/main/java/com/juick/components/controllers/StatusController.java
index d30a906d..cbd49009 100644
--- a/juick-xmpp-bot/src/main/java/com/juick/components/controllers/StatusController.java
+++ b/juick-xmpp-bot/src/main/java/com/juick/components/controllers/StatusController.java
@@ -21,10 +21,6 @@ public class StatusController {
@RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Status status() {
- if (xmpp != null) {
- String status = "OK";
- return new Status(status);
- }
- return new Status("Error");
+ return xmpp != null ? Status.OK : Status.ERROR;
}
}
diff --git a/juick-xmpp-ft/src/main/java/com/juick/components/controllers/StatusController.java b/juick-xmpp-ft/src/main/java/com/juick/components/controllers/StatusController.java
index 16a8aeb4..6d82054a 100644
--- a/juick-xmpp-ft/src/main/java/com/juick/components/controllers/StatusController.java
+++ b/juick-xmpp-ft/src/main/java/com/juick/components/controllers/StatusController.java
@@ -21,10 +21,6 @@ public class StatusController {
@RequestMapping(method = RequestMethod.GET, value = "/", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Status status() {
- if (xmpp != null) {
- String status = "OK";
- return new Status(status);
- }
- return new Status("Error");
+ return xmpp != null ? Status.OK : Status.ERROR;
}
}
diff --git a/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java b/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java
index 9617ab56..0b615e40 100644
--- a/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java
+++ b/juick-xmpp/src/main/java/com/juick/components/controllers/StatusController.java
@@ -24,8 +24,8 @@ public class StatusController {
if (xmpp != null) {
String status = String.format("s2s in: %d, s2s out: %d, cached: %d",
xmpp.getInConnections().size(), xmpp.getOutConnections().size(), xmpp.getOutCache().size());
- return new Status(status);
+ return Status.getStatus(status);
}
- return new Status("Error");
+ return Status.ERROR;
}
}