Add method to delete image.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 13 Apr 2011 03:54:37 +0000 (05:54 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 13 Apr 2011 04:41:06 +0000 (06:41 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java

index 7183063..91a04d3 100644 (file)
@@ -1892,6 +1892,24 @@ public class Core implements IdentityListener, UpdateListener, ImageInsertListen
        }
 
        /**
+        * Deletes the given image. This method will also delete a matching
+        * temporary image.
+        *
+        * @see #deleteTemporaryImage(TemporaryImage)
+        * @param image
+        *            The image to delete
+        */
+       public void deleteImage(Image image) {
+               Validation.begin().isNotNull("Image", image).check().is("Local Sone", isLocalSone(image.getSone())).check();
+               image.getAlbum().removeImage(image);
+               synchronized (images) {
+                       images.remove(image.getId());
+               }
+               deleteTemporaryImage(image.getId());
+               saveSone(image.getSone());
+       }
+
+       /**
         * Creates a new temporary image.
         *
         * @param mimeType