Examples of FreenetURI


Examples of freenet.keys.FreenetURI

      }
    if(identifier == null)
      throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No Identifier", null, global);
    try {
      if(binaryBlob)
        uri = new FreenetURI("CHK@");
      else {
        String u = fs.get("URI");
        if(u == null)
          throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "No URI", identifier, global);
        FreenetURI uu = new FreenetURI(u);
        String[] metas = uu.getAllMetaStrings();
        if(metas != null && metas.length == 1) {
          fnam = metas[0];
          uu = uu.setMetaString(null);
        } // if >1, will fail later
        uri = uu;
      }
    } catch (MalformedURLException e) {
      throw new MessageInvalidException(ProtocolErrorMessage.FREENET_URI_PARSE_ERROR, e.getMessage(), identifier, global);
    }
    String verbosityString = fs.get("Verbosity");
    if(verbosityString == null)
      verbosity = 0;
    else {
      try {
        verbosity = Integer.parseInt(verbosityString, 10);
      } catch (NumberFormatException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error parsing Verbosity field: "+e.getMessage(), identifier, global);
      }
    }
    contentType = fs.get("Metadata.ContentType");
    String maxRetriesString = fs.get("MaxRetries");
    if(maxRetriesString == null)
      // default to 0
      maxRetries = 0;
    else {
      try {
        maxRetries = Integer.parseInt(maxRetriesString, 10);
      } catch (NumberFormatException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error parsing MaxSize field: "+e.getMessage(), identifier, global);
      }
    }
    getCHKOnly = fs.getBoolean("GetCHKOnly", false);
    String priorityString = fs.get("PriorityClass");
    if(priorityString == null) {
      // defaults to the one just below FProxy
      priorityClass = RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS;
    } else {
      try {
        priorityClass = Short.parseShort(priorityString);
        if(!RequestStarter.isValidPriorityClass(priorityClass))
          throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Invalid priority class "+priorityClass+" - range is "+RequestStarter.PAUSED_PRIORITY_CLASS+" to "+RequestStarter.MAXIMUM_PRIORITY_CLASS, identifier, global);
      } catch (NumberFormatException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error parsing PriorityClass field: "+e.getMessage(), identifier, global);
      }
    }
    // We do *NOT* check that FileHash is valid here for backward compatibility... and to make the override work
    this.fileHash = fs.get(ClientPutBase.FILE_HASH);
    String uploadFrom = fs.get("UploadFrom");
    if((uploadFrom == null) || uploadFrom.equalsIgnoreCase("direct")) {
      uploadFromType = UploadFrom.DIRECT;
      String dataLengthString = fs.get("DataLength");
      if(dataLengthString == null)
        throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Need DataLength on a ClientPut", identifier, global);
      try {
        dataLength = Long.parseLong(dataLengthString, 10);
      } catch (NumberFormatException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error parsing DataLength field: "+e.getMessage(), identifier, global);
      }
      this.origFilename = null;
      redirectTarget = null;
    } else if(uploadFrom.equalsIgnoreCase("disk")) {
      uploadFromType = UploadFrom.DISK;
      String filename = fs.get("Filename");
      if(filename == null)
        throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Missing field Filename", identifier, global);
      File f = new File(filename);
      if(!(f.exists() && f.isFile() && f.canRead()))
        throw new MessageInvalidException(ProtocolErrorMessage.FILE_NOT_FOUND, null, identifier, global);
      dataLength = f.length();
      FileBucket fileBucket = new FileBucket(f, true, false, false, false);
      this.bucket = fileBucket;
      this.origFilename = f;
      redirectTarget = null;
      if(fnam == null)
        fnam = origFilename.getName();
    } else if(uploadFrom.equalsIgnoreCase("redirect")) {
      uploadFromType = UploadFrom.REDIRECT;
      String target = fs.get("TargetURI");
      if(target == null)
        throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "TargetURI missing but UploadFrom=redirect", identifier, global);
      try {
        redirectTarget = new FreenetURI(target);
      } catch (MalformedURLException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Invalid TargetURI: "+e, identifier, global);
      }
      dataLength = 0;
      origFilename = null;
View Full Code Here

Examples of freenet.keys.FreenetURI

    }
   
    extraDescription = fs.get("ExtraDescription");
    String euri = fs.get("ExpectedURI");
    if(euri != null && euri.length() > 0)
      expectedURI = new FreenetURI(euri);
    else
      expectedURI = null;
    SimpleFieldSet trackerSubset = fs.subset("Errors");
    if(trackerSubset != null) {
      tracker = new FailureCodeTracker(true, trackerSubset);
View Full Code Here

Examples of freenet.keys.FreenetURI

    // Ignore
  }
 
  @Override
  RequestStatus getStatus() {
    FreenetURI finalURI = getFinalURI();
    InsertExceptionMode failureCode = null;
    String failureReasonShort = null;
    String failureReasonLong = null;
    if(putFailedMessage != null) {
      failureCode = putFailedMessage.code;
View Full Code Here

Examples of freenet.keys.FreenetURI

  public static RedirectDirPutFile create(String name, String contentTypeOverride, SimpleFieldSet subset,
      String identifier, boolean global) throws MessageInvalidException {
    String target = subset.get("TargetURI");
    if(target == null)
      throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "TargetURI missing but UploadFrom=redirect", identifier, global);
    FreenetURI targetURI;
    try {
      targetURI = new FreenetURI(target);
    } catch (MalformedURLException e) {
      throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Invalid TargetURI: "+e, identifier, global);
    }
        if(logMINOR)
          Logger.minor(RedirectDirPutFile.class, "targetURI = "+targetURI);
View Full Code Here

Examples of freenet.keys.FreenetURI

      } catch (IOException e) {
        Logger.error(this, "Unable to process old blob: "+e, e);
        return;
      }
      if(oldBlob.renameTo(temp)) {
        FreenetURI uri = URI.setSuggestedEdition(currentVersion);
        uri = uri.sskForUSK();
        try {
          manager.uom.processMainJarBlob(temp, null, currentVersion, uri);
        } catch (Throwable t) {
          // Don't disrupt startup.
          Logger.error(this, "Unable to process old blob, caught "+t, t);
View Full Code Here

Examples of freenet.keys.FreenetURI

            Logger.minor(this, "Scheduling request for " + URI.setSuggestedEdition(availableVersion));
          if(availableVersion > currentVersion)
            System.err.println("Starting " + jarName() + " fetch for " + availableVersion);
          tempBlobFile =
            File.createTempFile(blobFilenamePrefix + availableVersion + "-", ".fblob.tmp", manager.node.clientCore.getPersistentTempDir());
          FreenetURI uri = URI.setSuggestedEdition(availableVersion);
          uri = uri.sskForUSK();
          cg = new ClientGetter(this, 
            uri, ctx, RequestStarter.IMMEDIATE_SPLITFILE_PRIORITY_CLASS,
            null, new BinaryBlobWriter(new FileBucket(tempBlobFile, false, false, false, false)), null);
          toStart = cg;
        } else {
View Full Code Here

Examples of freenet.keys.FreenetURI

    }
  }

  @Override
  RequestStatus getStatus() {
    FreenetURI finalURI = getFinalURI();
    InsertExceptionMode failureCode = null;
    String failureReasonShort = null;
    String failureReasonLong = null;
    if(putFailedMessage != null) {
      failureCode = putFailedMessage.code;
View Full Code Here

Examples of freenet.keys.FreenetURI

  private final FreenetURI uri;

  public SendURIMessage(SimpleFieldSet fs) throws MessageInvalidException {
    super(fs);
    try {
      uri = new FreenetURI(fs.get("URI"));
    } catch (MalformedURLException e) {
      throw new MessageInvalidException(ProtocolErrorMessage.FREENET_URI_PARSE_ERROR, e.getMessage(),
          identifier, false);
    }
  }
View Full Code Here

Examples of freenet.keys.FreenetURI

      expectedDataLength = Long.parseLong(s);
    } else
      expectedDataLength = -1;
    s = fs.get("RedirectURI");
    if(s != null)
      this.redirectURI = new FreenetURI(s);
    else
      this.redirectURI = null;
    this.global = fs.getBoolean("Global", false);
  }
View Full Code Here

Examples of freenet.keys.FreenetURI

        this.extraDescription = readPossiblyNull(dis);
        this.finalizedExpected = dis.readBoolean();
        String s = readPossiblyNull(dis);
        if(s != null) {
            try {
                redirectURI = new FreenetURI(s);
            } catch (MalformedURLException e) {
                throw new StorageFormatException("Bad redirect URI in GetFailedMessage: "+e);
            }
        } else {
            redirectURI = null;
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.