From: David ‘Bombe’ Roden Date: Sun, 10 Apr 2011 18:12:50 +0000 (+0200) Subject: Add method to create an Image from a TemporaryImage. X-Git-Tag: beta-freefall-0.6.2-1~51 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ac9de2e1be671e598f01b29baf3f824df4eb087a;p=Sone.git Add method to create an Image from a TemporaryImage. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 09b0cbf..767309d 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1793,6 +1793,27 @@ public class Core implements IdentityListener, UpdateListener { } /** + * Creates a new image. + * + * @param sone + * The Sone creating the image + * @param album + * The album the image will be inserted into + * @param temporaryImage + * The temporary image to create the image from + * @return The newly created image + */ + public Image createImage(Sone sone, Album album, TemporaryImage temporaryImage) { + Validation.begin().isNotNull("Sone", sone).isNotNull("Album", album).isNotNull("Temporary Image", temporaryImage).check().is("Local Sone", isLocalSone(sone)).check().isEqual("Owner and Album Owner", sone, album.getSone()).check(); + Image image = new Image(temporaryImage.getId()).setSone(sone).setCreationTime(System.currentTimeMillis()); + album.addImage(image); + synchronized (images) { + images.put(image.getId(), image); + } + return image; + } + + /** * Creates a new temporary image. * * @param mimeType