Package freenet.support

Examples of freenet.support.SimpleFieldSet


    }
  }

  @Override
  public SimpleFieldSet getFieldSet() {
    return new SimpleFieldSet(true);
  }
View Full Code Here


      ref = new StringBuilder(ref.toString().trim());
      if("".equals(ref.toString())) {
        throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from URL <"+urlString+ '>', identifier, false);
      }
      try {
        fs = new SimpleFieldSet(ref.toString(), false, true, true);
      } catch (IOException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from URL <"+urlString+">: "+e.getMessage(), identifier, false);
      }
    } else if(fileString != null) {
      File f = new File(fileString);
      if(!f.isFile()) {
        throw new MessageInvalidException(ProtocolErrorMessage.NOT_A_FILE_ERROR, "The given ref file path <"+fileString+"> is not a file", identifier, false);
      }
      try {
        in = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
        ref = new StringBuilder(1024);
        String line;
        while((line = in.readLine()) != null) {
          line = line.trim();
          ref.append( line ).append('\n');
        }
        in.close();
      } catch (FileNotFoundException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.FILE_NOT_FOUND, "File not found when retrieving ref file <"+fileString+">: "+e.getMessage(), identifier, false);
      } catch (IOException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.FILE_PARSE_ERROR, "IO error while retrieving ref file <"+fileString+">: "+e.getMessage(), identifier, false);
      }
      ref = new StringBuilder(ref.toString().trim());
      if("".equals(ref.toString())) {
        throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from file <"+fileString+ '>', identifier, false);
      }
      try {
        fs = new SimpleFieldSet(ref.toString(), false, true, true);
      } catch (IOException e) {
        throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from file <"+fileString+">: "+e.getMessage(), identifier, false);
      }
    }
    fs.setEndMarker( "End" );
View Full Code Here

    identifier = fs.get("Identifier");
  }
 
  @Override
  public SimpleFieldSet getFieldSet() {
    SimpleFieldSet fs = new SimpleFieldSet(true);
    if(identifier != null)
      fs.putSingle("Identifier", identifier);
    return fs;
  }
View Full Code Here

    detailed = fs.getBoolean("Detailed", false);
  }

  @Override
  public SimpleFieldSet getFieldSet() {
    return new SimpleFieldSet(true);
  }
View Full Code Here

    this.completionTime = completionTime;
  }

  @Override
  public SimpleFieldSet getFieldSet() {
    SimpleFieldSet fs = new SimpleFieldSet(true);
    fs.putSingle("Identifier", identifier);
    fs.put("Global", global);
    // This is useful for simple clients.
    if(uri != null)
      fs.putSingle("URI", uri.toString(false, false));
    fs.put("StartupTime", startupTime);
    fs.put("CompletionTime", completionTime);
    return fs;
  }
View Full Code Here

    this.nodeStatus = nodeStatus;
  }

  @Override
  public SimpleFieldSet getFieldSet() {
    SimpleFieldSet fs = new SimpleFieldSet(true);
    fs.putSingle("Identifier", identifier);
    fs.put("NodeStatus", nodeStatus);
    //TODO Textual description of the node status?
    return fs;
  }
View Full Code Here

    }
  }

  @Override
  public SimpleFieldSet getFieldSet() {
    SimpleFieldSet fs = super.getFieldSet();
    fs.putSingle("Name", name);
    fs.putSingle("URI", uri.toString());
    fs.put("HasAnActivelink", hasAnAnActiveLink);
    return fs;
  }
View Full Code Here

    ignoreUSKDatehints = fs.getBoolean("IgnoreUSKDatehints", false);
  }

  @Override
  public SimpleFieldSet getFieldSet() {
    SimpleFieldSet fs = new SimpleFieldSet(true);
    fs.put("IgnoreDS", ignoreDS);
    fs.putSingle("URI", uri.toString(false, false));
    fs.put("FilterData", filterData);
    fs.putSingle("Charset", charset);
    fs.putSingle("Identifier", identifier);
    fs.put("Verbosity", verbosity);
    fs.putSingle("ReturnType", getReturnTypeString());
    fs.put("MaxSize", maxSize);
    fs.put("MaxTempSize", maxTempSize);
    fs.put("MaxRetries", maxRetries);
    fs.put("BinaryBlob", binaryBlob);
    return fs;
  }
View Full Code Here

    final String identifier;
    final boolean global;
   
  @Override
  public SimpleFieldSet getFieldSet() {
    SimpleFieldSet fs = new SimpleFieldSet(false);
    fs.putOverwrite("Min", compat.min().name());
    fs.putOverwrite("Max", compat.max().name());
    fs.put("Min.Number", compat.min().ordinal());
    fs.put("Max.Number", compat.max().ordinal());
    fs.putOverwrite("Identifier", identifier);
    fs.put("Global", global);
    byte[] cryptoKey = compat.getCryptoKey();
    if(cryptoKey != null)
      fs.putOverwrite("SplitfileCryptoKey", HexUtil.bytesToHex(cryptoKey));
    fs.put("DontCompress", compat.dontCompress());
    fs.put("Definitive", compat.definitive());
    return fs;
  }
View Full Code Here

    LineReadingInputStream lis = new LineReadingInputStream(is);

    boolean firstMessage = true;

    while(true) {
      SimpleFieldSet fs;
      if(WrapperManager.hasShutdownHookBeenTriggered()) {
        FCPMessage msg = new ProtocolErrorMessage(ProtocolErrorMessage.SHUTTING_DOWN,true,"The node is shutting down","Node",false);
        handler.outputHandler.queue(msg);
        Closer.close(is);
        return;
      }
      // Read a message
      String messageType = lis.readLine(128, 128, true);
      if(messageType == null) {
        Closer.close(is);
        return;
      }
      if(messageType.equals(""))
        continue;
      fs = new SimpleFieldSet(lis, 4096, 128, true, true, true);

      // check for valid endmarker
      if (!firstMessage && fs.getEndMarker() != null && (!fs.getEndMarker().startsWith("End")) && (!"Data".equals(fs.getEndMarker()))) {
        FCPMessage err = new ProtocolErrorMessage(ProtocolErrorMessage.MESSAGE_PARSE_ERROR, false, "Invalid end marker: "+fs.getEndMarker(), fs.get("Identifer"), fs.getBoolean("Global", false));
        handler.outputHandler.queue(err);
        continue;
      }

      FCPMessage msg;
      try {
        if(logDEBUG)
          Logger.debug(this, "Incoming FCP message:\n"+messageType+'\n'+fs.toString());
        msg = FCPMessage.create(messageType, fs, handler.bf, handler.server.core.persistentTempBucketFactory);
        if(msg == null) continue;
      } catch (MessageInvalidException e) {
        if(firstMessage) {
          FCPMessage err = new ProtocolErrorMessage(ProtocolErrorMessage.CLIENT_HELLO_MUST_BE_FIRST_MESSAGE, true, null, null, false);
View Full Code Here

TOP

Related Classes of freenet.support.SimpleFieldSet

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.