*/
public enum SoneStatus {
+ /** The Sone is unknown, i.e. not yet downloaded. */
+ unknown,
+
/** The Sone is idle, i.e. not being downloaded or inserted. */
idle,
if (!soneCache.containsKey(soneId)) {
Sone sone = new Sone(soneId);
soneCache.put(soneId, sone);
- setSoneStatus(sone, SoneStatus.idle);
+ setSoneStatus(sone, SoneStatus.unknown);
}
return soneCache.get(soneId);
}
*/
public void addLocalSone(Sone sone) {
if (localSones.add(sone)) {
+ setSoneStatus(sone, SoneStatus.idle);
SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone);
soneInserter.start();
soneInserters.put(sone, soneInserter);
try {
FreenetURI realRequestUri = new FreenetURI(requestUri).setMetaString(new String[] { "sone.xml" });
FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri);
+ if (fetchResult == null) {
+ return;
+ }
Sone parsedSone = soneDownloader.parseSone(null, fetchResult, realRequestUri);
if (parsedSone != null) {
if (insertUri != null) {
@SuppressWarnings("synthetic-access")
public void run() {
FreenetURI realRequestUri = sone.getRequestUri().setMetaString(new String[] { "sone.xml" });
- FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri);
- Sone parsedSone = soneDownloader.parseSone(sone, fetchResult, realRequestUri);
- if (parsedSone != null) {
- addSone(parsedSone);
+ setSoneStatus(sone, SoneStatus.downloading);
+ try {
+ FetchResult fetchResult = freenetInterface.fetchUri(realRequestUri);
+ if (fetchResult == null) {
+ /* TODO - mark Sone as bad. */
+ return;
+ }
+ Sone parsedSone = soneDownloader.parseSone(sone, fetchResult, realRequestUri);
+ if (parsedSone != null) {
+ addSone(parsedSone);
+ }
+ } finally {
+ setSoneStatus(sone, (sone.getTime() == 0) ? SoneStatus.unknown : SoneStatus.idle);
}
}
}, "Sone Downloader").start();
return replies;
}
+ /**
+ * Deletes the given reply. It is removed from its Sone and from the reply
+ * cache.
+ *
+ * @param reply
+ * The reply to remove
+ */
+ public void deleteReply(Reply reply) {
+ reply.getSone().removeReply(reply);
+ replyCache.remove(reply.getId());
+ }
+
//
// SERVICE METHODS
//