use of org.apache.qpid.server.model.IntegrityViolationException in project qpid-broker-j by apache.
the class ManagementNode method performDeleteOperation.
private InternalMessage performDeleteOperation(final Class<? extends ConfiguredObject> clazz, final InternalMessage message) {
InternalMessageHeader requestHeader = message.getMessageHeader();
final Map<String, Object> headers = requestHeader.getHeaderMap();
ConfiguredObject<?> object = findObject(clazz, headers);
if (object != null) {
try {
object.delete();
final MutableMessageHeader responseHeader = new MutableMessageHeader();
responseHeader.setCorrelationId(requestHeader.getCorrelationId() == null ? requestHeader.getMessageId() : requestHeader.getCorrelationId());
responseHeader.setMessageId(UUID.randomUUID().toString());
responseHeader.setHeader(STATUS_CODE_HEADER, STATUS_CODE_NO_CONTENT);
return InternalMessage.createMapMessage(_addressSpace.getMessageStore(), responseHeader, Collections.emptyMap());
} catch (IntegrityViolationException e) {
return createFailureResponse(message, STATUS_CODE_FORBIDDEN, e.getMessage());
}
} else {
return createFailureResponse(message, STATUS_CODE_NOT_FOUND, "Not Found");
}
}
use of org.apache.qpid.server.model.IntegrityViolationException in project qpid-broker-j by apache.
the class AbstractVirtualHostNode method validateChange.
@Override
protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) {
super.validateChange(proxyForValidation, changedAttributes);
VirtualHostNode updated = (VirtualHostNode) proxyForValidation;
if (changedAttributes.contains(DEFAULT_VIRTUAL_HOST_NODE) && updated.isDefaultVirtualHostNode()) {
VirtualHostNode existingDefault = _broker.findDefautVirtualHostNode();
if (existingDefault != null && existingDefault != this) {
throw new IntegrityViolationException("Cannot make '" + getName() + "' the default virtual host node for" + " the Broker as virtual host node '" + existingDefault.getName() + "' is already the default.");
}
}
}
use of org.apache.qpid.server.model.IntegrityViolationException in project qpid-broker-j by apache.
the class RedirectingVirtualHostNodeImpl method validateChange.
@Override
protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes) {
super.validateChange(proxyForValidation, changedAttributes);
VirtualHostNode updated = (VirtualHostNode) proxyForValidation;
if (changedAttributes.contains(DEFAULT_VIRTUAL_HOST_NODE) && updated.isDefaultVirtualHostNode()) {
VirtualHostNode existingDefault = _broker.findDefautVirtualHostNode();
if (existingDefault != null && existingDefault != this) {
throw new IntegrityViolationException("Cannot make '" + getName() + "' the default virtual host node for" + " the Broker as virtual host node '" + existingDefault.getName() + "' is already the default.");
}
}
}
Aggregations