X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fcore%2FCore.java;h=89867f4e5234e2b09c7799e0dac23558334a9662;hp=26d21edae4ad35fb4fea259cde68502d1aaa05c7;hb=cd2ec98ba1ec7c66342dbb50ad2876572d953591;hpb=c9e306ac8e3ada846e87a0cc256a20fc148f381c diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 26d21ed..89867f4 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -1,5 +1,5 @@ /* - * Sone - Core.java - Copyright © 2010 David Roden + * Sone - Core.java - Copyright © 2010–2012 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 @@ -46,6 +46,7 @@ import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.Sone.ShowCustomAvatars; import net.pterodactylus.sone.data.Sone.SoneStatus; import net.pterodactylus.sone.data.TemporaryImage; +import net.pterodactylus.sone.data.impl.PostImpl; import net.pterodactylus.sone.fcp.FcpInterface; import net.pterodactylus.sone.fcp.FcpInterface.FullAccessRequired; import net.pterodactylus.sone.freenet.wot.Identity; @@ -131,45 +132,45 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis /** All local Sones. */ /* synchronize access on this on itself. */ - private Map localSones = new HashMap(); + private final Map localSones = new HashMap(); /** All remote Sones. */ /* synchronize access on this on itself. */ - private Map remoteSones = new HashMap(); + private final Map remoteSones = new HashMap(); /** All known Sones. */ - private Set knownSones = new HashSet(); + private final Set knownSones = new HashSet(); /** All posts. */ - private Map posts = new HashMap(); + private final Map posts = new HashMap(); /** All known posts. */ - private Set knownPosts = new HashSet(); + private final Set knownPosts = new HashSet(); /** All replies. */ - private Map replies = new HashMap(); + private final Map replies = new HashMap(); /** All known replies. */ - private Set knownReplies = new HashSet(); + private final Set knownReplies = new HashSet(); /** All bookmarked posts. */ /* synchronize access on itself. */ - private Set bookmarkedPosts = new HashSet(); + private final Set bookmarkedPosts = new HashSet(); /** Trusted identities, sorted by own identities. */ - private Map> trustedIdentities = Collections.synchronizedMap(new HashMap>()); + private final Map> trustedIdentities = Collections.synchronizedMap(new HashMap>()); /** All known albums. */ - private Map albums = new HashMap(); + private final Map albums = new HashMap(); /** All known images. */ - private Map images = new HashMap(); + private final Map images = new HashMap(); /** All temporary images. */ - private Map temporaryImages = new HashMap(); + private final Map temporaryImages = new HashMap(); /** Ticker for threads that mark own elements as known. */ - private Ticker localElementTicker = new Ticker(); + private final Ticker localElementTicker = new Ticker(); /** The time the configuration was last touched. */ private volatile long lastConfigurationUpdate; @@ -561,7 +562,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis synchronized (posts) { Post post = posts.get(postId); if ((post == null) && create) { - post = new Post(postId); + post = new PostImpl(postId); posts.put(postId, post); } return post; @@ -1456,7 +1457,9 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis } parentAlbum.addAlbum(album); } else { - topLevelAlbums.add(album); + if (!topLevelAlbums.contains(album)) { + topLevelAlbums.add(album); + } } } @@ -1597,7 +1600,7 @@ public class Core extends AbstractService implements IdentityListener, UpdateLis logger.log(Level.FINE, String.format("Tried to create post for non-local Sone: %s", sone)); return null; } - final Post post = new Post(sone, time, text); + final Post post = new PostImpl(sone, time, text); if (recipient != null) { post.setRecipient(recipient); }