Examples of Bucket


Examples of freenet.support.api.Bucket

      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

Examples of freenet.support.api.Bucket

  }

  @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

Examples of freenet.support.api.Bucket

    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

Examples of freenet.support.api.Bucket

        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

Examples of freenet.support.api.Bucket

  }

  @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

Examples of freenet.support.api.Bucket

  }

  @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

Examples of freenet.support.api.Bucket

    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

Examples of freenet.support.api.Bucket

  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

Examples of freenet.support.api.Bucket

  @Override
  public void run(FCPConnectionHandler handler, Node node) throws MessageInvalidException {
    if (bucket == null) {
      throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Must contain data", identifier, false);
    }
    Bucket resultBucket;
    try {
      resultBucket = bf.makeBucket(-1);
    } catch (IOException e) {
      Logger.error(this, "Failed to create temporary bucket", e);
      throw new MessageInvalidException(ProtocolErrorMessage.INTERNAL_ERROR, e.toString(), identifier, false);
    }
    String resultCharset = null;
    String resultMimeType = null;
    boolean unsafe = false;
    InputStream input = null;
    OutputStream output = null;
    try {
      input = bucket.getInputStream();
      output = resultBucket.getOutputStream();
      FilterStatus status = applyFilter(input, output, handler.server.core.clientContext);
      resultCharset = status.charset;
      resultMimeType = status.mimeType;
    } catch (UnsafeContentTypeException e) {
      unsafe = true;
View Full Code Here

Examples of freenet.support.api.Bucket

  @Override
  public CacheFetchResult lookupInstant(FreenetURI key, boolean noFilter, boolean mustCopy, Bucket preferred) {
    ClientGet get = globalRebootClient.getCompletedRequest(key);

    Bucket origData = null;
    String mime = null;
    boolean filtered = false;

    if(get != null && ((!noFilter) || (!(filtered = get.filterData())))) {
      origData = new NoFreeBucket(get.getBucket());
      mime = get.getMIMEType();
    }

    if(origData == null && globalForeverClient != null) {
      CacheFetchResult result = globalForeverClient.getRequestStatusCache().getShadowBucket(key, noFilter);
      if(result != null) {
        mime = result.getMimeType();
        origData = result.asBucket();
        filtered = result.alreadyFiltered;
      }
    }

    if(origData == null) return null;

    if(!mustCopy)
      return new CacheFetchResult(new ClientMetadata(mime), origData, filtered);

    Bucket newData = null;
    try {
      if(preferred != null) newData = preferred;
      else newData = core.tempBucketFactory.makeBucket(origData.size());
      BucketTools.copy(origData, newData);
      if(origData.size() != newData.size()) {
        Logger.normal(this, "Maybe it disappeared under us?");
        newData.free();
        newData = null;
        return null;
      }
      return new CacheFetchResult(new ClientMetadata(mime), newData, filtered);
    } catch (IOException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.