From 51d9de02265d6cc9d6045d79497d2a987ae2f7f7 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 15 Nov 2016 14:21:27 +0300 Subject: core classes are now serializeable with JAXB (to use as babbler extension) --- .../main/java/com/juick/ws/WebsocketComponent.java | 14 ++++----- .../src/main/java/com/juick/ws/XMPPConnection.java | 36 +++++++++++----------- 2 files changed, 25 insertions(+), 25 deletions(-) (limited to 'juick-ws/src/main/java/com/juick/ws') diff --git a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java index ac53b2ad..0ef5374c 100644 --- a/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java +++ b/juick-ws/src/main/java/com/juick/ws/WebsocketComponent.java @@ -56,7 +56,7 @@ public class WebsocketComponent extends TextWebSocketHandler { visitor = UserQueries.getUserByHash(jdbc, hash); } else { try { - logger.info(String.format("wrong hash for %d from %s", visitor.getUID(), hXRealIP)); + logger.info(String.format("wrong hash for %d from %s", visitor.getUid(), hXRealIP)); session.close(new CloseStatus(403, "Forbidden")); } catch (IOException e) { logger.warn("ws error", e); @@ -65,19 +65,19 @@ public class WebsocketComponent extends TextWebSocketHandler { break; } } - logger.info(String.format("user %d connected to %s from %s", visitor.getUID(), hLocation.getPath(), hXRealIP)); + logger.info(String.format("user %d connected to %s from %s", visitor.getUid(), hLocation.getPath(), hXRealIP)); int MID = 0; SocketSubscribed sockSubscr = null; if (hLocation.getPath().equals("/")) { - logger.info(String.format("user %d connected", visitor.getUID())); + logger.info(String.format("user %d connected", visitor.getUid())); sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, false); } else if (hLocation.getPath().equals("/_all")) { - logger.info(String.format("user %d connected to legacy _all (%s)", visitor.getUID(), hLocation.getPath())); + logger.info(String.format("user %d connected to legacy _all (%s)", visitor.getUid(), hLocation.getPath())); sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true); sockSubscr.allMessages = true; } else if (hLocation.getPath().equals("/_replies")) { - logger.info(String.format("user %d connected to legacy _replies (%s)", visitor.getUID(), hLocation.getPath())); + logger.info(String.format("user %d connected to legacy _replies (%s)", visitor.getUid(), hLocation.getPath())); sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true); sockSubscr.allReplies = true; } else if (hLocation.getPath().matches("/\\d+$")) { @@ -86,8 +86,8 @@ public class WebsocketComponent extends TextWebSocketHandler { } catch (Exception e) { } if (MID > 0) { - if (MessagesQueries.canViewThread(jdbc, MID, visitor.getUID())) { - logger.info(String.format("user %d connected to legacy thread (%d) from %s", visitor.getUID(), MID, hXRealIP)); + if (MessagesQueries.canViewThread(jdbc, MID, visitor.getUid())) { + logger.info(String.format("user %d connected to legacy thread (%d) from %s", visitor.getUid(), MID, hXRealIP)); sockSubscr = new SocketSubscribed(session, hXRealIP, visitor, true); sockSubscr.MID = MID; } else { diff --git a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java index 04ea5378..7a6feee1 100644 --- a/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java +++ b/juick-ws/src/main/java/com/juick/ws/XMPPConnection.java @@ -100,7 +100,7 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream. JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS); if (jmsg != null) { logger.info("got jmsg: " + ms.serialize(jmsg).toString()); - if (jmsg.getMID() == 0) { + if (jmsg.getMid() == 0) { int uid_to = 0; try { uid_to = Integer.parseInt(msg.to.Username); @@ -109,11 +109,11 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream. if (uid_to > 0) { onJuickPM(uid_to, jmsg); } - } else if (jmsg.getRID() == 0) { + } else if (jmsg.getRid() == 0) { onJuickMessagePost(jmsg); } else { // to get quote - com.juick.Message reply = MessagesQueries.getReply(jdbc, jmsg.getMID(), jmsg.getRID()); + com.juick.Message reply = MessagesQueries.getReply(jdbc, jmsg.getMid(), jmsg.getRid()); onJuickMessageReply(reply); } } @@ -124,9 +124,9 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream. private void onJuickPM(final int uid_to, final com.juick.Message jmsg) { String json = messageSerializer.serialize(jmsg).toString(); synchronized (wsHandler.getClients()) { - wsHandler.getClients().stream().filter(c -> !c.legacy && c.visitor.getUID() == uid_to).forEach(c -> { + wsHandler.getClients().stream().filter(c -> !c.legacy && c.visitor.getUid() == uid_to).forEach(c -> { try { - logger.info("sending pm to " + c.visitor.getUID()); + logger.info("sending pm to " + c.visitor.getUid()); c.session.sendMessage(new TextMessage(json)); } catch (IOException e) { logger.warn("ws error", e); @@ -137,15 +137,15 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream. private void onJuickMessagePost(final com.juick.Message jmsg) { String json = messageSerializer.serialize(jmsg).toString(); - List uids = SubscriptionsQueries.getSubscribedUsers(jdbc, jmsg.getUser().getUID(), jmsg.getMID()) - .stream().map(User::getUID).collect(Collectors.toList()); + List uids = SubscriptionsQueries.getSubscribedUsers(jdbc, jmsg.getUser().getUid(), jmsg.getMid()) + .stream().map(User::getUid).collect(Collectors.toList()); synchronized (wsHandler.getClients()) { wsHandler.getClients().stream().filter(c -> - (!c.legacy && c.visitor.getUID() == 0) // anonymous users - || (!c.legacy && uids.contains(c.visitor.getUID()))) // subscriptions + (!c.legacy && c.visitor.getUid() == 0) // anonymous users + || (!c.legacy && uids.contains(c.visitor.getUid()))) // subscriptions .forEach(c -> { try { - logger.info("sending message to " + c.visitor.getUID()); + logger.info("sending message to " + c.visitor.getUid()); c.session.sendMessage(new TextMessage(json)); } catch (IOException e) { logger.warn("ws error", e); @@ -155,7 +155,7 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream. c.legacy && c.allMessages) // legacy all posts .forEach(c -> { try { - logger.info("sending message to legacy client " + c.visitor.getUID()); + logger.info("sending message to legacy client " + c.visitor.getUid()); c.session.sendMessage(new TextMessage(json)); } catch (IOException e) { logger.warn("ws error", e); @@ -167,25 +167,25 @@ public class XMPPConnection implements InitializingBean, DisposableBean, Stream. private void onJuickMessageReply(final com.juick.Message jmsg) { String json = messageSerializer.serialize(jmsg).toString(); List threadUsers = - SubscriptionsQueries.getUsersSubscribedToComments(jdbc, jmsg.getMID(), jmsg.getUser().getUID()) - .stream().map(User::getUID).collect(Collectors.toList()); + SubscriptionsQueries.getUsersSubscribedToComments(jdbc, jmsg.getMid(), jmsg.getUser().getUid()) + .stream().map(User::getUid).collect(Collectors.toList()); synchronized (wsHandler.getClients()) { wsHandler.getClients().stream().filter(c -> - (!c.legacy && c.visitor.getUID() == 0) // anonymous users - || (!c.legacy && threadUsers.contains(c.visitor.getUID()))) // subscriptions + (!c.legacy && c.visitor.getUid() == 0) // anonymous users + || (!c.legacy && threadUsers.contains(c.visitor.getUid()))) // subscriptions .forEach(c -> { try { - logger.info("sending reply to " + c.visitor.getUID()); + logger.info("sending reply to " + c.visitor.getUid()); c.session.sendMessage(new TextMessage(json)); } catch (IOException e) { logger.warn("ws error", e); } }); wsHandler.getClients().stream().filter(c -> - (c.legacy && c.allReplies) || (c.legacy && c.MID == jmsg.getMID())) // legacy replies + (c.legacy && c.allReplies) || (c.legacy && c.MID == jmsg.getMid())) // legacy replies .forEach(c -> { try { - logger.info("sending reply to legacy client " + c.visitor.getUID()); + logger.info("sending reply to legacy client " + c.visitor.getUid()); c.session.sendMessage(new TextMessage(json)); } catch (IOException e) { logger.warn("ws error", e); -- cgit v1.2.3