4123 |
22 Sep 16 |
nicklas |
1 |
package net.sf.basedb.opengrid.filetransfer; |
4123 |
22 Sep 16 |
nicklas |
2 |
|
4123 |
22 Sep 16 |
nicklas |
3 |
import java.io.InputStream; |
4123 |
22 Sep 16 |
nicklas |
4 |
import java.util.Date; |
4123 |
22 Sep 16 |
nicklas |
5 |
|
4123 |
22 Sep 16 |
nicklas |
6 |
import net.sf.basedb.core.File; |
4123 |
22 Sep 16 |
nicklas |
7 |
|
4123 |
22 Sep 16 |
nicklas |
8 |
/** |
4123 |
22 Sep 16 |
nicklas |
Upload source implementation for uploading a BASE file to |
4123 |
22 Sep 16 |
nicklas |
a remote server. |
4123 |
22 Sep 16 |
nicklas |
11 |
|
4123 |
22 Sep 16 |
nicklas |
@author nicklas |
4123 |
22 Sep 16 |
nicklas |
@since 1.0 |
4123 |
22 Sep 16 |
nicklas |
14 |
*/ |
4123 |
22 Sep 16 |
nicklas |
15 |
public class BaseFileUploadSource |
4124 |
23 Sep 16 |
nicklas |
16 |
extends AbstractFileTransfer |
4123 |
22 Sep 16 |
nicklas |
17 |
implements UploadSource |
4123 |
22 Sep 16 |
nicklas |
18 |
{ |
4123 |
22 Sep 16 |
nicklas |
19 |
|
4123 |
22 Sep 16 |
nicklas |
20 |
private final File file; |
4123 |
22 Sep 16 |
nicklas |
21 |
|
4123 |
22 Sep 16 |
nicklas |
22 |
/** |
4123 |
22 Sep 16 |
nicklas |
Create a new upload source that references the |
4123 |
22 Sep 16 |
nicklas |
given file in BASE. |
4123 |
22 Sep 16 |
nicklas |
25 |
*/ |
4123 |
22 Sep 16 |
nicklas |
26 |
public BaseFileUploadSource(File file) |
4123 |
22 Sep 16 |
nicklas |
27 |
{ |
4124 |
23 Sep 16 |
nicklas |
28 |
super(file.getName()); |
4123 |
22 Sep 16 |
nicklas |
29 |
this.file = file; |
4123 |
22 Sep 16 |
nicklas |
30 |
} |
4123 |
22 Sep 16 |
nicklas |
31 |
|
4123 |
22 Sep 16 |
nicklas |
32 |
@Override |
4124 |
23 Sep 16 |
nicklas |
33 |
protected void initMetadata(FileMetaData metadata) |
4123 |
22 Sep 16 |
nicklas |
34 |
{ |
4124 |
23 Sep 16 |
nicklas |
35 |
metadata.setLastModifiedTime(file.getLastUpdate().getTime()); |
4124 |
23 Sep 16 |
nicklas |
36 |
metadata.setLastModifiedTime(new Date().getTime()); |
4124 |
23 Sep 16 |
nicklas |
37 |
metadata.setSize(file.getSize()); |
4123 |
22 Sep 16 |
nicklas |
38 |
} |
4123 |
22 Sep 16 |
nicklas |
39 |
|
4123 |
22 Sep 16 |
nicklas |
40 |
@Override |
4123 |
22 Sep 16 |
nicklas |
41 |
public InputStream getInputStream() |
4123 |
22 Sep 16 |
nicklas |
42 |
{ |
4123 |
22 Sep 16 |
nicklas |
43 |
return file.getDownloadStream(0); |
4123 |
22 Sep 16 |
nicklas |
44 |
} |
4123 |
22 Sep 16 |
nicklas |
45 |
|
4123 |
22 Sep 16 |
nicklas |
46 |
} |