From: David ‘Bombe’ Roden Date: Mon, 15 Sep 2014 16:23:56 +0000 (+0200) Subject: Create images using the core’s image builder. X-Git-Tag: 0.9-rc1^2~3^2~126 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=92737bf9d3c70eaa015434ae714a67995df4f6d4;p=Sone.git Create images using the core’s image builder. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index e1dbb4c..6d90516 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -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. * diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java index 1e1484d..e5ffaf9 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java @@ -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);