Rename fetch action methods
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneDownloaderImpl.java
index ff0eaf7..9f0559c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Sone - SoneDownloader.java - Copyright © 2010–2013 David Roden
+ * Sone - SoneDownloaderImpl.java - Copyright © 2010–2016 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -29,6 +29,8 @@ import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.inject.Inject;
+
 import net.pterodactylus.sone.core.FreenetInterface.Fetched;
 import net.pterodactylus.sone.data.Sone;
 import net.pterodactylus.sone.data.Sone.SoneStatus;
@@ -41,8 +43,6 @@ import freenet.keys.FreenetURI;
 import freenet.keys.USK;
 import freenet.node.RequestStarter;
 import freenet.support.api.Bucket;
-import freenet.support.io.Closer;
-import com.db4o.ObjectContainer;
 
 import com.google.common.annotations.VisibleForTesting;
 
@@ -54,7 +54,7 @@ import com.google.common.annotations.VisibleForTesting;
 public class SoneDownloaderImpl extends AbstractService implements SoneDownloader {
 
        /** The logger. */
-       private static final Logger logger = getLogger("Sone.Downloader");
+       private static final Logger logger = getLogger(SoneDownloaderImpl.class.getName());
 
        /** The maximum protocol version. */
        private static final int MAX_PROTOCOL_VERSION = 0;
@@ -77,6 +77,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
         * @param freenetInterface
         *              The Freenet interface
         */
+       @Inject
        public SoneDownloaderImpl(Core core, FreenetInterface freenetInterface) {
                this(core, freenetInterface, new SoneParser(core));
        }
@@ -118,7 +119,6 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
                        @Override
                        @SuppressWarnings("synthetic-access")
                        public void onFoundEdition(long edition, USK key,
-                                       ObjectContainer objectContainer,
                                        ClientContext clientContext, boolean metadata,
                                        short codec, byte[] data, boolean newKnownGood,
                                        boolean newSlotToo) {
@@ -127,7 +127,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
                                                sone, key, newKnownGood, newSlotToo));
                                if (edition > sone.getLatestEdition()) {
                                        sone.setLatestEdition(edition);
-                                       new Thread(fetchSoneAction(sone),
+                                       new Thread(fetchSoneAsSskAction(sone),
                                                        "Sone Downloader").start();
                                }
                        }
@@ -155,22 +155,8 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
                return (currentTimeMillis() - sone.getTime()) < DAYS.toMillis(7);
        }
 
-       private void fetchSone(Sone sone) {
-               fetchSone(sone, sone.getRequestUri().sskForUSK());
-       }
-
-       /**
-        * Fetches the updated Sone. This method can be used to fetch a Sone from a
-        * specific URI.
-        *
-        * @param sone
-        *              The Sone to fetch
-        * @param soneUri
-        *              The URI to fetch the Sone from
-        */
-       @Override
-       public void fetchSone(Sone sone, FreenetURI soneUri) {
-               fetchSone(sone, soneUri, false);
+       private void fetchSoneAsSsk(Sone sone) {
+               fetchSone(sone, sone.getRequestUri().sskForUSK(), false);
        }
 
        /**
@@ -245,21 +231,21 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade
        }
 
        @Override
-       public Runnable fetchSoneWithUriAction(final Sone sone) {
+       public Runnable fetchSoneAsUskAction(final Sone sone) {
                return new Runnable() {
                        @Override
                        public void run() {
-                               fetchSone(sone, sone.getRequestUri());
+                               fetchSone(sone, sone.getRequestUri(), false);
                        }
                };
        }
 
        @Override
-       public Runnable fetchSoneAction(final Sone sone) {
+       public Runnable fetchSoneAsSskAction(final Sone sone) {
                return new Runnable() {
                        @Override
                        public void run() {
-                               fetchSone(sone);
+                               fetchSoneAsSsk(sone);
                        }
                };
        }