import java.util.logging.Logger;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.util.collection.Pair;
import net.pterodactylus.util.logging.Logging;
import com.db4o.ObjectContainer;
* The URI to fetch
* @return The result of the fetch, or {@code null} if an error occured
*/
- public FetchResult fetchUri(FreenetURI uri) {
+ public Pair<FreenetURI, FetchResult> fetchUri(FreenetURI uri) {
FetchResult fetchResult = null;
FreenetURI currentUri = new FreenetURI(uri);
while (true) {
try {
fetchResult = client.fetch(currentUri);
- return fetchResult;
+ return new Pair<FreenetURI, FetchResult>(currentUri, fetchResult);
} catch (FetchException fe1) {
if (fe1.getMode() == FetchException.PERMANENT_REDIRECT) {
currentUri = fe1.newURI;
import net.pterodactylus.sone.data.Profile;
import net.pterodactylus.sone.data.Reply;
import net.pterodactylus.sone.data.Sone;
+import net.pterodactylus.util.collection.Pair;
import net.pterodactylus.util.io.Closer;
import net.pterodactylus.util.logging.Logging;
import net.pterodactylus.util.number.Numbers;
FreenetURI requestUri = sone.getRequestUri().setMetaString(new String[] { "sone.xml" });
core.setSoneStatus(sone, SoneStatus.downloading);
try {
- FetchResult fetchResult = freenetInterface.fetchUri(requestUri);
- if (fetchResult == null) {
+ Pair<FreenetURI, FetchResult> fetchResults = freenetInterface.fetchUri(requestUri);
+ if (fetchResults == null) {
/* TODO - mark Sone as bad. */
return;
}
- logger.log(Level.FINEST, "Got %d bytes back.", fetchResult.size());
- Sone parsedSone = parseSone(sone, fetchResult, requestUri);
+ logger.log(Level.FINEST, "Got %d bytes back.", fetchResults.getRight().size());
+ Sone parsedSone = parseSone(sone, fetchResults.getRight(), fetchResults.getLeft());
if (parsedSone != null) {
core.updateSone(parsedSone);
}