com.xerox.amazonws.sns
Class NotificationService

java.lang.Object
  extended by com.xerox.amazonws.sns.NotificationService

public class NotificationService
extends Object

This class provides an interface with the Amazon Simple Notification Service.

Author:
D. Kavanagh, developer@dotech.com

Constructor Summary
NotificationService(String awsAccessId, String awsSecretKey)
          Initializes the Simple Notification service with your AWS login information.
NotificationService(String awsAccessId, String awsSecretKey, boolean isSecure)
          Initializes the Simple Notification service with your AWS login information.
NotificationService(String awsAccessId, String awsSecretKey, boolean isSecure, String server)
          Initializes the Simple Notification service with your AWS login information.
NotificationService(String awsAccessId, String awsSecretKey, boolean isSecure, String server, int port)
          Initializes the Simple Notification service with your AWS login information.
 
Method Summary
 void addPermission(String topicArn, String label, List<String> accountIds, List<String> actionNames)
          Adds to the topic's access control policy.
 Result<String> confirmSubscription(String topicArn, String token, boolean authenticateOnUnsubscribe)
          Verifies an endpoint intends to receive messages
 Result<String> createTopic(String name)
          Creates a topic
 void deleteTopic(String topicArn)
          Deletes a topic
 AWSQueryConnection getConnectionDelegate()
          Returns connection object, so connection params can be tweaked
 Map<String,String> getTopicAttributes(String topicArn)
          Gets attributes for the topic
 ListResult<SubscriptionInfo> listSubscriptions(String nextToken)
          Lists the subscriptions
 ListResult<SubscriptionInfo> listSubscriptionsByTopic(String topicArn, String nextToken)
          Lists subscriptions for a topic
 ListResult<String> listTopics(String nextToken)
          Lists topics for this account
protected
<T> T
makeRequestInt(org.apache.http.client.methods.HttpRequestBase method, String action, Map<String,String> params, Class<T> respType)
           
 Result<String> publish(String topicArn, String message, String subject)
          Publishes a message to a topic's subscribed endpoints
 void removePermission(String topicArn, String label)
          Removes permissions from a topic
 void setTopicAttributes(String topicArn, String name, String value)
          Set a topic attribute.
 Result<String> subscribe(String topicArn, String protocol, String endpoint)
          Subscribe this account to a topic
 void unsubscribe(String subscriptionArn)
          Unsubscribe this account from a topic
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotificationService

public NotificationService(String awsAccessId,
                           String awsSecretKey)
Initializes the Simple Notification service with your AWS login information.

Parameters:
awsAccessId - The your user key into AWS
awsSecretKey - The secret string used to generate signatures for authentication.

NotificationService

public NotificationService(String awsAccessId,
                           String awsSecretKey,
                           boolean isSecure)
Initializes the Simple Notification service with your AWS login information.

Parameters:
awsAccessId - The your user key into AWS
awsSecretKey - The secret string used to generate signatures for authentication.
isSecure - True if the data should be encrypted on the wire on the way to or from LS.

NotificationService

public NotificationService(String awsAccessId,
                           String awsSecretKey,
                           boolean isSecure,
                           String server)
Initializes the Simple Notification service with your AWS login information.

Parameters:
awsAccessId - The your user key into AWS
awsSecretKey - The secret string used to generate signatures for authentication.
isSecure - True if the data should be encrypted on the wire on the way to or from LS.
server - Which host to connect to. Usually, this will be sns.amazonaws.com

NotificationService

public NotificationService(String awsAccessId,
                           String awsSecretKey,
                           boolean isSecure,
                           String server,
                           int port)
Initializes the Simple Notification service with your AWS login information.

Parameters:
awsAccessId - The your user key into AWS
awsSecretKey - The secret string used to generate signatures for authentication.
isSecure - True if the data should be encrypted on the wire on the way to or from LS.
server - Which host to connect to. Usually, this will be sns.amazonaws.com
port - Which port to use.
Method Detail

getConnectionDelegate

public AWSQueryConnection getConnectionDelegate()
Returns connection object, so connection params can be tweaked


addPermission

public void addPermission(String topicArn,
                          String label,
                          List<String> accountIds,
                          List<String> actionNames)
                   throws SNSException
Adds to the topic's access control policy.

Parameters:
topicArn - the ARN for the topic
label - the unique identifier for the new policy statement
accountIds - users being given access
actionNames - actions you are allowing
Throws:
SNSException - wraps checked exceptions

confirmSubscription

public Result<String> confirmSubscription(String topicArn,
                                          String token,
                                          boolean authenticateOnUnsubscribe)
                                   throws SNSException
Verifies an endpoint intends to receive messages

Parameters:
topicArn - the ARN for the topic
token - subscription token
authenticateOnUnsubscribe - requires authenticated unsubscribe from the topic
Returns:
the subscription ARN
Throws:
SNSException - wraps checked exceptions

createTopic

public Result<String> createTopic(String name)
                           throws SNSException
Creates a topic

Parameters:
name - name of the new topic
Returns:
the topic ARN
Throws:
SNSException - wraps checked exceptions

deleteTopic

public void deleteTopic(String topicArn)
                 throws SNSException
Deletes a topic

Parameters:
topicArn - the ARN for the topic
Throws:
SNSException - wraps checked exceptions

getTopicAttributes

public Map<String,String> getTopicAttributes(String topicArn)
                                      throws SNSException
Gets attributes for the topic

Parameters:
topicArn - the ARN for the topic
Returns:
a map of attributes
Throws:
SNSException - wraps checked exceptions

listSubscriptions

public ListResult<SubscriptionInfo> listSubscriptions(String nextToken)
                                               throws SNSException
Lists the subscriptions

Parameters:
nextToken - the user token
Returns:
the list of subscriptions
Throws:
SNSException - wraps checked exceptions

listSubscriptionsByTopic

public ListResult<SubscriptionInfo> listSubscriptionsByTopic(String topicArn,
                                                             String nextToken)
                                                      throws SNSException
Lists subscriptions for a topic

Parameters:
nextToken - the user token
Returns:
the list of subscriptions
Throws:
SNSException - wraps checked exceptions

listTopics

public ListResult<String> listTopics(String nextToken)
                              throws SNSException
Lists topics for this account

Parameters:
nextToken - the user token
Returns:
the list of topics
Throws:
SNSException - wraps checked exceptions

publish

public Result<String> publish(String topicArn,
                              String message,
                              String subject)
                       throws SNSException
Publishes a message to a topic's subscribed endpoints

Parameters:
topicArn - the ARN for the topic
message - the message to be sent
subject - the optional subject for the message
Returns:
true if product is subscribed
Throws:
SNSException - wraps checked exceptions

removePermission

public void removePermission(String topicArn,
                             String label)
                      throws SNSException
Removes permissions from a topic

Parameters:
topicArn - the ARN for the topic
label - the label for the permission statement
Throws:
SNSException - wraps checked exceptions

setTopicAttributes

public void setTopicAttributes(String topicArn,
                               String name,
                               String value)
                        throws SNSException
Set a topic attribute.

Parameters:
topicArn - the ARN for the topic
name - name of the attribute
value - value of the attribute
Throws:
SNSException - wraps checked exceptions

subscribe

public Result<String> subscribe(String topicArn,
                                String protocol,
                                String endpoint)
                         throws SNSException
Subscribe this account to a topic

Parameters:
topicArn - the ARN for the topic
Returns:
subscription ARN
Throws:
SNSException - wraps checked exceptions

unsubscribe

public void unsubscribe(String subscriptionArn)
                 throws SNSException
Unsubscribe this account from a topic

Parameters:
topicArn - the ARN for the topic
Throws:
SNSException - wraps checked exceptions

makeRequestInt

protected <T> T makeRequestInt(org.apache.http.client.methods.HttpRequestBase method,
                               String action,
                               Map<String,String> params,
                               Class<T> respType)
                    throws SNSException
Throws:
SNSException