* The Sone to add
*/
@Override
- public void addSone(Sone sone) {
+ public void addSone(final Sone sone) {
if (!sones.add(sone)) {
freenetInterface.unregisterUsk(sone);
}
- freenetInterface.registerUsk(sone, this);
+ freenetInterface.registerUsk(sone, new SoneUpdater() {
+ @Override
+ public void updateSone(long edition) {
+ if (edition > sone.getLatestEdition()) {
+ sone.setLatestEdition(edition);
+ new Thread(fetchSoneAction(sone),
+ "Sone Downloader").start();
+ }
+ }
+ });
}
- /**
- * Fetches the updated Sone. This method is a callback method for
- * {@link FreenetInterface#registerUsk(Sone, SoneDownloader)}.
- *
- * @param sone
- * The Sone to fetch
- */
- @Override
- public void fetchSone(Sone sone) {
+ private void fetchSone(Sone sone) {
fetchSone(sone, sone.getRequestUri().sskForUSK());
}
}
Album parent = null;
if (parentId != null) {
- parent = core.getAlbum(parentId, false);
+ parent = core.getAlbum(parentId);
if (parent == null) {
logger.log(Level.WARNING, String.format("Downloaded Sone %s has album with invalid parent!", sone));
return null;
}
}
- Album album = core.getAlbum(id).setSone(sone).modify().setTitle(title).setDescription(description).update();
+ Album album = core.albumBuilder()
+ .withId(id)
+ .by(sone)
+ .build()
+ .modify()
+ .setTitle(title)
+ .setDescription(description)
+ .update();
if (parent != null) {
parent.addAlbum(album);
} else {