Examples of EmailData


Examples of org.xmlBlaster.util.protocol.email.EmailData

   /**
    * Notification by Pop3Driver when a (response) email message arrives.
    * Enforced by I_ResponseListener
    */
   public void incomingMessage(String requestId, Object response) {
      EmailData emailData = (EmailData) response;

      AttachmentHolder msgUnitAttachmentHolder = null;
      String pop3Url = null;
      try {
         pop3Url = getPop3Driver().getPop3Url(); // for logging only
         msgUnitAttachmentHolder =
            emailData.getMsgUnitAttachment(); // "*.xbf", "*.xbfz", "*.xmlz", ...
      } catch (Throwable e) {
         log.warning("Error parsing email data from "
               + pop3Url
               + ", please check the format: "
               + e.toString());
         return;
      }

      if (msgUnitAttachmentHolder == null) {
         log.warning("Got email from POP3 but there was no MsgUnit attachment, we ignore it: " + emailData.toXml(true));
         return;
      }

      byte[] encodedMsgUnit = msgUnitAttachmentHolder.getContent();
      MsgInfo[] msgInfos = null;
      try {
         if (MsgInfo.isCompressed(msgUnitAttachmentHolder.getFileName(), msgUnitAttachmentHolder.getContentType())) {
            // Decompress the bytes
            int length = encodedMsgUnit.length;
            this.decompressor.reset();
            this.decompressor.setInput(encodedMsgUnit, 0, length);
            byte[] buf = new byte[2048+length];
            ByteArrayOutputStream out = new ByteArrayOutputStream(2048+length);
            while (!this.decompressor.finished()) {
               int resultLength = this.decompressor.inflate(buf);
               if (resultLength > 0)
                  out.write(buf, 0, resultLength);
            }
            encodedMsgUnit = out.toByteArray();
            if (log.isLoggable(Level.FINE)) log.fine("Decompressed message from " + length + " to " + encodedMsgUnit.length + " bytes");
         }
         String parserClassName = MsgInfoParserFactory.instance().guessParserName(msgUnitAttachmentHolder.getFileName(), msgUnitAttachmentHolder.getContentType());
         msgInfos = MsgInfo.parse(glob, this.progressListener, encodedMsgUnit, parserClassName, this.pluginConfig);
         if (msgInfos.length < 1) {
            // spam?
            log.warning("Unexpected msgInfo with length==0, requestId=" + requestId + " data=" + emailData.toXml(true));
            Thread.dumpStack();
            return;
         }
         for (int j=0; j<msgInfos.length; j++) {
            MsgInfo msgInfo = msgInfos[j];
            msgInfo.setRequestIdGuessed(emailData.isRequestIdFromSentDate());
            msgInfo.setBounceObject(BOUNCE_MAILFROM_KEY, emailData.getFrom());
            // The messageId could be in the subject and not in the attachment
            msgInfo.setBounceObject(BOUNCE_MESSAGEID_KEY, emailData.getMessageId(messageIdFileName));
            AttachmentHolder[] attachments = emailData.getAttachments();
            for (int i=0; i<attachments.length; i++) {
               AttachmentHolder a = attachments[i];
               if (a == msgUnitAttachmentHolder)
                  continue;
               // TODO: Determine which attachments to bounce
               msgInfo.setBounceObject(a.getFileName(), a);
            }
         }

      } catch (Throwable e) {
         log.warning("Error parsing email data from "
                           + pop3Url
                           + ", check if client and server have identical compression settings: "
                           + e.toString() + ": " + emailData.toXml(true));
         return;
      }

      // Response and Exception messages should NEVER expire
      if (emailData.isExpired(messageIdFileName) && msgInfos[0].isInvoke()) {
         log.warning("Message is expired, we discard it: " + emailData.toString());
         return;
      }

      // For XmlScript && INVOKE we could have multiple message bundled
      // else length is always 1!
      for (int i=0; i<msgInfos.length; i++) {
         MsgInfo msgInfo = msgInfos[i];
         // If counterside has stripped information we add it again from the messageId attachment
         if (msgInfo.getRequestId().length() == 0)
            msgInfo.setRequestId(emailData.getRequestId(messageIdFileName));
         if (msgInfo.getSecretSessionId().length() == 0)
            msgInfo.setSecretSessionId(emailData.getSessionId(messageIdFileName));
  
         try {
            if (i==0 && msgInfo.isInvoke()) {
               if (isLoopingMail(msgInfo, emailData))
                  return;
View Full Code Here

Examples of org.xmlBlaster.util.protocol.email.EmailData

      if (toAddr == null) {
         Thread.dumpStack();
         throw new IllegalArgumentException("No 'toAddress' email address is given, can't send mail: " + MsgInfo.toLiteral(msgInfo.createRawMsg(getMsgInfoParserClassName())));
      }

      EmailData emailData = new EmailData(toAddr, this.fromAddress, subject);
      emailData.setCc(this.cc);
      emailData.setBcc(this.bcc);
      emailData.setExpiryTime(expiryTimestamp);
      String payloadMimetype = msgInfo.getMsgInfoParser(getMsgInfoParserClassName(), pluginConfig).getMimetype(isCompressed);
      emailData.addAttachment(new AttachmentHolder(payloadFileName, payloadMimetype, payload));
      emailData.addAttachment(new AttachmentHolder(this.messageIdFileName, messageId));
      // Bounce all other attachments back to sender
      AttachmentHolder[] attachments = msgInfo.getBounceAttachments();
      for (int i=0; i<attachments.length; i++) {
         AttachmentHolder a = attachments[i];
         if (this.messageIdFileName.equals(a.getFileName()))
            continue; // added alread, see above
         emailData.addAttachment(a);
      }
     
      getSmtpClient().sendEmail(emailData, messageIdFileName);
      //this.smtpClient.sendEmail(this.fromAddress, toAddr, subject,
      //      attachmentName, attachment, attachmentName2, messageId,
View Full Code Here

Examples of org.xmlBlaster.util.protocol.email.EmailData

         if (summary == null) summary = "";
         if (description == null) description = "";

         if (forceSending) {
            EmailData emailData = this.smtpDestinationHelper.createEmailData();
            emailData.setSubject(replaceTokens(
                  this.smtpDestinationHelper.subjectTemplate, summary, description, eventType, errorCode, sessionName));
            emailData.setContent(replaceTokens(
                  this.smtpDestinationHelper.contentTemplate, summary, description, eventType, errorCode, sessionName));
            this.smtpDestinationHelper.smtpClient.sendEmail(emailData);
            return;
         }

         // Must be outside of sync as getting data from inside xmlBlaster e..g. on queue can block long time
         // and prevent other mails from being send
        
         // Build the email, if timer is active append new logging to the content of the existing mail ...
         final EmailData emailData = (this.currentEmailData == null) ? this.smtpDestinationHelper.createEmailData() : this.currentEmailData;
         emailData.setSubject(replaceTokens(
               this.smtpDestinationHelper.subjectTemplate, summary, description, eventType, errorCode, sessionName));
         String old = (emailData.getContent().length() == 0) ? "" :
               emailData.getContent() + this.smtpDestinationHelper.contentSeparator;
         emailData.setContent(old
               + replaceTokens(
                     this.smtpDestinationHelper.contentTemplate, summary, description, eventType, errorCode, sessionName));

         synchronized(this.smtpDestinationMonitor) {
            // If no timer was active send immeditately (usually the first email)
View Full Code Here

Examples of org.xmlBlaster.util.protocol.email.EmailData

         }
         if (this.collectIntervall < 0) this.collectIntervall = 0;
      }

      EmailData createEmailData() {
         EmailData emailData = new EmailData(this.to, this.from,
               "", "");
         emailData.setCc(this.cc);
         emailData.setBcc(this.bcc);
         emailData.setSendAsync(this.sendAsync);
         // emailData.setExpiryTime(expiryTimestamp);
         // emailData.addAttachment(new AttachmentHolder(payloadFileName,
         // payloadMimetype, payload));
         return emailData;
      }
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.