Package smilehouse.opensyncro.pipes.log

Examples of smilehouse.opensyncro.pipes.log.LogMessageEntry


        LogEntry logEntryOld = null;
      TD messageCell = new TD();
      boolean firstEntry = true;
        for(Iterator i = entries.iterator(); i.hasNext();) {

            LogMessageEntry entry = (LogMessageEntry) i.next();
           
          LogEntry logEntry = entry.getLog();
          /* 
           * Rows are added to table immediately after logEntry has changed.
           * To detect the change, logEntryOld is used for comparison.
           * When entering the for-loop for the first time logEntryOld is set to logEntry.
           */
          if (firstEntry){
            logEntryOld = logEntry;
            firstEntry = false;
            //check if entry is continued from previous page
            if(entry.getIndex() != 1){
              messageCell.addElement("...");
                messageCell.addElement(new BR());
            }
          }
          /*
           * When logEntry gets new value, the previously collected log message entries are written
           * to table and new TD() is created
           */
        if(!logEntry.equals(logEntryOld)){
              colorIndex = 1 - colorIndex;
              writeRow(logEntryOld, dFormat, colorIndex, tt, logTable, messageCell, labels);

              messageCell = new TD();
              messageCell.setAlign("left"); // IE6 would center the contents by default

              logEntryOld = logEntry;
          }
       
        messageCell.addElement(entry.getMessage());
        messageCell.addElement(new BR());
       
          //write last row (complete or incomplete entry)
        if (!i.hasNext()){
          //check if entry is continued on next page
          if (entry.getIndex() < pers.getMaxMessageIndex(logEntry.getId()))
              messageCell.addElement("...");
          colorIndex = 1 - colorIndex;
              writeRow(logEntryOld, dFormat, colorIndex, tt, logTable, messageCell, labels);
        }
         
View Full Code Here


                  
                  messages = persister.getLogMessageEntries(
                             logEntry.getId(),
                             getLoggingVerbosityLevel());
                    for(Iterator m = messages.iterator(); m.hasNext();) {
                        LogMessageEntry messageEntry = (LogMessageEntry) m.next();
                        message += (messageEntry.getMessage()) + "\n";
                    }
                } else {
                    message += MAIL_MESSAGE_NO_ENTRIES;
                }
               
                // Send notification email except when the message is
        // MAIL_MESSAGE_NO_ENTRIES or the pipe has aborted and
                // isAbortMailEnabled()==true
        if (!message.equals(MAIL_MESSAGE_NO_ENTRIES)
            || (statusCode==LogEntry.STATUS_ABORTED && isAbortMailEnabled())) {
          try {

            Properties props = new Properties();
            props.put("mail.host", getMailHost());

            Session mailConnection = Session.getInstance(props,
                null);
            Message msg = new MimeMessage(mailConnection);
            Address sender = new InternetAddress(MAIL_SENDER + "@"
                + getMailHost(), MAIL_SENDER);
            Address[] receivers = receiverAddresses(getRecipientAddress());

            // Set mail content and subject
            msg.setContent(message, "text/plain");
            msg.setFrom(sender);
            msg.setRecipients(Message.RecipientType.TO, receivers);
            msg.setSubject(subject);

            // Send the mail
            Transport.send(msg);

          } catch (MessagingException e) {
            String error = "An error occurred when sending mail report from "
                + MAIL_SENDER
                + "@"
                + getMailHost()
                + " to "
                + getRecipientAddress()
                + ":\n"
                + e.getMessage();
            Environment.getInstance().log(error);
            logEntry.logMessage(error, this, MessageLogger.ERROR);
            persister.update(logEntry);
          } catch (RuntimeException ex) {
            Environment.getInstance().log(
                "A RuntimeException has occurred: "
                    + ex.getMessage()
                    + ex.getStackTrace().toString());
          }
        }
      }
            // Remove unnecessary (debug level) messages from the LogEntry if Transfer log
            // verbosity level is set to DYNAMIC and the current LogEntry's status is either
            // OK or ABORTED
            if(getLoggingVerbosityLevel() == MessageLogger.LOG_DYNAMIC
                    && (statusCode == LogEntry.STATUS_OK || statusCode == LogEntry.STATUS_ABORTED) ) {
                messages = persister.getLogMessageEntries(logEntry.getId(), MessageLogger.DEBUG);
                if(messages.size() > 0) {
                    for(Iterator m = messages.iterator(); m.hasNext();) {
                        LogMessageEntry messageEntry = (LogMessageEntry) m.next();
                        if(messageEntry.getMessageType() == MessageLogger.DEBUG) {
                            persister.delete(messageEntry);
                           
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of smilehouse.opensyncro.pipes.log.LogMessageEntry

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.