aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2015-11-04 15:18:41 +0300
committerGravatar Vitaly Takmazov2015-11-04 15:18:41 +0300
commit63b14e7818a20d598e4634a0ee686376d7f687b2 (patch)
tree764d2924e34440e77945b1edd8501ee0aa6c1181 /src/main/java
parent9325971f2f6e2bf83e3d4d69bae3f8e63226bc63 (diff)
drop gson, refactoring
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/juick/api/Messages.java7
-rw-r--r--src/main/java/com/juick/api/Others.java5
-rw-r--r--src/main/java/com/juick/api/PM.java7
-rw-r--r--src/main/java/com/juick/api/Users.java9
4 files changed, 20 insertions, 8 deletions
diff --git a/src/main/java/com/juick/api/Messages.java b/src/main/java/com/juick/api/Messages.java
index b7a55361..548e816f 100644
--- a/src/main/java/com/juick/api/Messages.java
+++ b/src/main/java/com/juick/api/Messages.java
@@ -1,5 +1,6 @@
package com.juick.api;
+import com.juick.json.MessageSerializer;
import com.juick.server.MessagesQueries;
import com.juick.xmpp.JID;
import com.juick.xmpp.Message;
@@ -19,6 +20,8 @@ import javax.servlet.http.HttpServletResponse;
public class Messages {
Connection sql;
+
+ MessageSerializer messageSerializer = new MessageSerializer();
public Messages(Connection sql) {
this.sql = sql;
@@ -31,7 +34,7 @@ public class Messages {
if (mids != null && !mids.isEmpty()) {
ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids);
if (msgs != null && !msgs.isEmpty()) {
- String json = com.juick.json.Messages.arrayToString(msgs);
+ String json = messageSerializer.serializeList(msgs);
Main.replyJSON(request, response, json);
} else {
response.sendError(404);
@@ -48,7 +51,7 @@ public class Messages {
if (mids != null && !mids.isEmpty()) {
ArrayList<com.juick.Message> msgs = MessagesQueries.getMessages(sql, mids);
if (msgs != null && !msgs.isEmpty()) {
- String json = com.juick.json.Messages.arrayToString(msgs);
+ String json = messageSerializer.serializeList(msgs);
Main.replyJSON(request, response, json);
} else {
response.sendError(404);
diff --git a/src/main/java/com/juick/api/Others.java b/src/main/java/com/juick/api/Others.java
index 25df5bf4..5e5c7475 100644
--- a/src/main/java/com/juick/api/Others.java
+++ b/src/main/java/com/juick/api/Others.java
@@ -1,5 +1,6 @@
package com.juick.api;
+import com.juick.json.UserSerializer;
import com.juick.server.PMQueries;
import java.io.IOException;
import java.sql.Connection;
@@ -15,6 +16,8 @@ import javax.servlet.http.HttpServletResponse;
public class Others {
Connection sql;
+
+ UserSerializer userSerializer = new UserSerializer();
public Others(Connection sql) {
this.sql = sql;
@@ -36,7 +39,7 @@ public class Others {
ArrayList<com.juick.User> lastconv = PMQueries.getPMLastConversationsUsers(sql, vuid, cnt);
if (lastconv != null && !lastconv.isEmpty()) {
- String json = "{\"pms\":" + com.juick.json.Users.arrayToString(lastconv) + "}";
+ String json = "{\"pms\":" + userSerializer.serializeList(lastconv) + "}";
Main.replyJSON(request, response, json);
} else {
response.sendError(404);
diff --git a/src/main/java/com/juick/api/PM.java b/src/main/java/com/juick/api/PM.java
index 2722526d..ffcd155a 100644
--- a/src/main/java/com/juick/api/PM.java
+++ b/src/main/java/com/juick/api/PM.java
@@ -1,5 +1,6 @@
package com.juick.api;
+import com.juick.json.MessageSerializer;
import com.juick.server.PMQueries;
import com.juick.server.UserQueries;
import com.juick.xmpp.JID;
@@ -20,6 +21,8 @@ import javax.servlet.http.HttpServletResponse;
public class PM {
Connection sql;
+
+ MessageSerializer messageSerializer = new MessageSerializer();
public PM(Connection sql) {
this.sql = sql;
@@ -39,7 +42,7 @@ public class PM {
ArrayList<com.juick.Message> msgs = PMQueries.getPMMessages(sql, vuid, uid);
if (msgs != null && !msgs.isEmpty()) {
- String json = com.juick.json.Messages.arrayToString(msgs);
+ String json = messageSerializer.serializeList(msgs);
Main.replyJSON(request, response, json);
} else {
response.sendError(404);
@@ -77,7 +80,7 @@ public class PM {
msg.to.Host = "ws.juick.com";
xmpp.send(msg);
- Main.replyJSON(request, response, com.juick.json.Message.toJSON(jmsg).toString());
+ Main.replyJSON(request, response, messageSerializer.serialize(jmsg).toString());
String jid = UserQueries.getJIDbyUID(sql, uid);
if (jid != null) {
diff --git a/src/main/java/com/juick/api/Users.java b/src/main/java/com/juick/api/Users.java
index cdd48fd6..37c9ca49 100644
--- a/src/main/java/com/juick/api/Users.java
+++ b/src/main/java/com/juick/api/Users.java
@@ -1,6 +1,7 @@
package com.juick.api;
import com.juick.User;
+import com.juick.json.UserSerializer;
import com.juick.server.UserQueries;
import java.io.IOException;
import java.sql.Connection;
@@ -18,6 +19,8 @@ import javax.servlet.http.HttpServletResponse;
public class Users {
Connection sql;
+
+ UserSerializer userSerializer = new UserSerializer();
public Users(Connection sql) {
this.sql = sql;
@@ -55,7 +58,7 @@ public class Users {
}
if (!users.isEmpty()) {
- String json = com.juick.json.Users.arrayToString(users);
+ String json = userSerializer.serializeList(users);
Main.replyJSON(request, response, json);
} else {
response.sendError(404);
@@ -81,7 +84,7 @@ public class Users {
if (uids.size() > 0) {
ArrayList<com.juick.User> users = UserQueries.getUsersByID(sql, uids);
if (users.size() > 0) {
- String json = com.juick.json.Users.arrayToString(users);
+ String json = userSerializer.serializeList(users);
Main.replyJSON(request, response, json);
return;
}
@@ -109,7 +112,7 @@ public class Users {
if (uids.size() > 0) {
ArrayList<com.juick.User> users = UserQueries.getUsersByID(sql, uids);
if (users.size() > 0) {
- String json = com.juick.json.Users.arrayToString(users);
+ String json = userSerializer.serializeList(users);
Main.replyJSON(request, response, json);
return;
}