1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
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 |
|
} |