Search in sources :

Example 1 with CopyObjectResult

use of com.amazonaws.services.s3.model.CopyObjectResult in project camel by apache.

the class AmazonS3ClientMock method copyObject.

@Override
public CopyObjectResult copyObject(CopyObjectRequest copyObjectRequest) throws AmazonClientException, AmazonServiceException {
    CopyObjectResult copyObjectResult = new CopyObjectResult();
    copyObjectResult.setETag("3a5c8b1ad448bca04584ecb55b836264");
    copyObjectResult.setVersionId("11192828ahsh2723");
    return copyObjectResult;
}
Also used : CopyObjectResult(com.amazonaws.services.s3.model.CopyObjectResult)

Example 2 with CopyObjectResult

use of com.amazonaws.services.s3.model.CopyObjectResult in project camel by apache.

the class S3Producer method copyObject.

private void copyObject(AmazonS3 s3Client, Exchange exchange) {
    String bucketNameDestination;
    String destinationKey;
    String sourceKey;
    String bucketName;
    String versionId;
    bucketName = exchange.getIn().getHeader(S3Constants.BUCKET_NAME, String.class);
    if (ObjectHelper.isEmpty(bucketName)) {
        bucketName = getConfiguration().getBucketName();
    }
    sourceKey = exchange.getIn().getHeader(S3Constants.KEY, String.class);
    destinationKey = exchange.getIn().getHeader(S3Constants.DESTINATION_KEY, String.class);
    bucketNameDestination = exchange.getIn().getHeader(S3Constants.BUCKET_DESTINATION_NAME, String.class);
    versionId = exchange.getIn().getHeader(S3Constants.VERSION_ID, String.class);
    if (ObjectHelper.isEmpty(bucketName)) {
        throw new IllegalArgumentException("Bucket Name must be specified for copyObject Operation");
    }
    if (ObjectHelper.isEmpty(bucketNameDestination)) {
        throw new IllegalArgumentException("Bucket Name Destination must be specified for copyObject Operation");
    }
    if (ObjectHelper.isEmpty(sourceKey)) {
        throw new IllegalArgumentException("Source Key must be specified for copyObject Operation");
    }
    if (ObjectHelper.isEmpty(destinationKey)) {
        throw new IllegalArgumentException("Destination Key must be specified for copyObject Operation");
    }
    CopyObjectRequest copyObjectRequest;
    if (ObjectHelper.isEmpty(versionId)) {
        copyObjectRequest = new CopyObjectRequest(bucketName, sourceKey, bucketNameDestination, destinationKey);
    } else {
        copyObjectRequest = new CopyObjectRequest(bucketName, sourceKey, versionId, bucketNameDestination, destinationKey);
    }
    CopyObjectResult copyObjectResult = s3Client.copyObject(copyObjectRequest);
    Message message = getMessageForResponse(exchange);
    message.setHeader(S3Constants.E_TAG, copyObjectResult.getETag());
    if (copyObjectResult.getVersionId() != null) {
        message.setHeader(S3Constants.VERSION_ID, copyObjectResult.getVersionId());
    }
}
Also used : CopyObjectRequest(com.amazonaws.services.s3.model.CopyObjectRequest) Message(org.apache.camel.Message) CopyObjectResult(com.amazonaws.services.s3.model.CopyObjectResult)

Aggregations

CopyObjectResult (com.amazonaws.services.s3.model.CopyObjectResult)2 CopyObjectRequest (com.amazonaws.services.s3.model.CopyObjectRequest)1 Message (org.apache.camel.Message)1