X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=c861fd1bed6eb4d0ad66c988420b7e152a43beb8;hb=60882ec340d291f5e6a31aeb1fe9281dbe4efc9e;hp=6ecd5fccf61ee9a07a700d1b7665c74b14e938e5;hpb=a336f89f978670477463726eb6789134f225ae2f;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 6ecd5fc..c861fd1 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -330,6 +330,21 @@ public class Core extends AbstractService { * The request URI to load the Sone from */ public void loadSone(final String requestUri) { + loadSone(requestUri, null); + } + + /** + * Loads the Sone from the given request URI. The fetching of the data is + * performed in a new thread so this method returns immediately. If + * {@code insertUri} is not {@code null} the loaded Sone is converted into a + * local Sone and available using as any other local Sone. + * + * @param requestUri + * The request URI to load the Sone from + * @param insertUri + * The insert URI of the Sone + */ + public void loadSone(final String requestUri, final String insertUri) { new Thread(new Runnable() { @Override @@ -340,7 +355,12 @@ public class Core extends AbstractService { FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri); Sone parsedSone = soneDownloader.parseSone(null, fetchResult, realRequestUri); if (parsedSone != null) { - addSone(parsedSone); + if (insertUri != null) { + parsedSone.setInsertUri(new FreenetURI(insertUri)); + addLocalSone(parsedSone); + } else { + addSone(parsedSone); + } } } catch (MalformedURLException mue1) { logger.log(Level.INFO, "Could not create URI from “" + requestUri + "”.", mue1);