public void storePostReply(PostReply postReply);
/**
- * Stores the given post replies as exclusive collection of post replies for
- * the given Sone. This will remove all other post replies from this Sone!
- *
- * @param sone
- * The Sone to store all post replies for
- * @param postReplies
- * The post replies of the Sone
- * @throws IllegalArgumentException
- * if one of the replies does not belong to the given Sone
- */
- public void storePostReplies(Sone sone, Collection<PostReply> postReplies) throws IllegalArgumentException;
-
- /**
* Removes the given post reply from this store.
*
* @param postReply
*/
public void removePostReply(PostReply postReply);
- /**
- * Removes all post replies of the given Sone.
- *
- * @param sone
- * The Sone to remove all post replies for
- */
- public void removePostReplies(Sone sone);
-
}
*/
public void removePost(Post post);
- /**
- * Stores the given posts as all posts of a single {@link Sone}. This method
- * will removed all other posts from the Sone!
- *
- * @param sone
- * The Sone to store the posts for
- * @param posts
- * The posts to store
- * @throws IllegalArgumentException
- * if posts do not all belong to the same Sone
- */
- public void storePosts(Sone sone, Collection<Post> posts) throws IllegalArgumentException;
-
- /**
- * Removes all posts of the given {@link Sone}
- *
- * @param sone
- * The Sone to remove all posts for
- */
- public void removePosts(Sone sone);
-
}
}
}
- /** {@inheritDocs} */
- @Override
- public void storePosts(Sone sone, Collection<Post> posts) throws IllegalArgumentException {
- checkNotNull(sone, "sone must not be null");
- /* verify that all posts are from the same Sone. */
- for (Post post : posts) {
- if (!sone.equals(post.getSone())) {
- throw new IllegalArgumentException(String.format("Post from different Sone found: %s", post));
- }
- }
-
- lock.writeLock().lock();
- try {
- /* remove all posts by the Sone. */
- Collection<Post> oldPosts = getPostsFrom(sone.getId());
- for (Post post : oldPosts) {
- allPosts.remove(post.getId());
- }
-
- /* add new posts. */
- getPostsFrom(sone.getId()).addAll(posts);
- for (Post post : posts) {
- allPosts.put(post.getId(), post);
- }
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- /** {@inheritDocs} */
- @Override
- public void removePosts(Sone sone) {
- checkNotNull(sone, "sone must not be null");
- lock.writeLock().lock();
- try {
- /* remove all posts by the Sone. */
- getPostsFrom(sone.getId()).clear();
- for (Post post : sone.getPosts()) {
- allPosts.remove(post.getId());
- }
- } finally {
- lock.writeLock().unlock();
- }
- }
-
//
// POSTREPLYPROVIDER METHODS
//
/** {@inheritDocs} */
@Override
- public void storePostReplies(Sone sone, Collection<PostReply> postReplies) {
- checkNotNull(sone, "sone must not be null");
- /* verify that all posts are from the same Sone. */
- for (PostReply postReply : postReplies) {
- if (!sone.equals(postReply.getSone())) {
- throw new IllegalArgumentException(String.format("PostReply from different Sone found: %s", postReply));
- }
- }
-
- lock.writeLock().lock();
- try {
- /* remove all post replies of the Sone. */
- for (PostReply postReply : getRepliesFrom(sone.getId())) {
- removePostReply(postReply);
- }
- for (PostReply postReply : postReplies) {
- allPostReplies.put(postReply.getId(), postReply);
- sonePostReplies.put(postReply.getSone().getId(), postReply);
- }
- } finally {
- lock.writeLock().unlock();
- }
- }
-
- /** {@inheritDocs} */
- @Override
public void removePostReply(PostReply postReply) {
lock.writeLock().lock();
try {
}
}
- /** {@inheritDocs} */
- @Override
- public void removePostReplies(Sone sone) {
- checkNotNull(sone, "sone must not be null");
-
- lock.writeLock().lock();
- try {
- for (PostReply postReply : sone.getReplies()) {
- removePostReply(postReply);
- }
- } finally {
- lock.writeLock().unlock();
- }
- }
-
//
// ALBUMPROVDER METHODS
//