1 |
|
package org.apache.maven.wagon.providers.webdav; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
import java.io.File; |
20 |
|
import java.io.FileInputStream; |
21 |
|
import java.io.FileNotFoundException; |
22 |
|
import java.io.IOException; |
23 |
|
|
24 |
|
import org.apache.maven.wagon.Wagon; |
25 |
|
import org.apache.maven.wagon.events.TransferEvent; |
26 |
|
import org.apache.maven.wagon.events.TransferEventSupport; |
27 |
|
import org.apache.maven.wagon.resource.Resource; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
public class PutInputStream |
36 |
|
extends FileInputStream |
37 |
|
{ |
38 |
|
private TransferEventSupport eventSupport; |
39 |
|
|
40 |
|
private TransferEvent event; |
41 |
|
|
42 |
|
public PutInputStream( File file, Resource resource, Wagon wagon, TransferEventSupport eventSupport ) |
43 |
|
throws FileNotFoundException |
44 |
|
{ |
45 |
43 |
super( file ); |
46 |
|
|
47 |
43 |
this.eventSupport = eventSupport; |
48 |
|
|
49 |
43 |
event = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT ); |
50 |
|
|
51 |
43 |
event.setLocalFile( file ); |
52 |
43 |
} |
53 |
|
|
54 |
|
public int read( byte buffer[] ) |
55 |
|
throws IOException |
56 |
|
{ |
57 |
2 |
return read( buffer, 0, buffer.length ); |
58 |
|
} |
59 |
|
|
60 |
|
public int read() |
61 |
|
throws IOException |
62 |
|
{ |
63 |
0 |
byte buffer[] = new byte[1]; |
64 |
|
|
65 |
0 |
return read( buffer ); |
66 |
|
} |
67 |
|
|
68 |
|
public int read( byte buffer[], int offset, int length ) |
69 |
|
throws IOException |
70 |
|
{ |
71 |
44 |
int retValue = super.read( buffer, offset, length ); |
72 |
|
|
73 |
44 |
if ( retValue > 0 ) |
74 |
|
{ |
75 |
43 |
event.setTimestamp( System.currentTimeMillis() ); |
76 |
|
|
77 |
43 |
eventSupport.fireTransferProgress( event, buffer, retValue ); |
78 |
|
} |
79 |
44 |
return retValue; |
80 |
|
} |
81 |
|
} |