Create images using the core’s image builder.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 15 Sep 2014 16:23:56 +0000 (18:23 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 15 Sep 2014 16:23:56 +0000 (18:23 +0200)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java

index e1dbb4c..6d90516 100644 (file)
@@ -78,6 +78,7 @@ import net.pterodactylus.sone.data.TemporaryImage;
 import net.pterodactylus.sone.database.AlbumBuilder;
 import net.pterodactylus.sone.database.Database;
 import net.pterodactylus.sone.database.DatabaseException;
+import net.pterodactylus.sone.database.ImageBuilder;
 import net.pterodactylus.sone.database.PostBuilder;
 import net.pterodactylus.sone.database.PostProvider;
 import net.pterodactylus.sone.database.PostReplyBuilder;
@@ -610,6 +611,10 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                return database.getAlbum(albumId).orNull();
        }
 
+       public ImageBuilder imageBuilder() {
+               return database.newImageBuilder();
+       }
+
        /**
         * Returns the image with the given ID, creating it if necessary.
         *
index 1e1484d..e5ffaf9 100644 (file)
@@ -531,7 +531,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
                                                        logger.log(Level.WARNING, String.format("Downloaded Sone %s contains image %s with invalid dimensions (%s, %s)!", sone, imageId, imageWidthString, imageHeightString));
                                                        return null;
                                                }
-                                               Image image = core.getImage(imageId).modify().setSone(sone).setKey(imageKey).setCreationTime(creationTime).update();
+                                               Image image = core.imageBuilder().withId(imageId).build().modify().setSone(sone).setKey(imageKey).setCreationTime(creationTime).update();
                                                image = image.modify().setTitle(imageTitle).setDescription(imageDescription).update();
                                                image = image.modify().setWidth(imageWidth).setHeight(imageHeight).update();
                                                album.addImage(image);