Simplify album removal.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 2628127..e61a58f 100644 (file)
@@ -1224,7 +1224,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                                followSone(sone, friendId);
                        }
                        for (Album album : sone.getRootAlbum().getAlbums()) {
-                               sone.getRootAlbum().removeAlbum(album);
+                               album.remove();
                        }
                        soneInserters.get(sone).setLastInsertFingerprint(lastInsertFingerprint);
                }
@@ -1483,24 +1483,6 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
        }
 
        /**
-        * Deletes the given album. The owner of the album has to be a local Sone, and
-        * the album has to be {@link Album#isEmpty() empty} to be deleted.
-        *
-        * @param album
-        *              The album to remove
-        */
-       public void deleteAlbum(Album album) {
-               checkNotNull(album, "album must not be null");
-               checkArgument(album.getSone().isLocal(), "album’s Sone must be a local Sone");
-               if (!album.isEmpty()) {
-                       return;
-               }
-               album.getParent().removeAlbum(album);
-               database.removeAlbum(album);
-               touchConfiguration();
-       }
-
-       /**
         * Creates a new image.
         *
         * @param sone
@@ -1518,7 +1500,6 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                checkArgument(sone.isLocal(), "sone must be a local Sone");
                checkArgument(sone.equals(album.getSone()), "album must belong to the given Sone");
                Image image = album.newImageBuilder().withId(temporaryImage.getId()).createdNow().sized(temporaryImage.getWidth(), temporaryImage.getHeight()).build();
-               database.storeImage(image);
                imageInserter.insertImage(temporaryImage, image);
                return image;
        }
@@ -1535,8 +1516,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                checkNotNull(image, "image must not be null");
                checkArgument(image.getSone().isLocal(), "image must belong to a local Sone");
                deleteTemporaryImage(image.getId());
-               image.getAlbum().removeImage(image);
-               database.removeImage(image);
+               image.remove();
                touchConfiguration();
        }