public Album build() throws IllegalStateException {
validate();
DefaultAlbum album = new DefaultAlbum(database, getId(), sone, parentId);
- if (parentId != null) {
- database.storeAlbum(album);
- }
+ database.storeAlbum(album);
return album;
}
lock.writeLock().lock();
try {
allAlbums.put(album.getId(), album);
- albumChildren.put(album.getParent().getId(), album.getId());
+ if (!album.isRoot()) {
+ albumChildren.put(album.getParent().getId(), album.getId());
+ }
} finally {
lock.writeLock().unlock();
}