} else if (parameters.containsKey("DeleteAll")) {
try {
ListTopicsRequest listTopicRequest = new ListTopicsRequest();
if (nextToken != null) {
listTopicRequest.setNextToken(nextToken);
}
ListTopicsResult listTopicResult = sns.listTopics(listTopicRequest);
topics = listTopicResult.getTopics();
} catch (Exception ex) {
logger.error("event=list_topics user_id= " + userId, ex);
throw new ServletException(ex);
}
for (int i = 0; topics != null && i < topics.size(); i++) {
Topic t = topics.get(i);
try {
DeleteTopicRequest deleteTopicRequest = new DeleteTopicRequest(t.getTopicArn());
sns.deleteTopic(deleteTopicRequest);
logger.debug("event=delete_topic topic_arn=" + (t != null ? t.getTopicArn() : "null") + " user_id= " + userId);
} catch (Exception ex) {
logger.error("event=delete_topic topic_arn=" + (t != null ? t.getTopicArn() : "null") + " user_id= " + userId, ex);
}
}
}
out.println("<html>");
header(request, out, "Topics");
out.println("<body>");
out.println("<h2>Topics</h2>");
long numTopics = 0;
try {
numTopics = PersistenceFactory.getUserPersistence().getNumUserTopics(userId);
} catch (PersistenceException ex) {
logger.warn("event=queue_count_failure", ex);
}
if (user != null) {
out.println("<table><tr><td><b>User Name:</b></td><td>"+ user.getUserName()+"</td></tr>");
out.println("<tr><td><b>User ID:</b></td><td>"+ user.getUserId()+"</td></tr>");
out.println("<tr><td><b>Access Key:</b></td><td>"+user.getAccessKey()+"</td></tr>");
out.println("<tr><td><b>Access Secret:</b></td><td>"+user.getAccessSecret()+"</td>");
out.println("<tr><td><b>Topic Count</b></td><td>"+numTopics+"</td></tr></table>");
}
out.println("<p><table>");
out.println("<tr><td><b>Topic Name</b></td><td><b>Topic Display Name</b></td><td></td></tr>");
out.println("<form action=\"/webui/cnsuser?userId=" + userId + "\" " + "method=POST>");
out.println("<tr><td><input type='text' name='topic' /></td><td><input type='text' name='display'><input type='hidden' name='userId' value='"+ userId + "'></td><td><input type='submit' value='Create' name='Create' /></td></tr></form></table></p>");
out.println("<p><table>");
out.println("<form action=\"/webui/cnsuser?userId=" + userId + "\" " + "method=POST>");
out.println("<tr><td><input type='hidden' name='userId' value='"+ userId + "'></td><td><input type='submit' value='Delete All' name='DeleteAll' onclick=\"return confirm('Are you sure you want to delete all topics?')\" /></td></tr></form></table></p>");
ListTopicsResult listTopicResult = null;
try {
ListTopicsRequest listTopicRequest = new ListTopicsRequest();
if (nextToken != null) {
listTopicRequest.setNextToken(nextToken);
}
listTopicResult = sns.listTopics(listTopicRequest);
topics = listTopicResult.getTopics();