Coverage Report - org.apache.camel.component.file.remote.RemoteFileMessage
 
Classes in this File Line Coverage Branch Coverage Complexity
RemoteFileMessage
37% 
100% 
0
 
 1  
 /**
 2  
  *
 3  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 4  
  * contributor license agreements.  See the NOTICE file distributed with
 5  
  * this work for additional information regarding copyright ownership.
 6  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 7  
  * (the "License"); you may not use this file except in compliance with
 8  
  * the License.  You may obtain a copy of the License at
 9  
  *
 10  
  * http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 package org.apache.camel.component.file.remote;
 19  
 
 20  
 import org.apache.camel.impl.DefaultMessage;
 21  
 
 22  
 import java.io.OutputStream;
 23  
 import java.util.Map;
 24  
 
 25  1
 public class RemoteFileMessage extends DefaultMessage {
 26  
     private OutputStream outputStream;
 27  
     private String fullFileName;
 28  
     private String hostname;
 29  
 
 30  0
     public RemoteFileMessage() {
 31  0
     }
 32  
 
 33  1
     public RemoteFileMessage(String hostname, String fullFileName, OutputStream outputStream) {
 34  1
         this.hostname = hostname;
 35  1
         this.fullFileName = fullFileName;
 36  1
         this.outputStream = outputStream;
 37  1
         setMessageId(hostname + ":" + fullFileName);
 38  1
     }
 39  
 
 40  
     public String getHostname() {
 41  0
         return hostname;
 42  
     }
 43  
 
 44  
     public void setHostname(String hostname) {
 45  0
         this.hostname = hostname;
 46  0
     }
 47  
 
 48  
     public String getFullFileName() {
 49  0
         return fullFileName;
 50  
     }
 51  
 
 52  
     public void setFullFileName(String fullFileName) {
 53  0
         this.fullFileName = fullFileName;
 54  0
     }
 55  
 
 56  
     public OutputStream getOutputStream() {
 57  0
         return outputStream;
 58  
     }
 59  
 
 60  
     public void setOutputStream(OutputStream outputStream) {
 61  0
         this.outputStream = outputStream;
 62  0
     }
 63  
 
 64  
     @Override
 65  
     public RemoteFileExchange getExchange() {
 66  3
         return (RemoteFileExchange) super.getExchange();
 67  
     }
 68  
 
 69  
     @Override
 70  
     protected Object createBody() {
 71  1
         if (outputStream != null) {
 72  1
             return getExchange().getBinding().extractBodyFromOutputStream(getExchange(), outputStream);
 73  
         }
 74  0
         return null;
 75  
     }
 76  
 
 77  
     @Override
 78  
     public RemoteFileMessage newInstance() {
 79  0
         return new RemoteFileMessage();
 80  
     }
 81  
 
 82  
     @Override
 83  
     protected void populateInitialHeaders(Map<String, Object> map) {
 84  0
         super.populateInitialHeaders(map);
 85  0
         map.put("file.remote.host", hostname);
 86  0
         map.put("file.remote.name", fullFileName);
 87  0
     }
 88  
 }