Package freenet.client

Examples of freenet.client.FetchException


      onFailure(e, null);
    } catch (Throwable t) {
      synchronized(this) {
        started = true;
      }
      onFailure(new FetchException(FetchExceptionMode.INTERNAL_ERROR, t), null);
    }
  }
View Full Code Here


    // if request is still running, send a GetFailed with code=cancelled
    if( !finished ) {
      synchronized(this) {
        succeeded = false;
        finished = true;
        FetchException cancelled = new FetchException(FetchExceptionMode.CANCELLED);
        getFailedMessage = new GetFailedMessage(cancelled, identifier, global);
      }
      trySendDataFoundOrGetFailed(null);
    }
    // notify client that request was removed
View Full Code Here

  }

    public FetchException getFetchException() {
        // Data length etc have already been handled separately. Ignore them.
        if(tracker != null) {
            return new FetchException(FetchExceptionMode.getByCode(code), tracker, extraDescription);
        } else {
            return new FetchException(FetchExceptionMode.getByCode(code), extraDescription);
        }
    }
View Full Code Here

      File parent = filename.getParentFile();
      if(parent == null) parent = new File(".");
      try {
        tempFile = File.createTempFile(filename.getName(), NodeUpdateManager.TEMP_FILE_SUFFIX, parent);
      } catch (InsufficientDiskSpaceException e) {
          throw new FetchException(FetchExceptionMode.NOT_ENOUGH_DISK_SPACE);
      } catch (IOException e) {
        throw new FetchException(FetchExceptionMode.BUCKET_ERROR, "Cannot create temp file for "+filename+" in "+parent+" - disk full? permissions problem?");
      }
      getter = new ClientGetter(this, 
          chk, myCtx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
          new FileBucket(tempFile, false, false, false, false), null, null);
      myCtx.eventProducer.addEventListener(this);
View Full Code Here

      }
            if(!MainJarDependenciesChecker.validFile(tempFile, expectedHash, expectedLength, executable)) {
                Logger.error(this, "Unable to download dependency "+filename+" : not the expected size or hash!");
                System.err.println("Download of "+filename+" for update failed because temp file appears to be corrupted!");
                if(cb != null)
                    cb.onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, "Downloaded jar from Freenet but failed consistency check: "+tempFile+" length "+tempFile.length()+" "));
                tempFile.delete();
                return;
            }
      if(!FileUtil.renameTo(tempFile, filename)) {
        Logger.error(this, "Unable to rename temp file "+tempFile+" to "+filename);
        System.err.println("Download of "+filename+" for update failed because cannot rename from "+tempFile);
        if(cb != null)
            cb.onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, "Unable to rename temp file "+tempFile+" to "+filename));
                tempFile.delete();
        return;
      }
      if(cb != null) cb.onSuccess();
    }
View Full Code Here

    private void checkDecodedBlock(int i, byte[] data) {
        ClientCHK key = getKey(i);
        if(key == null) {
            Logger.error(this, "Key not found");
            failOffThread(new FetchException(FetchExceptionMode.INTERNAL_ERROR, "Key not found"));
            return;
        }
        ClientCHKBlock block = encodeBlock(key, data);
        String decoded = i >= dataBlockCount ? "Encoded" : "Decoded";
        if(block == null || !key.getNodeCHK().equals(block.getKey())) {
            Logger.error(this, decoded+" cross-segment block "+i+" failed!");
            failOffThread(new FetchException(FetchExceptionMode.SPLITFILE_DECODE_ERROR, decoded+" cross-segment block does not match expected key"));
            return;
        } else {
            reportBlockToSegmentOffThread(i, key, block, data);
        }
    }
View Full Code Here

  // Real onFailure
  protected void onFailure(FetchException e, boolean forceFatal, ClientContext context) {
    if(logMINOR) Logger.minor(this, "onFailure( "+e+" , "+forceFatal+")", e);
    if(parent.isCancelled() || cancelled) {
      if(logMINOR) Logger.minor(this, "Failing: cancelled");
      e = new FetchException(FetchExceptionMode.CANCELLED);
      forceFatal = true;
    }
    if(!(e.isFatal() || forceFatal) ) {
      if(retry(context)) {
        if(logMINOR) Logger.minor(this, "Retrying");
View Full Code Here

  /** Will be overridden by SingleFileFetcher */
  protected void onSuccess(FetchResult data, ClientContext context) {
    if(parent.isCancelled()) {
      data.asBucket().free();
      onFailure(new FetchException(FetchExceptionMode.CANCELLED), false, context);
      return;
    }
    rcb.onSuccess(new SingleFileStreamGenerator(data.asBucket(), persistent), data.getMetadata(), null, this, context);
  }
View Full Code Here

    if(data == null) return; // failed
    context.uskManager.checkUSK(key.getURI(), fromStore, block.isMetadata());
    if(!block.isMetadata()) {
      onSuccess(new FetchResult(new ClientMetadata(null), data), context);
    } else {
      onFailure(new FetchException(FetchExceptionMode.INVALID_METADATA, "Metadata where expected data"), false, context);
    }
  }
View Full Code Here

    try {
      data = block.decode(context.getBucketFactory(parent.persistent()), (int)(Math.min(ctx.maxOutputLength, Integer.MAX_VALUE)), false);
    } catch (KeyDecodeException e1) {
      if(logMINOR)
        Logger.minor(this, "Decode failure: "+e1, e1);
      onFailure(new FetchException(FetchExceptionMode.BLOCK_DECODE_ERROR, e1.getMessage()), false, context);
      return null;
    } catch (TooBigException e) {
      onFailure(new FetchException(FetchExceptionMode.TOO_BIG, e), false, context);
      return null;
    } catch (InsufficientDiskSpaceException e) {
        onFailure(new FetchException(FetchExceptionMode.NOT_ENOUGH_DISK_SPACE), false, context);
        return null;
    } catch (IOException e) {
      Logger.error(this, "Could not capture data - disk full?: "+e, e);
      onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, e), false, context);
      return null;
    }
    return data;
  }
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.