use of com.adeptj.modules.aws.core.AwsException in project adeptj-modules by AdeptJ.
the class AwsS3Service method createFolder.
/**
* {@inheritDoc}
*/
@Override
public S3Response createFolder(String bucketName, String folderName) {
ObjectMetadata objectMetadata = new ObjectMetadata();
objectMetadata.setContentLength(0);
try {
return new S3Response().withPutObjectResult(this.s3Client.putObject(new PutObjectRequest(bucketName, folderName + PATH_SEPARATOR, new ByteArrayInputStream(new byte[0]), objectMetadata)));
} catch (RuntimeException ex) {
LOGGER.error("Exception while creating folder!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
use of com.adeptj.modules.aws.core.AwsException in project adeptj-modules by AdeptJ.
the class AwsSnsService method start.
@Activate
protected void start(SmsConfig smsConfig) {
this.smsAttributes = new HashMap<>();
this.smsAttributes.put("AWS.SNS.SMS.SenderID", new MessageAttributeValue().withStringValue(smsConfig.senderId()).withDataType("String"));
this.smsAttributes.put("AWS.SNS.SMS.SMSType", new MessageAttributeValue().withStringValue(smsConfig.smsType()).withDataType("String"));
try {
this.asyncSNS = AmazonSNSAsyncClient.asyncBuilder().withEndpointConfiguration(AwsUtil.getEndpointConfig(smsConfig.serviceEndpoint(), smsConfig.signingRegion())).withCredentials(AwsUtil.getCredentialsProvider(smsConfig.accessKey(), smsConfig.secretKey())).build();
} catch (Exception ex) {
LOGGER.error("Exception while starting SmsService!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
use of com.adeptj.modules.aws.core.AwsException in project adeptj-modules by AdeptJ.
the class AwsS3Service method uploadFile.
/**
* {@inheritDoc}
*/
@Override
public S3Response uploadFile(S3Request request) {
ObjectMetadata objectMetadata = Objects.requireNonNull(request.getMetadata(), OBJ_METADATA_NULL_MSG);
CannedAccessControlList cannedACL = Objects.requireNonNull(request.getCannedACL(), ACL_NULL_MSG);
try (InputStream data = Objects.requireNonNull(request.getData(), DATA_NULL_MSG)) {
return new S3Response().withPutObjectResult(this.s3Client.putObject(new PutObjectRequest(request.getBucketName(), request.getKey(), data, objectMetadata).withCannedAcl(cannedACL)));
} catch (Exception ex) {
LOGGER.error("Exception while uploading file!!", ex);
throw new AwsException(ex.getMessage(), ex);
}
}
Aggregations