Examples of MimeParser


Examples of com.elasticinbox.core.message.MimeParser

  {
    StopWatch stopWatch = Activator.getDefault().getStopWatch();
    Message message;

    try {
      MimeParser parser = new MimeParser();
      parser.parse(env.getMessageInputStream());
      message = parser.getMessage();
    } catch (MimeParserException mpe) {
      logger.error("DID" + deliveryId + ": unable to parse message: ", mpe);
      throw new DeliveryException("Unable to parse message: " + mpe.getMessage());
    } catch (IOException ioe) {
      logger.error("DID" + deliveryId + ": unable to read message stream: ", ioe);
View Full Code Here

Examples of com.elasticinbox.core.message.MimeParser

    // generate new UUID
    UUID messageId = new MessageIdBuilder().build();

    try {
      FileInputStream in = new FileInputStream(file);
      MimeParser parser = new MimeParser();

      // parse message
      parser.parse(in);
      Message message = parser.getMessage();
      message.setSize(file.length()); // update message size
      in.close();

      // add labels to message
      for(Integer label : labels) {
View Full Code Here

Examples of com.elasticinbox.core.message.MimeParser

    InputStream partIn = null;
    MimePart part = null;

    try {
      rawIn = messageDAO.getRaw(mailbox, messageId).getUncompressedInputStream();
      MimeParser mimeParser = new MimeParser();
      mimeParser.parse(rawIn);
      part = mimeParser.getMessage().getPart(partId);
      partIn = mimeParser.getInputStreamByPartId(partId);
      rawIn.close();
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.warn("Internal Server Error: ", e);
View Full Code Here

Examples of com.elasticinbox.core.message.MimeParser

    InputStream partIn = null;
    MimePart part = null;

    try {
      rawIn = messageDAO.getRaw(mailbox, messageId).getUncompressedInputStream();
      MimeParser mimeParser = new MimeParser();
      mimeParser.parse(rawIn);
      part = mimeParser.getMessage().getPartByContentId(contentId);
      partIn = mimeParser.getInputStreamByContentId(contentId);
      rawIn.close();
    } catch (IllegalArgumentException iae) {
      throw new BadRequestException(iae.getMessage());
    } catch (Exception e) {
      logger.info("Internal Server Error: ", e);
View Full Code Here

Examples of com.elasticinbox.core.message.MimeParser

    try {
      Message oldMessage = messageDAO.getParsed(mailbox, messageId);

      FileInputStream in = new FileInputStream(file);
      MimeParser parser = new MimeParser();

      // parse message
      parser.parse(in);
      Message newMessage = parser.getMessage();
      newMessage.setSize(file.length()); // update message size
      in.close();

      // add labels to message
      for(Integer label : oldMessage.getLabels()) {
View Full Code Here

Examples of org.w3c.www.mime.MimeParser

      reply.setContentType(MimeType.TEXT_PLAIN);
      reply.setStream(process.getInputStream());
      return reply;
  }
  // We MUST parse at least one header:
  MimeParser p = new MimeParser(process.getInputStream(),
              new CGIHeaderHolderFactory());
  Reply           reply  = null ;
  try {
      CGIHeaderHolder h = (CGIHeaderHolder) p.parse();
      // Check for a status code:
      String svalue   = h.getStatus();
      String location = h.getLocation();
      if ( svalue != null ) {
    int status = -1;
    try {
                    String _st = svalue.trim();
        int _space = _st.indexOf(' ');
                    if (_space != -1) {
      _st = _st.substring(0, _space);
        }
        status = Integer.parseInt(_st);
    } catch (Exception ex) {
        // This script has emited an invalid status line:
        String msg = ("Emited an invalid status line ["+
          svalue + "].");
        getServer().errlog(this, msg);
        // Throw an HTTPException:
        reply = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
        reply.setContent("CGI script emited invalid status.");
        throw new HTTPException(reply);
    }
    // we will use the default for this frame, but remove
    // the length calculated from the script size.
    reply = createDefaultReply(request, status);
    reply.setContentLength(-1);
      } else {
    // No status code available, any location header ?
    if (location != null) {
        reply = request.makeReply(HTTP.FOUND);
    } else {
        reply = createDefaultReply(request, HTTP.OK);
        reply.setContentLength(-1);
    }
      }
      // Set up the location header if needed:
      if ( location != null ) {
    try {
        reply.setLocation(new URL(getURL(request), location));
    } catch (MalformedURLException ex) {
        // This should really not happen:
        getServer().errlog(this, "unable to create location url "+
               location+
               " in base "+getURL(request));
    }
      }
      // And then, the remaining headers:
      Enumeration e = h.enumerateHeaders();
      if ( e != null ) {
    while ( e.hasMoreElements() ) {
        String hname = (String) e.nextElement();
        reply.setValue(hname, (String) h.getValue(hname));
    }
      }
      reply.setStream(p.getInputStream()) ;
  } catch (IOException ex) {
      ex.printStackTrace();
  } catch (MimeParserException ex) {
      // This script has generated invalid output:
      String msg = (getURL(request)
View Full Code Here

Examples of org.w3c.www.mime.MimeParser

    } catch (FileNotFoundException fex) {
        // should never happen
    }
    CountInputStream cis = new CountInputStream(fis);
    MimeParserReplyFactory repfact = new MimeParserReplyFactory();
    MimeParser mp = new MimeParser(cis, repfact);
    try {
        asisreply = (HttpReplyMessage) mp.parse();
    } catch (MimeParserException mex) {
        // probably a "normal" file, serve it as-is...
        return;
    } catch (IOException ioex) {
        // silently fail, iot will fail later anyway
View Full Code Here

Examples of org.w3c.www.mime.MimeParser

  int       processed = 0;
  ClientException err = null;

  this.input  = in;
  this.output = out;
  this.parser = new MimeParser(input, factory);
  try {
      running = true;
  alive_loop:
      while ( (! interrupted&& keep ) {
    // Get the next available request, and  mark client as used:
View Full Code Here

Examples of org.w3c.www.mime.MimeParser

    TimedSocket ts = new TimedSocket();
    socket = ts.getSocket(inetaddr, port);
    socket.setSoTimeout(timeout);
    output = new BufferedOutputStream(socket.getOutputStream());
    input  = new BufferedInputStream(socket.getInputStream());
    parser = new MimeParser(input, reply_factory);
    cached = false;
      } catch (Throwable ex) {
    if (debug) {
        ex.printStackTrace();
    }
View Full Code Here

Examples of org.w3c.www.mime.MimeParser

      acquireConnection();
      s = conn.connect(80);
      OutputStream os     = (new DataOutputStream
           (new BufferedOutputStream
            (s.getOutputStream())));
      MimeParser   parser = new MimeParser(s.getInputStream()
             , manager.getReplyFactory());
      if ( isTwoStage(req) ) {
    // Emit the request headers:
    req.emit(os, Request.EMIT_HEADERS);
    os.flush();
    if ( o != null )
        notifyObserver(o, new ConnectedEvent(this, req, os));
    rep = (Reply) parser.parse();
    // Wait for a 100 status code:
    if ((rep.getStatus() / 100) == 1) {
        // Notify the observer if any:
        if ( o != null )
      notifyObserver(o, new ContinueEvent(this, req, rep));
        // Finish the request normally:
        req.emit(os, Request.EMIT_BODY|Request.EMIT_FOOTERS);
        os.flush();
        rep = (Reply) parser.parse();
    }
      } else {
    req.emit(os, Request.EMIT_HEADERS);
    os.flush();
    if ( o != null )
        notifyObserver(o, new ConnectedEvent(this, req, os));
    rep = (Reply) parser.parse();
    while ((rep.getStatus() / 100) == 1) {
        if ( o != null )
      notifyObserver(o, new ContinueEvent(this, req, rep));
        // Finish the request normally:
        req.emit(os, Request.EMIT_BODY|Request.EMIT_FOOTERS);
        os.flush();
        rep = (Reply) parser.parse();
    }
      }
      os.close();
  } catch (IOException ex) {
      ex.printStackTrace();
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.