Package freenet.client

Examples of freenet.client.FetchException


        output.close(); output = null;
        pipeOut.close(); pipeOut = null;
        pipeIn.close(); pipeIn = null;
      } catch (Throwable t) {
        Logger.error(this, "Caught "+t, t);
        onFailure(new FetchException(FetchExceptionMode.INTERNAL_ERROR, t), state, context);
        return;
      } finally {
        Closer.close(pipeOut);
        Closer.close(pipeIn);
        Closer.close(output);
View Full Code Here


            while(hasher.read(buf) > 0);
            hasher.close();
            is = null;
            HashResult[] results = hasher.getResults();
            if(!HashResult.strictEquals(results, hashes)) {
              onFailure(new FetchException(FetchExceptionMode.CONTENT_HASH_FAILED), SingleFileFetcher.this, context);
              return;
            }
          } catch (InsufficientDiskSpaceException e) {
              onFailure(new FetchException(FetchExceptionMode.NOT_ENOUGH_DISK_SPACE), SingleFileFetcher.this, context);
          } catch (IOException e) {
            onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, e), SingleFileFetcher.this, context);
            return;
          } finally {
            Closer.close(is);
          }
        }
        ah.extractToCache(data, actx, element, callback, context.archiveManager, context);
      } catch (ArchiveFailureException e) {
        SingleFileFetcher.this.onFailure(new FetchException(e), false, context);
        return;
      } catch (ArchiveRestartException e) {
        SingleFileFetcher.this.onFailure(new FetchException(e), false, context);
        return;
      } finally {
        data.free();
      }
      if(callback != null) return;
View Full Code Here

    return rawTitle;
  }

  @Override
  public FetchException recreateFetchException(FetchException e, String mime) {
    return new FetchException(e.expectedSize, this, mime);
  }
View Full Code Here

    return new FetchException(e.expectedSize, this, mime);
  }
 
  @Override
  public FetchException createFetchException(String mime, long expectedSize) {
    return new FetchException(expectedSize, this, mime);
  }
View Full Code Here

       
        // Run directly - we are running on some thread somewhere, don't worry about it.
        innerSuccess(data, context);
      } catch (Throwable t) {
        Logger.error(this, "Caught "+t, t);
        onFailure(new FetchException(FetchExceptionMode.INTERNAL_ERROR, t), state, context);
        return;
      } finally {
        boolean dbrsFinished;
        synchronized(USKFetcher.this) {
          dbrAttempts.remove(this);
View Full Code Here

            output.close();
        }

      } catch (Throwable t) {
        Logger.error(this, "Caught "+t, t);
        onFailure(new FetchException(FetchExceptionMode.INTERNAL_ERROR, t), state, context);
        return;
      } finally {
        Closer.close(pipeOut);
        Closer.close(pipeIn);
        Closer.close(output);
      }

      try {
        parent.onTransition(state, SingleFileFetcher.this, context);
        //FIXME: Pass an InputStream here, and save ourselves a Bucket
        Metadata meta = Metadata.construct(finalData);
        synchronized(SingleFileFetcher.this) {
          metadata = meta;
        }
        innerWrapHandleMetadata(true, context);
      } catch (MetadataParseException e) {
        SingleFileFetcher.this.onFailure(new FetchException(FetchExceptionMode.INVALID_METADATA, e), false, context);
        return;
      } catch (InsufficientDiskSpaceException e) {
          SingleFileFetcher.this.onFailure(new FetchException(FetchExceptionMode.NOT_ENOUGH_DISK_SPACE), false, context);
          return;
      } catch (IOException e) {
        // Bucket error?
        SingleFileFetcher.this.onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, e), false, context);
        return;
      } finally {
        finalData.free();
      }
    }
View Full Code Here

          if(tag != null) {
            cb.onTransition(tag, sf, context);
          }
          sf.schedule(context);
        } else {
          cb.onFailure(new FetchException(FetchExceptionMode.PERMANENT_REDIRECT, newUSK.getURI().addMetaStrings(metaStrings)), null, context);
        }
      } catch (FetchException e) {
        cb.onFailure(e, null, context);
      }
    }
View Full Code Here

      }
    }
   
    @Override
    public void onFailure(ClientContext context) {
      FetchException e = null;
      if(datastoreOnly) {
        try {
          onFoundEdition(usk.suggestedEdition, usk, context, false, (short) -1, null, false, false);
          return;
        } catch (Throwable t) {
          e = new FetchException(FetchExceptionMode.INTERNAL_ERROR, t);
        }
      }
      if(e == null) e = new FetchException(FetchExceptionMode.DATA_NOT_FOUND, "No USK found");
      if(logMINOR) Logger.minor(this, "Failing USK with "+e, e);
      if(cb == null)
        throw new NullPointerException("Callback is null in "+this+" for usk "+usk+" with datastoreOnly="+datastoreOnly);
      cb.onFailure(e, null, context);
    }
View Full Code Here

      cb.onFailure(e, null, context);
    }

    @Override
    public void onCancelled(ClientContext context) {
      cb.onFailure(new FetchException(FetchExceptionMode.CANCELLED, (String)null), null, context);
    }
View Full Code Here

  public FetchExceptionMode getFetchErrorCode() {
    return FetchExceptionMode.CONTENT_VALIDATION_FAILED;
  }

  public FetchException recreateFetchException(FetchException e, String mime) {
    return new FetchException(getFetchErrorCode(), e.expectedSize, this, mime);
  }
View Full Code Here

TOP

Related Classes of freenet.client.FetchException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.