use of software.amazon.awssdk.awscore.exception.AwsServiceException in project flyway by flyway.
the class AwsS3Resource method read.
@Override
public Reader read() {
S3Client s3 = S3ClientFactory.getClient();
try {
GetObjectRequest.Builder builder = GetObjectRequest.builder().bucket(bucketName).key(s3ObjectSummary.key());
GetObjectRequest request = builder.build();
ResponseInputStream o = s3.getObject(request);
return Channels.newReader(Channels.newChannel(o), encoding.name());
} catch (AwsServiceException e) {
LOG.error(e.getMessage(), e);
throw new FlywayException("Failed to get object from s3: " + e.getMessage(), e);
}
}
use of software.amazon.awssdk.awscore.exception.AwsServiceException in project aws-doc-sdk-examples by awsdocs.
the class DeleteIdentityPool method deleteIdPool.
// snippet-start:[cognito.java2.deleteidpool.main]
public static void deleteIdPool(CognitoIdentityClient cognitoIdClient, String identityPoold) {
try {
DeleteIdentityPoolRequest identityPoolRequest = DeleteIdentityPoolRequest.builder().identityPoolId(identityPoold).build();
cognitoIdClient.deleteIdentityPool(identityPoolRequest);
System.out.println("Done");
} catch (AwsServiceException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.awscore.exception.AwsServiceException in project aws-doc-sdk-examples by awsdocs.
the class AmazonPersonalizeRecommender method putEvent.
public void putEvent(UserEvent e) {
try {
Event event = Event.builder().eventId(UUID.randomUUID().toString()).eventType(e.event).itemId(e.itemId).sentAt(Instant.ofEpochMilli(System.currentTimeMillis() + 10 * 60 * 1000)).build();
PutEventsRequest putEventsRequest = PutEventsRequest.builder().trackingId(trackingId).userId(e.getUserId()).sessionId("temp").eventList(event).build();
personalizeEventsClient.putEvents(putEventsRequest);
System.out.println("Event sent: " + e);
} catch (AwsServiceException ex) {
System.err.println(ex.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.awscore.exception.AwsServiceException in project aws-doc-sdk-examples by awsdocs.
the class AmazonPersonalizeRecommender method getItemsForUser.
public List<Item> getItemsForUser(String userId) {
List<Item> list = new ArrayList<>();
try {
GetRecommendationsRequest recommendationsRequest = GetRecommendationsRequest.builder().campaignArn(userPersonalizationCampaignArn).numResults(20).userId(userId).build();
GetRecommendationsResponse recommendationsResponse = personalizeRuntimeClient.getRecommendations(recommendationsRequest);
List<PredictedItem> items = recommendationsResponse.itemList();
for (PredictedItem item : items) {
list.add(new Item(item.itemId(), itemIdToNameMap.get(item.itemId())));
}
} catch (AwsServiceException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return list;
}
use of software.amazon.awssdk.awscore.exception.AwsServiceException in project aws-doc-sdk-examples by awsdocs.
the class AmazonPersonalizeRecommender method getItemsForItem.
public List<Item> getItemsForItem(String itemId) {
List<Item> list = new ArrayList<>();
try {
GetRecommendationsRequest simsRequest = GetRecommendationsRequest.builder().campaignArn(simsCampaignArn).itemId(itemId).build();
GetRecommendationsResponse simsResponse = personalizeRuntimeClient.getRecommendations(simsRequest);
List<PredictedItem> items = simsResponse.itemList();
for (PredictedItem item : items) {
list.add(new Item(item.itemId(), itemIdToNameMap.get(item.itemId())));
}
} catch (AwsServiceException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return list;
}
Aggregations