🔥 Replace NOT_EMPTY with Kotlin version
[Sone.git] / src / main / java / net / pterodactylus / sone / core / Core.java
index 18588a1..7a8f5df 100644 (file)
@@ -53,6 +53,7 @@ import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidPostFound;
 import net.pterodactylus.sone.core.ConfigurationSoneParser.InvalidPostReplyFound;
 import net.pterodactylus.sone.core.event.*;
 import net.pterodactylus.sone.data.Album;
+import net.pterodactylus.sone.data.AlbumsKt;
 import net.pterodactylus.sone.data.Client;
 import net.pterodactylus.sone.data.Image;
 import net.pterodactylus.sone.data.Post;
@@ -90,7 +91,6 @@ import net.pterodactylus.util.thread.NamedThreadFactory;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Stopwatch;
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimaps;
@@ -180,24 +180,10 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
        private final MetricRegistry metricRegistry;
        private final Histogram configurationSaveTimeHistogram;
 
-       /**
-        * Creates a new core.
-        *
-        * @param configuration
-        *            The configuration of the core
-        * @param freenetInterface
-        *            The freenet interface
-        * @param identityManager
-        *            The identity manager
-        * @param webOfTrustUpdater
-        *            The WebOfTrust updater
-        * @param eventBus
-        *            The event bus
-        * @param database
-        *            The database
-        */
+       private final SoneUriCreator soneUriCreator;
+
        @Inject
-       public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database, MetricRegistry metricRegistry) {
+       public Core(Configuration configuration, FreenetInterface freenetInterface, IdentityManager identityManager, SoneDownloader soneDownloader, ImageInserter imageInserter, UpdateChecker updateChecker, WebOfTrustUpdater webOfTrustUpdater, EventBus eventBus, Database database, MetricRegistry metricRegistry, SoneUriCreator soneUriCreator) {
                super("Sone Core");
                this.configuration = configuration;
                this.freenetInterface = freenetInterface;
@@ -209,6 +195,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                this.eventBus = eventBus;
                this.database = database;
                this.metricRegistry = metricRegistry;
+               this.soneUriCreator = soneUriCreator;
                preferences = new Preferences(eventBus);
                this.configurationSaveTimeHistogram = metricRegistry.histogram("configuration.save.duration", () -> new Histogram(new ExponentiallyDecayingReservoir(3000, 0)));
        }
@@ -626,7 +613,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                sone.setLatestEdition(fromNullable(tryParse(property)).or(0L));
                sone.setClient(new Client("Sone", SonePlugin.getPluginVersion()));
                sone.setKnown(true);
-               SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, metricRegistry, ownIdentity.getId());
+               SoneInserter soneInserter = new SoneInserter(this, eventBus, freenetInterface, metricRegistry, soneUriCreator, ownIdentity.getId());
                soneInserter.insertionDelayChanged(new InsertionDelayChangedEvent(preferences.getInsertionDelay()));
                eventBus.register(soneInserter);
                synchronized (soneInserters) {
@@ -1405,7 +1392,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                        configuration.getStringValue(sonePrefix + "/Likes/Reply/" + replyLikeCounter + "/ID").setValue(null);
 
                        /* save albums. first, collect in a flat structure, top-level first. */
-                       List<Album> albums = FluentIterable.from(sone.getRootAlbum().getAlbums()).transformAndConcat(Album.FLATTENER).toList();
+                       List<Album> albums = AlbumsKt.getAllAlbums(sone.getRootAlbum());
 
                        int albumCounter = 0;
                        for (Album album : albums) {