Merge branch 'release/0.9-rc1'
[Sone.git] / src / main / java / net / pterodactylus / sone / web / EditImagePage.java
index b0297a8..178add1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * FreenetSone - WebInterface.java - Copyright © 2010–2012 David Roden
+ * Sone - EditImagePage.java - Copyright © 2010–2013 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
@@ -60,21 +60,20 @@ public class EditImagePage extends SoneTemplatePage {
                        if (image == null) {
                                throw new RedirectException("invalid.html");
                        }
-                       if (!webInterface.getCore().isLocalSone(image.getSone())) {
+                       if (!image.getSone().isLocal()) {
                                throw new RedirectException("noPermission.html");
                        }
                        if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveLeft", 4))) {
                                image.getAlbum().moveImageUp(image);
-                       } else  if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveRight", 4))) {
+                       } else if ("true".equals(request.getHttpRequest().getPartAsStringFailsafe("moveRight", 4))) {
                                image.getAlbum().moveImageDown(image);
                        } else {
                                String title = request.getHttpRequest().getPartAsStringFailsafe("title", 100).trim();
                                String description = request.getHttpRequest().getPartAsStringFailsafe("description", 1024).trim();
                                if (title.length() == 0) {
-                                       templateContext.set("titleMissing", true);
+                                       throw new RedirectException("emptyImageTitle.html");
                                }
-                               image.setTitle(title);
-                               image.setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description));
+                               image.modify().setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).update();
                        }
                        webInterface.getCore().touchConfiguration();
                        throw new RedirectException(returnPage);