Coverage Report - org.apache.camel.component.file.remote.FtpEndpoint
 
Classes in this File Line Coverage Branch Coverage Complexity
FtpEndpoint
18% 
0% 
0
 
 1  
 /**
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.camel.component.file.remote;
 18  
 
 19  
 import java.io.IOException;
 20  
 
 21  
 import org.apache.camel.Processor;
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 import org.apache.commons.net.ftp.FTPClient;
 25  
 
 26  0
 public class FtpEndpoint extends RemoteFileEndpoint<RemoteFileExchange> {
 27  1
     private static final transient Log LOG = LogFactory.getLog(FtpEndpoint.class);
 28  
 
 29  
     public FtpEndpoint(String uri, RemoteFileComponent remoteFileComponent, RemoteFileConfiguration configuration) {
 30  3
         super(uri, remoteFileComponent, configuration);
 31  3
     }
 32  
 
 33  
     public FtpProducer createProducer() throws Exception {
 34  0
         return new FtpProducer(this, createFtpClient());
 35  
     }
 36  
 
 37  
     public FtpConsumer createConsumer(Processor processor) throws Exception {
 38  0
         final FtpConsumer consumer = new FtpConsumer(this, processor, createFtpClient());
 39  0
         configureConsumer(consumer);
 40  0
         return consumer;
 41  
     }
 42  
 
 43  
     protected FTPClient createFtpClient() throws IOException {
 44  0
         final FTPClient client = new FTPClient();
 45  0
         RemoteFileConfiguration config = getConfiguration();
 46  0
         String host = config.getHost();
 47  0
         int port = config.getPort();
 48  0
         LOG.debug("Connecting to host: " + host + " port: " + port);
 49  
 
 50  0
         client.connect(host, port);
 51  0
         client.login(config.getUsername(), config.getPassword());
 52  0
         client.setFileType(config.isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
 53  0
         return client;
 54  
     }
 55  
 }