- * Returns whether the target Sone is trusted by the origin Sone.
- *
- * @param origin
- * The origin Sone
- * @param target
- * The target Sone
- * @return {@code true} if the target Sone is trusted by the origin Sone
- */
- public boolean isSoneTrusted(Sone origin, Sone target) {
- checkNotNull(origin, "origin must not be null");
- checkNotNull(target, "target must not be null");
- checkArgument(origin.getIdentity() instanceof OwnIdentity, "origin’s identity must be an OwnIdentity");
- return trustedIdentities.containsKey(origin.getIdentity()) && trustedIdentities.get(origin.getIdentity()).contains(target.getIdentity());
- }
-
- /**
- * Returns a post builder.
- *
- * @return A new post builder
- */
- public PostBuilder postBuilder() {
- return postBuilderFactory.newPostBuilder();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Post getPost(String postId) {
- synchronized (posts) {
- return posts.get(postId);
- }
- }
-
- /**
- * Returns all posts that have the given Sone as recipient.
- *
- * @see Post#getRecipient()
- * @param recipient
- * The recipient of the posts
- * @return All posts that have the given Sone as recipient
- */
- public Set<Post> getDirectedPosts(Sone recipient) {
- checkNotNull(recipient, "recipient must not be null");
- Set<Post> directedPosts = new HashSet<Post>();
- synchronized (posts) {
- for (Post post : posts.values()) {
- if (recipient.equals(post.getRecipient())) {
- directedPosts.add(post);
- }
- }
- }
- return directedPosts;
- }
-
- /**
- * Returns a post reply builder.
- *
- * @return A new post reply builder
- */
- public PostReplyBuilder postReplyBuilder() {
- return postReplyBuilderFactory.newPostReplyBuilder();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public PostReply getPostReply(String replyId) {
- synchronized (replies) {
- return replies.get(replyId);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<PostReply> getReplies(Post post) {
- Set<Sone> sones = getSones();
- List<PostReply> replies = new ArrayList<PostReply>();
- for (Sone sone : sones) {
- for (PostReply reply : sone.getReplies()) {
- if (reply.getPost().equals(post)) {
- replies.add(reply);
- }
- }
- }
- Collections.sort(replies, Reply.TIME_COMPARATOR);
- return replies;
- }
-
- /**