Examples of MailArchiva


Examples of com.stimulus.archiva.webservice.MailArchiva

    // log.info("startup parameters {mailarchivaserver='"+mailArchivaServerURL.getHost()+"',mailServer='"+mailURL.getHost()+"',
    // pollinterval='"+interval/1000+" sec'}");
    log.info("startup parameters {mailarchivaserver='" + mailArchivaServerURL.getHost() + "',mailServer='" + mailServerURL
        + "', pollinterval='" + interval / 1000 + " sec'}");

    MailArchiva mailArchiva = null;
    try
    {
      MailArchivaService service = new MailArchivaServiceLocator();
      mailArchiva = service.getMailArchiva(mailArchivaServerURL);
    }
    catch (Exception e)
    {
      log.error("failed to connect to mailarchiva server {url='" + mailArchivaServerURL.getHost() + "'}", e);
      System.exit(1);
    }

    IAPAgent IAPAgent = new IAPAgent(mailServerURL);

    while (!exit)
    {

      log.info("connecting to email server {url='" + mailServerURL + "'}");
      try
      {
        IAPAgent.connect();
      }
      catch (Exception e)
      {
        log.error("failed to connect to email server {popserver='" + mailServerURL + "'}", e);
        System.exit(1);
      }

      int messageCount = 0;
      int unreadCount = 0;

      try
      {
        messageCount = IAPAgent.getMessageCount();
        unreadCount = IAPAgent.getUnreadMessageCount();
      }
      catch (Exception e)
      {
        log.error("failed to retrieve no. of messages in the default inbox", e);
        System.exit(1);
      }
      log.info("connected to mail server {totmsgs='" + messageCount + "',unreadmsgs='" + unreadCount + "'}");
      for (int i = 1; i <= messageCount; i++)
      {
        try
        {
          MimeMessage m = (MimeMessage) IAPAgent.getMessage(i);
          Address from[] = m.getFrom();
          log.info("store message {from='" + from[0].toString() + "',subject='" + m.getSubject() + "'}");
          // FileOutputStream fos = new FileOutputStream("test.eml");
          // m.writeTo(fos);

          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          GZIPOutputStream gs = new GZIPOutputStream(baos);
          m.writeTo(gs);
          gs.finish();
          mailArchiva.storeMessage(baos.toByteArray());
          // m.setFlag(Flag.DELETED, true);
        }
        catch (Exception e)
        {
          log.error("failed to store message", e);
View Full Code Here

Examples of com.stimulus.archiva.webservice.MailArchiva

    {
      log.error("mailarchiva server url is malformed", e);
      System.exit(1);
    }

    MailArchiva mailArchiva = null;
    try
    {
      MailArchivaService service = new MailArchivaServiceLocator();
      mailArchiva = service.getMailArchiva(mailArchivaServerURL);
    }
    catch (Exception e)
    {
      log.error("failed to connect to mailarchiva server {url='" + mailArchivaServerURL.getHost() + "'}", e);
      System.exit(1);
    }

    InputStream is = null;
   
    if (args.length == 2)
    {
      String emailFilename = args[1];
      log.info("startup parameters {mailarchivaserver='" + mailArchivaServerURL.getHost() + "',emailFile='" + emailFilename + "'}");
      File emailFile = new File(emailFilename);
      try
      {
        log.debug("Reading file: " + emailFile);
        is = new FileInputStream(emailFile);
      }
      catch (FileNotFoundException e)
      {
        log.error("File: " + emailFilename + " not found", e);
      }
    }
    else
    {
      log.debug("Reading from Stdin");
      is = System.in;
    }
   
    MimeMessage m;
    try
    {
      m = new MimeMessage(session, is);
      Address from[] = m.getFrom();
      log.info("store message {from='" + from[0].toString() + "',subject='" + m.getSubject() + "'}");
     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      GZIPOutputStream gs = new GZIPOutputStream(baos);
      m.writeTo(gs);
      gs.finish();
      mailArchiva.storeMessage(baos.toByteArray());
    }
    catch (MessagingException e)
    {
      log.error("Message not a valid email-file",e);
    }
View Full Code Here

Examples of com.stimulus.archiva.webservice.MailArchiva

     
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      GZIPOutputStream gs = new GZIPOutputStream(baos);
      m.writeTo(gs);
      gs.finish();
      MailArchiva mailArchiva = null;
      MailArchivaService service = new MailArchivaServiceLocator();
      try
      {
        mailArchiva = service.getMailArchiva(mailArchivaServerURL);
        mailArchiva.storeMessage(baos.toByteArray());
      }
      catch (Exception e)
      {
        log.error("failed to connect to mailarchiva server {url='" + mailArchivaServerURL.getHost() + "'}", e);
        System.exit(1);
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.