aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/Main.java38
-rw-r--r--juick-api/src/main/java/com/juick/api/Messages.java16
-rw-r--r--juick-api/src/main/java/com/juick/api/Notifications.java10
-rw-r--r--juick-api/src/main/java/com/juick/api/Others.java2
-rw-r--r--juick-api/src/main/java/com/juick/api/PM.java10
-rw-r--r--juick-api/src/main/java/com/juick/api/Subscriptions.java4
-rw-r--r--juick-api/src/main/java/com/juick/api/Users.java6
-rw-r--r--juick-rss/src/main/java/com/juick/rss/Main.java10
-rw-r--r--juick-www/src/main/java/com/juick/www/Errors.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/Login.java8
-rw-r--r--juick-www/src/main/java/com/juick/www/Main.java28
-rw-r--r--juick-www/src/main/java/com/juick/www/NewMessage.java28
-rw-r--r--juick-www/src/main/java/com/juick/www/PM.java6
-rw-r--r--juick-www/src/main/java/com/juick/www/RSS.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/Settings.java10
-rw-r--r--juick-www/src/main/java/com/juick/www/TwitterAuth.java4
-rw-r--r--juick-www/src/main/java/com/juick/www/UserThread.java2
17 files changed, 93 insertions, 93 deletions
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 dffb9d66..f902fc6b 100644
--- a/juick-api/src/main/java/com/juick/api/Main.java
+++ b/juick-api/src/main/java/com/juick/api/Main.java
@@ -153,7 +153,7 @@ public class Main extends HttpServlet {
if (vuid > 0) {
messages.doGetHome(request, response, vuid);
} else {
- response.sendError(401);
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
} else if (uri.equals("/messages")) {
messages.doGet(request, response, vuid);
@@ -169,19 +169,19 @@ public class Main extends HttpServlet {
if (vuid > 0) {
pm.doGetPM(request, response, vuid);
} else {
- response.sendError(401);
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
} else if (uri.equals("/groups_pms")) {
if (vuid > 0) {
others.doGetGroupsPMs(request, response, vuid);
} else {
- response.sendError(401);
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
} else if (uri.equals("/messages/recommended")) {
if (vuid > 0) {
messages.doGetRecommended(request, response, vuid);
} else {
- response.sendError(401);
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
}
} else if (uri.equals("/messages/set_popular") && vuid == 3694) {
messages.doSetPopular(request, response, xmpp);
@@ -192,7 +192,7 @@ public class Main extends HttpServlet {
} else if (uri.equals("/notifications")) {
notifications.doGet(request, response, vuid);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
@@ -228,7 +228,7 @@ public class Main extends HttpServlet {
vuid = Utils.getVisitorQueryStringUID(jdbc, request);
}
if (vuid == 0) {
- response.sendError(401);
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
switch (uri) {
@@ -244,7 +244,7 @@ public class Main extends HttpServlet {
pm.doPostPM(request, response, xmpp, vuid);
break;
default:
- response.sendError(405);
+ response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
break;
}
}
@@ -253,7 +253,7 @@ public class Main extends HttpServlet {
throws ServletException, IOException {
String body = request.getParameter("body");
if (body == null || body.length() < 1 || body.length() > 4096) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
body = body.replace("\r", "");
@@ -282,7 +282,7 @@ public class Main extends HttpServlet {
attachmentFName = Utils.receiveMultiPartFile(request, "attach");
} catch (Exception e) {
log("MULTIPART ERROR", e);
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -293,7 +293,7 @@ public class Main extends HttpServlet {
attachmentFName = Utils.downloadImage(imgUrl);
} catch (Exception e) {
log("DOWNLOAD ERROR", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
@@ -366,12 +366,12 @@ public class Main extends HttpServlet {
throws ServletException, IOException {
int mid = NumberUtils.toInt(request.getParameter("mid"), 0);
if (mid == 0) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
com.juick.Message msg = MessagesQueries.getMessage(sql, mid);
if (msg == null) {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
@@ -380,21 +380,21 @@ public class Main extends HttpServlet {
if (rid > 0) {
reply = MessagesQueries.getReply(sql, mid, rid);
if (reply == null) {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
}
String body = request.getParameter("body");
if (body == null || body.length() < 1 || body.length() > 4096) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
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))) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -403,7 +403,7 @@ public class Main extends HttpServlet {
attachmentFName = Utils.receiveMultiPartFile(request, "attach");
} catch (Exception e) {
log("MULTIPART ERROR", e);
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -413,7 +413,7 @@ public class Main extends HttpServlet {
attachmentFName = Utils.downloadImage(new URL(paramImg));
} catch (Exception e) {
log("DOWNLOAD ERROR", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
@@ -488,7 +488,7 @@ public class Main extends HttpServlet {
vuid = Utils.getVisitorQueryStringUID(jdbc, req);
}
if (vuid == 0) {
- resp.sendError(401);
+ resp.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
String uri = req.getRequestURI();
@@ -497,7 +497,7 @@ public class Main extends HttpServlet {
notifications.doDelete(req, resp, vuid);
break;
default:
- resp.sendError(400);
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
break;
}
}
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 93abb06b..024a79c1 100644
--- a/juick-api/src/main/java/com/juick/api/Messages.java
+++ b/juick-api/src/main/java/com/juick/api/Messages.java
@@ -76,13 +76,13 @@ public class Messages {
if (tagObject != null) {
mids = MessagesQueries.getUserTag(sql, user.getUid(), tagObject.TID, 0, before_mid);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else {
mids = MessagesQueries.getUserBlog(sql, user.getUid(), 0, before_mid);
}
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else {
if (!StringUtils.isEmpty(popular)) {
@@ -94,7 +94,7 @@ public class Messages {
if (tagObject != null) {
mids = MessagesQueries.getTag(sql, tagObject.TID, vuid, before_mid, 20);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else {
mids = MessagesQueries.getAll(sql, vuid, before_mid);
@@ -108,14 +108,14 @@ public class Messages {
com.juick.Message msg = MessagesQueries.getMessage(sql, mid);
if (msg != null) {
if (!MessagesQueries.canViewThread(sql, mid, vuid)) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
} else {
List<com.juick.Message> replies = MessagesQueries.getReplies(sql, mid);
replies.add(0, msg);
feedMessages(request, response, replies);
}
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
@@ -131,10 +131,10 @@ public class Messages {
String json = messageSerializer.serializeList(msgs);
Main.replyJSON(request, response, json);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
@@ -146,7 +146,7 @@ public class Messages {
if (user != null && user.getUid() == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) {
Main.replyJSON(request, response, "{\"status\":\"ok\"}");
} else {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
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 707df6e4..dbd128b0 100644
--- a/juick-api/src/main/java/com/juick/api/Notifications.java
+++ b/juick-api/src/main/java/com/juick/api/Notifications.java
@@ -33,7 +33,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.getName().equals("juick"))) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
String type = request.getParameter("type");
@@ -54,7 +54,7 @@ public class Notifications {
Main.replyJSON(request, response, mapper.writeValueAsString(mpnsTokens));
break;
default:
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
} else {
@@ -84,11 +84,11 @@ public class Notifications {
Main.replyJSON(request, response, mapper.writeValueAsString(mpnsTokens));
break;
default:
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
} else {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
}
@@ -96,7 +96,7 @@ public class Notifications {
public void doDelete(HttpServletRequest request, HttpServletResponse response, int vuid) throws IOException {
User visitor = UserQueries.getUserByUID(jdbc, vuid).orElse(new User());
if ((visitor.getUid() == 0) || !(visitor.getName().equals("juick"))) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
ObjectMapper mapper = new ObjectMapper();
diff --git a/juick-api/src/main/java/com/juick/api/Others.java b/juick-api/src/main/java/com/juick/api/Others.java
index 6b032531..446c03b5 100644
--- a/juick-api/src/main/java/com/juick/api/Others.java
+++ b/juick-api/src/main/java/com/juick/api/Others.java
@@ -46,7 +46,7 @@ public class Others {
String json = "{\"pms\":" + userSerializer.serializeList(lastconv) + "}";
Main.replyJSON(request, response, json);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
}
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 86d9c534..1e06e67d 100644
--- a/juick-api/src/main/java/com/juick/api/PM.java
+++ b/juick-api/src/main/java/com/juick/api/PM.java
@@ -39,7 +39,7 @@ public class PM {
}
if (uid == 0) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -48,7 +48,7 @@ public class PM {
String json = messageSerializer.serializeList(msgs);
Main.replyJSON(request, response, json);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
@@ -63,12 +63,12 @@ public class PM {
String body = request.getParameter("body");
if (uid == 0 || body == null || body.length() < 1 || body.length() > 10240) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
if (UserQueries.isInBLAny(sql, uid, vuid)) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -103,7 +103,7 @@ public class PM {
}
} else {
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
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 f8bd162f..126832a9 100644
--- a/juick-api/src/main/java/com/juick/api/Subscriptions.java
+++ b/juick-api/src/main/java/com/juick/api/Subscriptions.java
@@ -27,7 +27,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.getName().equals("juick"))) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
int uid = NumberUtils.toInt(request.getParameter("uid"), 0);
@@ -43,6 +43,6 @@ public class Subscriptions {
Main.replyJSON(request, response, userSerializer.serializeList(users));
}
}
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
}
}
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 a98af7a8..04e53346 100644
--- a/juick-api/src/main/java/com/juick/api/Users.java
+++ b/juick-api/src/main/java/com/juick/api/Users.java
@@ -66,7 +66,7 @@ public class Users {
String json = userSerializer.serializeList(users);
Main.replyJSON(request, response, json);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
@@ -97,7 +97,7 @@ public class Users {
}
}
}
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
public void doGetUserReaders(HttpServletRequest request,
@@ -122,6 +122,6 @@ public class Users {
Main.replyJSON(request, response, json);
return;
}
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
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 029057e3..04d87729 100644
--- a/juick-rss/src/main/java/com/juick/rss/Main.java
+++ b/juick-rss/src/main/java/com/juick/rss/Main.java
@@ -77,14 +77,14 @@ public class Main extends HttpServlet {
List<Message> msgs = MessagesQueries.getMessages(sql, mids);
responseMessages(response, 0, null, msgs);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else if (uri.equals("/comments")) {
int hours = NumberUtils.toInt(request.getParameter("hours"), 0);
if (hours > 0 && hours < 13) {
responseReplies(response, hours);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else if (uri.matches("^/[a-zA-Z0-9\\-]{2,16}/blog$")) {
String uname = uri.substring(1, uri.length() - 5);
@@ -95,13 +95,13 @@ public class Main extends HttpServlet {
List<Message> msgs = MessagesQueries.getMessages(sql, mids);
responseMessages(response, uid, uname, msgs);
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
}
diff --git a/juick-www/src/main/java/com/juick/www/Errors.java b/juick-www/src/main/java/com/juick/www/Errors.java
index 85ebf1a6..75fdddde 100644
--- a/juick-www/src/main/java/com/juick/www/Errors.java
+++ b/juick-www/src/main/java/com/juick/www/Errors.java
@@ -20,7 +20,7 @@ public class Errors {
public static void doGet404(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
- response.setStatus(404);
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.setContentType("text/html; charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
PebbleTemplate template = Utils.getEngine().getTemplate("views/404.html");
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 19cc855b..27f34c1c 100644
--- a/juick-www/src/main/java/com/juick/www/Login.java
+++ b/juick-www/src/main/java/com/juick/www/Login.java
@@ -186,7 +186,7 @@ public class Login {
protected void doGetLogin(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String hash = request.getQueryString();
if (hash.length() > 32) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -196,7 +196,7 @@ public class Login {
response.addCookie(c);
response.sendRedirect("/");
} else {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
}
@@ -204,7 +204,7 @@ public class Login {
String username = request.getParameter("username");
String password = request.getParameter("password");
if (username == null || password == null || username.length() > 32 || password.isEmpty()) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -222,7 +222,7 @@ public class Login {
response.sendRedirect("/");
}
} else {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
}
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 075b33fa..99d06fe6 100644
--- a/juick-www/src/main/java/com/juick/www/Main.java
+++ b/juick-www/src/main/java/com/juick/www/Main.java
@@ -182,7 +182,7 @@ public class Main extends HttpServlet {
pm.doGetInbox(sql, request, response, visitor);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
break;
case "/pm/sent":
@@ -190,7 +190,7 @@ public class Main extends HttpServlet {
pm.doGetSent(sql, request, response, visitor);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
break;
default:
@@ -206,10 +206,10 @@ public class Main extends HttpServlet {
rss.doGet(sql, response, uid);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} else {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
} else if (uri.equals("/logout")) {
login.doGetLogout(sql, request, response);
@@ -218,7 +218,7 @@ public class Main extends HttpServlet {
settings.doGet(sql, request, response);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} else if (uri.equals("/_fblogin")) {
loginFacebook.doGet(sql, request, response);
@@ -231,7 +231,7 @@ public class Main extends HttpServlet {
signup.doGet(sql, request, response);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} else if (uri.equals("/help") || uri.equals("/help/")) {
help.doRedirectToHelpIndex(response);
@@ -240,10 +240,10 @@ public class Main extends HttpServlet {
help.doGetHelp(sql, request, response);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
} catch (URISyntaxException e) {
log("help exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} else if (uri.startsWith("/tag/")) {
discover.doGet(sql, sqlSearch, request, response);
@@ -332,7 +332,7 @@ public class Main extends HttpServlet {
if (visitor.getUid() > 0 && !visitor.isBanned()) {
pagesNewMessage.doPostMessage(sql, request, response, xmpp, visitor);
} else {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
break;
}
@@ -341,7 +341,7 @@ public class Main extends HttpServlet {
if (visitor.getUid() > 0 && !visitor.isBanned()) {
pagesNewMessage.doPostComment(sql, request, response, xmpp, visitor);
} else {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
break;
}
@@ -350,7 +350,7 @@ public class Main extends HttpServlet {
if (visitor.getUid() > 0 && !visitor.isBanned()) {
pagesNewMessage.doPostRecomm(sql, request, response, xmpp, visitor);
} else {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
break;
}
@@ -359,7 +359,7 @@ public class Main extends HttpServlet {
if (visitor.getUid() > 0 && !visitor.isBanned()) {
pm.doPostPM(sql, request, response, xmpp, visitor);
} else {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
}
break;
}
@@ -374,11 +374,11 @@ public class Main extends HttpServlet {
settings.doPost(sql, request, response);
} catch (PebbleException e) {
log("pebble exception", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
break;
default:
- response.sendError(405);
+ response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
break;
}
}
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 29c834d6..f6e8ec47 100644
--- a/juick-www/src/main/java/com/juick/www/NewMessage.java
+++ b/juick-www/src/main/java/com/juick/www/NewMessage.java
@@ -151,7 +151,7 @@ public class NewMessage {
public void doPostMessage(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, XmppSession xmpp, com.juick.User visitor) throws ServletException, IOException {
String body = request.getParameter("body");
if (body == null || body.length() < 1 || body.length() > 4096) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
body = body.replace("\r", "");
@@ -180,7 +180,7 @@ public class NewMessage {
attachmentFName = Utils.receiveMultiPartFile(request, "attach");
} catch (Exception e) {
logger.error("MULTIPART ERROR", e);
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -191,7 +191,7 @@ public class NewMessage {
attachmentFName = Utils.downloadImage(imgUrl);
} catch (Exception e) {
logger.error("DOWNLOAD ERROR", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
@@ -307,12 +307,12 @@ public class NewMessage {
public void doPostComment(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, XmppSession xmpp, com.juick.User visitor) throws ServletException, IOException {
int mid = NumberUtils.toInt(request.getParameter("mid"), 0);
if (mid == 0) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
com.juick.Message msg = MessagesQueries.getMessage(sql, mid);
if (msg == null) {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
@@ -321,20 +321,20 @@ public class NewMessage {
if (rid > 0) {
reply = MessagesQueries.getReply(sql, mid, rid);
if (reply == null) {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
}
String body = request.getParameter("body");
if (body == null || body.length() < 1 || body.length() > 4096) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
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()))) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -343,7 +343,7 @@ public class NewMessage {
attachmentFName = Utils.receiveMultiPartFile(request, "attach");
} catch (Exception e) {
logger.error("MULTIPART ERROR", e);
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
@@ -353,7 +353,7 @@ public class NewMessage {
attachmentFName = Utils.downloadImage(new URL(paramImg));
} catch (Exception e) {
logger.error("DOWNLOAD ERROR", e);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
@@ -420,16 +420,16 @@ public class NewMessage {
public void doPostRecomm(JdbcTemplate sql, HttpServletRequest request, HttpServletResponse response, XmppSession xmpp, com.juick.User visitor) throws ServletException, IOException {
int mid = NumberUtils.toInt(request.getParameter("mid"), 0);
if (mid == 0) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
com.juick.Message msg = MessagesQueries.getMessage(sql, mid);
if (msg == null) {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
if (msg.getUser().getUid() == visitor.getUid()) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -451,7 +451,7 @@ public class NewMessage {
Utils.replyJSON(request, response, "{\"status\":\"ok\"}");
} else {
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
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 79128e3d..78dbff10 100644
--- a/juick-www/src/main/java/com/juick/www/PM.java
+++ b/juick-www/src/main/java/com/juick/www/PM.java
@@ -99,12 +99,12 @@ public class PM {
String body = request.getParameter("body");
if (uid == 0 || body == null || body.length() < 1 || body.length() > 10240) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
if (UserQueries.isInBLAny(sql, uid, visitor.getUid())) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
@@ -143,7 +143,7 @@ public class PM {
Utils.sendTemporaryRedirect(response, "/pm/sent");
} else {
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
diff --git a/juick-www/src/main/java/com/juick/www/RSS.java b/juick-www/src/main/java/com/juick/www/RSS.java
index 5218494d..a343d13b 100644
--- a/juick-www/src/main/java/com/juick/www/RSS.java
+++ b/juick-www/src/main/java/com/juick/www/RSS.java
@@ -44,7 +44,7 @@ public class RSS {
protected void doGet(JdbcTemplate sql, HttpServletResponse response, int uid) throws ServletException, IOException, PebbleException {
List<Integer> mids = MessagesQueries.getUserBlog(sql, uid, 0, 0);
if (mids.isEmpty()) {
- response.sendError(404);
+ response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
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 5c25564f..89eb6718 100644
--- a/juick-www/src/main/java/com/juick/www/Settings.java
+++ b/juick-www/src/main/java/com/juick/www/Settings.java
@@ -118,7 +118,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) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
List<String> pages = Arrays.asList("main", "password", "about", "email", "email-add", "email-del",
@@ -126,7 +126,7 @@ public class Settings {
"facebook-enable", "vk-del");
String page = request.getParameter("page");
if (StringUtils.isEmpty(page) || !pages.contains(page)) {
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
String result = "";
@@ -191,7 +191,7 @@ public class Settings {
result = String.format("<p>New secret email: <strong>%s@mail.juick.com</strong></p>" +
"<p><a href=\"/settings\">Back</a>.</p>", newHash);
} else {
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
break;
@@ -218,7 +218,7 @@ public class Settings {
} catch (MessagingException ex) {
logger.error("mail exception", ex);
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
}
@@ -277,7 +277,7 @@ public class Settings {
result = "<p><a href=\"/settings\">Back</a></p>";
break;
default:
- response.sendError(400);
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
response.setContentType("text/html; charset=UTF-8");
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 173ad7b7..5ea58eb3 100644
--- a/juick-www/src/main/java/com/juick/www/TwitterAuth.java
+++ b/juick-www/src/main/java/com/juick/www/TwitterAuth.java
@@ -49,7 +49,7 @@ public class TwitterAuth {
}
com.juick.User user = UserQueries.getUserByHash(sql, hash);
if ( user == null || user.getUid() == 0) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
OAuth10aService oAuthService = new ServiceBuilder()
@@ -79,7 +79,7 @@ public class TwitterAuth {
response.setStatus(HttpServletResponse.SC_FOUND);
response.setHeader("Location", "http://juick.com/settings");
} else {
- response.sendError(500);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
}
diff --git a/juick-www/src/main/java/com/juick/www/UserThread.java b/juick-www/src/main/java/com/juick/www/UserThread.java
index 394d6712..6355e87e 100644
--- a/juick-www/src/main/java/com/juick/www/UserThread.java
+++ b/juick-www/src/main/java/com/juick/www/UserThread.java
@@ -42,7 +42,7 @@ public class UserThread {
com.juick.User visitor = Utils.getVisitorUser(sql, request, response);
if (!MessagesQueries.canViewThread(sql, MID, visitor.getUid())) {
- response.sendError(403);
+ response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}