Search in sources :

Example 1 with IntegrityViolationException

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");
    }
}
Also used : InternalMessageHeader(org.apache.qpid.server.message.internal.InternalMessageHeader) ManagedObject(org.apache.qpid.server.model.ManagedObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) IntegrityViolationException(org.apache.qpid.server.model.IntegrityViolationException)

Example 2 with IntegrityViolationException

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.");
        }
    }
}
Also used : VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) IntegrityViolationException(org.apache.qpid.server.model.IntegrityViolationException)

Example 3 with IntegrityViolationException

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.");
        }
    }
}
Also used : VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) IntegrityViolationException(org.apache.qpid.server.model.IntegrityViolationException)

Aggregations

IntegrityViolationException (org.apache.qpid.server.model.IntegrityViolationException)3 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 ManagedObject (org.apache.qpid.server.model.ManagedObject)1