- int postCounter = 0;
- while (true) {
- String knownPostId = configuration.getStringValue(prefix + postCounter++ + "/ID").getValue(null);
- if (knownPostId == null) {
- break;
- }
- knownPosts.add(knownPostId);
+ allPostReplies.put(postReply.getId(), postReply);
+ postReplies.put(postReply.getPostId(), postReply);
+ } finally {
+ lock.writeLock().unlock();
+ }
+ }
+
+ /** {@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);
+ this.postReplies.put(postReply.getPostId(), postReply);