throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange: " + exchangeName);
}
else if (!(body.getType() == null || body.getType().length() ==0) && !exchange.getTypeName().equals(body.getType().asString()))
{
throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " +
exchangeName + " of type " + exchange.getTypeName()
+ " to " + body.getType() +".",body.getClazz(), body.getMethod(),body.getMajor(),body.getMinor(),null);
}
}
else
{
try
{
exchange = virtualHost.createExchange(null,
exchangeName == null ? null : exchangeName.intern().toString(),
body.getType() == null ? null : body.getType().intern().toString(),
body.getDurable(),
body.getAutoDelete(),
null);
}
catch(ReservedExchangeNameException e)
{
throw body.getConnectionException(AMQConstant.NOT_ALLOWED,
"Attempt to declare exchange: " + exchangeName +
" which begins with reserved prefix.");
}
catch(ExchangeExistsException e)
{
exchange = e.getExistingExchange();
if(!new AMQShortString(exchange.getTypeName()).equals(body.getType()))
{
throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: "
+ exchangeName + " of type "
+ exchange.getTypeName()
+ " to " + body.getType() +".",
body.getClazz(), body.getMethod(),
body.getMajor(), body.getMinor(),null);