aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/http/www/PM.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/http/www/PM.java')
-rw-r--r--src/main/java/com/juick/http/www/PM.java20
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);