- FetchResult fetchResult = freenetInterface.fetchUri(sone.getRequestUri().setMetaString(new String[] { "sone.xml" }));
- logger.log(Level.FINEST, "Got %d bytes back.", fetchResult.size());
- updateSoneFromXml(sone, fetchResult);
- }
-
- //
- // SERVICE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void serviceStop() {
- for (Sone sone : sones) {
- freenetInterface.unregisterUsk(sone);
+ FreenetURI requestUri = sone.getRequestUri().setMetaString(new String[] { "sone.xml" });
+ core.setSoneStatus(sone, SoneStatus.downloading);
+ try {
+ FetchResult fetchResult = freenetInterface.fetchUri(requestUri);
+ if (fetchResult == null) {
+ /* TODO - mark Sone as bad. */
+ return;
+ }
+ logger.log(Level.FINEST, "Got %d bytes back.", fetchResult.size());
+ Sone parsedSone = parseSone(sone, fetchResult, requestUri);
+ if (parsedSone != null) {
+ core.addSone(parsedSone);
+ }
+ } finally {
+ core.setSoneStatus(sone, SoneStatus.idle);