@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); return hashCode; }
public CreateTopicResult unmarshall(StaxUnmarshallerContext context) throws Exception { CreateTopicResult createTopicResult = new CreateTopicResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return createTopicResult; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("TopicArn", targetDepth)) { createTopicResult.setTopicArn(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return createTopicResult; } } } }
/** * <p> * The Amazon Resource Name (ARN) assigned to the created topic. * </p> * * @param topicArn * The Amazon Resource Name (ARN) assigned to the created topic. * @return Returns a reference to this object so that method calls can be chained together. */ public CreateTopicResult withTopicArn(String topicArn) { setTopicArn(topicArn); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateTopicResult == false) return false; CreateTopicResult other = (CreateTopicResult) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; return true; }
public CreateTopicResult unmarshall(StaxUnmarshallerContext context) throws Exception { CreateTopicResult createTopicResult = new CreateTopicResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("TopicArn", targetDepth)) { createTopicResult.setTopicArn(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return createTopicResult; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTopicArn() != null) sb.append("TopicArn: ").append(getTopicArn()); sb.append("}"); return sb.toString(); }
public CreateTopicResult unmarshall(StaxUnmarshallerContext context) throws Exception { CreateTopicResult createTopicResult = new CreateTopicResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 2; while (true) { int xmlEvent = context.nextEvent(); if (xmlEvent == XmlPullParser.END_DOCUMENT) break; if (xmlEvent == XmlPullParser.START_TAG) { if (context.testExpression("TopicArn", targetDepth)) { createTopicResult.setTopicArn(StringStaxUnmarshaller.getInstance().unmarshall( context)); continue; } } else if (xmlEvent == XmlPullParser.END_TAG) { if (context.getCurrentDepth() < originalDepth) { break; } } } return createTopicResult; }
topicArn = createTopicResult.getTopicArn();
private void setupQueueAndTopic() { String randomSeed = UUID.randomUUID().toString(); String queueName = "glacier-archive-transfer-" + randomSeed; String topicName = "glacier-archive-transfer-" + randomSeed; queueUrl = sqs.createQueue(new CreateQueueRequest(queueName)).getQueueUrl(); topicArn = sns.createTopic(new CreateTopicRequest(topicName)).getTopicArn(); String queueARN = sqs.getQueueAttributes(new GetQueueAttributesRequest(queueUrl).withAttributeNames("QueueArn")).getAttributes().get("QueueArn"); Policy sqsPolicy = new Policy().withStatements( new Statement(Effect.Allow) .withPrincipals(Principal.AllUsers) .withActions(SQSActions.SendMessage) .withResources(new Resource(queueARN)) .withConditions(ConditionFactory.newSourceArnCondition(topicArn))); sqs.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, newAttributes("Policy", sqsPolicy.toJson()))); sns.subscribe(new SubscribeRequest(topicArn, "sqs", queueARN)); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateTopicResult == false) return false; CreateTopicResult other = (CreateTopicResult) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTopicArn() != null) sb.append("TopicArn: " + getTopicArn()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTopicArn() == null) ? 0 : getTopicArn().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateTopicResult == false) return false; CreateTopicResult other = (CreateTopicResult) obj; if (other.getTopicArn() == null ^ this.getTopicArn() == null) return false; if (other.getTopicArn() != null && other.getTopicArn().equals(this.getTopicArn()) == false) return false; return true; } }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTopicArn() != null) sb.append("TopicArn: " + getTopicArn()); sb.append("}"); return sb.toString(); }
@Override public String get() { // This will create the topic if it doesn't exist or return the existing topic if it does. CreateTopicResult topic = _amazonSNS.createTopic(topicName); return topic.getTopicArn(); } });
/** * Creates a new sns test topic. * * @param snsClient the Simple Notification Service (SNS) client * @return the Amazon Resource Name (ARN) of the created sns topic */ public static String createTestTopic(final AmazonSNS snsClient) { final String queueName = "jvm-sdk-test-topic-" + UUID.randomUUID(); final CreateTopicResult queueCreationResult = snsClient.createTopic(queueName); return queueCreationResult.getTopicArn(); }
@Override public String resolveDestination(String name) throws DestinationResolutionException { if (this.autoCreate) { return this.amazonSns.createTopic(new CreateTopicRequest(name)).getTopicArn(); } else { String physicalTopicName = name; if (this.resourceIdResolver != null) { physicalTopicName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (physicalTopicName != null && AmazonResourceName.isValidAmazonResourceName(physicalTopicName)) { return physicalTopicName; } String topicArn = getTopicResourceName(null, physicalTopicName); if (topicArn == null) { throw new IllegalArgumentException("No Topic with name: '" + name + "' found. Please use " + "the right topic name or enable auto creation of topics for this DestinationResolver"); } return topicArn; } }
@Override public String resolveDestination(String name) throws DestinationResolutionException { if (this.autoCreate) { return this.amazonSns.createTopic(new CreateTopicRequest(name)).getTopicArn(); } else { String physicalTopicName = name; if (this.resourceIdResolver != null) { physicalTopicName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (physicalTopicName != null && AmazonResourceName.isValidAmazonResourceName(physicalTopicName)) { return physicalTopicName; } String topicArn = getTopicResourceName(null, physicalTopicName); if (topicArn == null) { throw new IllegalArgumentException("No Topic with name: '" + name + "' found. Please use " + "the right topic name or enable auto creation of topics for this DestinationResolver"); } return topicArn; } }
CreateTopicResult createTopicResult = sns.createTopic(createTopicRequest); arn = createTopicResult.getTopicArn();