projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add sone change detector that finds new and removed elements.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
core
/
Core.java
diff --git
a/src/main/java/net/pterodactylus/sone/core/Core.java
b/src/main/java/net/pterodactylus/sone/core/Core.java
index
9a5d983
..
7d38ed9
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/core/Core.java
+++ b/
src/main/java/net/pterodactylus/sone/core/Core.java
@@
-25,6
+25,7
@@
import static com.google.common.primitives.Longs.tryParse;
import static java.lang.String.format;
import static java.util.logging.Level.WARNING;
import static net.pterodactylus.sone.data.Sone.LOCAL_SONE_FILTER;
import static java.lang.String.format;
import static java.util.logging.Level.WARNING;
import static net.pterodactylus.sone.data.Sone.LOCAL_SONE_FILTER;
+import static net.pterodactylus.sone.data.Sone.toAllAlbums;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.net.MalformedURLException;
import java.util.ArrayList;
@@
-77,6
+78,7
@@
import net.pterodactylus.sone.data.TemporaryImage;
import net.pterodactylus.sone.database.AlbumBuilder;
import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.database.DatabaseException;
import net.pterodactylus.sone.database.AlbumBuilder;
import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.database.DatabaseException;
+import net.pterodactylus.sone.database.ImageBuilder;
import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.database.PostProvider;
import net.pterodactylus.sone.database.PostReplyBuilder;
import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.database.PostProvider;
import net.pterodactylus.sone.database.PostReplyBuilder;
@@
-609,6
+611,10
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
return database.getAlbum(albumId).orNull();
}
return database.getAlbum(albumId).orNull();
}
+ public ImageBuilder imageBuilder() {
+ return database.newImageBuilder();
+ }
+
/**
* Returns the image with the given ID, creating it if necessary.
*
/**
* Returns the image with the given ID, creating it if necessary.
*
@@
-1008,7
+1014,7
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
for (PostReply newPostReply : newPostReplies) {
eventBus.post(new NewPostReplyFoundEvent(newPostReply));
}
for (PostReply newPostReply : newPostReplies) {
eventBus.post(new NewPostReplyFoundEvent(newPostReply));
}
- for (Album album :
sone.getRootAlbum().getAlbums(
)) {
+ for (Album album :
toAllAlbums.apply(sone
)) {
database.storeAlbum(album);
for (Image image : album.getImages()) {
database.storeImage(image);
database.storeAlbum(album);
for (Image image : album.getImages()) {
database.storeImage(image);
@@
-1162,7
+1168,9
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
/* load avatar. */
String avatarId = configuration.getStringValue(sonePrefix + "/Profile/Avatar").getValue(null);
if (avatarId != null) {
/* load avatar. */
String avatarId = configuration.getStringValue(sonePrefix + "/Profile/Avatar").getValue(null);
if (avatarId != null) {
- profile.setAvatar(getImage(avatarId, false));
+ final Map<String, Image> images =
+ configurationSoneParser.getImages();
+ profile.setAvatar(images.get(avatarId));
}
/* load options. */
}
/* load options. */
@@
-1191,6
+1199,12
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
sone.getRootAlbum().addAlbum(album);
}
soneInserters.get(sone).setLastInsertFingerprint(lastInsertFingerprint);
sone.getRootAlbum().addAlbum(album);
}
soneInserters.get(sone).setLastInsertFingerprint(lastInsertFingerprint);
+ for (Album album : toAllAlbums.apply(sone)) {
+ database.storeAlbum(album);
+ for (Image image : album.getImages()) {
+ database.storeImage(image);
+ }
+ }
}
synchronized (knownSones) {
for (String friend : friends) {
}
synchronized (knownSones) {
for (String friend : friends) {
@@
-1938,19
+1952,14
@@
public class Core extends AbstractService implements SoneProvider, PostProvider,
OwnIdentity ownIdentity = identityRemovedEvent.ownIdentity();
Identity identity = identityRemovedEvent.identity();
trustedIdentities.remove(ownIdentity, identity);
OwnIdentity ownIdentity = identityRemovedEvent.ownIdentity();
Identity identity = identityRemovedEvent.identity();
trustedIdentities.remove(ownIdentity, identity);
- boolean foundIdentity = false;
for (Entry<OwnIdentity, Collection<Identity>> trustedIdentity : trustedIdentities.asMap().entrySet()) {
if (trustedIdentity.getKey().equals(ownIdentity)) {
continue;
}
if (trustedIdentity.getValue().contains(identity)) {
for (Entry<OwnIdentity, Collection<Identity>> trustedIdentity : trustedIdentities.asMap().entrySet()) {
if (trustedIdentity.getKey().equals(ownIdentity)) {
continue;
}
if (trustedIdentity.getValue().contains(identity)) {
-
foundIdentity = true
;
+
return
;
}
}
}
}
- if (foundIdentity) {
- /* some local identity still trusts this identity, don’t remove. */
- return;
- }
Optional<Sone> sone = getSone(identity.getId());
if (!sone.isPresent()) {
/* TODO - we don’t have the Sone anymore. should this happen? */
Optional<Sone> sone = getSone(identity.getId());
if (!sone.isPresent()) {
/* TODO - we don’t have the Sone anymore. should this happen? */