diff options
author | Vitaly Takmazov | 2016-06-27 10:39:24 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-06-27 10:39:24 +0300 |
commit | 0d93073c6988a22246db61a59b97c2fd7c9f462b (patch) | |
tree | d5f27cdb9a4fe51690f7af067608a9bee62087e3 /src/main/java/com/juick/http/www/PM.java | |
parent | 2d7f61242de54b0c0670bac1953e45ee18d9ecec (diff) | |
parent | 53fb0b3e0e790df007a198deef21c115ed236b3e (diff) |
merge
Diffstat (limited to 'src/main/java/com/juick/http/www/PM.java')
-rw-r--r-- | src/main/java/com/juick/http/www/PM.java | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/main/java/com/juick/http/www/PM.java b/src/main/java/com/juick/http/www/PM.java index a9505bdb..b64e6c43 100644 --- a/src/main/java/com/juick/http/www/PM.java +++ b/src/main/java/com/juick/http/www/PM.java @@ -23,6 +23,8 @@ import com.juick.xmpp.JID; import com.juick.xmpp.Message; import com.juick.xmpp.Stream; import com.juick.xmpp.extensions.JuickMessage; +import org.springframework.jdbc.core.JdbcTemplate; + import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; @@ -38,7 +40,7 @@ import javax.servlet.http.HttpServletResponse; */ public class PM { - protected void doGetInbox(Connection sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { + protected void doGetInbox(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { /* int paramBefore = 0; String paramBeforeStr = request.getParameter("before"); @@ -54,8 +56,7 @@ public class PM { List<com.juick.Message> msgs = PMQueries.getLastPMInbox(sql, visitor.getUID()); response.setContentType("text/html; charset=UTF-8"); - PrintWriter out = response.getWriter(); - try { + try (PrintWriter out = response.getWriter()) { PageTemplates.pageHead(out, title, null); PageTemplates.pageNavigation(out, visitor, null); PageTemplates.pageHomeColumn(out, sql, visitor); @@ -97,12 +98,10 @@ public class PM { PageTemplates.pageFooter(request, out, visitor, false); PageTemplates.pageEnd(out); - } finally { - out.close(); } } - protected void doGetSent(Connection sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { + protected void doGetSent(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, com.juick.User visitor) throws ServletException, IOException { /* int paramBefore = 0; String paramBeforeStr = request.getParameter("before"); @@ -123,8 +122,7 @@ public class PM { } response.setContentType("text/html; charset=UTF-8"); - PrintWriter out = response.getWriter(); - try { + try (PrintWriter out = response.getWriter()) { PageTemplates.pageHead(out, title, null); PageTemplates.pageNavigation(out, visitor, null); PageTemplates.pageHomeColumn(out, sql, visitor); @@ -169,12 +167,10 @@ public class PM { PageTemplates.pageFooter(request, out, visitor, false); PageTemplates.pageEnd(out); - } finally { - out.close(); } } - public void doPostPM(Connection sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException { + public void doPostPM(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, Stream xmpp, com.juick.User visitor) throws ServletException, IOException { String uname = request.getParameter("uname"); if (uname.startsWith("@")) { uname = uname.substring(1); @@ -200,7 +196,7 @@ public class PM { msg.from = new JID("juick", "juick.com", null); msg.to = new JID(Integer.toString(uid), "push.juick.com", null); JuickMessage jmsg = new JuickMessage(); - jmsg.setUser(UserQueries.getUserByUID(sql, visitor.getUID())); + jmsg.setUser(visitor); jmsg.setText(body); msg.childs.add(jmsg); xmpp.send(msg); |