diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/juick/api/Messages.java | 7 | ||||
-rw-r--r-- | src/main/java/com/juick/api/Others.java | 5 | ||||
-rw-r--r-- | src/main/java/com/juick/api/PM.java | 7 | ||||
-rw-r--r-- | src/main/java/com/juick/api/Users.java | 9 |
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 b7a553614..548e816fb 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 25df5bf46..5e5c74754 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 2722526d3..ffcd155a8 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 cdd48fd67..37c9ca496 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; } |