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

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

Introduction

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

Prototype

public VaultNotificationConfig() 

Source Link

Document

Default constructor for VaultNotificationConfig 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  ww .j av a 2 s. com
    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);
    }
}