Example usage for com.amazonaws.services.glacier.model SetVaultNotificationsRequest SetVaultNotificationsRequest

List of usage examples for com.amazonaws.services.glacier.model SetVaultNotificationsRequest SetVaultNotificationsRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.glacier.model SetVaultNotificationsRequest SetVaultNotificationsRequest.

Prototype

public SetVaultNotificationsRequest() 

Source Link

Document

Default constructor for SetVaultNotificationsRequest object.

Usage

From source file:com.connexience.server.model.archive.glacier.SetupUtils.java

License:Open Source License

public static void setupVault(String accessKey, String secretKey, String domainName, String vaultName,
        String topicARN) {//from   w  w w. ja va 2 s  .c o m
    try {
        AWSCredentials awsCredentials = new BasicAWSCredentials(accessKey, secretKey);

        AmazonGlacierClient amazonGlacierClient = new AmazonGlacierClient(awsCredentials);
        amazonGlacierClient.setEndpoint("https://glacier." + domainName + ".amazonaws.com/");

        CreateVaultRequest createVaultRequest = new CreateVaultRequest();
        createVaultRequest.withVaultName(vaultName);

        CreateVaultResult createVaultResult = amazonGlacierClient.createVault(createVaultRequest);
        if (createVaultResult != null) {
            VaultNotificationConfig vaultNotificationConfig = new VaultNotificationConfig();
            vaultNotificationConfig.withSNSTopic(topicARN);
            vaultNotificationConfig.withEvents("ArchiveRetrievalCompleted", "InventoryRetrievalCompleted");

            SetVaultNotificationsRequest setVaultNotificationsRequest = new SetVaultNotificationsRequest();
            setVaultNotificationsRequest.withVaultName(vaultName);
            setVaultNotificationsRequest.withVaultNotificationConfig(vaultNotificationConfig);

            amazonGlacierClient.setVaultNotifications(setVaultNotificationsRequest);
        } else
            logger.warn("Unable to create vault: \"" + vaultName + "\"");

        amazonGlacierClient.shutdown();
    } catch (AmazonServiceException amazonServiceException) {
        logger.warn("AmazonServiceException: " + amazonServiceException);
        logger.debug(amazonServiceException);
    } catch (IllegalArgumentException illegalArgumentException) {
        logger.warn("IllegalArgumentException: " + illegalArgumentException);
        logger.debug(illegalArgumentException);
    } catch (AmazonClientException amazonClientException) {
        logger.warn("AmazonClientException: " + amazonClientException);
        logger.debug(amazonClientException);
    } catch (Throwable throwable) {
        logger.warn("Throwable: " + throwable);
        logger.debug(throwable);
    }
}