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