X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=6bfa5cd983c441e164d29f2c4d6c148aaac84df2;hb=4b3a99603aaa202c325bb3c4c54fc58e414d6b83;hp=ccd5aff17607720a21f8d1036190db23dfba048b;hpb=fb6621f7a25478c3e31a7485397371cbb63c2db8;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 ccd5aff..6bfa5cd 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -303,18 +303,30 @@ public class Core extends AbstractService { } /** - * Loads the Sone from the given request URI. + * Loads the Sone from the given request URI. The fetching of the data is + * performed in a new thread so this method returns immediately. * * @param requestUri * The request URI to load the Sone from */ - public void loadSone(String requestUri) { - try { - FetchResult fetchResult = freenetInterface.fetchUri(new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" })); - soneDownloader.parseSone(null, fetchResult); - } catch (MalformedURLException mue1) { - logger.log(Level.INFO, "Could not create URI from “" + requestUri + "”.", mue1); - } + public void loadSone(final String requestUri) { + new Thread(new Runnable() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() { + try { + FreenetURI realRequestUri = new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" }); + FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri); + Sone parsedSone = soneDownloader.parseSone(null, fetchResult, realRequestUri); + if (parsedSone != null) { + addSone(parsedSone); + } + } catch (MalformedURLException mue1) { + logger.log(Level.INFO, "Could not create URI from “" + requestUri + "”.", mue1); + } + } + }, "Sone Downloader").start(); } /** @@ -482,7 +494,7 @@ public class Core extends AbstractService { String friendKey = configuration.getStringValue(friendPrefix + "/Key").getValue(null); String friendName = configuration.getStringValue(friendPrefix + "/Name").getValue(null); friendSone.setRequestUri(new FreenetURI(friendKey)).setName(friendName); - soneDownloader.addSone(friendSone); + loadSone(friendKey); sone.addFriend(friendSone); }