HornetQRestLogger.LOGGER.debug("Handling POST request for \"" + uriInfo.getPath() + "\"");
try
{
JMSServerConfigParserImpl parser = new JMSServerConfigParserImpl();
TopicConfiguration topic = parser.parseTopicConfiguration(document.getDocumentElement());
HornetQTopic hqTopic = HornetQDestination.createTopic(topic.getName());
String topicName = hqTopic.getAddress();
ClientSession session = manager.getSessionFactory().createSession(false, false, false);
try
{
ClientSession.QueueQuery query = session.queueQuery(new SimpleString(topicName));
if (!query.isExists())
{
session.createQueue(topicName, topicName, "__HQX=-1", true);
}
else
{
throw new WebApplicationException(Response.status(412).type("text/plain").entity("Queue already exists.").build());
}
}
finally
{
try { session.close(); } catch (Exception ignored) {}
}
if (topic.getBindings() != null && topic.getBindings().length > 0 && manager.getRegistry() != null)
{
for (String binding : topic.getBindings())
{
manager.getRegistry().bind(binding, hqTopic);
}
}
URI uri = uriInfo.getRequestUriBuilder().path(topicName).build();