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) --- juick-api/src/main/java/com/juick/api/Main.java | 12 +- .../src/main/java/com/juick/api/Messages.java | 8 +- .../src/main/java/com/juick/api/Notifications.java | 10 +- juick-api/src/main/java/com/juick/api/PM.java | 4 +- .../src/main/java/com/juick/api/Subscriptions.java | 4 +- .../main/java/com/juick/api/TelegramBotHook.java | 16 +-- juick-api/src/main/java/com/juick/api/Users.java | 8 +- juick-core/src/main/java/com/juick/Message.java | 119 ++++++++++++------ juick-core/src/main/java/com/juick/Tag.java | 17 ++- juick-core/src/main/java/com/juick/User.java | 57 ++++++--- .../com/juick/formatters/PlainTextFormatter.java | 12 +- .../java/com/juick/json/MessageSerializer.java | 26 ++-- .../main/java/com/juick/json/UserSerializer.java | 12 +- .../src/main/java/com/juick/package-info.java | 16 +++ .../com/juick/xml/adapters/SimpleDateAdapter.java | 35 ++++++ .../com/juick/xmpp/extensions/JuickMessage.java | 36 +++--- .../java/com/juick/xmpp/extensions/JuickUser.java | 12 +- .../main/java/com/juick/components/Crosspost.java | 24 ++-- juick-demo/src/main/java/com/juick/demo/Demo.java | 2 +- .../java/com/juick/components/Notifications.java | 26 ++-- juick-rss/src/main/java/com/juick/rss/Main.java | 30 ++--- .../main/java/com/juick/ws/WebsocketComponent.java | 14 +-- .../src/main/java/com/juick/ws/XMPPConnection.java | 36 +++--- .../src/main/java/com/juick/www/Discover.java | 4 +- juick-www/src/main/java/com/juick/www/Home.java | 24 ++-- juick-www/src/main/java/com/juick/www/Login.java | 6 +- juick-www/src/main/java/com/juick/www/Main.java | 26 ++-- .../src/main/java/com/juick/www/NewMessage.java | 34 +++--- juick-www/src/main/java/com/juick/www/PM.java | 14 +-- .../src/main/java/com/juick/www/PageTemplates.java | 54 ++++----- .../src/main/java/com/juick/www/Settings.java | 54 ++++----- juick-www/src/main/java/com/juick/www/SignUp.java | 4 +- .../src/main/java/com/juick/www/TwitterAuth.java | 2 +- juick-www/src/main/java/com/juick/www/User.java | 104 ++++++++-------- .../src/main/java/com/juick/www/UserThread.java | 134 ++++++++++----------- juick-www/src/main/java/com/juick/www/Utils.java | 4 +- juick-www/src/main/resources/views/pm_inbox.html | 8 +- juick-www/src/main/resources/views/pm_sent.html | 6 +- .../com/juick/components/s2s/ConnectionRouter.java | 52 ++++---- .../java/com/juick/components/s2s/JuickBot.java | 28 ++--- .../java/com/juick/server/MessagesQueries.java | 32 ++--- .../src/main/java/com/juick/server/PMQueries.java | 14 +-- .../main/java/com/juick/server/PrivacyQueries.java | 8 +- .../main/java/com/juick/server/ShowQueries.java | 2 +- .../com/juick/server/SubscriptionsQueries.java | 20 +-- .../main/java/com/juick/server/UserQueries.java | 52 ++++---- .../com/juick/server/protocol/JuickProtocol.java | 48 ++++---- .../com/juick/service/MessagesServiceImpl.java | 32 ++--- .../com/juick/service/PMQueriesServiceImpl.java | 14 +-- .../juick/service/PrivacyQueriesServiceImpl.java | 12 +- .../com/juick/service/ShowQueriesServiceImpl.java | 8 +- .../com/juick/service/SubscriptionServiceImpl.java | 20 +-- .../java/com/juick/service/UserServiceImpl.java | 52 ++++---- src/test/java/com/juick/tests/ApiTests.java | 34 +++--- src/test/java/com/juick/tests/JsonTests.java | 68 ----------- src/test/java/com/juick/tests/MessageTests.java | 6 +- .../java/com/juick/tests/SerializationTests.java | 96 +++++++++++++++ 57 files changed, 886 insertions(+), 726 deletions(-) create mode 100644 juick-core/src/main/java/com/juick/package-info.java create mode 100644 juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java delete mode 100644 src/test/java/com/juick/tests/JsonTests.java create mode 100644 src/test/java/com/juick/tests/SerializationTests.java diff --git a/juick-api/src/main/java/com/juick/api/Main.java b/juick-api/src/main/java/com/juick/api/Main.java index 80cbecd4..c102bf18 100644 --- a/juick-api/src/main/java/com/juick/api/Main.java +++ b/juick-api/src/main/java/com/juick/api/Main.java @@ -308,7 +308,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { xmsg.addChild(jmsg); Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -334,7 +334,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { for (String tag : tagsArr) { tagsStr2 += " *" + tag; } - xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; + xmsg.body = "@" + jmsg.getUser().getName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; xmsg.to = new JID("juick", "s2s.juick.com", null); xmpp.send(xmsg); @@ -391,8 +391,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { } body = body.replace("\r", ""); - if ((msg.ReadOnly && msg.getUser().getUID() != vuid) || UserQueries.isInBLAny(sql, msg.getUser().getUID(), vuid) - || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUID(), vuid))) { + if ((msg.ReadOnly && msg.getUser().getUid() != vuid) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), vuid) + || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), vuid))) { response.sendError(403); return; } @@ -436,7 +436,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -458,7 +458,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { xmsg.addChild(xoob); } - xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; + xmsg.body = "Reply by @" + jmsg.getUser().getName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; xmsg.to = new JID("juick", "s2s.juick.com", null); xmpp.send(xmsg); diff --git a/juick-api/src/main/java/com/juick/api/Messages.java b/juick-api/src/main/java/com/juick/api/Messages.java index d9d506f3..de845d45 100644 --- a/juick-api/src/main/java/com/juick/api/Messages.java +++ b/juick-api/src/main/java/com/juick/api/Messages.java @@ -71,16 +71,16 @@ public class Messages { User user = UserQueries.getUserByName(sql, uname); if (user != null) { if (!StringUtils.isEmpty(media)) { - mids = MessagesQueries.getUserPhotos(sql, user.getUID(), 0, before_mid); + mids = MessagesQueries.getUserPhotos(sql, user.getUid(), 0, before_mid); } else if (!StringUtils.isEmpty(tag)) { Tag tagObject = TagQueries.getTag(sql, tag, false); if (tagObject != null) { - mids = MessagesQueries.getUserTag(sql, user.getUID(), tagObject.TID, 0, before_mid); + mids = MessagesQueries.getUserTag(sql, user.getUid(), tagObject.TID, 0, before_mid); } else { response.sendError(404); } } else { - mids = MessagesQueries.getUserBlog(sql, user.getUID(), 0, before_mid); + mids = MessagesQueries.getUserBlog(sql, user.getUid(), 0, before_mid); } } else { response.sendError(404); @@ -144,7 +144,7 @@ public class Messages { throws ServletException, IOException { int mid = NumberUtils.toInt(request.getParameter("mid"), 0); com.juick.User user = MessagesQueries.getMessageAuthor(sql, mid); - if (user != null && user.getUID() == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) { + if (user != null && user.getUid() == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) { Main.replyJSON(request, response, "{\"status\":\"ok\"}"); } else { response.sendError(400); diff --git a/juick-api/src/main/java/com/juick/api/Notifications.java b/juick-api/src/main/java/com/juick/api/Notifications.java index bec365ba..60fe95f3 100644 --- a/juick-api/src/main/java/com/juick/api/Notifications.java +++ b/juick-api/src/main/java/com/juick/api/Notifications.java @@ -29,7 +29,7 @@ public class Notifications { public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException { User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User()); - if ((visitor.getUID() == 0) || !(visitor.getUName().equals("juick"))) { + if ((visitor.getUid() == 0) || !(visitor.getName().equals("juick"))) { response.sendError(403); return; } @@ -57,13 +57,13 @@ public class Notifications { Message msg = MessagesQueries.getMessage(jdbc, mid); if (msg != null) { List users; - if (msg.getRID() > 0) { - users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUID()); + if (msg.getRid() > 0) { + users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUid()); } else { - users = SubscriptionsQueries.getSubscribedUsers(jdbc, msg.getUser().getUID(), mid); + users = SubscriptionsQueries.getSubscribedUsers(jdbc, msg.getUser().getUid(), mid); } - List uids = users.stream().map(User::getUID).collect(Collectors.toList()); + List uids = users.stream().map(User::getUid).collect(Collectors.toList()); switch (type) { case "gcm": diff --git a/juick-api/src/main/java/com/juick/api/PM.java b/juick-api/src/main/java/com/juick/api/PM.java index 44c43f89..d8f17366 100644 --- a/juick-api/src/main/java/com/juick/api/PM.java +++ b/juick-api/src/main/java/com/juick/api/PM.java @@ -94,11 +94,11 @@ public class PM { mm.to = new JID(jid); mm.type = Message.Type.chat; if (PMQueries.havePMinRoster(sql, vuid, jid)) { - mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick"); + mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick"); mm.body = body; } else { mm.from = new JID("juick", "juick.com", "Juick"); - mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + body; + mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + body; } xmpp.send(mm); } diff --git a/juick-api/src/main/java/com/juick/api/Subscriptions.java b/juick-api/src/main/java/com/juick/api/Subscriptions.java index 4c767dc9..f8bd162f 100644 --- a/juick-api/src/main/java/com/juick/api/Subscriptions.java +++ b/juick-api/src/main/java/com/juick/api/Subscriptions.java @@ -26,7 +26,7 @@ public class Subscriptions { } public void doGet(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException { User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User()); - if ((visitor.getUID() == 0) && !(visitor.getUName().equals("juick"))) { + if ((visitor.getUid() == 0) && !(visitor.getName().equals("juick"))) { response.sendError(403); return; } @@ -39,7 +39,7 @@ public class Subscriptions { // thread Message msg = MessagesQueries.getMessage(jdbc, mid); if (msg != null) { - List users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUID()); + List users = SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, msg.getUser().getUid()); Main.replyJSON(request, response, userSerializer.serializeList(users)); } } diff --git a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java index 2ec380db..e089250b 100644 --- a/juick-api/src/main/java/com/juick/api/TelegramBotHook.java +++ b/juick-api/src/main/java/com/juick/api/TelegramBotHook.java @@ -72,10 +72,10 @@ public class TelegramBotHook { com.juick.Message jmsg = ms.deserialize(new JSONObject(text)); logger.info("got jmsg: " + ms.serialize(jmsg).toString()); String msgUrl = formatUrl(jmsg); - if (jmsg.getRID() == 0) { + if (jmsg.getRid() == 0) { String msg = formatPost(jmsg); - List users = getSubscribers(jmsg.getUser().getUID()); + List users = getSubscribers(jmsg.getUser().getUid()); List chats = getChats(); // registered subscribed users @@ -84,9 +84,9 @@ public class TelegramBotHook { chats.stream().filter(u -> getUser(u) == 0).forEach(c -> telegramNotify(c, msg, msgUrl)); } else { // get quote - com.juick.Message msg = MessagesQueries.getReply(jdbc, jmsg.getMID(), jmsg.getRID()); + com.juick.Message msg = MessagesQueries.getReply(jdbc, jmsg.getMid(), jmsg.getRid()); String fmsg = formatPost(msg); - getSubscribersToComments(jmsg.getMID(), jmsg.getUser().getUID()).stream() + getSubscribersToComments(jmsg.getMid(), jmsg.getUser().getUid()).stream() .forEach(c -> telegramNotify(c, fmsg, msgUrl)); } } @@ -141,7 +141,7 @@ public class TelegramBotHook { } logger.info(String.format("got telegram msg %s", message.toString())); User user_from = UserQueries.getUserByUID(jdbc, getUser(message.chat().id())).orElse(new User()); - logger.info(String.format("Found juick user %d", user_from.getUID())); + logger.info(String.format("Found juick user %d", user_from.getUid())); List chats = getChats(); String username = message.from().username(); @@ -154,14 +154,14 @@ public class TelegramBotHook { createTelegramUser(message.from().id(), username); telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username)); } else { - if (user_from.getUID() == 0) { + if (user_from.getUid() == 0) { telegramSignupNotify(message.from().id().longValue(), UserQueries.getSignUpHashByTelegramID(jdbc, message.from().id().longValue(), username)); } else { String text = message.text(); if (text != null) { if (text.equalsIgnoreCase("/login")) { - String msg = String.format("Hi, %s!\nTap to log in", user_from.getUName()); - String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUID()); + String msg = String.format("Hi, %s!\nTap to log in", user_from.getName()); + String msgUrl = "http://juick.com/login?" + UserQueries.getHashByUID(jdbc, user_from.getUid()); telegramNotify(message.from().id().longValue(), msg, msgUrl); } /* else { ProtocolReply reply = protocol.getReply(user_from, text); diff --git a/juick-api/src/main/java/com/juick/api/Users.java b/juick-api/src/main/java/com/juick/api/Users.java index 2be288bc..a98af7a8 100644 --- a/juick-api/src/main/java/com/juick/api/Users.java +++ b/juick-api/src/main/java/com/juick/api/Users.java @@ -80,8 +80,8 @@ public class Users { } else { if (UserUtils.checkUserNameValid(uname)) { com.juick.User u = UserQueries.getUserByName(sql, uname); - if (u != null && u.getUID() > 0) { - uid = u.getUID(); + if (u != null && u.getUid() > 0) { + uid = u.getUid(); } } } @@ -110,8 +110,8 @@ public class Users { } else { if (UserUtils.checkUserNameValid(uname)) { com.juick.User u = UserQueries.getUserByName(sql, uname); - if (u != null && u.getUID() > 0) { - uid = u.getUID(); + if (u != null && u.getUid() > 0) { + uid = u.getUid(); } } } diff --git a/juick-core/src/main/java/com/juick/Message.java b/juick-core/src/main/java/com/juick/Message.java index 8afd1d7b..d60abc5e 100644 --- a/juick-core/src/main/java/com/juick/Message.java +++ b/juick-core/src/main/java/com/juick/Message.java @@ -20,7 +20,10 @@ package com.juick; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import com.juick.xml.adapters.SimpleDateAdapter; +import javax.xml.bind.annotation.*; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.util.*; import java.util.stream.Collectors; @@ -28,31 +31,37 @@ import java.util.stream.Collectors; * * @author Ugnich Anton */ +@XmlRootElement(name = "juick", namespace = "http://juick.com/message") +@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) public class Message implements Comparable { - private int MID = 0; - private int RID = 0; - - @JsonProperty("replyto") - public int ReplyTo = 0; - private String Text = null; - private User User = null; - @JsonProperty("tags") - public List Tags = new ArrayList<>(); + private int mid = 0; + private int rid = 0; + private int replyto = 0; + private String text = null; + private User user = null; + private List Tags = new ArrayList<>(); private Date date; + @XmlTransient public int TimeAgo = 0; @JsonIgnore - public int Privacy = 1; + private int privacy = 1; + @XmlTransient public boolean FriendsOnly = false; + @XmlTransient public boolean ReadOnly = false; + @XmlTransient public boolean Hidden = false; @JsonIgnore + @XmlTransient public boolean VisitorCanComment = true; + @XmlTransient public int Replies = 0; public String RepliesBy = null; public String AttachmentType = null; public String Photo = null; public String Video = null; public Place Place = null; + @XmlTransient public int Likes = 0; private boolean liked = false; public List childs = new ArrayList<>(); @@ -64,15 +73,15 @@ public class Message implements Comparable { } public Message(Message msg) { - setMID(msg.getMID()); - setRID(msg.getRID()); - ReplyTo = msg.ReplyTo; + setMid(msg.getMid()); + setRid(msg.getRid()); + replyto = msg.replyto; setText(msg.getText()); setUser(msg.getUser()); Tags = msg.Tags; setDate(msg.getDate()); TimeAgo = msg.TimeAgo; - Privacy = msg.Privacy; + privacy = msg.privacy; FriendsOnly = msg.FriendsOnly; ReadOnly = msg.ReadOnly; Hidden = msg.Hidden; @@ -101,7 +110,7 @@ public class Message implements Comparable { return false; } Message jmsg = (Message) obj; - return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID()); + return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid()); } @Override @@ -111,16 +120,16 @@ public class Message implements Comparable { } Message jmsg = (Message) obj; - if (this.getMID() != jmsg.getMID()) { - if (this.getMID() > jmsg.getMID()) { + if (this.getMid() != jmsg.getMid()) { + if (this.getMid() > jmsg.getMid()) { return -1; } else { return 1; } } - if (this.getRID() != jmsg.getRID()) { - if (this.getRID() < jmsg.getRID()) { + if (this.getRid() != jmsg.getRid()) { + if (this.getRid() < jmsg.getRid()) { return -1; } else { return 1; @@ -151,9 +160,9 @@ public class Message implements Comparable { if (AttachmentType != null) { String url = "http://i.juick.com/"; url += AttachmentType.equals("mp4") ? "video" : "photos-1024"; - url += "/" + getMID(); - if (getRID() > 0) { - url += "-" + getRID(); + url += "/" + getMid(); + if (getRid() > 0) { + url += "-" + getRid(); } url += "." + AttachmentType; return url; @@ -171,13 +180,13 @@ public class Message implements Comparable { if (FriendsOnly) { ret += " *friends"; } - if (Privacy == -2) { + if (privacy == -2) { ret += " *private"; } - if (Privacy == -1) { + if (privacy == -1) { ret += " *friends"; } - if (Privacy == 2) { + if (privacy == 2) { ret += " *public"; } if (ReadOnly) { @@ -188,42 +197,48 @@ public class Message implements Comparable { } @JsonProperty("mid") - public int getMID() { - return MID; + @XmlAttribute(name = "mid") + public int getMid() { + return mid; } - public void setMID(int MID) { - this.MID = MID; + public void setMid(int mid) { + this.mid = mid; } @JsonProperty("rid") - public int getRID() { - return RID; + @XmlAttribute(name = "rid") + public int getRid() { + return rid; } - public void setRID(int RID) { - this.RID = RID; + public void setRid(int rid) { + this.rid = rid; } + @XmlElement(name = "user", namespace = "http://juick.com/user") public com.juick.User getUser() { - return User; + return user; } public void setUser(com.juick.User user) { - User = user; + this.user = user; } @JsonProperty("body") + @XmlElement(name = "body") public String getText() { - return Text; + return text; } public void setText(String text) { - Text = text; + this.text = text; } @JsonProperty("timestamp") @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss", timezone="UTC") + @XmlAttribute(name = "ts") + @XmlJavaTypeAdapter(SimpleDateAdapter.class) public Date getDate() { return date; } @@ -248,6 +263,7 @@ public class Message implements Comparable { this.Recommendation = recommendation; } + @XmlTransient public boolean isLiked() { return liked; } @@ -262,4 +278,33 @@ public class Message implements Comparable { public void setReplyQuote(String quote) { replyQuote = quote; } + + @JsonProperty("replyto") + @XmlAttribute(name = "replyto") + public int getReplyto() { + return replyto; + } + + public void setReplyto(int replyto) { + this.replyto = replyto; + } + + @JsonProperty("tags") + @XmlElement(name = "tag") + public List getTags() { + return Tags; + } + + public void setTags(List tags) { + Tags = tags; + } + + @XmlAttribute + public int getPrivacy() { + return privacy; + } + + public void setPrivacy(int privacy) { + this.privacy = privacy; + } } diff --git a/juick-core/src/main/java/com/juick/Tag.java b/juick-core/src/main/java/com/juick/Tag.java index fa518e84..4ba3a812 100644 --- a/juick-core/src/main/java/com/juick/Tag.java +++ b/juick-core/src/main/java/com/juick/Tag.java @@ -20,18 +20,28 @@ package com.juick; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonValue; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlValue; import java.util.Objects; /** * @author Ugnich Anton */ +@XmlRootElement(name = "tag", namespace = "http://juick.com/message") +@XmlAccessorType(XmlAccessType.PROPERTY) public class Tag { - private final String name; + + private String name; public int TID = 0; public int SynonymID = 0; public int UsageCnt = 0; + public Tag() { + + } public Tag(String name) { this.name = name; @@ -44,6 +54,7 @@ public class Tag { } @JsonIgnore + @XmlValue public String getName() { return name; } @@ -53,4 +64,8 @@ public class Tag { public String toString() { return name; } + + public void setName(String name) { + this.name = name; + } } diff --git a/juick-core/src/main/java/com/juick/User.java b/juick-core/src/main/java/com/juick/User.java index b8936bab..83dcda5f 100644 --- a/juick-core/src/main/java/com/juick/User.java +++ b/juick-core/src/main/java/com/juick/User.java @@ -20,27 +20,29 @@ package com.juick; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; +import javax.xml.bind.annotation.*; + /** * @author Ugnich Anton */ +@XmlRootElement(name = "user", namespace = "http://juick.com/user") +@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) public class User { - private int UID = 0; - private String UName = null; - @JsonIgnore - public Object Avatar = null; + private int uid = 0; + private String name = null; + private Object Avatar = null; private String FullName = null; private String JID = null; private int MessagesCount = 0; private String AuthHash = null; - @JsonIgnore - public boolean Banned = false; + private boolean Banned = false; public User() { } public User(User u) { - setUID(u.getUID()); - setUName(u.getUName()); + setUid(u.getUid()); + setName(u.getName()); Avatar = u.Avatar; setFullName(u.getFullName()); setJID(u.getJID()); @@ -52,28 +54,31 @@ public class User { @Override public boolean equals(Object obj) { return obj == this || - (obj instanceof User && ((User) obj).getUID() == this.getUID()); + (obj instanceof User && ((User) obj).getUid() == this.getUid()); } @JsonProperty("uid") - public int getUID() { - return UID; + @XmlAttribute(name = "uid") + public int getUid() { + return uid; } - public void setUID(int UID) { - this.UID = UID; + public void setUid(int uid) { + this.uid = uid; } @JsonProperty("uname") - public String getUName() { - return UName; + @XmlAttribute(name = "uname") + public String getName() { + return name; } - public void setUName(String UName) { - this.UName = UName; + public void setName(String name) { + this.name = name; } @JsonProperty("fullname") + @XmlTransient public String getFullName() { return FullName; } @@ -101,6 +106,7 @@ public class User { } @JsonProperty("unreadCount") + @XmlTransient public Integer getUnreadCount() { return MessagesCount; } @@ -108,4 +114,21 @@ public class User { public void setUnreadCount(Integer count) { MessagesCount = count; } + + @XmlTransient + public boolean isBanned() { + return Banned; + } + + public void setBanned(boolean banned) { + Banned = banned; + } + + public Object getAvatar() { + return Avatar; + } + + public void setAvatar(Object avatar) { + Avatar = avatar; + } } diff --git a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java index 6c712d28..be2c6838 100644 --- a/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java +++ b/juick-core/src/main/java/com/juick/formatters/PlainTextFormatter.java @@ -1,17 +1,15 @@ package com.juick.formatters; -import com.juick.Message; - /** * Created by vitalyster on 12.10.2016. */ public class PlainTextFormatter { public static String formatPost(com.juick.Message jmsg) { StringBuilder sb = new StringBuilder(); - boolean isReply = jmsg.getRID() > 0; + boolean isReply = jmsg.getRid() > 0; String title = isReply ? "Reply by @" : "@"; String subtitle = isReply ? jmsg.getReplyQuote() : jmsg.getTagsString(); - sb.append(title).append(jmsg.getUser().getUName()).append(":\n") + sb.append(title).append(jmsg.getUser().getName()).append(":\n") .append(subtitle).append("\n").append(jmsg.getText()).append("\n"); if (jmsg.Photo != null) { sb.append(jmsg.Photo); @@ -20,9 +18,9 @@ public class PlainTextFormatter { } public static String formatUrl(com.juick.Message jmsg) { - if (jmsg.getRID() > 0) { - return String.format("https://juick.com/%d#%d", jmsg.getMID(), jmsg.getRID()); + if (jmsg.getRid() > 0) { + return String.format("https://juick.com/%d#%d", jmsg.getMid(), jmsg.getRid()); } - return "https://juick.com/" + jmsg.getMID(); + return "https://juick.com/" + jmsg.getMid(); } } diff --git a/juick-core/src/main/java/com/juick/json/MessageSerializer.java b/juick-core/src/main/java/com/juick/json/MessageSerializer.java index 3ef903f0..ebc3b0b0 100644 --- a/juick-core/src/main/java/com/juick/json/MessageSerializer.java +++ b/juick-core/src/main/java/com/juick/json/MessageSerializer.java @@ -51,12 +51,12 @@ public class MessageSerializer extends JSONSerializer { @Override public Message deserialize(JSONObject json) throws JSONException, ParseException { com.juick.Message jmsg = new com.juick.Message(); - jmsg.setMID(json.getInt("mid")); + jmsg.setMid(json.getInt("mid")); if (json.has("rid")) { - jmsg.setRID(json.getInt("rid")); + jmsg.setRid(json.getInt("rid")); } if (json.has("replyto")) { - jmsg.ReplyTo = json.getInt("replyto"); + jmsg.setReplyto(json.getInt("replyto")); } jmsg.FriendsOnly = json.has("friendsonly"); @@ -70,7 +70,7 @@ public class MessageSerializer extends JSONSerializer { if (json.has("tags")) { JSONArray tags = json.getJSONArray("tags"); for (int n = 0; n < tags.length(); n++) { - jmsg.Tags.add(new Tag(tags.getString(n).replace(""", "\""))); + jmsg.getTags().add(new Tag(tags.getString(n).replace(""", "\""))); } } @@ -90,14 +90,14 @@ public class MessageSerializer extends JSONSerializer { JSONObject json = new JSONObject(); try { - if (msg.getMID() > 0) { - json.put("mid", msg.getMID()); + if (msg.getMid() > 0) { + json.put("mid", msg.getMid()); } - if (msg.getRID() > 0) { - json.put("rid", msg.getRID()); + if (msg.getRid() > 0) { + json.put("rid", msg.getRid()); } - if (msg.ReplyTo > 0) { - json.put("replyto", msg.ReplyTo); + if (msg.getReplyto() > 0) { + json.put("replyto", msg.getReplyto()); } if (msg.FriendsOnly) { json.put("friendsonly", 1); @@ -114,8 +114,8 @@ public class MessageSerializer extends JSONSerializer { if (msg.getUser() != null) { json.put("user", userSerializer.serialize(msg.getUser())); } - if (msg.Tags != null && msg.Tags.size() > 0) { - json.put("tags", new JSONArray(msg.Tags.stream().map(Tag::getName).collect(Collectors.toList()))); + if (msg.getTags() != null && msg.getTags().size() > 0) { + json.put("tags", new JSONArray(msg.getTags().stream().map(Tag::getName).collect(Collectors.toList()))); } if (msg.Replies > 0) { json.put("replies", msg.Replies); @@ -124,7 +124,7 @@ public class MessageSerializer extends JSONSerializer { json.put("place", placeSerializer.serialize(msg.Place)); } if (msg.AttachmentType != null) { - String fname = msg.getMID() + (msg.getRID() > 0 ? "-" + msg.getRID() : "") + "." + msg.AttachmentType; + String fname = msg.getMid() + (msg.getRid() > 0 ? "-" + msg.getRid() : "") + "." + msg.AttachmentType; JSONObject photo = new JSONObject(); String protocol = getUriScheme() == URIScheme.Plain ? "http:" : "https:"; photo.put("thumbnail", protocol + "//i.juick.com/ps/" + fname); diff --git a/juick-core/src/main/java/com/juick/json/UserSerializer.java b/juick-core/src/main/java/com/juick/json/UserSerializer.java index 390f4bf6..08d21d39 100644 --- a/juick-core/src/main/java/com/juick/json/UserSerializer.java +++ b/juick-core/src/main/java/com/juick/json/UserSerializer.java @@ -30,8 +30,8 @@ public class UserSerializer extends JSONSerializer { @Override public User deserialize(JSONObject json) throws JSONException { User juser = new User(); - juser.setUID(json.getInt("uid")); - juser.setUName(json.getString("uname")); + juser.setUid(json.getInt("uid")); + juser.setName(json.getString("uname")); if (json.has("fullname")) { juser.setFullName(json.getString("fullname")); } @@ -43,11 +43,11 @@ public class UserSerializer extends JSONSerializer { JSONObject json = new JSONObject(); try { - if (user.getUID() > 0) { - json.put("uid", user.getUID()); + if (user.getUid() > 0) { + json.put("uid", user.getUid()); } - if (user.getUName() != null) { - json.put("uname", user.getUName()); + if (user.getName() != null) { + json.put("uname", user.getName()); } if (user.getFullName() != null) { json.put("fullname", user.getFullName()); diff --git a/juick-core/src/main/java/com/juick/package-info.java b/juick-core/src/main/java/com/juick/package-info.java new file mode 100644 index 00000000..1ebddc60 --- /dev/null +++ b/juick-core/src/main/java/com/juick/package-info.java @@ -0,0 +1,16 @@ +/** + * Created by vitalyster on 15.11.2016. + */ +@XmlSchema( + namespace="http://juick.com/message", + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns={ + @XmlNs(prefix="", namespaceURI="http://juick.com/message"), + @XmlNs(prefix="user", namespaceURI="http://juick.com/user") + } +) +package com.juick; + +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; \ No newline at end of file diff --git a/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java b/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java new file mode 100644 index 00000000..9cb56909 --- /dev/null +++ b/juick-core/src/main/java/com/juick/xml/adapters/SimpleDateAdapter.java @@ -0,0 +1,35 @@ +package com.juick.xml.adapters; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * Created by vitalyster on 15.11.2016. + */ + +public class SimpleDateAdapter extends XmlAdapter { + + private final SimpleDateFormat dateFormat; + public SimpleDateAdapter() { + dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + @Override + public String marshal(Date v) throws Exception { + synchronized (dateFormat) { + return dateFormat.format(v); + } + } + + @Override + public Date unmarshal(String v) throws Exception { + synchronized (dateFormat) { + return dateFormat.parse(v); + } + } + +} diff --git a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java index d259bc43..2c3875c5 100644 --- a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java +++ b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickMessage.java @@ -60,19 +60,19 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { final String sMID = parser.getAttributeValue(null, "mid"); if (sMID != null) { - jmsg.setMID(Integer.parseInt(sMID)); + jmsg.setMid(Integer.parseInt(sMID)); } final String sRID = parser.getAttributeValue(null, "rid"); if (sRID != null) { - jmsg.setRID(Integer.parseInt(sRID)); + jmsg.setRid(Integer.parseInt(sRID)); } final String sReplyTo = parser.getAttributeValue(null, "replyto"); if (sReplyTo != null) { - jmsg.ReplyTo = Integer.parseInt(sReplyTo); + jmsg.setReplyto(Integer.parseInt(sReplyTo)); } final String sPrivacy = parser.getAttributeValue(null, "privacy"); if (sPrivacy != null) { - jmsg.Privacy = Integer.parseInt(sPrivacy); + jmsg.setPrivacy(Integer.parseInt(sPrivacy)); } final String sFriendsOnly = parser.getAttributeValue(null, "friendsonly"); if (sFriendsOnly != null) { @@ -96,7 +96,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { } else if (tag.equals(JuickUser.TagName) && xmlns != null && xmlns.equals(JuickUser.XMLNS)) { jmsg.setUser(new JuickUser().parse(parser)); } else if (tag.equals("tag")) { - jmsg.Tags.add(new Tag(XmlUtils.getTagText(parser))); + jmsg.getTags().add(new Tag(XmlUtils.getTagText(parser))); } else { XmlUtils.skip(parser); } @@ -109,16 +109,16 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { String ret = ""; ret = "<" + TagName + " xmlns=\"" + XMLNS + "\""; - if (getMID() > 0) { - ret += " mid=\"" + getMID() + "\""; + if (getMid() > 0) { + ret += " mid=\"" + getMid() + "\""; } - if (getRID() > 0) { - ret += " rid=\"" + getRID() + "\""; + if (getRid() > 0) { + ret += " rid=\"" + getRid() + "\""; } - if (ReplyTo > 0) { - ret += " replyto=\"" + ReplyTo + "\""; + if (getReplyto() > 0) { + ret += " replyto=\"" + getReplyto() + "\""; } - ret += " privacy=\"" + Privacy + "\""; + ret += " privacy=\"" + getPrivacy() + "\""; if (FriendsOnly) { ret += " friendsonly=\"1\""; } @@ -138,7 +138,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { if (getText() != null) { ret += "" + XmlUtils.escape(getText()) + ""; } - for (com.juick.Tag Tag : Tags) { + for (com.juick.Tag Tag : getTags()) { ret += "" + XmlUtils.escape(Tag.getName()) + ""; } ret += ""; @@ -152,7 +152,7 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { return false; } JuickMessage jmsg = (JuickMessage) obj; - return (this.getMID() == jmsg.getMID() && this.getRID() == jmsg.getRID()); + return (this.getMid() == jmsg.getMid() && this.getRid() == jmsg.getRid()); } @Override @@ -162,16 +162,16 @@ public class JuickMessage extends com.juick.Message implements StanzaChild { } JuickMessage jmsg = (JuickMessage) obj; - if (this.getMID() != jmsg.getMID()) { - if (this.getMID() > jmsg.getMID()) { + if (this.getMid() != jmsg.getMid()) { + if (this.getMid() > jmsg.getMid()) { return -1; } else { return 1; } } - if (this.getRID() != jmsg.getRID()) { - if (this.getRID() < jmsg.getRID()) { + if (this.getRid() != jmsg.getRid()) { + if (this.getRid() < jmsg.getRid()) { return -1; } else { return 1; diff --git a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java index edc6749a..7473134c 100644 --- a/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java +++ b/juick-core/src/main/java/com/juick/xmpp/extensions/JuickUser.java @@ -49,20 +49,20 @@ public class JuickUser extends com.juick.User implements StanzaChild { JuickUser juser = new JuickUser(); String strUID = parser.getAttributeValue(null, "uid"); if (strUID != null) { - juser.setUID(Integer.parseInt(strUID)); + juser.setUid(Integer.parseInt(strUID)); } - juser.setUName(parser.getAttributeValue(null, "uname")); + juser.setName(parser.getAttributeValue(null, "uname")); XmlUtils.skip(parser); return juser; } public static String toString(com.juick.User user) { String str = "<" + TagName + " xmlns='" + XMLNS + "'"; - if (user.getUID() > 0) { - str += " uid='" + user.getUID() + "'"; + if (user.getUid() > 0) { + str += " uid='" + user.getUid() + "'"; } - if (user.getUName() != null && user.getUName().length() > 0) { - str += " uname='" + XmlUtils.escape(user.getUName()) + "'"; + if (user.getName() != null && user.getName().length() > 0) { + str += " uname='" + XmlUtils.escape(user.getName()) + "'"; } str += "/>"; return str; diff --git a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java index c82fc542..8ccca67c 100644 --- a/juick-crosspost/src/main/java/com/juick/components/Crosspost.java +++ b/juick-crosspost/src/main/java/com/juick/components/Crosspost.java @@ -127,7 +127,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea @Override public void onMessage(final com.juick.xmpp.Message msg) { JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS); - if (msg.to != null && msg.to.Username != null && jmsg != null && jmsg.getRID() == 0) { + if (msg.to != null && msg.to.Username != null && jmsg != null && jmsg.getRid() == 0) { if (msg.to.Username.equals("twitter")) { twitterPost(jmsg); } else if (msg.to.Username.equals("fb")) { @@ -139,12 +139,12 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea } public boolean facebookPost(final com.juick.Message jmsg) { - String token = crosspostService.getFacebookToken(jmsg.getUser().getUID()).orElse(""); + String token = crosspostService.getFacebookToken(jmsg.getUser().getUid()).orElse(""); if (token.isEmpty()) { return false; } - logger.info("FB: #" + jmsg.getMID()); + logger.info("FB: #" + jmsg.getMid()); String status = getMessageHashTags(jmsg) + "\n" + jmsg.getText(); @@ -155,7 +155,7 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea + "&message=" + URLEncoder.encode(status, "UTF-8") + "&link=http%3A%2F%2Fjuick.com%2F" - + jmsg.getMID(); + + jmsg.getMid(); HttpsURLConnection conn = (HttpsURLConnection) new URL(FBURL).openConnection(); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); @@ -181,14 +181,14 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea } public boolean vkontaktePost(final com.juick.Message jmsg) { - Pair tokens = crosspostService.getVkTokens(jmsg.getUser().getUID()).orElse(Pair.of("", "")); + Pair tokens = crosspostService.getVkTokens(jmsg.getUser().getUid()).orElse(Pair.of("", "")); if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) { return false; } - logger.info("VK: #" + jmsg.getMID()); + logger.info("VK: #" + jmsg.getMid()); - String status = getMessageHashTags(jmsg) + "\n" + jmsg.getText() + "\nhttp://juick.com/" + jmsg.getMID(); + String status = getMessageHashTags(jmsg) + "\n" + jmsg.getText() + "\nhttp://juick.com/" + jmsg.getMid(); boolean ret = false; try { @@ -218,20 +218,20 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea } public boolean twitterPost(final com.juick.Message jmsg) { - Pair tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUID()).orElse(Pair.of("", "")); + Pair tokens = crosspostService.getTwitterTokens(jmsg.getUser().getUid()).orElse(Pair.of("", "")); if (tokens.getLeft().isEmpty() || tokens.getRight().isEmpty()) { return false; } String token = percentEncode(tokens.getLeft()); String token_secret = percentEncode(tokens.getRight()); - logger.info("TWITTER: #" + jmsg.getMID()); + logger.info("TWITTER: #" + jmsg.getMid()); String status = getMessageHashTags(jmsg) + jmsg.getText(); if (status.length() > 115) { status = status.substring(0, 114) + "…"; } - status += " http://juick.com/" + jmsg.getMID(); + status += " http://juick.com/" + jmsg.getMid(); status = percentEncode(status); boolean ret = false; @@ -316,8 +316,8 @@ public class Crosspost implements InitializingBean, DisposableBean, Stream.Strea public String getMessageHashTags(final com.juick.Message jmsg) { String hashtags = ""; - for (int i = 0; i < jmsg.Tags.size(); i++) { - hashtags += "#" + jmsg.Tags.get(i) + " "; + for (int i = 0; i < jmsg.getTags().size(); i++) { + hashtags += "#" + jmsg.getTags().get(i) + " "; } return hashtags; } diff --git a/juick-demo/src/main/java/com/juick/demo/Demo.java b/juick-demo/src/main/java/com/juick/demo/Demo.java index 0ed18079..b94c9830 100644 --- a/juick-demo/src/main/java/com/juick/demo/Demo.java +++ b/juick-demo/src/main/java/com/juick/demo/Demo.java @@ -57,7 +57,7 @@ public class Demo { reader.setPrompt("ugnich>"); PrintWriter out = new PrintWriter(reader.getOutput()); User ugnich = UserQueries.getUserByUID(jdbc, ugnich_id).get(); - out.println(String.format("logged in as @%s", ugnich.getUName())); + out.println(String.format("logged in as @%s", ugnich.getName())); out.flush(); String input; JuickProtocol protocol = new JuickProtocol(jdbc, "http://localhost/"); diff --git a/juick-notifications/src/main/java/com/juick/components/Notifications.java b/juick-notifications/src/main/java/com/juick/components/Notifications.java index b7e6b2b8..d37f7a25 100644 --- a/juick-notifications/src/main/java/com/juick/components/Notifications.java +++ b/juick-notifications/src/main/java/com/juick/components/Notifications.java @@ -128,20 +128,20 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S @Override public void onMessage(final com.juick.xmpp.Message msg) { JuickMessage jmsg = (JuickMessage) msg.getChild(JuickMessage.XMLNS); - boolean isPM = jmsg.getMID() == 0; - boolean isReply = jmsg.getRID() > 0; + boolean isPM = jmsg.getMid() == 0; + boolean isReply = jmsg.getRid() > 0; int pmTo = 0; /*** ANDROID ***/ final List regids = new ArrayList<>(); if (isPM) { regids.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=gcm&uid=%s", - jmsg.getUser().getUID()), + jmsg.getUser().getUid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } else { regids.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=gcm&uid=%s&mid=%s", - jmsg.getUser().getUID(), jmsg.getMID()), + jmsg.getUser().getUid(), jmsg.getMid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } @@ -170,12 +170,12 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S final List urls = new ArrayList<>(); if (isPM) { urls.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=mpns&uid=%s", - jmsg.getUser().getUID()), + jmsg.getUser().getUid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } else { urls.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=mpns&uid=%s&mid=%s", - jmsg.getUser().getUID(), jmsg.getMID()), + jmsg.getUser().getUid(), jmsg.getMid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } @@ -185,8 +185,8 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S } else { try { String wnsToken = getWnsAccessToken(); - String text1 = "@" + jmsg.getUser().getUName(); - if (!jmsg.Tags.isEmpty()) { + String text1 = "@" + jmsg.getUser().getName(); + if (!jmsg.getTags().isEmpty()) { text1 += ":" + XmlUtils.escape(jmsg.getTagsString()); } String text2 = XmlUtils.escape(jmsg.getText()); @@ -194,13 +194,13 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S + "" + "" + "" - + "" + + "" + "" + text1 + "" + "" + text2 + "" + "" + "" + "" - + "" + + "" + "" + ""; logger.trace(xml); @@ -217,12 +217,12 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S final List tokens = new ArrayList<>(); if (isPM) { tokens.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=apns&uid=%s", - jmsg.getUser().getUID()), + jmsg.getUser().getUid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } else { tokens.addAll(rest.exchange(String.format("http://api.juick.com/notifications?type=apns&uid=%s&mid=%s", - jmsg.getUser().getUID(), jmsg.getMID()), + jmsg.getUser().getUid(), jmsg.getMid()), HttpMethod.GET, null, new ParameterizedTypeReference>() { }).getBody()); } @@ -230,7 +230,7 @@ public class Notifications implements InitializingBean, DisposableBean, Stream.S ApnsService service = APNS.newService().withCert("/etc/juick/ios.p12", "juick") .withSandboxDestination().build(); for (String token : tokens) { - String payload = APNS.newPayload().alertTitle("@" + jmsg.getUser().getUName()).alertBody(jmsg.getText()).build(); + String payload = APNS.newPayload().alertTitle("@" + jmsg.getUser().getName()).alertBody(jmsg.getText()).build(); logger.info("APNS: " + token); service.push(token, payload); } diff --git a/juick-rss/src/main/java/com/juick/rss/Main.java b/juick-rss/src/main/java/com/juick/rss/Main.java index 471753b7..bf8348fb 100644 --- a/juick-rss/src/main/java/com/juick/rss/Main.java +++ b/juick-rss/src/main/java/com/juick/rss/Main.java @@ -126,13 +126,13 @@ public class Main extends HttpServlet { for (Message msg : msgs) { out.println(""); - out.println("http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + ""); - out.println("http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + ""); + out.println("http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + ""); + out.println("http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + ""); - out.print("<![CDATA[@" + msg.getUser().getUName() + ":"); - if (!msg.Tags.isEmpty()) { - for (int n = 0; n < msg.Tags.size(); n++) { - out.print(" *" + msg.Tags.get(n)); + out.print("<title><![CDATA[@" + msg.getUser().getName() + ":"); + if (!msg.getTags().isEmpty()) { + for (int n = 0; n < msg.getTags().size(); n++) { + out.print(" *" + msg.getTags().get(n)); } } out.println("]]>"); @@ -140,22 +140,22 @@ public class Main extends HttpServlet { out.println("" + sdfRSS.format(msg.getDate()) + ""); - out.println("http://juick.com/" + msg.getUser().getUName() + "/" + msg.getMID() + ""); - if (!msg.Tags.isEmpty()) { - for (int n = 0; n < msg.Tags.size(); n++) { - out.println("" + escapeHtml(msg.Tags.get(n).getName()) + ""); + out.println("http://juick.com/" + msg.getUser().getName() + "/" + msg.getMid() + ""); + if (!msg.getTags().isEmpty()) { + for (int n = 0; n < msg.getTags().size(); n++) { + out.println("" + escapeHtml(msg.getTags().get(n).getName()) + ""); } } if (msg.AttachmentType != null) { if (msg.AttachmentType.equals("jpg")) { - out.println(""); - out.println(""); + out.println(""); + out.println(""); } else if (msg.AttachmentType.equals("png")) { - out.println(""); - out.println(""); + out.println(""); + out.println(""); } } - out.println(""); + out.println(""); out.println(""); } 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); diff --git a/juick-www/src/main/java/com/juick/www/Discover.java b/juick-www/src/main/java/com/juick/www/Discover.java index 4fd8c3b6..860ad893 100644 --- a/juick-www/src/main/java/com/juick/www/Discover.java +++ b/juick-www/src/main/java/com/juick/www/Discover.java @@ -72,7 +72,7 @@ public class Discover { } } - int visitor_uid = visitor.getUID(); + int visitor_uid = visitor.getUid(); String title = "*" + StringEscapeUtils.escapeHtml4(paramTag.getName()); List mids = MessagesQueries.getTag(sql, paramTag.TID, visitor_uid, paramBefore, (visitor_uid == 0) ? 40 : 20); @@ -91,7 +91,7 @@ public class Discover { out.println("
"); if (mids.size() > 0) { - int vuid = visitor.getUID(); + int vuid = visitor.getUid(); int ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); diff --git a/juick-www/src/main/java/com/juick/www/Home.java b/juick-www/src/main/java/com/juick/www/Home.java index d8688b68..870c2d55 100644 --- a/juick-www/src/main/java/com/juick/www/Home.java +++ b/juick-www/src/main/java/com/juick/www/Home.java @@ -53,9 +53,9 @@ public class Home { title = "Поиск: " + StringEscapeUtils.escapeHtml4(paramSearch); mids = MessagesQueries.getSearch(sql, sqlSearch, Utils.encodeSphinx(paramSearch), paramBefore); } else if (paramShow == null) { - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { title = "Популярные"; - mids = MessagesQueries.getPopular(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getPopular(sql, visitor.getUid(), paramBefore); } else { title = "Микроблоги Juick: популярные записи"; mids = MessagesQueries.getPopular(sql, 0, paramBefore); @@ -66,27 +66,27 @@ public class Home { return; } else if (paramShow.equals("my") && visitor != null) { title = "Моя лента"; - mids = MessagesQueries.getMyFeed(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getMyFeed(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("private") && visitor != null) { title = "Приватные"; - mids = MessagesQueries.getPrivate(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getPrivate(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("discuss") && visitor != null) { title = "Обсуждения"; - mids = MessagesQueries.getDiscussions(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getDiscussions(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("recommended") && visitor != null) { title = "Рекомендации"; - mids = MessagesQueries.getRecommended(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getRecommended(sql, visitor.getUid(), paramBefore); } else if (paramShow.equals("photos")) { title = "Фотографии"; if (visitor != null) { - mids = MessagesQueries.getPhotos(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getPhotos(sql, visitor.getUid(), paramBefore); } else { mids = MessagesQueries.getPhotos(sql, 0, paramBefore); } } else if (paramShow.equals("all")) { title = "Все сообщения"; if (visitor != null) { - mids = MessagesQueries.getAll(sql, visitor.getUID(), paramBefore); + mids = MessagesQueries.getAll(sql, visitor.getUid(), paramBefore); } else { mids = MessagesQueries.getAll(sql, 0, paramBefore); } @@ -110,7 +110,7 @@ public class Home { out.println(""); } - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { out.println("
"); out.println("
"); out.println(" "); @@ -129,7 +129,7 @@ public class Home { if (mids.size() > 0) { int ad_mid = 0; if (paramShow == null || paramShow.equals("top") || paramShow.equals("all")) { - int vuid = visitor.getUID(); + int vuid = visitor.getUid(); ad_mid = AdsQueries.getAdMID(sql, vuid); if (ad_mid > 0 && mids.indexOf(ad_mid) == -1) { mids.add(0, ad_mid); @@ -139,7 +139,7 @@ public class Home { } } - PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUID() == 0 ? 2 : 3, ad_mid); + PageTemplates.printMessages(out, sql, null, mids, visitor, visitor.getUid() == 0 ? 2 : 3, ad_mid); } if (mids.size() >= 20) { @@ -160,7 +160,7 @@ public class Home { out.println("
"); - PageTemplates.pageHomeColumn(out, sql, visitor, paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUID() == 0); + PageTemplates.pageHomeColumn(out, sql, visitor, paramShow == null && paramBefore == 0 && paramSearch == null && visitor.getUid() == 0); PageTemplates.pageFooter(request, out, visitor, true); PageTemplates.pageEnd(out); diff --git a/juick-www/src/main/java/com/juick/www/Login.java b/juick-www/src/main/java/com/juick/www/Login.java index 55cfa03c..19cc855b 100644 --- a/juick-www/src/main/java/com/juick/www/Login.java +++ b/juick-www/src/main/java/com/juick/www/Login.java @@ -34,7 +34,7 @@ public class Login { protected void doGetLoginForm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { Utils.sendTemporaryRedirect(response, "/"); return; } @@ -228,8 +228,8 @@ public class Login { protected void doGetLogout(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0) { - sql.update("DELETE FROM logins WHERE user_id=?", visitor.getUID()); + if (visitor.getUid() > 0) { + sql.update("DELETE FROM logins WHERE user_id=?", visitor.getUid()); } Cookie c = new Cookie("hash", "-"); diff --git a/juick-www/src/main/java/com/juick/www/Main.java b/juick-www/src/main/java/com/juick/www/Main.java index 35617295..4a873cf3 100644 --- a/juick-www/src/main/java/com/juick/www/Main.java +++ b/juick-www/src/main/java/com/juick/www/Main.java @@ -172,7 +172,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } else if (uri.equals("/post")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { pagesNewMessage.doGetNewMessage(sql, request, response, visitor); } else { Utils.sendTemporaryRedirect(response, "/login"); @@ -185,7 +185,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } } else if (uri.startsWith("/pm/")) { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { Utils.sendTemporaryRedirect(response, "/login"); } else { switch (uri) { @@ -269,7 +269,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { if (mid > 0) { com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid); if (author != null) { - Utils.sendPermanentRedirect(response, "/" + author.getUName() + "/" + mid); + Utils.sendPermanentRedirect(response, "/" + author.getName() + "/" + mid); return; } } @@ -277,14 +277,14 @@ public class Main extends HttpServlet implements Stream.StreamListener { } else if (uri.matches("^/[^/]+$")) { com.juick.User user = com.juick.server.UserQueries.getUserByName(sql, request.getRequestURI().substring(1)); if (user != null) { - Utils.sendPermanentRedirect(response, "/" + user.getUName() + "/"); + Utils.sendPermanentRedirect(response, "/" + user.getName() + "/"); } else { Errors.doGet404(sql, request, response); } } else if (uri.matches("^/.+/.*")) { String uriparts[] = uri.split("/"); com.juick.User user = com.juick.server.UserQueries.getUserByName(sql, uriparts[1]); - if (user != null && user.getUName().equals(uriparts[1]) && !user.Banned) { + if (user != null && user.getName().equals(uriparts[1]) && !user.isBanned()) { if (uriparts.length == 2) { // http://juick.com/username/ pagesUser.doGetBlog(sql, sqlSearch, request, response, user); } else if (uriparts[2].equals("tags")) { @@ -302,8 +302,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { if (mid > 0) { com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid); if (author != null) { - if (!author.getUName().equals(user.getUName())) { - Utils.sendPermanentRedirect(response, "/" + author.getUName() + "/" + mid); + if (!author.getName().equals(user.getName())) { + Utils.sendPermanentRedirect(response, "/" + author.getName() + "/" + mid); } else { pagesUserThread.doGetThread(sql, request, response, mid); } @@ -314,8 +314,8 @@ public class Main extends HttpServlet implements Stream.StreamListener { Errors.doGet404(sql, request, response); } } - } else if (user != null && !user.Banned) { - Utils.sendPermanentRedirect(response, "/" + user.getUName() + "/" + (uriparts.length > 2 ? uriparts[2] : "")); + } else if (user != null && !user.isBanned()) { + Utils.sendPermanentRedirect(response, "/" + user.getName() + "/" + (uriparts.length > 2 ? uriparts[2] : "")); } else { Errors.doGet404(sql, request, response); } @@ -341,7 +341,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { switch (uri) { case "/post": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pagesNewMessage.doPostMessage(sql, request, response, xmpp, visitor); } else { response.sendError(403); @@ -350,7 +350,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } case "/comment": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pagesNewMessage.doPostComment(sql, request, response, xmpp, visitor); } else { response.sendError(403); @@ -359,7 +359,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } case "/like": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pagesNewMessage.doPostRecomm(sql, request, response, xmpp, visitor); } else { response.sendError(403); @@ -368,7 +368,7 @@ public class Main extends HttpServlet implements Stream.StreamListener { } case "/pm/send": { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() > 0 && !visitor.Banned) { + if (visitor.getUid() > 0 && !visitor.isBanned()) { pm.doPostPM(sql, request, response, xmpp, visitor); } else { response.sendError(403); diff --git a/juick-www/src/main/java/com/juick/www/NewMessage.java b/juick-www/src/main/java/com/juick/www/NewMessage.java index aaa3e550..310ede73 100644 --- a/juick-www/src/main/java/com/juick/www/NewMessage.java +++ b/juick-www/src/main/java/com/juick/www/NewMessage.java @@ -101,7 +101,7 @@ public class NewMessage { } void printUserTags(JdbcTemplate sql, PrintWriter out, com.juick.User visitor) { - List tags = TagQueries.getUserTagsAll(sql, visitor.getUID()); + List tags = TagQueries.getUserTagsAll(sql, visitor.getUid()); if (tags.isEmpty()) { return; @@ -128,7 +128,7 @@ public class NewMessage { String taglink = ""; try { taglink = "" + StringEscapeUtils.escapeHtml4(tags.get(i).getName()) + ""; } catch (UnsupportedEncodingException e) { } @@ -197,8 +197,8 @@ public class NewMessage { } String attachmentType = attachmentFName != null ? attachmentFName.substring(attachmentFName.length() - 3) : null; - int mid = MessagesQueries.createMessage(sql, visitor.getUID(), body, attachmentType, tags); - SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUID()); + int mid = MessagesQueries.createMessage(sql, visitor.getUid(), body, attachmentType, tags); + SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUid()); Message xmsg = new Message(); xmsg.from = new JID("juick", "juick.com", null); @@ -209,7 +209,7 @@ public class NewMessage { xmsg.addChild(jmsg); Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -236,7 +236,7 @@ public class NewMessage { for (String tag : tagsArr) { tagsStr2 += " *" + tag; } - xmsg.body = "@" + jmsg.getUser().getUName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; + xmsg.body = "@" + jmsg.getUser().getName() + ":" + tagsStr2 + "\n" + body + "\n\n#" + mid + " http://juick.com/" + mid; xmsg.to = new JID("juick", "s2s.juick.com", null); xmpp.send(xmsg); @@ -289,12 +289,12 @@ public class NewMessage { out.println("
"); out.println("

Сообщение опубликовано

"); out.println("

Поделитесь своим новым постом в социальных сетях:

"); - if (CrosspostQueries.getTwitterTokens(sql, visitor.getUID()).isPresent()) { + if (CrosspostQueries.getTwitterTokens(sql, visitor.getUid()).isPresent()) { out.println("

Отправить в Twitter

"); } out.println("

Отправить в LiveJournal

"); out.println("

Отправить в ВКонтакте

"); - if (CrosspostQueries.getFacebookToken(sql, visitor.getUID()).isPresent()) { + if (CrosspostQueries.getFacebookToken(sql, visitor.getUid()).isPresent()) { out.println("

Отправить в Facebook

"); } out.println("

Отправить в Google+

"); @@ -337,7 +337,7 @@ public class NewMessage { } body = body.replace("\r", ""); - if ((msg.ReadOnly && msg.getUser().getUID() != visitor.getUID()) || UserQueries.isInBLAny(sql, msg.getUser().getUID(), visitor.getUID()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUID(), visitor.getUID()))) { + if ((msg.ReadOnly && msg.getUser().getUid() != visitor.getUid()) || UserQueries.isInBLAny(sql, msg.getUser().getUid(), visitor.getUid()) || (reply != null && UserQueries.isInBLAny(sql, reply.getUser().getUid(), visitor.getUid()))) { response.sendError(403); return; } @@ -363,8 +363,8 @@ public class NewMessage { } String attachmentType = attachmentFName != null ? attachmentFName.substring(attachmentFName.length() - 3) : null; - int ridnew = MessagesQueries.createReply(sql, mid, rid, visitor.getUID(), body, attachmentType); - SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUID()); + int ridnew = MessagesQueries.createReply(sql, mid, rid, visitor.getUid(), body, attachmentType); + SubscriptionsQueries.subscribeMessage(sql, mid, visitor.getUid()); Message xmsg = new Message(); xmsg.from = new JID("juick", "juick.com", null); @@ -380,7 +380,7 @@ public class NewMessage { } Nickname nick = new Nickname(); - nick.Nickname = "@" + jmsg.getUser().getUName(); + nick.Nickname = "@" + jmsg.getUser().getName(); xmsg.addChild(nick); if (attachmentFName != null) { @@ -404,7 +404,7 @@ public class NewMessage { if (xmpp != null) { - xmsg.body = "Reply by @" + jmsg.getUser().getUName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; + xmsg.body = "Reply by @" + jmsg.getUser().getName() + ":\n>" + quote + "\n" + body + "\n\n#" + mid + "/" + ridnew + " http://juick.com/" + mid + "#" + ridnew; xmsg.to = new JID("juick", "s2s.juick.com", null); xmpp.send(xmsg); @@ -418,7 +418,7 @@ public class NewMessage { logger.warn("XMPP unavailable"); } - Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getUName() + "/" + mid + "#" + ridnew); + Utils.sendTemporaryRedirect(response, "/" + msg.getUser().getName() + "/" + mid + "#" + ridnew); } public void doPostRecomm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException { @@ -432,12 +432,12 @@ public class NewMessage { response.sendError(404); return; } - if (msg.getUser().getUID() == visitor.getUID()) { + if (msg.getUser().getUid() == visitor.getUid()) { response.sendError(403); return; } - boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUID()); + boolean res = MessagesQueries.recommendMessage(sql, mid, visitor.getUid()); if (res) { if (xmpp != null) { @@ -445,7 +445,7 @@ public class NewMessage { xmsg.from = new JID("juick", "juick.com", null); xmsg.to = new JID("recomm", "s2s.juick.com", null); JuickMessage jmsg = new JuickMessage(); - jmsg.setMID(mid); + jmsg.setMid(mid); jmsg.setUser(new JuickUser(visitor)); xmsg.addChild(jmsg); xmpp.send(xmsg); diff --git a/juick-www/src/main/java/com/juick/www/PM.java b/juick-www/src/main/java/com/juick/www/PM.java index 8190d65b..2e35ec1c 100644 --- a/juick-www/src/main/java/com/juick/www/PM.java +++ b/juick-www/src/main/java/com/juick/www/PM.java @@ -50,7 +50,7 @@ public class PM { protected void doGetInbox(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException { String title = "PM: Inbox"; - List msgs = PMQueries.getLastPMInbox(sql, visitor.getUID()); + List msgs = PMQueries.getLastPMInbox(sql, visitor.getUid()); msgs.forEach(m -> m.setText(Utils.formatMessage(m.getText()))); response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { @@ -67,7 +67,7 @@ public class PM { protected void doGetSent(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException, PebbleException { String title = "PM: Sent"; - List msgs = PMQueries.getLastPMSent(sql, visitor.getUID()); + List msgs = PMQueries.getLastPMSent(sql, visitor.getUid()); String uname = request.getParameter("uname"); if (!UserUtils.checkUserNameValid(uname)) { @@ -103,12 +103,12 @@ public class PM { return; } - if (UserQueries.isInBLAny(sql, uid, visitor.getUID())) { + if (UserQueries.isInBLAny(sql, uid, visitor.getUid())) { response.sendError(403); return; } - if (PMQueries.createPM(sql, visitor.getUID(), uid, body)) { + if (PMQueries.createPM(sql, visitor.getUid(), uid, body)) { if (xmpp != null) { Message msg = new Message(); msg.from = new JID("juick", "juick.com", null); @@ -127,12 +127,12 @@ public class PM { Message mm = new Message(); mm.to = new JID(jid); mm.type = Message.Type.chat; - if (PMQueries.havePMinRoster(sql, visitor.getUID(), jid)) { - mm.from = new JID(jmsg.getUser().getUName(), "juick.com", "Juick"); + if (PMQueries.havePMinRoster(sql, visitor.getUid(), jid)) { + mm.from = new JID(jmsg.getUser().getName(), "juick.com", "Juick"); mm.body = body; } else { mm.from = new JID("juick", "juick.com", "Juick"); - mm.body = "Private message from @" + jmsg.getUser().getUName() + ":\n" + body; + mm.body = "Private message from @" + jmsg.getUser().getName() + ":\n" + body; } xmpp.send(mm); } diff --git a/juick-www/src/main/java/com/juick/www/PageTemplates.java b/juick-www/src/main/java/com/juick/www/PageTemplates.java index f8873739..4f7e17b7 100644 --- a/juick-www/src/main/java/com/juick/www/PageTemplates.java +++ b/juick-www/src/main/java/com/juick/www/PageTemplates.java @@ -72,7 +72,7 @@ public class PageTemplates { out.println(""); out.println(""); out.flush(); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { out.println(""); } else { out.println(""); @@ -93,7 +93,7 @@ public class PageTemplates { } out.println("/>"); out.println("
"); - if (visitor.getUID() > 0) { + if (visitor.getUid() > 0) { out.print(" "); out.print(" "); } else { @@ -151,7 +151,7 @@ public class PageTemplates { String queryString = request.getQueryString(); String requestURI = request.getRequestURI(); - if (sapeon && sape != null && (visitor.getUID() == 0 || visitor.getUID() == 1) && queryString == null) { + if (sapeon && sape != null && (visitor.getUid() == 0 || visitor.getUid() == 1) && queryString == null) { String links = sape.getPageLinks(requestURI, request.getCookies()).render(); if (links != null && !links.isEmpty()) { out.print("
Спонсоры: " + links); @@ -284,7 +284,7 @@ public class PageTemplates { for (int i = 0; i < msgs.size(); i++) { com.juick.Message msg = msgs.get(i); - if (msg.getMID() == ad_mid) { + if (msg.getMid() == ad_mid) { msgs.remove(i); msgs.add(0, msg); break; @@ -294,43 +294,43 @@ public class PageTemplates { List blUIDs = new ArrayList(20); if (visitor != null) { for (Message msg : msgs) { - blUIDs.add(msg.getUser().getUID()); + blUIDs.add(msg.getUser().getUid()); } - blUIDs = UserQueries.checkBL(sql, visitor.getUID(), blUIDs); + blUIDs = UserQueries.checkBL(sql, visitor.getUid(), blUIDs); } for (Message msg : msgs) { - List tags = MessagesQueries.getMessageTags(sql, msg.getMID()); + List tags = MessagesQueries.getMessageTags(sql, msg.getMid()); String tagsStr = formatTags(tags); if (msg.ReadOnly) { tagsStr += "readonly"; } - if (msg.Privacy < 0) { + if (msg.getPrivacy() < 0) { tagsStr += "friends"; } - if (msg.getMID() == ad_mid) { + if (msg.getMid() == ad_mid) { tagsStr += "реклама"; } String txt; - if (msg.Tags.stream().anyMatch(t -> t.getName().equals("code"))) { + if (msg.getTags().stream().anyMatch(t -> t.getName().equals("code"))) { txt = Utils.formatMessageCode(msg.getText()); } else { txt = Utils.formatMessage(msg.getText()); } - out.println("
"); + out.println("
"); out.println("
"); - out.println(" @" + msg.getUser().getUName() + ":"); - out.println("
\""
"); - out.println(" "); + out.println(" @" + msg.getUser().getName() + ":"); + out.println("
\""
"); + out.println(" "); out.println("
" + tagsStr + "
"); out.println("
"); if (msg.AttachmentType != null) { - String fname = msg.getMID() + "." + msg.AttachmentType; + String fname = msg.getMid() + "." + msg.AttachmentType; out.println("

\"\"/

"); } out.println("

" + txt + "

"); @@ -338,21 +338,21 @@ public class PageTemplates { out.println("
"); } out.print("
"); diff --git a/juick-www/src/main/java/com/juick/www/Settings.java b/juick-www/src/main/java/com/juick/www/Settings.java index 6be16acc..5c25564f 100644 --- a/juick-www/src/main/java/com/juick/www/Settings.java +++ b/juick-www/src/main/java/com/juick/www/Settings.java @@ -71,7 +71,7 @@ public class Settings { protected void doGet(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { response.sendRedirect("/login"); } List pages = Arrays.asList("main", "password", "about", "auth-email", "privacy"); @@ -95,17 +95,17 @@ public class Settings { List hours = IntStream.rangeClosed(0, 23).boxed() .map(i -> StringUtils.leftPad(String.format("%d", i), 2, "0")).collect(Collectors.toList()); context.put("hours", hours); - context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUID())); - context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUID())); - context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUID())); + context.put("fbstatus", CrosspostQueries.isFBCrossPostEnabled(sql, visitor.getUid())); + context.put("twitter_name", CrosspostQueries.getTwitterName(sql, visitor.getUid())); + context.put("telegram_name", CrosspostQueries.getTelegramName(sql, visitor.getUid())); context.put("notify_options", SubscriptionsQueries.getNotifyOptions(sql, visitor)); context.put("userinfo", UserQueries.getUserInfo(sql, visitor)); if (page.equals("auth-email")) { try { String account = sql.queryForObject("SELECT account FROM auth WHERE user_id=? AND protocol='email' AND authcode=?", - String.class, visitor.getUID(), request.getParameter("code")); - sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUID(), account); - sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUID(), request.getParameter("code")); + String.class, visitor.getUid(), request.getParameter("code")); + sql.update("INSERT INTO emails(user_id,email) VALUES (?,?)", visitor.getUid(), account); + sql.update("DELETE FROM auth WHERE user_id=? AND authcode=?", visitor.getUid(), request.getParameter("code")); context.put("result", "OK!"); } catch (EmptyResultDataAccessException e) { context.put("result", "Sorry, code unknown."); @@ -117,7 +117,7 @@ public class Settings { protected void doPost(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, PebbleException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { response.sendError(400); return; } @@ -134,7 +134,7 @@ public class Settings { case "password": if (UserQueries.updatePassword(sql, visitor, request.getParameter("password"))) { result = "

Password has been changed.

"; - String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUID()); + String hash = com.juick.server.UserQueries.getHashByUID(sql, visitor.getUid()); Cookie c = new Cookie("hash", hash); c.setMaxAge(365 * 24 * 60 * 60); response.addCookie(c); @@ -158,8 +158,8 @@ public class Settings { String avatarTmpPath = Utils.receiveMultiPartFile(request, "avatar"); if (StringUtils.isNotEmpty(avatarTmpPath)) { String originalExtension = FilenameUtils.getExtension(avatarTmpPath); - String originalName = String.format("%s.%s", visitor.getUID(), originalExtension); - String targetName = String.format("%s.png", visitor.getUID()); + String originalName = String.format("%s.%s", visitor.getUid(), originalExtension); + String targetName = String.format("%s.png", visitor.getUid()); Path ao = Paths.get(imgPath, "ao", originalName); Path a = Paths.get(imgPath, "a", targetName); Path as = Paths.get(imgPath, "as", targetName); @@ -168,16 +168,16 @@ public class Settings { Thumbnails.of(ao.toFile()).size(32, 32).toFile(as.toFile()); } if (UserQueries.updateUserInfo(sql, visitor, info)) { - result = String.format("

Your info is updated.

Back to blog.

", visitor.getUName()); + result = String.format("

Your info is updated.

Back to blog.

", visitor.getName()); } break; case "jid-del": String[] params = request.getParameter("delete").split(";", 2); int res = -1; if (params[0].equals("xmpp")) { - res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUID(), params[1]); + res = sql.update("DELETE FROM jids WHERE user_id=? AND jid=?", visitor.getUid(), params[1]); } else if (params[0].equals("xmpp-unauth")) { - res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUID(), params[1]); + res = sql.update("DELETE FROM auth WHERE user_id=? AND protocol='xmpp' AND account=?", visitor.getUid(), params[1]); } if (res == 1) { result = "

Deleted. Back.

"; @@ -198,11 +198,11 @@ public class Settings { case "email-add": try { sql.queryForObject("SELECT authcode FROM auth WHERE user_id=? AND protocol='email' " + - "AND account=?", String.class, visitor.getUID(), request.getParameter("account")); + "AND account=?", String.class, visitor.getUid(), request.getParameter("account")); } catch (EmptyResultDataAccessException e) { String authCode = UserUtils.generateHash(8); if (sql.update("INSERT INTO auth(user_id,protocol,account,authcode) VALUES (?,'email',?,?)", - visitor.getUID(), request.getParameter("account"), authCode) > 0) { + visitor.getUid(), request.getParameter("account"), authCode) > 0) { Session session = Session.getDefaultInstance(System.getProperties()); try { MimeMessage message = new MimeMessage(session); @@ -225,18 +225,18 @@ public class Settings { } break; case "email-del": - if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUID(), request.getParameter("account")) > 0) { + if (sql.update("DELETE FROM emails WHERE user_id=? AND email=?", visitor.getUid(), request.getParameter("account")) > 0) { result = "

Deleted. Back.

"; } else { result = "

An error occured while deleting.

"; } break; case "email-subscr": - sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUID()); + sql.update("UPDATE emails SET subscr_hour=NULL WHERE user_id=?", visitor.getUid()); String email = request.getParameter("account"); if (StringUtils.isNotEmpty(email)) { sql.update("UPDATE emails SET subscr_hour=? WHERE user_id=? AND email=?", - request.getParameter("time"), visitor.getUID(), email); + request.getParameter("time"), visitor.getUid(), email); result = String.format("

Saved! Will send to %s at %s:00 GMT." + "

Back

", email, request.getParameter("time")); } else { @@ -244,8 +244,8 @@ public class Settings { } break; case "twitter-del": - sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUID()); - sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUID()); + sql.update("DELETE FROM twitter WHERE user_id=?", visitor.getUid()); + sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=1741", visitor.getUid()); for (Cookie cookie : request.getCookies()) { if (cookie.getName().equals("request_token")) { cookie.setMaxAge(0); @@ -259,21 +259,21 @@ public class Settings { result = "

Back

"; break; case "telegram-del": - sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUID()); + sql.update("DELETE FROM telegram WHERE user_id=?", visitor.getUid()); result = "

Back

"; break; case "facebook-disable": - sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUID()); - sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUID()); + sql.update("UPDATE facebook SET crosspost=0 WHERE user_id=?", visitor.getUid()); + sql.update("DELETE FROM subscr_users WHERE user_id=? AND suser_id=5863", visitor.getUid()); result = "

Back

"; break; case "facebook-enable": - sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUID()); - sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUID()); + sql.update("UPDATE facebook SET crosspost=1 WHERE user_id=?", visitor.getUid()); + sql.update("INSERT INTO subscr_users(user_id,suser_id,jid,active) VALUES (?,5863,'juick@facebook.juick.com',1)", visitor.getUid()); result = "

Back

"; break; case "vk-del": - sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUID()); + sql.update("DELETE FROM vk WHERE user_id=?", visitor.getUid()); result = "

Back

"; break; default: diff --git a/juick-www/src/main/java/com/juick/www/SignUp.java b/juick-www/src/main/java/com/juick/www/SignUp.java index 43c82a9a..ea40c810 100644 --- a/juick-www/src/main/java/com/juick/www/SignUp.java +++ b/juick-www/src/main/java/com/juick/www/SignUp.java @@ -97,7 +97,7 @@ public class SignUp { String action = request.getParameter("action"); if (action.charAt(0) == 'l') { - if (visitor.getUID() == 0) { + if (visitor.getUid() == 0) { String username = request.getParameter("username"); String password = request.getParameter("password"); if (username == null || password == null || username.length() > 32 || password.isEmpty()) { @@ -106,7 +106,7 @@ public class SignUp { } uid = com.juick.server.UserQueries.checkPassword(sql, username, password); } else { - uid = visitor.getUID(); + uid = visitor.getUid(); } if (uid <= 0) { diff --git a/juick-www/src/main/java/com/juick/www/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/TwitterAuth.java index d4be4335..173ad7b7 100644 --- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java +++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java @@ -48,7 +48,7 @@ public class TwitterAuth { } } com.juick.User user = UserQueries.getUserByHash(sql, hash); - if ( user == null || user.getUID() == 0) { + if ( user == null || user.getUid() == 0) { response.sendError(403); return; } diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java index 967d06c7..3cc38b37 100644 --- a/juick-www/src/main/java/com/juick/www/User.java +++ b/juick-www/src/main/java/com/juick/www/User.java @@ -58,7 +58,7 @@ public class User { Errors.doGet404(sql, request, response); return; } else if (!paramTag.getName().equals(paramTagStr)) { - String url = "/" + user.getUName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8"); + String url = "/" + user.getName() + "/?tag=" + URLEncoder.encode(paramTag.getName(), "UTF-8"); Utils.sendPermanentRedirect(response, url); return; } @@ -79,10 +79,10 @@ public class User { } int privacy = 0; - if (visitor.getUID() > 0) { - if (user.getUID() == visitor.getUID() || visitor.getUID() == 1) { + if (visitor.getUid() > 0) { + if (user.getUid() == visitor.getUid() || visitor.getUid() == 1) { privacy = -3; - } else if (UserQueries.isInWL(sql, user.getUID(), visitor.getUID())) { + } else if (UserQueries.isInWL(sql, user.getUid(), visitor.getUid())) { privacy = -2; } } @@ -90,34 +90,34 @@ public class User { String title; if (paramShow == null) { if (paramTag != null) { - title = "Блог " + user.getUName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName()); - mids = MessagesQueries.getUserTag(sql, user.getUID(), paramTag.TID, privacy, paramBefore); + title = "Блог " + user.getName() + ": *" + StringEscapeUtils.escapeHtml4(paramTag.getName()); + mids = MessagesQueries.getUserTag(sql, user.getUid(), paramTag.TID, privacy, paramBefore); } else if (paramSearch != null) { - title = "Блог " + user.getUName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch); - mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUID(), Utils.encodeSphinx(paramSearch), privacy, paramBefore); + title = "Блог " + user.getName() + ": " + StringEscapeUtils.escapeHtml4(paramSearch); + mids = MessagesQueries.getUserSearch(sql, sqlSearch, user.getUid(), Utils.encodeSphinx(paramSearch), privacy, paramBefore); } else { - title = "Блог " + user.getUName(); - mids = MessagesQueries.getUserBlog(sql, user.getUID(), privacy, paramBefore); + title = "Блог " + user.getName(); + mids = MessagesQueries.getUserBlog(sql, user.getUid(), privacy, paramBefore); } } else if (paramShow.equals("recomm")) { - title = "Рекомендации " + user.getUName(); - mids = MessagesQueries.getUserRecommendations(sql, user.getUID(), paramBefore); + title = "Рекомендации " + user.getName(); + mids = MessagesQueries.getUserRecommendations(sql, user.getUid(), paramBefore); } else if (paramShow.equals("photos")) { - title = "Фотографии " + user.getUName(); - mids = MessagesQueries.getUserPhotos(sql, user.getUID(), privacy, paramBefore); + title = "Фотографии " + user.getName(); + mids = MessagesQueries.getUserPhotos(sql, user.getUid(), privacy, paramBefore); } else { Errors.doGet404(sql, request, response); return; } - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; + user.getName() + "\" href=\"//rss.juick.com/" + user.getName() + "/blog\"/>"; if (paramTag != null && TagQueries.getTagNoIndex(sql, paramTag.TID)) { head += ""; } else if (paramBefore > 0 || paramShow != null) { @@ -136,7 +136,7 @@ public class User { StringEscapeUtils.escapeHtml4(paramTag.getName()) + "

"); } - PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUID() == 0 ? 4 : 5, 0); + PageTemplates.printMessages(out, sql, user, mids, visitor, visitor.getUid() == 0 ? 4 : 5, 0); if (mids.size() >= 20) { String nextpage = "?before=" + mids.get(mids.size() - 1); @@ -163,14 +163,14 @@ public class User { protected void doGetTags(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; - PageTemplates.pageHead(out, visitor, "Теги " + user.getUName(), head); + PageTemplates.pageHead(out, visitor, "Теги " + user.getName(), head); PageTemplates.pageNavigation(out, visitor, null); pageUserColumn(out, sql, user, visitor); @@ -186,28 +186,28 @@ public class User { protected void doGetFriends(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; - PageTemplates.pageHead(out, visitor, "Подписки " + user.getUName(), head); + PageTemplates.pageHead(out, visitor, "Подписки " + user.getName(), head); PageTemplates.pageNavigation(out, visitor, null); pageUserColumn(out, sql, user, visitor); out.println("
"); out.println(""); - List friends = UserQueries.getUserFriends(sql, user.getUID()); + List friends = UserQueries.getUserFriends(sql, user.getUid()); for (int i = 0; i < friends.size(); i++) { if (i % 3 == 0 && i > 0) { out.print(""); } - out.print(""); + out.print(""); } out.println("
" - + friends.get(i).getUName() + "" + + friends.get(i).getName() + "
"); @@ -221,28 +221,28 @@ public class User { protected void doGetReaders(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User user) throws ServletException, IOException { com.juick.User visitor = Utils.getVisitorUser(sql, request, response); - if (visitor.getUID() == 0) { - pageUserRefCookie(request, response, user.getUID()); + if (visitor.getUid() == 0) { + pageUserRefCookie(request, response, user.getUid()); } response.setContentType("text/html; charset=UTF-8"); try (PrintWriter out = response.getWriter()) { String head = ""; - PageTemplates.pageHead(out, visitor, "Читатели " + user.getUName(), head); + PageTemplates.pageHead(out, visitor, "Читатели " + user.getName(), head); PageTemplates.pageNavigation(out, visitor, null); pageUserColumn(out, sql, user, visitor); out.println("
"); out.println(""); - List readers = UserQueries.getUserReaders(sql, user.getUID()); + List readers = UserQueries.getUserReaders(sql, user.getUid()); for (int i = 0; i < readers.size(); i++) { if (i % 3 == 0 && i > 0) { out.print(""); } - out.print(""); + out.print(""); } out.println("
" - + readers.get(i).getUName() + "" + + readers.get(i).getName() + "
"); @@ -267,21 +267,21 @@ public class User { public static void pageUserColumn(PrintWriter out, JdbcTemplate sql, com.juick.User user, com.juick.User visitor) { out.println("