+ public IdentityManager getIdentityManager() {
+ return identityManager;
+ }
+
+ /**
+ * Returns the status of the given Sone.
+ *
+ * @param sone
+ * The Sone to get the status for
+ * @return The status of the Sone
+ */
+ public SoneStatus getSoneStatus(Sone sone) {
+ synchronized (soneStatuses) {
+ return soneStatuses.get(sone);
+ }
+ }
+
+ /**
+ * Sets the status of the given Sone.
+ *
+ * @param sone
+ * The Sone to set the status of
+ * @param soneStatus
+ * The status to set
+ */
+ public void setSoneStatus(Sone sone, SoneStatus soneStatus) {
+ synchronized (soneStatuses) {
+ soneStatuses.put(sone, soneStatus);
+ }
+ }
+
+ /**
+ * Returns all Sones, remote and local.
+ *
+ * @return All Sones
+ */
+ public Set<Sone> getSones() {
+ Set<Sone> allSones = new HashSet<Sone>();
+ allSones.addAll(getLocalSones());
+ allSones.addAll(getRemoteSones());
+ return allSones;
+ }
+
+ /**
+ * Returns the Sone with the given ID, regardless whether it’s local or
+ * remote.
+ *
+ * @param id
+ * The ID of the Sone to get
+ * @return The Sone with the given ID, or {@code null} if there is no such
+ * Sone
+ */
+ public Sone getSone(String id) {
+ Sone sone = getRemoteSone(id);
+ if (sone != null) {
+ return sone;
+ }
+ sone = getLocalSone(id);
+ return sone;
+ }
+
+ /**
+ * Returns whether the given Sone is a local Sone.
+ *
+ * @param sone
+ * The Sone to check for its locality
+ * @return {@code true} if the given Sone is local, {@code false} otherwise
+ */
+ public boolean isLocalSone(Sone sone) {
+ synchronized (localSones) {
+ return localSones.containsKey(sone.getId());
+ }
+ }
+
+ /**
+ * Returns all local Sones.
+ *
+ * @return All local Sones
+ */
+ public Set<Sone> getLocalSones() {
+ synchronized (localSones) {
+ return new HashSet<Sone>(localSones.values());
+ }
+ }
+
+ /**
+ * Returns the local Sone with the given ID.
+ *
+ * @param id
+ * The ID of the Sone to get
+ * @return The Sone, or {@code null} if there is no Sone with the given ID
+ */
+ public Sone getLocalSone(String id) {
+ synchronized (localSones) {
+ return localSones.get(id);
+ }
+ }
+
+ /**
+ * Returns all remote Sones.
+ *
+ * @return All remote Sones
+ */
+ public Set<Sone> getRemoteSones() {
+ synchronized (remoteSones) {
+ return new HashSet<Sone>(remoteSones.values());
+ }
+ }
+
+ /**
+ * Returns the remote Sone with the given ID.
+ *
+ * @param id
+ * The ID of the remote Sone to get
+ * @return The Sone, or {@code null} if there is no such Sone
+ */
+ public Sone getRemoteSone(String id) {
+ synchronized (remoteSones) {
+ return remoteSones.get(id);
+ }
+ }
+
+ /**
+ * Returns whether the given Sone is a remote Sone.
+ *
+ * @param sone
+ * The Sone to check
+ * @return {@code true} if the given Sone is a remote Sone, {@code false}
+ * otherwise
+ */
+ public boolean isRemoteSone(Sone sone) {
+ synchronized (remoteSones) {
+ return remoteSones.containsKey(sone.getId());
+ }
+ }
+
+ /**
+ * Returns the post with the given ID.
+ *
+ * @param postId
+ * The ID of the post to get
+ * @return The post, or {@code null} if there is no such post
+ */
+ public Post getPost(String postId) {
+ synchronized (posts) {
+ return posts.get(postId);
+ }
+ }
+
+ /**
+ * Returns the reply with the given ID.
+ *
+ * @param replyId
+ * The ID of the reply to get
+ * @return The reply, or {@code null} if there is no such reply
+ */
+ public Reply getReply(String replyId) {
+ synchronized (replies) {
+ return replies.get(replyId);
+ }