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