Package freenet.support.api

Examples of freenet.support.api.ManifestElement


        if(f.isFile()) {
          FileBucket bucket = new FileBucket(f, true, false, false, false);
          if(logMINOR)
            Logger.minor(this, "Add file : " + f.getAbsolutePath());
         
          map.put(f.getName(), new ManifestElement(f.getName(), prefix + f.getName(), bucket, DefaultMIMETypes.guessMIMEType(f.getName(), true), f.length()));
        } else if(f.isDirectory()) {
          if(logMINOR)
            Logger.minor(this, "Add dir : " + f.getAbsolutePath());
         
          map.put(f.getName(), makeDiskDirManifest(f, prefix + f.getName() + "/", allowUnreadableFiles, includeHiddenFiles));
View Full Code Here


    if(logMINOR) Logger.minor(this, "freeData() inner on "+this+" persistence type = "+persistence+" size = "+manifestElements.size());
    for(Object o: manifestElements.values()) {
      if(o instanceof HashMap) {
        freeData((HashMap<String, Object>) o);
      } else {
        ManifestElement e = (ManifestElement) o;
        if(logMINOR) Logger.minor(this, "Freeing "+e);
        e.freeData();
      }
    }
  }
View Full Code Here

        convertFilesByNameToManifestElements(h, manifests, node);
      } else {
        DirPutFile f = (DirPutFile) val;
        if(f instanceof DiskDirPutFile && !node.clientCore.allowUploadFrom(((DiskDirPutFile)f).getFile()))
          throw new MessageInvalidException(ProtocolErrorMessage.ACCESS_DENIED, "Not allowed to upload "+((DiskDirPutFile) f).getFile(), identifier, global);
        ManifestElement e = f.getElement();
        manifestElements.put(tempName, e);
      }
    }
  }
View Full Code Here

    return null;
  }

  @Override
  public ManifestElement getElement() {
    return new ManifestElement(name, targetURI, getMIMEType());
  }
View Full Code Here

    String n = name;
    int idx = n.lastIndexOf('/');
    if(idx != -1) n = n.substring(idx+1);
    if(logMINOR)
      Logger.minor(this, "Element name: "+name+" -> "+n);
    return new ManifestElement(n, getData(), getMIMEType(), getData().size());
  }
View Full Code Here

            if (filelist[i].isFile()) {
              File f = filelist[i];
             
              FileBucket bucket = new FileBucket(f, true, false, false, false);
             
              ret.put(f.getName(), new ManifestElement(f.getName(), prefix + f.getName(), bucket, DefaultMIMETypes.guessMIMEType(f.getName(), true), f.length()));
            } else if(filelist[i].isDirectory()) {
              HashMap<String, Object> subdir = makeBucketsByName(new File(thisdir, filelist[i].getName()), prefix
                  + filelist[i].getName() + '/');
              ret.put(filelist[i].getName(), subdir);
            } else if(!allowUnreadableFiles) {
View Full Code Here

    //                 Is it really necessary to include the file list here?
    ManifestElement[] elements = BaseManifestPutter.flatten(manifestElements);
    fs.putSingle("DefaultName", defaultName);
    for(int i=0;i<elements.length;i++) {
      String num = Integer.toString(i);
      ManifestElement e = elements[i];
      String mimeOverride = e.getMimeTypeOverride();
      SimpleFieldSet subset = new SimpleFieldSet(false);
      FreenetURI tempURI = e.getTargetURI();
      subset.putSingle("Name", e.getName());
      if(tempURI != null) {
        subset.putSingle("UploadFrom", "redirect");
        subset.putSingle("TargetURI", tempURI.toString());
      } else {
        Bucket origData = e.getData();
        Bucket data = origData;
        if(data instanceof DelayedFreeBucket) {
          data = ((DelayedFreeBucket)data).getUnderlying();
        } else if(data instanceof DelayedFreeRandomAccessBucket) {
            data = ((DelayedFreeRandomAccessBucket)data).getUnderlying();
        }
        subset.put("DataLength", e.getSize());
        if(mimeOverride != null)
          subset.putSingle("Metadata.ContentType", mimeOverride);
        // What to do with the bucket?
        // It is either a persistent encrypted bucket or a file bucket ...
        if(data == null) {
          Logger.error(this, "Bucket already freed: "+e.getData()+" for "+e+" for "+e.getName()+" for "+identifier);
        } else if(data instanceof FileBucket) {
          subset.putSingle("UploadFrom", "disk");
          subset.putSingle("Filename", ((FileBucket)data).getFile().getPath());
        } else if (data instanceof PaddedEphemerallyEncryptedBucket || data instanceof NullBucket || data instanceof PersistentTempFileBucket || data instanceof TempBucketFactory.TempBucket || data instanceof EncryptedRandomAccessBucket) {
          subset.putSingle("UploadFrom", "direct");
View Full Code Here

     * enough that we need to split it.
     * @param isDefaultDoc If true, add a link from "" to this element, making it the default document
     * in this container.
     */
    public void addItem(String name, String nameInArchive, ManifestElement element, boolean isDefaultDoc) {
      ManifestElement me = new ManifestElement(element, name, nameInArchive);
      addItem(name, me, isDefaultDoc);
    }
View Full Code Here

    /** FIXME what is going on here? Why do we need to add a JokerPutHandler, when a lot of code just
     * calls addItem()? */
    public void addArchiveItem(ContainerBuilder archive, String name, ManifestElement element, boolean isDefaultDoc) {
      assert(element.getData() != null);
      archive.addItem(name, new ManifestElement(element, name, name), false);
      PutHandler ph = new JokerPutHandler(BaseManifestPutter.this, selfHandle, name, guessMime(name, element.mimeOverride));
      putHandlersTransformMap.put(ph, currentDir);
      perContainerPutHandlersWaitingForMetadata.get(selfHandle).add(ph);
      putHandlersArchiveTransformMap.get(archive.selfHandle).add(ph);
      if (isDefaultDoc) {
View Full Code Here

            Object o = entry.getValue();
            if(o instanceof ManifestElement) {
                manifestEntries.put(name, o);
            } else if(o instanceof Bucket) {
                RandomAccessBucket data = (RandomAccessBucket) o;
                manifestEntries.put(name, new ManifestElement(name, data, null,data.size()));
            } else if(o instanceof HashMap) {
                manifestEntries.put(name, bucketsByNameToManifestEntries(Metadata.forceMap(o)));
            } else
                throw new IllegalArgumentException(String.valueOf(o));
        }
View Full Code Here

TOP

Related Classes of freenet.support.api.ManifestElement

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.