|
@ -4,6 +4,7 @@ package verteiltesysteme.aws; |
|
|
import javax.ws.rs.*; |
|
|
import javax.ws.rs.*; |
|
|
import javax.ws.rs.core.MediaType; |
|
|
import javax.ws.rs.core.MediaType; |
|
|
|
|
|
|
|
|
|
|
|
import com.amazonaws.regions.Regions; |
|
|
import com.amazonaws.services.s3.AmazonS3; |
|
|
import com.amazonaws.services.s3.AmazonS3; |
|
|
import com.amazonaws.services.s3.AmazonS3ClientBuilder; |
|
|
import com.amazonaws.services.s3.AmazonS3ClientBuilder; |
|
|
|
|
|
|
|
@ -17,12 +18,14 @@ public class TCPTimeCounterRESTService { |
|
|
private Long getCounter() { |
|
|
private Long getCounter() { |
|
|
// Verbindung zu S3 |
|
|
// Verbindung zu S3 |
|
|
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); |
|
|
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); |
|
|
|
|
|
s3Client.setRegion(com.amazonaws.regions.Region.getRegion(Regions.EU_CENTRAL_1)); |
|
|
return new Long(s3Client.getObjectAsString(bucketName, bucketRegion)); |
|
|
return new Long(s3Client.getObjectAsString(bucketName, bucketRegion)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private boolean setCounter(Long counter) { |
|
|
private boolean setCounter(Long counter) { |
|
|
// Verbindung zu S3 |
|
|
// Verbindung zu S3 |
|
|
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); |
|
|
AmazonS3 s3Client = AmazonS3ClientBuilder.defaultClient(); |
|
|
|
|
|
s3Client.setRegion(com.amazonaws.regions.Region.getRegion(Regions.EU_CENTRAL_1)); |
|
|
s3Client.putObject(bucketName, bucketRegion, new Long(counter).toString()); |
|
|
s3Client.putObject(bucketName, bucketRegion, new Long(counter).toString()); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|