- if (insertInformation != null) {
- logger.log(Level.INFO, String.format("Inserting Sone “%s”…", sone.getName()));
-
- boolean success = false;
- try {
- sone.setStatus(SoneStatus.inserting);
- long insertTime = System.currentTimeMillis();
- insertInformation.setTime(insertTime);
- soneInsertListenerManager.fireInsertStarted();
- FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri(), insertInformation.generateManifestEntries(), "index.html");
- soneInsertListenerManager.fireInsertFinished(System.currentTimeMillis() - insertTime);
- /* at this point we might already be stopped. */
- if (shouldStop()) {
- /* if so, bail out, don’t change anything. */
- break;
+ if (insertInformation != null) {
+ logger.log(Level.INFO, String.format("Inserting Sone “%s”…", sone.getName()));
+
+ boolean success = false;
+ try {
+ sone.setStatus(SoneStatus.inserting);
+ long insertTime = System.currentTimeMillis();
+ insertInformation.setTime(insertTime);
+ eventBus.post(new SoneInsertingEvent(sone));
+ FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri(), insertInformation.generateManifestEntries(), "index.html");
+ eventBus.post(new SoneInsertedEvent(sone, System.currentTimeMillis() - insertTime));
+ /* at this point we might already be stopped. */
+ if (shouldStop()) {
+ /* if so, bail out, don’t change anything. */
+ break;
+ }
+ sone.setTime(insertTime);
+ sone.modify().setLatestEdition(finalUri.getEdition()).update();
+ core.touchConfiguration();
+ success = true;
+ logger.log(Level.INFO, String.format("Inserted Sone “%s” at %s.", sone.getName(), finalUri));
+ } catch (SoneException se1) {
+ eventBus.post(new SoneInsertAbortedEvent(sone, se1));
+ logger.log(Level.WARNING, String.format("Could not insert Sone “%s”!", sone.getName()), se1);
+ } finally {
+ insertInformation.freeBuckets();
+ sone.setStatus(SoneStatus.idle);