4124 |
23 Sep 16 |
nicklas |
1 |
package net.sf.basedb.opengrid.filetransfer; |
4124 |
23 Sep 16 |
nicklas |
2 |
|
4124 |
23 Sep 16 |
nicklas |
3 |
import java.io.InputStream; |
4124 |
23 Sep 16 |
nicklas |
4 |
|
4124 |
23 Sep 16 |
nicklas |
5 |
/** |
4124 |
23 Sep 16 |
nicklas |
Generic upload source implementation that simply wraps an |
4124 |
23 Sep 16 |
nicklas |
existing input stream. File metadata is optional. |
4124 |
23 Sep 16 |
nicklas |
8 |
|
4124 |
23 Sep 16 |
nicklas |
@author nicklas |
4124 |
23 Sep 16 |
nicklas |
@since 1.0 |
4124 |
23 Sep 16 |
nicklas |
11 |
*/ |
4124 |
23 Sep 16 |
nicklas |
12 |
public class InputStreamUploadSource |
4124 |
23 Sep 16 |
nicklas |
13 |
implements UploadSource |
4124 |
23 Sep 16 |
nicklas |
14 |
{ |
4124 |
23 Sep 16 |
nicklas |
15 |
|
4124 |
23 Sep 16 |
nicklas |
16 |
private final String name; |
4124 |
23 Sep 16 |
nicklas |
17 |
private final InputStream in; |
4124 |
23 Sep 16 |
nicklas |
18 |
private final FileMetaData metadata; |
4124 |
23 Sep 16 |
nicklas |
19 |
|
4124 |
23 Sep 16 |
nicklas |
20 |
/** |
4124 |
23 Sep 16 |
nicklas |
Create a new upload source from the existing input stream. |
4124 |
23 Sep 16 |
nicklas |
22 |
*/ |
4124 |
23 Sep 16 |
nicklas |
23 |
public InputStreamUploadSource(String name, InputStream in) |
4124 |
23 Sep 16 |
nicklas |
24 |
{ |
4124 |
23 Sep 16 |
nicklas |
25 |
this(name, in, null); |
4124 |
23 Sep 16 |
nicklas |
26 |
} |
4124 |
23 Sep 16 |
nicklas |
27 |
|
4124 |
23 Sep 16 |
nicklas |
28 |
/** |
4124 |
23 Sep 16 |
nicklas |
Create a new upload source from the existing input stream |
4124 |
23 Sep 16 |
nicklas |
and file metadata. |
4124 |
23 Sep 16 |
nicklas |
31 |
*/ |
4124 |
23 Sep 16 |
nicklas |
32 |
public InputStreamUploadSource(String name, InputStream in, FileMetaData metadata) |
4124 |
23 Sep 16 |
nicklas |
33 |
{ |
4124 |
23 Sep 16 |
nicklas |
34 |
this.name = name; |
4124 |
23 Sep 16 |
nicklas |
35 |
this.in = in; |
4124 |
23 Sep 16 |
nicklas |
36 |
this.metadata = metadata; |
4124 |
23 Sep 16 |
nicklas |
37 |
} |
4124 |
23 Sep 16 |
nicklas |
38 |
|
4124 |
23 Sep 16 |
nicklas |
39 |
@Override |
4124 |
23 Sep 16 |
nicklas |
40 |
public String getName() |
4124 |
23 Sep 16 |
nicklas |
41 |
{ |
4124 |
23 Sep 16 |
nicklas |
42 |
return name; |
4124 |
23 Sep 16 |
nicklas |
43 |
} |
4124 |
23 Sep 16 |
nicklas |
44 |
|
4124 |
23 Sep 16 |
nicklas |
45 |
@Override |
4124 |
23 Sep 16 |
nicklas |
46 |
public FileMetaData getMetadata() |
4124 |
23 Sep 16 |
nicklas |
47 |
{ |
4124 |
23 Sep 16 |
nicklas |
48 |
return metadata; |
4124 |
23 Sep 16 |
nicklas |
49 |
} |
4124 |
23 Sep 16 |
nicklas |
50 |
|
4124 |
23 Sep 16 |
nicklas |
51 |
@Override |
4124 |
23 Sep 16 |
nicklas |
52 |
public InputStream getInputStream() |
4124 |
23 Sep 16 |
nicklas |
53 |
{ |
4124 |
23 Sep 16 |
nicklas |
54 |
return in; |
4124 |
23 Sep 16 |
nicklas |
55 |
} |
4124 |
23 Sep 16 |
nicklas |
56 |
|
4124 |
23 Sep 16 |
nicklas |
57 |
} |