Set URIs and latest edition differently.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 2 Nov 2010 20:38:57 +0000 (21:38 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 2 Nov 2010 20:38:57 +0000 (21:38 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java

index b929c23..e39644d 100644 (file)
@@ -407,8 +407,14 @@ public class Core implements IdentityListener {
                                logger.log(Level.FINE, "Tried to add known local Sone: %s", ownIdentity);
                                return localSones.get(ownIdentity.getId());
                        }
-                       String latestEdition = ownIdentity.getProperty("Sone.LatestEdition");
-                       final Sone sone = new Sone(ownIdentity).setInsertUri(getSoneUri(ownIdentity.getInsertUri(), latestEdition)).setRequestUri(getSoneUri(ownIdentity.getRequestUri(), latestEdition));
+                       final Sone sone;
+                       try {
+                               sone = new Sone(ownIdentity).setInsertUri(new FreenetURI(ownIdentity.getInsertUri())).setRequestUri(new FreenetURI(ownIdentity.getRequestUri()));
+                               sone.setLatestEdition(Numbers.safeParseLong(ownIdentity.getProperty("Sone.LatestEdition"), (long) 0));
+                       } catch (MalformedURLException mue1) {
+                               logger.log(Level.SEVERE, "Could not convert the Identity’s URIs to Freenet URIs: " + ownIdentity.getInsertUri() + ", " + ownIdentity.getRequestUri(), mue1);
+                               return null;
+                       }
                        /* TODO - load posts ’n stuff */
                        localSones.put(ownIdentity.getId(), sone);
                        SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone);