aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/juick/http/www/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/juick/http/www/Main.java')
-rw-r--r--src/java/com/juick/http/www/Main.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/java/com/juick/http/www/Main.java b/src/java/com/juick/http/www/Main.java
index 226ac729..a41ccf9b 100644
--- a/src/java/com/juick/http/www/Main.java
+++ b/src/java/com/juick/http/www/Main.java
@@ -42,7 +42,6 @@ public class Main extends HttpServlet implements XmppListener {
Connection sqlSearch;
XmppConnection xmpp;
Blogs blogs;
- RootRedirects rootRedirects = new RootRedirects();
Login login = new Login();
Help help = new Help();
User pagesUser = new User();
@@ -122,6 +121,7 @@ public class Main extends HttpServlet implements XmppListener {
request.setCharacterEncoding("UTF-8");
}
String uri = request.getRequestURI();
+
if (uri.equals("/")) {
blogs.doGet(sql, sqlSearch, request, response);
} else if (uri.equals("/post")) {
@@ -150,9 +150,27 @@ public class Main extends HttpServlet implements XmppListener {
} else if (uri.startsWith("/places/")) {
blogs.doGet(sql, sqlSearch, request, response);
} else if (uri.matches("^/\\d+$")) {
- rootRedirects.doGetPostID(sql, request, response);
+ String strID = request.getRequestURI().substring(1);
+ int mid = 0;
+ try {
+ mid = Integer.parseInt(strID);
+ } catch (NumberFormatException e) {
+ }
+ if (mid > 0) {
+ com.juick.User author = com.juick.server.MessagesQueries.getMessageAuthor(sql, mid);
+ if (author != null) {
+ Utils.sendPermanentRedirect(response, "/" + author.UName + "/" + mid);
+ return;
+ }
+ }
+ response.sendError(404);
} else if (uri.matches("^/[^/]+$")) {
- rootRedirects.doGetUsername(sql, request, response);
+ com.juick.User user = com.juick.server.UserQueries.getUserByNick(sql, request.getRequestURI().substring(1));
+ if (user != null) {
+ Utils.sendPermanentRedirect(response, "/" + user.UName + "/");
+ } else {
+ response.sendError(404);
+ }
} else if (uri.matches("^/.+/.*")) {
String uriparts[] = uri.split("/");
com.juick.User user = com.juick.server.UserQueries.getUserByNick(sql, uriparts[1]);