Coverage Report - org.mule.transport.sftp.notification.SftpTransportNotification
 
Classes in this File Line Coverage Branch Coverage Complexity
SftpTransportNotification
0%
0/19
0%
0/2
1.5
 
 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.sftp.notification;
 8  
 
 9  
 import org.apache.commons.logging.Log;
 10  
 import org.apache.commons.logging.LogFactory;
 11  
 import org.mule.api.MuleMessage;
 12  
 import org.mule.api.endpoint.ImmutableEndpoint;
 13  
 import org.mule.context.notification.CustomNotification;
 14  
 import org.mule.context.notification.EndpointMessageNotification;
 15  
 
 16  
 public class SftpTransportNotification extends CustomNotification
 17  
 {
 18  
 
 19  
     /**
 20  
      * serial version
 21  
      */
 22  
     private static final long serialVersionUID = 4662315555948069782L;
 23  
 
 24  
     /**
 25  
      * logger used by this class
 26  
      */
 27  0
     protected static final Log logger = LogFactory.getLog(EndpointMessageNotification.class);
 28  
 
 29  
     /**
 30  
      * sftp transport specific actions
 31  
      */
 32  
     private static final int SFTP_ACTION_BASE = CUSTOM_EVENT_ACTION_START_RANGE * 2;
 33  
     public static final int SFTP_GET_ACTION = SFTP_ACTION_BASE + 1;
 34  
     public static final int SFTP_PUT_ACTION = SFTP_ACTION_BASE + 2;
 35  
     public static final int SFTP_RENAME_ACTION = SFTP_ACTION_BASE + 3;
 36  
     public static final int SFTP_DELETE_ACTION = SFTP_ACTION_BASE + 4;
 37  
 
 38  
     public static final String SFTP_GET_ACTION_MSG = "sftp.get";
 39  
     public static final String SFTP_PUT_ACTION_MSG = "sftp.put";
 40  
     public static final String SFTP_RENAME_ACTION_MSG = "sftp.rename";
 41  
     public static final String SFTP_DELETE_ACTION_MSG = "sftp.delete";
 42  
 
 43  
     /**
 44  
      * sftp transport specific information
 45  
      */
 46  
     private ImmutableEndpoint endpoint;
 47  
     private String info;
 48  
     private long size;
 49  
 
 50  
     static
 51  
     {
 52  0
         registerAction(SFTP_GET_ACTION_MSG, SFTP_GET_ACTION);
 53  0
         registerAction(SFTP_PUT_ACTION_MSG, SFTP_PUT_ACTION);
 54  0
         registerAction(SFTP_RENAME_ACTION_MSG, SFTP_RENAME_ACTION);
 55  0
         registerAction(SFTP_DELETE_ACTION_MSG, SFTP_DELETE_ACTION);
 56  0
     }
 57  
 
 58  
     public SftpTransportNotification(MuleMessage resource,
 59  
                                      ImmutableEndpoint endpoint,
 60  
                                      String resourceIdentifier,
 61  
                                      int action,
 62  
                                      String info,
 63  
                                      long size)
 64  
     {
 65  
 
 66  0
         super(resource, action, resourceIdentifier);
 67  
 
 68  0
         if (logger.isDebugEnabled()) logger.debug("*** SftpTransportNotification object created ***");
 69  
 
 70  0
         this.endpoint = endpoint;
 71  0
         this.info = info;
 72  0
         this.size = size;
 73  0
     }
 74  
 
 75  
     protected String getPayloadToString()
 76  
     {
 77  
         try
 78  
         {
 79  0
             return ((MuleMessage) source).getPayloadAsString();
 80  
         }
 81  0
         catch (Exception e)
 82  
         {
 83  0
             return source.toString();
 84  
         }
 85  
     }
 86  
 
 87  
     public String toString()
 88  
     {
 89  0
         return EVENT_NAME + "{action = " + getActionName(action) + ", endpoint = "
 90  
                + endpoint.getEndpointURI() + ", info = " + info + ", size = " + size
 91  
                + ", resourceIdentifier = " + resourceIdentifier + ", timestamp = " + timestamp
 92  
                + ", serverId = " + serverId + ", message = " + source + "}";
 93  
     }
 94  
 
 95  
     public ImmutableEndpoint getEndpoint()
 96  
     {
 97  0
         return endpoint;
 98  
     }
 99  
 
 100  
     public String getInfo()
 101  
     {
 102  0
         return info;
 103  
     }
 104  
 
 105  
     public long getSize()
 106  
     {
 107  0
         return size;
 108  
     }
 109  
 
 110  
 }