throw body.getChannelException(AMQConstant.NOT_FOUND, "Unknown exchange: " + exchangeName);
}
else if (!exchange.getTypeShortString().equals(body.getType()) && !(body.getType() == null || body.getType().length() ==0))
{
throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " +
exchangeName + " of type " + exchange.getTypeShortString()
+ " 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(!exchange.getTypeShortString().equals(body.getType()))
{
throw new AMQConnectionException(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: "
+ exchangeName + " of type "
+ exchange.getTypeShortString()
+ " to " + body.getType() +".",
body.getClazz(), body.getMethod(),
body.getMajor(), body.getMinor(),null);