Package freenet.client.async

Examples of freenet.client.async.ClientGetCallback


    tempContext.maxTempLength = NodeUpdateManager.MAX_REVOCATION_KEY_TEMP_LENGTH;
    tempContext.localRequestOnly = true;

    final ArrayBucket cleanedBlob = new ArrayBucket();

    ClientGetCallback myCallback = new ClientGetCallback() {

      @Override
      public void onFailure(FetchException e, ClientGetter state) {
        if(e.mode == FetchExceptionMode.CANCELLED) {
          // Eh?
          Logger.error(this, "Cancelled fetch from store/blob of revocation certificate from " + source);
          System.err.println("Cancelled fetch from store/blob of revocation certificate from " + source + " to " + temp + " - please report to developers");
        // Probably best to keep files around for now.
        } else if(e.isFatal()) {
          // Blown: somebody inserted a revocation message, but it was corrupt as inserted
          // However it had valid signatures etc.

          System.err.println("Got revocation certificate from " + source + " (fatal error i.e. someone with the key inserted bad data) : "+e);
          // Blow the update, and propagate the revocation certificate.
          updateManager.revocationChecker.onFailure(e, state, cleanedBlob);
          // Don't delete it if it's from disk, as it's already in the right place.
          if(!fromDisk)
            temp.free();

          insertBlob(updateManager.revocationChecker.getBlobBucket(), "revocation");
        } else {
          String message = "Failed to fetch revocation certificate from blob from " +
            source + " : "+e+
            (fromDisk ? " : did you change the revocation key?" :
              " : this is almost certainly bogus i.e. the auto-update is fine but the node is broken.");
          Logger.error(this, message);
          System.err.println(message);
          // This is almost certainly bogus.
          // Delete it, even if it's fromDisk.
          temp.free();
          cleanedBlob.free();
        }
      }

      @Override
      public void onSuccess(FetchResult result, ClientGetter state) {
        System.err.println("Got revocation certificate from " + source);
        updateManager.revocationChecker.onSuccess(result, state, cleanedBlob);
        if(!fromDisk)
          temp.free();
        insertBlob(updateManager.revocationChecker.getBlobBucket(), "revocation");
      }
     
            @Override
            public void onResume(ClientContext context) {
                // Not persistent.
            }
           
            @Override
            public RequestClient getRequestClient() {
                return UpdateOverMandatoryManager.this;
            }
    };

    ClientGetter cg = new ClientGetter(myCallback,
      updateManager.getRevocationURI(), tempContext, (short) 0, null, new BinaryBlobWriter(cleanedBlob), null);

    try {
      updateManager.node.clientCore.clientContext.start(cg);
    } catch(FetchException e1) {
      System.err.println("Failed to decode UOM blob: " + e1);
      e1.printStackTrace();
      myCallback.onFailure(e1, cg);
    } catch (PersistenceDisabledException e) {
      // Impossible
    }

  }
View Full Code Here


      f = null;
    }
    final FileBucket cleanedBlob = b;
    final File cleanedBlobFile = f;

    ClientGetCallback myCallback = new ClientGetCallback() {

      @Override
      public void onFailure(FetchException e, ClientGetter state) {
        if(e.mode == FetchExceptionMode.CANCELLED) {
          // Eh?
          Logger.error(this, "Cancelled fetch from store/blob of main jar (" + version + ") from " + toString);
          System.err.println("Cancelled fetch from store/blob of main jar (" + version + ") from " + toString + " to " + temp + " - please report to developers");
        // Probably best to keep files around for now.
        } else if(e.newURI != null) {
          temp.delete();
          Logger.error(this, "URI changed fetching main jar "+version+" from "+toString);
          System.out.println("URI changed fetching main jar "+version+" from "+toString);
        } else if(e.isFatal()) {
          // Bogus as inserted. Ignore.
          temp.delete();
          Logger.error(this, "Failed to fetch main jar " + version + " from " + toString + " : fatal error (update was probably inserted badly): " + e, e);
          System.err.println("Failed to fetch main jar " + version + " from " + toString + " : fatal error (update was probably inserted badly): " + e);
        } else {
          Logger.error(this, "Failed to fetch main jar " + version + " from blob from " + toString);
          System.err.println("Failed to fetch main jar " + version + " from blob from " + toString);
        }
      }

      @Override
      public void onSuccess(FetchResult result, ClientGetter state) {
        System.err.println("Got main jar version " + version + " from " + toString);
        if(result.size() == 0) {
          System.err.println("Ignoring because 0 bytes long");
          return;
        }

        NodeUpdater mainUpdater = updateManager.getMainUpdater();
        if(mainUpdater == null) {
          System.err.println("Not updating because updater is disabled!");
          return;
        }
        mainUpdater.onSuccess(result, state, cleanedBlobFile, version);
        temp.delete();
        insertBlob(mainUpdater.getBlobBucket(version), "main jar");
      }

            @Override
            public void onResume(ClientContext context) {
                // Not persistent.
            }
           
            @Override
            public RequestClient getRequestClient() {
                return UpdateOverMandatoryManager.this;
            }

    };

    ClientGetter cg = new ClientGetter(myCallback,
      uri, tempContext, (short) 0, null, new BinaryBlobWriter(cleanedBlob), null);

    try {
      updateManager.node.clientCore.clientContext.start(cg);
    } catch(FetchException e1) {
      myCallback.onFailure(e1, cg);
    } catch (PersistenceDisabledException e) {
      // Impossible
    }

  }
View Full Code Here

TOP

Related Classes of freenet.client.async.ClientGetCallback

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.