Move all AJAX handlers to the same directory as the HTML handlers.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / ajax / DeleteReplyAjaxPage.java
index 75f4b5b..7614de8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - DeletePostAjaxPage.java - Copyright © 2010 David Roden
+ * Sone - DeleteReplysAjaxPage.java - Copyright © 2010 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@ public class DeleteReplyAjaxPage extends JsonPage {
         *            The Sone web interface
         */
        public DeleteReplyAjaxPage(WebInterface webInterface) {
-               super("ajax/deleteReply.ajax", webInterface);
+               super("deleteReply.ajax", webInterface);
        }
 
        //
@@ -49,19 +49,19 @@ public class DeleteReplyAjaxPage extends JsonPage {
        @Override
        protected JsonObject createJsonObject(Request request) {
                String replyId = request.getHttpRequest().getParam("reply");
-               Reply reply = webInterface.core().getReply(replyId);
+               Reply reply = webInterface.getCore().getReply(replyId);
                Sone currentSone = getCurrentSone(request.getToadletContext());
                if (reply == null) {
-                       return new JsonObject().put("success", false).put("error", "invalid-reply-id");
+                       return createErrorJsonObject("invalid-reply-id");
                }
                if (currentSone == null) {
-                       return new JsonObject().put("success", false).put("error", "auth-required");
+                       return createErrorJsonObject("auth-required");
                }
                if (!reply.getSone().equals(currentSone)) {
-                       return new JsonObject().put("success", false).put("error", "not-authorized");
+                       return createErrorJsonObject("not-authorized");
                }
-               webInterface.core().deleteReply(reply);
-               return new JsonObject().put("success", true);
+               webInterface.getCore().deleteReply(reply);
+               return createSuccessJsonObject();
        }
 
 }