X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=20ff26cdc3467729072bc69622c78ad8cc40b343;hb=053f8bc95a7060af10687fcaedc5d8ff46f79d1b;hp=9f762231a6abf3b26fd7464e5a28113b46de872c;hpb=cd1004ddbcb1f2aa57ca8781ded6c56dd776ae21;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 9f76223..20ff26c 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -451,6 +451,15 @@ public class Core implements IdentityListener { soneInserter.start(); setSoneStatus(sone, SoneStatus.idle); loadSone(sone); + new Thread(new Runnable() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() { + soneDownloader.fetchSone(sone); + } + + }, "Sone Downloader").start(); return sone; } } @@ -486,7 +495,8 @@ public class Core implements IdentityListener { } synchronized (remoteSones) { final Sone sone = getRemoteSone(identity.getId()).setIdentity(identity); - sone.setRequestUri(getSoneUri(identity.getRequestUri(), identity.getProperty("Sone.LatestEdition"))); + sone.setRequestUri(getSoneUri(identity.getRequestUri())); + sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), (long) 0)); remoteSones.put(identity.getId(), sone); soneDownloader.addSone(sone); new Thread(new Runnable() { @@ -540,6 +550,7 @@ public class Core implements IdentityListener { storedSone.setLikePostIds(sone.getLikedPostIds()); storedSone.setLikeReplyIds(sone.getLikedReplyIds()); storedSone.setLatestEdition(sone.getRequestUri().getEdition()); + storedSone.setModificationCounter(0); } saveSone(storedSone); } @@ -569,7 +580,7 @@ public class Core implements IdentityListener { identityManager.removeContext((OwnIdentity) sone.getIdentity(), "Sone"); identityManager.removeProperty((OwnIdentity) sone.getIdentity(), "Sone.LatestEdition"); try { - configuration.getStringValue("Sone/" + sone.getId() + "/Time").setValue(null); + configuration.getLongValue("Sone/" + sone.getId() + "/Time").setValue(null); } catch (ConfigurationException ce1) { logger.log(Level.WARNING, "Could not remove Sone from configuration!", ce1); } @@ -592,7 +603,7 @@ public class Core implements IdentityListener { String sonePrefix = "Sone/" + sone.getId(); Long soneTime = configuration.getLongValue(sonePrefix + "/Time").getValue(null); if (soneTime == null) { - logger.log(Level.INFO, "Could not load Sone because there is no Sone has been saved."); + logger.log(Level.INFO, "Could not load Sone because no Sone has been saved."); return; } long soneModificationCounter = configuration.getLongValue(sonePrefix + "/ModificationCounter").getValue((long) 0); @@ -957,13 +968,11 @@ public class Core implements IdentityListener { * * @param uriString * The URI to derive the Sone URI from - * @param latestEditionString - * The latest edition as a {@link String}, or {@code null} * @return The derived URI */ - private FreenetURI getSoneUri(String uriString, String latestEditionString) { + private FreenetURI getSoneUri(String uriString) { try { - FreenetURI uri = new FreenetURI(uriString).setDocName("Sone").setMetaString(new String[0]).setSuggestedEdition(Numbers.safeParseLong(latestEditionString, (long) 0)); + FreenetURI uri = new FreenetURI(uriString).setDocName("Sone").setMetaString(new String[0]); return uri; } catch (MalformedURLException mue1) { logger.log(Level.WARNING, "Could not create Sone URI from URI: " + uriString, mue1); @@ -991,7 +1000,7 @@ public class Core implements IdentityListener { */ @Override public void ownIdentityRemoved(OwnIdentity ownIdentity) { - /* TODO */ + logger.log(Level.FINEST, "Removing OwnIdentity: " + ownIdentity); } /** @@ -1007,8 +1016,16 @@ public class Core implements IdentityListener { * {@inheritDoc} */ @Override - public void identityUpdated(Identity identity) { - /* TODO */ + public void identityUpdated(final Identity identity) { + new Thread(new Runnable() { + + @Override + @SuppressWarnings("synthetic-access") + public void run() { + Sone sone = getRemoteSone(identity.getId()); + soneDownloader.fetchSone(sone); + } + }).start(); } /**