- * 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, sone.getRootAlbum());
- }
-
- /**
- * 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 = database.newAlbumBuilder().randomId().build();
- database.storeAlbum(album);
- album.setSone(sone);
- parent.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;
- }
- album.getParent().removeAlbum(album);
- database.removeAlbum(album);
- touchConfiguration();
- }
-
- /**