Set client in Sone builder.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneParser.java
index 5851b18..0323796 100644 (file)
@@ -62,14 +62,13 @@ public class SoneParser {
                if (originalSone.isLocal()) {
                        soneBuilder = soneBuilder.local();
                }
-               Sone sone = soneBuilder.build();
 
                SimpleXML soneXml;
                try {
                        soneXml = SimpleXML.fromDocument(document);
                } catch (NullPointerException npe1) {
                        /* for some reason, invalid XML can cause NPEs. */
-                       logger.log(Level.WARNING, String.format("XML for Sone %s can not be parsed!", sone), npe1);
+                       logger.log(Level.WARNING, String.format("XML for Sone %s can not be parsed!", originalSone), npe1);
                        return null;
                }
 
@@ -97,14 +96,14 @@ public class SoneParser {
                String soneTime = soneXml.getValue("time", null);
                if (soneTime == null) {
                        /* TODO - mark Sone as bad. */
-                       logger.log(Level.WARNING, String.format("Downloaded time for Sone %s was null!", sone));
+                       logger.log(Level.WARNING, String.format("Downloaded time for Sone %s was null!", originalSone));
                        return null;
                }
                try {
-                       sone.setTime(Long.parseLong(soneTime));
+                       soneBuilder.lastUpdated(Long.parseLong(soneTime));
                } catch (NumberFormatException nfe1) {
                        /* TODO - mark Sone as bad. */
-                       logger.log(Level.WARNING, String.format("Downloaded Sone %s with invalid time: %s", sone, soneTime));
+                       logger.log(Level.WARNING, String.format("Downloaded Sone %s with invalid time: %s", originalSone, soneTime));
                        return null;
                }
 
@@ -113,11 +112,14 @@ public class SoneParser {
                        String clientName = clientXml.getValue("name", null);
                        String clientVersion = clientXml.getValue("version", null);
                        if ((clientName == null) || (clientVersion == null)) {
-                               logger.log(Level.WARNING, String.format("Download Sone %s with client XML but missing name or version!", sone));
+                               logger.log(Level.WARNING, String.format("Download Sone %s with client XML but missing name or version!", originalSone));
                                return null;
                        }
-                       sone.setClient(new Client(clientName, clientVersion));
+                       soneBuilder.using(new Client(clientName, clientVersion));
+               } else {
+                       soneBuilder.using(new Client("Unknown Client", "0.0"));
                }
+               Sone sone = soneBuilder.build();
 
                SimpleXML profileXml = soneXml.getNode("profile");
                if (profileXml == null) {