@Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof UnsubscribeRequest == false) return false;
    UnsubscribeRequest other = (UnsubscribeRequest) obj;

    if (other.getSubscriptionArn() == null ^ this.getSubscriptionArn() == null) return false;
    if (other.getSubscriptionArn() != null
        && other.getSubscriptionArn().equals(this.getSubscriptionArn()) == false) return false;
    return true;
  }
示例#2
0
  /**
   * Unsubscribes from a given Amazon SNS topic.
   *
   * @param topic topic to unsubscribe from
   */
  public void unsubscribeFromTopic(final SnsTopic topic) {
    // Rely on the status stored locally even though it's likely that the device is
    // subscribed to a topic, but the subscription arn is lost, say due to clearing app data.
    if (!topic.isSubscribed()) {
      return;
    }

    final UnsubscribeRequest request = new UnsubscribeRequest();
    request.setSubscriptionArn(topic.getSubscriptionArn());
    sns.unsubscribe(request);

    // update topic and save subscription in shared preferences
    topic.setSubscriptionArn("");
    sharedPreferences.edit().putString(topic.getTopicArn(), "").commit();
  }
  public Request<UnsubscribeRequest> marshall(UnsubscribeRequest unsubscribeRequest) {

    if (unsubscribeRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<UnsubscribeRequest> request =
        new DefaultRequest<UnsubscribeRequest>(unsubscribeRequest, "AmazonSNS");
    request.addParameter("Action", "Unsubscribe");
    request.addParameter("Version", "2010-03-31");

    if (unsubscribeRequest.getSubscriptionArn() != null) {
      request.addParameter(
          "SubscriptionArn", StringUtils.fromString(unsubscribeRequest.getSubscriptionArn()));
    }

    return request;
  }