From: David ‘Bombe’ Roden Date: Sun, 20 Oct 2013 00:31:56 +0000 (+0200) Subject: Add database parameter to Sone parser. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f41ac326f99f0dfb804b0d433656ae87e170c268;p=Sone.git Add database parameter to Sone parser. --- 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()) {