@Override
public void exchangeDeclare(Session session, ExchangeDeclare method)
{
String exchangeName = method.getExchange();
VirtualHost virtualHost = getVirtualHost(session);
//we must check for any unsupported arguments present and throw not-implemented
if(method.hasArguments())
{
Map<String,Object> args = method.getArguments();
//QPID-3392: currently we don't support any!
if(!args.isEmpty())
{
exception(session, method, ExecutionErrorCode.NOT_IMPLEMENTED, "Unsupported exchange argument(s) found " + args.keySet().toString());
return;
}
}
if(method.getPassive())
{
Exchange exchange = getExchange(session, exchangeName);
if(exchange == null)
{
exception(session, method, ExecutionErrorCode.NOT_FOUND, "not-found: exchange-name '" + exchangeName + "'");
}
else
{
if (!exchange.getTypeName().equals(method.getType())
&& (method.getType() != null && method.getType().length() > 0))
{
exception(session, method, ExecutionErrorCode.NOT_ALLOWED, "Attempt to redeclare exchange: "
+ exchangeName + " of type " + exchange.getTypeName() + " to " + method.getType() + ".");
}
}
}
else
{
try
{
virtualHost.createExchange(null,
method.getExchange(),
method.getType(),
method.getDurable(),
method.getAutoDelete(),
method.getAlternateExchange());