Store request URI in yet unknown Sones when parsing.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index eb517fc..b838216 100644 (file)
@@ -19,6 +19,7 @@ package net.pterodactylus.sone.core;
 
 import java.net.MalformedURLException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
@@ -141,6 +142,15 @@ public class Core extends AbstractService {
        }
 
        /**
+        * Returns all known sones.
+        *
+        * @return All known sones
+        */
+       public Collection<Sone> getKnownSones() {
+               return soneCache.values();
+       }
+
+       /**
         * Creates a new post.
         *
         * @param sone
@@ -216,6 +226,7 @@ public class Core extends AbstractService {
         *            The Sone to watch for updates
         */
        public void addSone(Sone sone) {
+               soneCache.put(sone.getId(), sone);
                soneDownloader.addSone(sone);
        }
 
@@ -299,8 +310,9 @@ public class Core extends AbstractService {
         */
        public void loadSone(String requestUri) {
                try {
-                       FetchResult fetchResult = freenetInterface.fetchUri(new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" }));
-                       soneDownloader.parseSone(null, fetchResult);
+                       FreenetURI realRequestUri = new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" });
+                       FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri);
+                       soneDownloader.parseSone(null, fetchResult, realRequestUri);
                } catch (MalformedURLException mue1) {
                        logger.log(Level.INFO, "Could not create URI from “" + requestUri + "”.", mue1);
                }