} else {
soneBuilder.using(new Client("Unknown Client", "0.0"));
}
- Sone sone = soneBuilder.build();
SimpleXML profileXml = soneXml.getNode("profile");
if (profileXml == null) {
/* TODO - mark Sone as bad. */
- logger.log(Level.WARNING, String.format("Downloaded Sone %s has no profile!", sone));
+ logger.log(Level.WARNING, String.format("Downloaded Sone %s has no profile!", originalSone));
return null;
}
Integer profileBirthDay = parseInt(profileXml.getValue("birth-day", ""), null);
Integer profileBirthMonth = parseInt(profileXml.getValue("birth-month", ""), null);
Integer profileBirthYear = parseInt(profileXml.getValue("birth-year", ""), null);
- Profile profile = new Profile(sone).setFirstName(profileFirstName).setMiddleName(profileMiddleName).setLastName(profileLastName);
+ Profile profile = new Profile(originalSone).setFirstName(profileFirstName).setMiddleName(profileMiddleName).setLastName(profileLastName);
profile.setBirthDay(profileBirthDay).setBirthMonth(profileBirthMonth).setBirthYear(profileBirthYear);
/* avatar is processed after images are loaded. */
String avatarId = profileXml.getValue("avatar", null);
String fieldName = fieldXml.getValue("field-name", null);
String fieldValue = fieldXml.getValue("field-value", "");
if (fieldName == null) {
- logger.log(Level.WARNING, String.format("Downloaded profile field for Sone %s with missing data! Name: %s, Value: %s", sone, fieldName, fieldValue));
+ logger.log(Level.WARNING, String.format("Downloaded profile field for Sone %s with missing data! Name: %s, Value: %s", originalSone, fieldName, fieldValue));
return null;
}
try {
/* parse posts. */
SimpleXML postsXml = soneXml.getNode("posts");
- Set<Post> posts = new HashSet<Post>();
if (postsXml == null) {
/* TODO - mark Sone as bad. */
- logger.log(Level.WARNING, String.format("Downloaded Sone %s has no posts!", sone));
+ logger.log(Level.WARNING, String.format("Downloaded Sone %s has no posts!", originalSone));
} else {
+ Set<Post> posts = new HashSet<Post>();
for (SimpleXML postXml : postsXml.getNodes("post")) {
String postId = postXml.getValue("id", null);
String postRecipientId = postXml.getValue("recipient", null);
String postText = postXml.getValue("text", null);
if ((postId == null) || (postTime == null) || (postText == null)) {
/* TODO - mark Sone as bad. */
- logger.log(Level.WARNING, String.format("Downloaded post for Sone %s with missing data! ID: %s, Time: %s, Text: %s", sone, postId, postTime, postText));
+ logger.log(Level.WARNING, String.format("Downloaded post for Sone %s with missing data! ID: %s, Time: %s, Text: %s", originalSone, postId, postTime, postText));
return null;
}
try {
PostBuilder postBuilder = core.postBuilder();
/* TODO - parse time correctly. */
- postBuilder.withId(postId).from(sone.getId()).withTime(Long.parseLong(postTime)).withText(postText);
+ postBuilder.withId(postId).from(originalSone.getId()).withTime(Long.parseLong(postTime)).withText(postText);
if ((postRecipientId != null) && (postRecipientId.length() == 43)) {
postBuilder.to(postRecipientId);
}
posts.add(postBuilder.build());
} catch (NumberFormatException nfe1) {
/* TODO - mark Sone as bad. */
- logger.log(Level.WARNING, String.format("Downloaded post for Sone %s with invalid time: %s", sone, postTime));
+ logger.log(Level.WARNING, String.format("Downloaded post for Sone %s with invalid time: %s", originalSone, postTime));
return null;
}
}
+ soneBuilder.withPosts(posts);
}
+ Sone sone = soneBuilder.build();
/* parse replies. */
SimpleXML repliesXml = soneXml.getNode("replies");
/* atomic setter operation on the Sone. */
synchronized (sone) {
sone.setProfile(profile);
- sone.setPosts(posts);
sone.setReplies(replies);
sone.setLikePostIds(likedPostIds);
sone.setLikeReplyIds(likedReplyIds);