Store and parse replies in/from inserted Sone.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Oct 2010 11:24:14 +0000 (13:24 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 23 Oct 2010 11:24:14 +0000 (13:24 +0200)
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java
src/main/java/net/pterodactylus/sone/core/SoneInserter.java
src/main/resources/templates/insert/sone.xml

index 4923736..ac39291 100644 (file)
@@ -290,6 +290,20 @@ public class SoneDownloader extends AbstractService {
                                likedPostIds.add(postId);
                        }
 
+                       /* parse liked reply IDs. */
+                       SimpleXML likeReplyIdsXml = soneXml.getNode("reply-likes");
+                       if (likeReplyIdsXml == null) {
+                               /* TODO - mark Sone as bad. */
+                               logger.log(Level.WARNING, "Downloaded Sone %s has no reply likes!", new Object[] { sone });
+                               return null;
+                       }
+
+                       Set<String> likedReplyIds = new HashSet<String>();
+                       for (SimpleXML likedReplyIdXml : likeReplyIdsXml.getNodes("reply-like")) {
+                               String replyId = likedReplyIdXml.getValue();
+                               likedReplyIds.add(replyId);
+                       }
+
                        /* parse known Sones. */
                        SimpleXML knownSonesXml = soneXml.getNode("known-sones");
                        if (knownSonesXml == null) {
index 8c67a91..136c1e3 100644 (file)
@@ -183,6 +183,7 @@ public class SoneInserter extends AbstractService {
                        soneProperties.put("replies", new HashSet<Reply>(sone.getReplies()));
                        soneProperties.put("blockedSoneIds", new HashSet<String>(sone.getBlockedSoneIds()));
                        soneProperties.put("likedPostIds", new HashSet<String>(sone.getLikedPostIds()));
+                       soneProperties.put("likeReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
                }
 
                //
index 66032d5..229ac42 100644 (file)
                <%/foreach>
        </post-likes>
 
+       <reply-likes>
+               <%foreach currentSone.likedReplyIds replyId>
+               <reply-like><% replyId|xml></reply-like>
+               <%/foreach>
+       </reply-likes>
+
        <known-sones>
                <%foreach knownSones sone>
                <known-sone>