Parse client information from downloaded Sones.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Nov 2010 11:01:17 +0000 (12:01 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 14 Nov 2010 11:01:17 +0000 (12:01 +0100)
src/main/java/net/pterodactylus/sone/core/SoneDownloader.java

index 7133797..42f6702 100644 (file)
@@ -26,6 +26,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import net.pterodactylus.sone.core.Core.SoneStatus;
+import net.pterodactylus.sone.data.Client;
 import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.data.Profile;
 import net.pterodactylus.sone.data.Reply;
@@ -215,6 +216,17 @@ public class SoneDownloader extends AbstractService {
                        return null;
                }
 
+               SimpleXML clientXml = soneXml.getNode("client");
+               if (clientXml != null) {
+                       String clientName = clientXml.getValue("name", null);
+                       String clientVersion = clientXml.getValue("version", null);
+                       if ((clientName == null) || (clientVersion == null)) {
+                               logger.log(Level.WARNING, "Download Sone %s with client XML but missing name or version!", sone);
+                               return null;
+                       }
+                       sone.setClient(new Client(clientName, clientVersion));
+               }
+
                String soneRequestUri = soneXml.getValue("request-uri", null);
                if (soneRequestUri != null) {
                        try {