From bf6da11210fb439f2cdc8fcb8755589d04b4db3b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 23 Oct 2010 13:24:14 +0200 Subject: [PATCH] Store and parse replies in/from inserted Sone. --- .../java/net/pterodactylus/sone/core/SoneDownloader.java | 14 ++++++++++++++ .../java/net/pterodactylus/sone/core/SoneInserter.java | 1 + src/main/resources/templates/insert/sone.xml | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java index 4923736..ac39291 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloader.java @@ -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 likedReplyIds = new HashSet(); + 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) { diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index 8c67a91..136c1e3 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -183,6 +183,7 @@ public class SoneInserter extends AbstractService { soneProperties.put("replies", new HashSet(sone.getReplies())); soneProperties.put("blockedSoneIds", new HashSet(sone.getBlockedSoneIds())); soneProperties.put("likedPostIds", new HashSet(sone.getLikedPostIds())); + soneProperties.put("likeReplyIds", new HashSet(sone.getLikedReplyIds())); } // diff --git a/src/main/resources/templates/insert/sone.xml b/src/main/resources/templates/insert/sone.xml index 66032d5..229ac42 100644 --- a/src/main/resources/templates/insert/sone.xml +++ b/src/main/resources/templates/insert/sone.xml @@ -38,6 +38,12 @@ <%/foreach> + + <%foreach currentSone.likedReplyIds replyId> + <% replyId|xml> + <%/foreach> + + <%foreach knownSones sone> -- 2.7.4