Package freenet.support.api

Examples of freenet.support.api.Bucket


    }
  }

  @Override
  protected void freeData() {
    Bucket d;
    synchronized(this) {
      d = data;
      data = null;
      if(d == null) return;
      finishedSize = d.size();
    }
    d.free();
  }
View Full Code Here


      this.priorityClass = priorityClass;
      this.updatedTime = updatedTime;

      //The text may contain newlines
      try {
        Bucket textBucket = new ArrayBucket(text.getBytes("UTF-8"));
        buckets.put("Text", textBucket);
      } catch (UnsupportedEncodingException e) {
        throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
      }
  }
View Full Code Here

      String name, FreenetURI URI, String description, boolean hasAnActivelink) {
    super(header, shortText, text, priorityClass, updatedTime, sourceNodeName, composed, sent, received);
    this.name = name;
    this.URI = URI;
    this.hasAnActivelink = hasAnActivelink;
    final Bucket descriptionBucket;
    try {
      if(description != null)
        descriptionBucket = new ArrayBucket(description.getBytes("UTF-8"));
      else
        descriptionBucket = new NullBucket();
View Full Code Here

  }

  @Override
  public void run(final FCPConnectionHandler handler, final Node node) throws MessageInvalidException {

    Bucket data2 = this.bucket;
   
    PluginTalker pt;
    try {
      pt = new PluginTalker(node, handler, pluginname, identifier, handler.hasFullAccess());
    } catch (PluginNotFoundException e) {
View Full Code Here

    fctx.maxOutputLength = maxOutputLength;
    fctx.maxTempLength = maxOutputLength;
    fctx.canWriteClientCache = writeToClientCache;
    compatMode = new CompatibilityAnalyser();
    // FIXME fctx.ignoreUSKDatehints = ignoreUSKDatehints;
    Bucket ret = null;
    this.returnType = returnType;
    this.binaryBlob = binaryBlob;
    String extensionCheck = null;
    if(returnType == ReturnType.DISK) {
      this.targetFile = returnFilename;
View Full Code Here

        fctx.allowedMIMETypes.add(mime);
    }

    this.returnType = message.returnType;
    this.binaryBlob = message.binaryBlob;
    Bucket ret = null;
    String extensionCheck = null;
    if(returnType == ReturnType.DISK) {
      this.targetFile = message.diskFile;
      if(!core.allowDownloadTo(targetFile))
        throw new MessageInvalidException(ProtocolErrorMessage.ACCESS_DENIED, "Not allowed to download to "+targetFile, identifier, global);
View Full Code Here

  }

  @Override
  public void onSuccess(FetchResult result, ClientGetter state) {
    Logger.minor(this, "Succeeded: "+identifier);
    Bucket data = result.asBucket();
    synchronized(this) {
      if(succeeded) {
        Logger.error(this, "onSuccess called twice for "+this+" ("+identifier+ ')');
        return; // We might be called twice; ignore it if so.
      }
      started = true;
      if(!binaryBlob)
        this.foundDataMimeType = result.getMimeType();
      else
        this.foundDataMimeType = BinaryBlob.MIME_TYPE;

      // completionTime is set here rather than in finish() for two reasons:
      // 1. It must be set inside the lock.
      // 2. It must be set before AllData is sent so it is consistent.
            completionTime = System.currentTimeMillis();
      progressPending = null;
      this.foundDataLength = data.size();
      this.succeeded = true;
      finished = true;
      if(returnType == ReturnType.DIRECT)
          returnBucketDirect = data;
    }
View Full Code Here

  }

  @Override
  protected void freeData() {
      // We don't remove the data if written to a file.
    Bucket data;
    synchronized(this) {
      data = returnBucketDirect;
      returnBucketDirect = null;
    }
    if(data != null) {
      data.free();
    }
    if(initialMetadata != null)
        initialMetadata.free();
  }
View Full Code Here

    long dataSize = foundDataLength;
    File target = getDestFilename();
    if(target != null)
      target = new File(target.getPath());
   
    Bucket shadow = (finished && succeeded) ? getBucket() : null;
    if(shadow != null) {
        if(dataSize != shadow.size()) {
            Logger.error(this, "Size of downloaded data has changed: "+dataSize+" -> "+shadow.size()+" on "+shadow);
            shadow = null;
        } else {
            shadow = shadow.createShadow();
        }
    }
   
    boolean filterData;
    boolean overriddenDataType;
View Full Code Here

  public synchronized CacheFetchResult getShadowBucket(FreenetURI key, boolean noFilter) {
    Object[] downloads = downloadsByURI.getArray(key);
    if(downloads == null) return null;
    for(Object o : downloads) {
      DownloadRequestStatus download = (DownloadRequestStatus) o;
      Bucket data = download.getDataShadow();
      if(data == null) continue;
      if(data.size() == 0) continue;
      if(noFilter && download.filterData) continue;
      // FIXME it probably *is* worth the effort to allow this when it is overridden on the fetcher, since the user changed the type???
      if(download.overriddenDataType) continue;
      return new CacheFetchResult(new ClientMetadata(download.getMIMEType()), new NoFreeBucket(data), download.filterData);
    }
View Full Code Here

TOP

Related Classes of freenet.support.api.Bucket

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.