001 /** 002 * 003 * Licensed to the Apache Software Foundation (ASF) under one or more 004 * contributor license agreements. See the NOTICE file distributed with 005 * this work for additional information regarding copyright ownership. 006 * The ASF licenses this file to You under the Apache License, Version 2.0 007 * (the "License"); you may not use this file except in compliance with 008 * the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.camel.component.file.remote; 019 020 import org.apache.camel.impl.DefaultMessage; 021 022 import java.io.OutputStream; 023 import java.util.Map; 024 025 public class RemoteFileMessage extends DefaultMessage { 026 private OutputStream outputStream; 027 private String fullFileName; 028 private String hostname; 029 030 public RemoteFileMessage() { 031 } 032 033 public RemoteFileMessage(String hostname, String fullFileName, OutputStream outputStream) { 034 this.hostname = hostname; 035 this.fullFileName = fullFileName; 036 this.outputStream = outputStream; 037 setMessageId(hostname + ":" + fullFileName); 038 } 039 040 public String getHostname() { 041 return hostname; 042 } 043 044 public void setHostname(String hostname) { 045 this.hostname = hostname; 046 } 047 048 public String getFullFileName() { 049 return fullFileName; 050 } 051 052 public void setFullFileName(String fullFileName) { 053 this.fullFileName = fullFileName; 054 } 055 056 public OutputStream getOutputStream() { 057 return outputStream; 058 } 059 060 public void setOutputStream(OutputStream outputStream) { 061 this.outputStream = outputStream; 062 } 063 064 @Override 065 public RemoteFileExchange getExchange() { 066 return (RemoteFileExchange) super.getExchange(); 067 } 068 069 @Override 070 protected Object createBody() { 071 if (outputStream != null) { 072 return getExchange().getBinding().extractBodyFromOutputStream(getExchange(), outputStream); 073 } 074 return null; 075 } 076 077 @Override 078 public RemoteFileMessage newInstance() { 079 return new RemoteFileMessage(); 080 } 081 082 @Override 083 protected void populateInitialHeaders(Map<String, Object> map) { 084 super.populateInitialHeaders(map); 085 map.put("file.remote.host", hostname); 086 map.put("file.remote.name", fullFileName); 087 } 088 }