/**
  * Subscribe a given commenter to future comments posted to the given entry.
  *
  * @param entry the entry to subscribe the commenter to
  * @param commenter the commenter to be subscribed
  * @return the result returned by AWS
  */
 public SubscribeResult subscribe(Entry entry, Commenter commenter) {
   if (StringUtils.isEmpty(entry.getSnsArn())) {
     // If ARN isn't set then entry didn't have an SNS topic created with it so we ignore
     logger.log(Level.WARNING, "Entry did not have an SNS topic associated with it");
     return null;
   }
   SubscribeRequest request =
       new SubscribeRequest(entry.getSnsArn(), EMAIL_PROTOCOL, commenter.getEmail());
   SubscribeResult result = snsClient.subscribe(request);
   return result;
 }
  /**
   * Publishes a comment to the specified entry. The method takes the comment and builds an SNS
   * PublishRequest object. Then the comment is published to the topic associated with the incoming
   * entry.
   *
   * @param entry the entry to publish to
   * @param comment the comment to publish
   * @return the result returned from AWS
   */
  public PublishResult publish(Entry entry, Comment comment) {
    PublishRequest request = new PublishRequest();
    request.setTopicArn(entry.getSnsArn());

    StringBuilder subject = new StringBuilder("Comment Posted to Entry '");
    subject.append(entry.getTitle()).append("'");
    request.setSubject(subject.toString());

    StringBuilder body = new StringBuilder();
    body.append("The following comment was posted to the post '")
        .append(entry.getTitle())
        .append("'\n");
    body.append("Posted by: ").append(comment.getCommenter().getName()).append("\n\n");
    body.append(comment.getBody());

    request.setMessage(body.toString());

    return snsClient.publish(request);
  }
 /**
  * Deletes a previously created topic associated with the entry.
  *
  * @param entry the entry to be deleted
  */
 public void deleteTopic(Entry entry) {
   DeleteTopicRequest request = new DeleteTopicRequest(entry.getSnsArn());
   snsClient.deleteTopic(request);
 }