Create message digest in core and hash fetched URLs.
[arachne.git] / src / net / pterodactylus / arachne / core / Core.java
index 1061325..f6b050d 100644 (file)
@@ -5,6 +5,7 @@ package net.pterodactylus.arachne.core;
 
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Executor;
@@ -164,8 +165,14 @@ public class Core extends AbstractService {
                                logger.log(Level.INFO, "Skipping “" + nextPage + "”.");
                                continue;
                        }
-                       URLFetcher urlFetcher = new URLFetcher(this, nextURL);
-                       urlFetcherExecutor.execute(urlFetcher);
+                       URLFetcher urlFetcher;
+                       try {
+                               logger.log(Level.INFO, "Fetching “" + nextURL + "”...");
+                               urlFetcher = new URLFetcher(this, nextURL);
+                               urlFetcherExecutor.execute(urlFetcher);
+                       } catch (NoSuchAlgorithmException nsae1) {
+                               logger.log(Level.SEVERE, "Could not get “SHA-256” message digest!", nsae1);
+                       }
                }
        }
 
@@ -206,7 +213,7 @@ public class Core extends AbstractService {
         */
        private URL createURL(Page page) {
                try {
-                       return new URL("http://" + nodeHost + ":" + nodePort + "/");
+                       return new URL("http://" + nodeHost + ":" + nodePort + "/SSK@" + page.getEdition().getSite().getKey() + "/" + page.getEdition().getSite().getBasename() + "-" + page.getEdition().getNumber() + "/" + page.getPath());
                } catch (MalformedURLException mue1) {
                        /* nearly impossible. */
                }