Add method to update the suggested edition on the insert and request URIs.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Oct 2010 16:06:28 +0000 (18:06 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Oct 2010 16:06:28 +0000 (18:06 +0200)
src/main/java/net/pterodactylus/sone/data/Sone.java

index 3baed89..8dcb442 100644 (file)
@@ -44,11 +44,11 @@ public class Sone {
        private final String name;
 
        /** The URI under which the Sone is stored in Freenet. */
-       private final FreenetURI requestUri;
+       private FreenetURI requestUri;
 
        /** The URI used to insert a new version of this Sone. */
        /* This will be null for remote Sones! */
-       private final FreenetURI insertUri;
+       private FreenetURI insertUri;
 
        /** The profile of this Sone. */
        private Profile profile;
@@ -307,6 +307,19 @@ public class Sone {
                this.modificationCounter = modificationCounter;
        }
 
+       /**
+        * Updates the suggested edition in both the request URI and the insert URI.
+        *
+        * @param requestUri
+        *            The request URI that resulted from an insert
+        */
+       public void updateUris(FreenetURI requestUri) {
+               /* TODO - check for the correct URI. */
+               long latestEdition = requestUri.getSuggestedEdition();
+               this.requestUri = this.requestUri.setSuggestedEdition(latestEdition);
+               this.insertUri = this.insertUri.setSuggestedEdition(latestEdition);
+       }
+
        //
        // OBJECT METHODS
        //