Coverage Report - org.mule.transport.email.AbstractRetrieveMailConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractRetrieveMailConnector
0%
0/30
0%
0/2
1.071
 
 1  
 /*
 2  
  * $Id: AbstractRetrieveMailConnector.java 20321 2010-11-24 15:21:24Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.transport.email;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.construct.FlowConstruct;
 15  
 import org.mule.api.endpoint.InboundEndpoint;
 16  
 import org.mule.api.transport.MessageReceiver;
 17  
 
 18  
 import javax.mail.Flags;
 19  
 
 20  
 /**
 21  
  * Support for connecting to and receiving email from a mailbox (the exact protocol depends on
 22  
  * the subclass).
 23  
  */
 24  
 public abstract class AbstractRetrieveMailConnector extends AbstractMailConnector
 25  
 {
 26  
     public static final int DEFAULT_CHECK_FREQUENCY = 60000;
 27  
 
 28  
     /**
 29  
      * Holds the time in milliseconds that the endpoint should wait before checking a
 30  
      * mailbox
 31  
      */
 32  0
     private volatile long checkFrequency = DEFAULT_CHECK_FREQUENCY;
 33  
 
 34  
     /**
 35  
      * Holds a path where messages should be backed up to (auto-generated if empty)
 36  
      */
 37  0
     private volatile String backupFolder = null;
 38  
 
 39  
     /**
 40  
      * Holds a remote folder name where messages should be moved to after being read
 41  
      */
 42  0
     private volatile String moveToFolder = null;
 43  
 
 44  
     /**
 45  
      * Should we save backups to backupFolder?
 46  
      */
 47  0
     private boolean backupEnabled = false;
 48  
 
 49  
     /**
 50  
      * Once a message has been read, should it be deleted
 51  
      */
 52  0
     private volatile boolean deleteReadMessages = true;
 53  
     
 54  
     /**
 55  
      * The action performed if the deleteReadMessages actions is set to false
 56  
      */
 57  0
     private Flags.Flag defaultProcessMessageAction = Flags.Flag.SEEN;
 58  
 
 59  
     
 60  
     protected AbstractRetrieveMailConnector(int defaultPort, MuleContext context)
 61  
     {
 62  0
         super(defaultPort, MAILBOX, context);
 63  0
     }
 64  
 
 65  
     /**
 66  
      * @return the milliseconds between checking the folder for messages
 67  
      */
 68  
     public long getCheckFrequency()
 69  
     {
 70  0
         return checkFrequency;
 71  
     }
 72  
 
 73  
     public void setCheckFrequency(long l)
 74  
     {
 75  0
         if (l < 1)
 76  
         {
 77  0
             l = DEFAULT_CHECK_FREQUENCY;
 78  
         }
 79  0
         checkFrequency = l;
 80  0
     }
 81  
 
 82  
     /**
 83  
      * @return a relative or absolute path to a directory on the file system
 84  
      */
 85  
     public String getBackupFolder()
 86  
     {
 87  0
         return backupFolder;
 88  
     }
 89  
 
 90  
     public void setBackupFolder(String string)
 91  
     {
 92  0
         backupFolder = string;
 93  0
     }
 94  
 
 95  
     /**
 96  
      * @see org.mule.api.transport.Connector#registerListener(org.mule.api.service.Service, org.mule.api.endpoint.InboundEndpoint) 
 97  
      */
 98  
     public MessageReceiver createReceiver(FlowConstruct flowConstruct, InboundEndpoint endpoint) throws Exception
 99  
     {
 100  0
         Object[] args = {checkFrequency, isBackupEnabled(), backupFolder};
 101  0
         return serviceDescriptor.createMessageReceiver(this, flowConstruct, endpoint, args);
 102  
     }
 103  
 
 104  
     public boolean isDeleteReadMessages()
 105  
     {
 106  0
         return deleteReadMessages;
 107  
     }
 108  
 
 109  
     public void setDeleteReadMessages(boolean deleteReadMessages)
 110  
     {
 111  0
         this.deleteReadMessages = deleteReadMessages;
 112  0
     }
 113  
 
 114  
     public boolean isBackupEnabled()
 115  
     {
 116  0
         return backupEnabled;
 117  
     }
 118  
 
 119  
     public void setBackupEnabled(boolean backupEnabled)
 120  
     {
 121  0
         this.backupEnabled = backupEnabled;
 122  0
     }
 123  
 
 124  
     public String getMoveToFolder()
 125  
     {
 126  0
         return moveToFolder;
 127  
     }
 128  
 
 129  
     public void setMoveToFolder(String moveToFolder)
 130  
     {
 131  0
         this.moveToFolder = moveToFolder;
 132  0
     }
 133  
 
 134  
     public Flags.Flag getDefaultProcessMessageAction()
 135  
     {
 136  0
         return defaultProcessMessageAction;
 137  
     }
 138  
 
 139  
     public void setDefaultProcessMessageAction(Flags.Flag defaultProcessMessageAction)
 140  
     {
 141  0
         this.defaultProcessMessageAction = defaultProcessMessageAction;
 142  0
     }
 143  
 }