1 | |
package org.kuali.maven.wagon; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import com.amazonaws.services.s3.AmazonS3Client; |
6 | |
import com.amazonaws.services.s3.model.PutObjectRequest; |
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
public class PutThread implements Runnable { |
12 | |
|
13 | |
PutThreadContext context; |
14 | |
|
15 | |
public PutThread() { |
16 | 0 | this(null); |
17 | 0 | } |
18 | |
|
19 | |
public PutThread(PutThreadContext context) { |
20 | 0 | super(); |
21 | 0 | this.context = context; |
22 | 0 | } |
23 | |
|
24 | |
public void run() { |
25 | 0 | int offset = context.getOffset(); |
26 | 0 | int length = context.getLength(); |
27 | 0 | List<PutContext> list = context.getContexts(); |
28 | 0 | RequestFactory factory = context.getFactory(); |
29 | 0 | AmazonS3Client client = context.getClient(); |
30 | 0 | for (int i = offset; i < offset + length; i++) { |
31 | 0 | if (i >= list.size()) { |
32 | 0 | break; |
33 | |
} |
34 | 0 | if (context.getHandler().isStopThreads()) { |
35 | 0 | break; |
36 | |
} |
37 | 0 | PutContext pc = list.get(i); |
38 | 0 | PutObjectRequest request = factory.getPutObjectRequest(pc); |
39 | 0 | pc.fireStart(); |
40 | 0 | client.putObject(request); |
41 | 0 | pc.fireComplete(); |
42 | |
} |
43 | 0 | } |
44 | |
|
45 | |
public PutThreadContext getContext() { |
46 | 0 | return context; |
47 | |
} |
48 | |
|
49 | |
public void setContext(PutThreadContext context) { |
50 | 0 | this.context = context; |
51 | 0 | } |
52 | |
} |