Coverage Report - org.apache.camel.component.file.remote.RemoteFileComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
RemoteFileComponent
56% 
100% 
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.net.URI;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.apache.camel.CamelContext;
 23  
 import org.apache.camel.RuntimeCamelException;
 24  
 import org.apache.camel.impl.DefaultComponent;
 25  
 import org.apache.camel.util.IntrospectionSupport;
 26  
 
 27  6
 public class RemoteFileComponent extends DefaultComponent<RemoteFileExchange> {
 28  
     private RemoteFileConfiguration configuration;
 29  
 
 30  6
     public RemoteFileComponent() {
 31  6
         this.configuration = new RemoteFileConfiguration();
 32  6
     }
 33  
 
 34  0
     public RemoteFileComponent(RemoteFileConfiguration configuration) {
 35  0
         this.configuration = configuration;
 36  0
     }
 37  
 
 38  
     public RemoteFileComponent(CamelContext context) {
 39  0
         super(context);
 40  0
         this.configuration = new RemoteFileConfiguration();
 41  0
     }
 42  
 
 43  
     public String toString() {
 44  0
         return "RemoteFileComponent";
 45  
     }
 46  
 
 47  
     public static RemoteFileComponent remoteFileComponent() {
 48  0
         return new RemoteFileComponent();
 49  
     }
 50  
 
 51  
     protected RemoteFileEndpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception {
 52  6
         RemoteFileConfiguration config = getConfiguration().copy();
 53  6
         config.configure(new URI(uri));
 54  
 
 55  
         // lets make sure we copy the configuration as each endpoint can
 56  
         // customize its own version
 57  
         final RemoteFileEndpoint endpoint;
 58  6
         if ("ftp".equals(config.getProtocol())) {
 59  3
             endpoint = new FtpEndpoint(uri, this, config);
 60  3
         } else if ("sftp".equals(config.getProtocol())) {
 61  3
             endpoint = new SftpEndpoint(uri, this, config);
 62  3
         } else {
 63  0
             throw new RuntimeCamelException("Unsupported protocol: " + config.getProtocol());
 64  
         }
 65  
 
 66  6
         IntrospectionSupport.setProperties(endpoint.getConfiguration(), parameters);
 67  6
         return endpoint;
 68  
     }
 69  
 
 70  
     public RemoteFileConfiguration getConfiguration() {
 71  6
         return configuration;
 72  
     }
 73  
 
 74  
     public void setConfiguration(RemoteFileConfiguration configuration) {
 75  0
         this.configuration = configuration;
 76  0
     }
 77  
 }