import net.pterodactylus.util.xml.SimpleXML;
import net.pterodactylus.util.xml.XML;
+import com.google.common.base.Optional;
import org.w3c.dom.Document;
/**
logger.log(Level.WARNING, String.format("Downloaded Sone %s contains invalid album!", sone));
return null;
}
- Album parent = null;
+ Optional<Album> parent = Optional.absent();
if (parentId != null) {
parent = core.getAlbum(parentId);
- if (parent == null) {
+ if (!parent.isPresent()) {
logger.log(Level.WARNING, String.format("Downloaded Sone %s has album with invalid parent!", sone));
return null;
}
.setTitle(title)
.setDescription(description)
.update();
- if (parent != null) {
- parent.addAlbum(album);
+ if (parent.isPresent()) {
+ parent.get().addAlbum(album);
} else {
topLevelAlbums.add(album);
}
}
/* okay, apparently everything was parsed correctly. Now import. */
- /* atomic setter operation on the Sone. */
- synchronized (sone) {
- sone.setProfile(profile);
- sone.setPosts(posts);
- sone.setReplies(replies);
- sone.setLikePostIds(likedPostIds);
- sone.setLikeReplyIds(likedReplyIds);
- for (Album album : topLevelAlbums) {
- sone.getRootAlbum().addAlbum(album);
- }
+ sone.setProfile(profile);
+ sone.setPosts(posts);
+ sone.setReplies(replies);
+ sone.setLikePostIds(likedPostIds);
+ sone.setLikeReplyIds(likedReplyIds);
+ for (Album album : topLevelAlbums) {
+ sone.getRootAlbum().addAlbum(album);
}
return sone;