Use static import for currentTimeMillis().
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneInserter.java
index 01e414d..59524b3 100644 (file)
@@ -18,6 +18,8 @@
 package net.pterodactylus.sone.core;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static java.lang.System.currentTimeMillis;
+import static net.pterodactylus.sone.data.Album.NOT_EMPTY;
 
 import java.io.InputStreamReader;
 import java.io.StringWriter;
@@ -190,14 +192,13 @@ public class SoneInserter extends AbstractService {
                long lastModificationTime = 0;
                String lastInsertedFingerprint = lastInsertFingerprint;
                String lastFingerprint = "";
-               Sone sone;
                while (!shouldStop()) {
                        try {
-                               /* check every seconds. */
+                               /* check every second. */
                                sleep(1000);
 
                                /* don’t insert locked Sones. */
-                               sone = this.sone;
+                               Sone sone = this.sone;
                                if (core.isLocked(sone)) {
                                        /* trigger redetection when the Sone is unlocked. */
                                        synchronized (sone) {
@@ -235,11 +236,11 @@ public class SoneInserter extends AbstractService {
                                        boolean success = false;
                                        try {
                                                sone.setStatus(SoneStatus.inserting);
-                                               long insertTime = System.currentTimeMillis();
+                                               long insertTime = currentTimeMillis();
                                                insertInformation.setTime(insertTime);
                                                eventBus.post(new SoneInsertingEvent(sone));
                                                FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri(), insertInformation.generateManifestEntries(), "index.html");
-                                               eventBus.post(new SoneInsertedEvent(sone, System.currentTimeMillis() - insertTime));
+                                               eventBus.post(new SoneInsertedEvent(sone, currentTimeMillis() - insertTime));
                                                /* at this point we might already be stopped. */
                                                if (shouldStop()) {
                                                        /* if so, bail out, don’t change anything. */
@@ -308,7 +309,7 @@ public class SoneInserter extends AbstractService {
                        soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies()));
                        soneProperties.put("likedPostIds", new HashSet<String>(sone.getLikedPostIds()));
                        soneProperties.put("likedReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
-                       soneProperties.put("albums", FluentIterable.from(sone.getAlbums()).transformAndConcat(Album.FLATTENER).toList());
+                       soneProperties.put("albums", FluentIterable.from(sone.getRootAlbum().getAlbums()).transformAndConcat(Album.FLATTENER).filter(NOT_EMPTY).toList());
                }
 
                //