From f41ac326f99f0dfb804b0d433656ae87e170c268 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 20 Oct 2013 02:31:56 +0200 Subject: [PATCH] Add database parameter to Sone parser. --- src/main/java/net/pterodactylus/sone/core/SoneDownloader.java | 2 +- src/main/java/net/pterodactylus/sone/core/SoneParser.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index ef6c10a..27348e1 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -207,7 +207,7 @@ public class SoneDownloader extends AbstractService { * if a parse error occurs, or the protocol is invalid */ public Sone parseSone(Sone originalSone, InputStream soneInputStream) throws SoneException { - return new SoneParser(core).parseSone(originalSone, soneInputStream); + return new SoneParser(core).parseSone(core.getDatabase(), originalSone, soneInputStream); } // diff --git a/src/main/java/net/pterodactylus/sone/core/SoneParser.java b/src/main/java/net/pterodactylus/sone/core/SoneParser.java index 63bba74..0ca508b 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneParser.java @@ -36,6 +36,7 @@ import net.pterodactylus.sone.data.PostReply; import net.pterodactylus.sone.data.Profile; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.impl.DefaultSone; +import net.pterodactylus.sone.database.Database; import net.pterodactylus.sone.database.ImageBuilder.ImageCreated; import net.pterodactylus.sone.database.PostBuilder; import net.pterodactylus.sone.database.PostBuilder.PostCreated; @@ -78,7 +79,7 @@ public class SoneParser { * @throws SoneException * if a parse error occurs, or the protocol is invalid */ - public Sone parseSone(Sone originalSone, InputStream soneInputStream) throws SoneException { + public Sone parseSone(Database database, Sone originalSone, InputStream soneInputStream) throws SoneException { /* TODO - impose a size limit? */ Document document; @@ -99,7 +100,7 @@ public class SoneParser { } Optional parsedClient = parseClient(originalSone, soneXml.get()); - Sone sone = new DefaultSone(new MemoryDatabase(null), originalSone.getId(), originalSone.isLocal(), parsedClient.or(originalSone.getClient())); + Sone sone = new DefaultSone(database, originalSone.getId(), originalSone.isLocal(), parsedClient.or(originalSone.getClient())); Optional protocolVersion = parseProtocolVersion(soneXml.get()); if (protocolVersion.isPresent()) { -- 2.7.4