import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.sone.database.AlbumBuilder;
+import net.pterodactylus.sone.database.Database;
+import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.util.logging.Logging;
import freenet.keys.FreenetURI;
+import com.google.common.base.Optional;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
/** The logger. */
private static final Logger logger = Logging.getLogger(DefaultSone.class);
+ /** The database. */
+ private final Database database;
+
/** The ID of this Sone. */
private final String id;
private final Set<String> likedReplyIds = new CopyOnWriteArraySet<String>();
/** The root album containing all albums. */
- private final Album rootAlbum = new DefaultAlbum(this, null);
+ private final Album rootAlbum;
/** Sone-specific options. */
private Options options = new Options();
* @param local
* {@code true} if the Sone is a local Sone, {@code false} otherwise
*/
- public DefaultSone(String id, boolean local) {
+ public DefaultSone(Database database, String id, boolean local) {
+ this.database = database;
this.id = id;
this.local = local;
+ rootAlbum = new DefaultAlbumBuilder(database, this, null).build();
}
//
this.options = options;
}
+ @Override
+ public AlbumBuilder newAlbumBuilder() {
+ return new DefaultAlbumBuilder(database, this, rootAlbum.getId());
+ }
+
+ public PostBuilder newPostBuilder() {
+ return new DefaultPostBuilder(database, getId()) {
+ @Override
+ public Post build(Optional<PostCreated> postCreated) {
+ Post post = super.build(postCreated);
+ database.storePost(post);
+ return post;
+ }
+ };
+ }
+
//
// FINGERPRINTABLE METHODS
//