synchronized (bookmarkedPosts) {
for (String bookmarkedPostId : bookmarkedPosts) {
Optional<Post> post = getPost(bookmarkedPostId);
- if (!post.isPresent()) {
+ if (post.isPresent()) {
posts.add(post.get());
}
}
logger.log(Level.WARNING, "Given OwnIdentity is null!");
return null;
}
+ logger.info(String.format("Adding Sone from OwnIdentity: %s", ownIdentity));
synchronized (sones) {
final Sone sone;
try {
database.storePostReplies(sone, sone.getReplies());
synchronized (albums) {
synchronized (images) {
- for (Album album : storedSone.get().getAlbums()) {
+ for (Album album : storedSone.get().getRootAlbum().getAlbums()) {
albums.remove(album.getId());
for (Image image : album.getImages()) {
images.remove(image.getId());
}
}
- for (Album album : sone.getAlbums()) {
+ for (Album album : sone.getRootAlbum().getAlbums()) {
albums.put(album.getId(), album);
for (Image image : album.getImages()) {
images.put(image.getId(), image);
}
synchronized (sones) {
sone.setOptions(storedSone.get().getOptions());
+ sone.setKnown(storedSone.get().isKnown());
+ sone.setStatus((sone.getTime() == 0) ? SoneStatus.unknown : SoneStatus.idle);
+ if (sone.isLocal()) {
+ soneInserters.get(storedSone.get()).setSone(sone);
+ touchConfiguration();
+ }
sones.put(sone.getId(), sone);
}
}
logger.log(Level.FINE, String.format("Tried to load non-local Sone: %s", sone));
return;
}
+ logger.info(String.format("Loading local Sone: %s", sone));
/* initialize options. */
sone.getOptions().addBooleanOption("AutoFollow", new DefaultOption<Boolean>(false));
for (String friendId : friends) {
followSone(sone, friendId);
}
- sone.setAlbums(topLevelAlbums);
+ for (Album album : sone.getRootAlbum().getAlbums()) {
+ sone.getRootAlbum().removeAlbum(album);
+ }
+ for (Album album : topLevelAlbums) {
+ sone.getRootAlbum().addAlbum(album);
+ }
soneInserters.get(sone).setLastInsertFingerprint(lastInsertFingerprint);
}
synchronized (knownSones) {
for (PostReply reply : replies) {
reply.setKnown(true);
}
+
+ logger.info(String.format("Sone loaded successfully: %s", sone));
}
/**
* @return The new album
*/
public Album createAlbum(Sone sone) {
- return createAlbum(sone, null);
+ return createAlbum(sone, sone.getRootAlbum());
}
/**
albums.put(album.getId(), album);
}
album.setSone(sone);
- if (parent != null) {
- parent.addAlbum(album);
- } else {
- sone.addAlbum(album);
- }
+ parent.addAlbum(album);
return album;
}
if (!album.isEmpty()) {
return;
}
- if (album.getParent() == null) {
- album.getSone().removeAlbum(album);
- } else {
- album.getParent().removeAlbum(album);
- }
+ album.getParent().removeAlbum(album);
synchronized (albums) {
albums.remove(album.getId());
}
configuration.getStringValue(sonePrefix + "/Friends/" + friendCounter + "/ID").setValue(null);
/* save albums. first, collect in a flat structure, top-level first. */
- List<Album> albums = FluentIterable.from(sone.getAlbums()).transformAndConcat(Album.FLATTENER).toList();
+ List<Album> albums = FluentIterable.from(sone.getRootAlbum().getAlbums()).transformAndConcat(Album.FLATTENER).toList();
int albumCounter = 0;
for (Album album : albums) {
configuration.getStringValue(albumPrefix + "/ID").setValue(album.getId());
configuration.getStringValue(albumPrefix + "/Title").setValue(album.getTitle());
configuration.getStringValue(albumPrefix + "/Description").setValue(album.getDescription());
- configuration.getStringValue(albumPrefix + "/Parent").setValue(album.getParent() == null ? null : album.getParent().getId());
+ configuration.getStringValue(albumPrefix + "/Parent").setValue(album.getParent().equals(sone.getRootAlbum()) ? null : album.getParent().getId());
configuration.getStringValue(albumPrefix + "/AlbumImage").setValue(album.getAlbumImage() == null ? null : album.getAlbumImage().getId());
}
configuration.getStringValue(sonePrefix + "/Albums/" + albumCounter + "/ID").setValue(null);
@SuppressWarnings("synthetic-access")
public void run() {
Sone sone = getRemoteSone(identity.getId(), false);
+ if (sone.isLocal()) {
+ return;
+ }
sone.setIdentity(identity);
sone.setLatestEdition(Numbers.safeParseLong(identity.getProperty("Sone.LatestEdition"), sone.getLatestEdition()));
soneDownloader.addSone(sone);