X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneDownloader.java;h=b0805494b8aae26818ee8db0e8180f6dc67946ed;hb=ad0bc2de2393c76b47d849f6ae74e44faafefbb0;hp=7fc3a32f1510ad96baf652a0a61d439d4ce7864e;hpb=f9ec36b55750b14c7aec195e7f3ff092a570003d;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 7fc3a32..b080549 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -45,6 +45,7 @@ import net.pterodactylus.util.service.AbstractService; import net.pterodactylus.util.xml.SimpleXML; import net.pterodactylus.util.xml.XML; +import com.google.common.annotations.VisibleForTesting; import org.w3c.dom.Document; import freenet.client.FetchResult; @@ -105,18 +106,6 @@ public class SoneDownloader extends AbstractService { } /** - * Removes the given Sone from the downloader. - * - * @param sone - * The Sone to stop watching - */ - public void removeSone(Sone sone) { - if (sones.remove(sone)) { - freenetInterface.unregisterUsk(sone); - } - } - - /** * Fetches the updated Sone. This method is a callback method for * {@link FreenetInterface#registerUsk(Sone, SoneDownloader)}. * @@ -189,7 +178,7 @@ public class SoneDownloader extends AbstractService { * The requested URI * @return The parsed Sone, or {@code null} if the Sone could not be parsed */ - public Sone parseSone(Sone originalSone, FetchResult fetchResult, FreenetURI requestUri) { + private Sone parseSone(Sone originalSone, FetchResult fetchResult, FreenetURI requestUri) { logger.log(Level.FINEST, String.format("Parsing FetchResult (%d bytes, %s) for %s…", fetchResult.size(), fetchResult.getMimeType(), originalSone)); Bucket soneBucket = fetchResult.asBucket(); InputStream soneInputStream = null; @@ -226,7 +215,8 @@ public class SoneDownloader extends AbstractService { * @throws SoneException * if a parse error occurs, or the protocol is invalid */ - public Sone parseSone(Sone originalSone, InputStream soneInputStream) throws SoneException { + @VisibleForTesting + protected Sone parseSone(Sone originalSone, InputStream soneInputStream) throws SoneException { /* TODO - impose a size limit? */ Document document; @@ -342,7 +332,7 @@ public class SoneDownloader extends AbstractService { return null; } try { - profile.addField(fieldName).setValue(fieldValue); + profile.addField(fieldName.trim()).setValue(fieldValue); } catch (IllegalArgumentException iae1) { logger.log(Level.WARNING, String.format("Duplicate field: %s", fieldName), iae1); return null; @@ -449,7 +439,7 @@ public class SoneDownloader extends AbstractService { String title = albumXml.getValue("title", null); String description = albumXml.getValue("description", ""); String albumImageId = albumXml.getValue("album-image", null); - if ((id == null) || (title == null) || (description == null)) { + if ((id == null) || (title == null)) { logger.log(Level.WARNING, String.format("Downloaded Sone %s contains invalid album!", sone)); return null; }