From: David ‘Bombe’ Roden Date: Wed, 13 Apr 2011 03:54:19 +0000 (+0200) Subject: Add method to delete an album. X-Git-Tag: beta-freefall-0.6.2-1~28 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=3c255a88f7580334bb7941493a3be2ba08c82bfe Add method to delete an album. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index c30aef6..f8cee11 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1847,6 +1847,29 @@ public class Core implements IdentityListener, UpdateListener, ImageInsertListen } /** + * 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) { + Validation.begin().isNotNull("Album", album).check().is("Local Sone", isLocalSone(album.getSone())).check(); + if (!album.isEmpty()) { + return; + } + if (album.getParent() == null) { + album.getSone().removeAlbum(album); + } else { + album.getParent().removeAlbum(album); + } + synchronized (albums) { + albums.remove(album.getId()); + } + saveSone(album.getSone()); + } + + /** * Creates a new image. * * @param sone