- synchronized (replies) {
- replies.remove(reply.getId());
- }
- synchronized (knownReplies) {
- markReplyKnown(reply);
- knownReplies.remove(reply.getId());
- }
- sone.removeReply(reply);
- touchConfiguration();
- }
-
- /**
- * Marks the given reply as known, if it is currently not a known reply
- * (according to {@link Reply#isKnown()}).
- *
- * @param reply
- * The reply to mark as known
- */
- public void markReplyKnown(PostReply reply) {
- reply.setKnown(true);
- synchronized (knownReplies) {
- eventBus.post(new MarkPostReplyKnownEvent(reply));
- if (knownReplies.add(reply.getId())) {
- touchConfiguration();
- }
- }
- }
-
- /**
- * Creates a new top-level album for the given Sone.
- *
- * @param sone
- * The Sone to create the album for
- * @return The new album
- */
- public Album createAlbum(Sone sone) {
- return createAlbum(sone, null);
- }
-
- /**
- * Creates a new album for the given Sone.
- *
- * @param sone
- * The Sone to create the album for
- * @param parent
- * The parent of the album (may be {@code null} to create a
- * top-level album)
- * @return The new album
- */
- public Album createAlbum(Sone sone, Album parent) {
- Album album = new Album();
- synchronized (albums) {
- albums.put(album.getId(), album);
- }
- album.setSone(sone);
- if (parent != null) {
- parent.addAlbum(album);
- } else {
- sone.addAlbum(album);
- }
- return album;
- }
-
- /**
- * Deletes the given album. The owner of the album has to be a local Sone,
- * and the album has to be {@link Album#isEmpty() empty} to be deleted.
- *
- * @param album
- * The album to remove
- */
- public void deleteAlbum(Album album) {
- checkNotNull(album, "album must not be null");
- checkArgument(album.getSone().isLocal(), "album’s Sone must be a local Sone");
- if (!album.isEmpty()) {
- return;
- }
- if (album.getParent() == null) {
- album.getSone().removeAlbum(album);
- } else {
- album.getParent().removeAlbum(album);
- }
- synchronized (albums) {
- albums.remove(album.getId());
- }