X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneDownloader.java;h=c5f4816203af692e92375444c3a5a7499df3ac22;hb=3cb9b01a360dbdb51512ae0055056167988b9ff3;hp=13154a088d17b2e8f89d56dde50addaa7e33cd27;hpb=52d670f5e47eb7417a5a82662416beeb39c9a774;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 13154a0..c5f4816 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -147,7 +147,7 @@ public class SoneDownloader extends AbstractService { * @return The parsed Sone, or {@code null} if the Sone could not be parsed */ public Sone parseSone(Sone originalSone, FetchResult fetchResult, FreenetURI requestUri) { - logger.log(Level.FINEST, "Persing FetchResult (%d bytes, %s) for %s…", new Object[] { fetchResult.size(), fetchResult.getMimeType(), originalSone }); + logger.log(Level.FINEST, "Parsing FetchResult (%d bytes, %s) for %s…", new Object[] { fetchResult.size(), fetchResult.getMimeType(), originalSone }); Bucket soneBucket = fetchResult.asBucket(); InputStream soneInputStream = null; try { @@ -167,16 +167,16 @@ public class SoneDownloader extends AbstractService { } /** - * Parses a Sone from the given input stream and updates the given Sone, or - * creates a new Sone. + * Parses a Sone from the given input stream and creates a new Sone from the + * parsed data. * - * @param sone + * @param originalSone * The Sone to update * @param soneInputStream * The input stream to parse the Sone from * @return The parsed Sone */ - public Sone parseSone(Sone sone, InputStream soneInputStream) { + public Sone parseSone(Sone originalSone, InputStream soneInputStream) { /* TODO - impose a size limit? */ Document document; @@ -186,9 +186,12 @@ public class SoneDownloader extends AbstractService { } if (document == null) { /* TODO - mark Sone as bad. */ - logger.log(Level.WARNING, "Could not parse XML for Sone %s!", new Object[] { sone }); + logger.log(Level.WARNING, "Could not parse XML for Sone %s!", new Object[] { originalSone }); return null; } + + Sone sone = new Sone(originalSone.getId()).setIdentity(originalSone.getIdentity()); + SimpleXML soneXml; try { soneXml = SimpleXML.fromDocument(document);