From: David ‘Bombe’ Roden Date: Wed, 13 Apr 2011 03:54:37 +0000 (+0200) Subject: Add method to delete image. X-Git-Tag: beta-freefall-0.6.2-1~26 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=93bcc92cdf6a44b32ee7bd6ff6b48624ec9589d1;p=Sone.git Add method to delete image. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 7183063..91a04d3 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -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