Add possibility to change album image.
[Sone.git] / src / main / java / net / pterodactylus / sone / web / EditAlbumPage.java
index c3c2525..fd4bf7c 100644 (file)
@@ -24,17 +24,19 @@ import net.pterodactylus.util.template.TemplateContext;
 import net.pterodactylus.util.web.Method;
 
 /**
- * TODO
+ * Page that lets the user edit the name and description of an album.
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
 public class EditAlbumPage extends SoneTemplatePage {
 
        /**
-        * TODO
+        * Creates a new “edit album” page.
         *
         * @param template
+        *            The template to render
         * @param webInterface
+        *            The Sone web interface
         */
        public EditAlbumPage(Template template, WebInterface webInterface) {
                super("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, true);
@@ -55,6 +57,11 @@ public class EditAlbumPage extends SoneTemplatePage {
                        if (!webInterface.getCore().isLocalSone(album.getSone())) {
                                throw new RedirectException("noPermission.html");
                        }
+                       String albumImageId = request.getHttpRequest().getPartAsStringFailsafe("album-image", 36);
+                       if (webInterface.getCore().getImage(albumImageId, false) == null) {
+                               albumImageId = null;
+                       }
+                       album.setAlbumImage(albumImageId);
                        String title = request.getHttpRequest().getPartAsStringFailsafe("title", 100).trim();
                        if (title.length() == 0) {
                                templateContext.set("titleMissing", true);