X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FSoneInserter.java;h=35910ebebcef0305b331b779ad4481829b9de910;hp=05e36008a11ae686b69bf43dcd1b9f783202031d;hb=e675a2814d586e899ff070f8045c59f295304fc3;hpb=b29cf0908e6dfd2b55220a3a7e44200f2fe5b19e diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 05e3600..35910eb 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -21,11 +21,9 @@ import java.io.InputStreamReader; import java.io.StringWriter; import java.nio.charset.Charset; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -34,8 +32,6 @@ import net.pterodactylus.sone.data.Post; import net.pterodactylus.sone.data.Reply; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.freenet.StringBucket; -import net.pterodactylus.util.filter.Filter; -import net.pterodactylus.util.filter.Filters; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.logging.Logging; import net.pterodactylus.util.service.AbstractService; @@ -147,7 +143,7 @@ public class SoneInserter extends AbstractService { try { core.setSoneStatus(sone, SoneStatus.inserting); FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri().setKeyType("USK").setSuggestedEdition(0), insertInformation.generateManifestEntries(), "index.html"); - sone.updateUris(finalUri.getEdition()); + sone.setLatestEdition(finalUri.getEdition()); success = true; logger.log(Level.INFO, "Inserted Sone “%s” at %s.", new Object[] { sone.getName(), finalUri }); } catch (SoneException se1) { @@ -165,6 +161,7 @@ public class SoneInserter extends AbstractService { if (sone.getModificationCounter() == modificationCounter) { logger.log(Level.FINE, "Sone “%s” was not modified further, resetting counter…", new Object[] { sone }); sone.setModificationCounter(0); + core.saveSone(sone); modificationCounter = 0; lastModificationTime = 0; } @@ -201,7 +198,6 @@ public class SoneInserter extends AbstractService { soneProperties.put("profile", sone.getProfile()); soneProperties.put("posts", new ArrayList(sone.getPosts())); soneProperties.put("replies", new HashSet(sone.getReplies())); - soneProperties.put("blockedSoneIds", new HashSet(sone.getBlockedSoneIds())); soneProperties.put("likedPostIds", new HashSet(sone.getLikedPostIds())); soneProperties.put("likeReplyIds", new HashSet(sone.getLikedReplyIds())); } @@ -267,21 +263,8 @@ public class SoneInserter extends AbstractService { } finally { Closer.close(templateInputStreamReader); } - @SuppressWarnings("unchecked") - final Set blockedSoneIds = (Set) soneProperties.get("blockedSoneIds"); - Collection knownSones = Filters.filteredCollection(core.getKnownSones(), new Filter() { - - /** - * {@inheritDoc} - */ - @Override - public boolean filterObject(Sone object) { - return !blockedSoneIds.contains(object.getId()) && !object.getId().equals(soneProperties.get("id")); - } - }); template.set("currentSone", soneProperties); - template.set("knownSones", knownSones); StringWriter writer = new StringWriter(); StringBucket bucket = null; try {