private static ConnectionConfigurationInvalidException.Builder invalidValueForConfig(final Object value, final String configName, final String location) { final String message = MessageFormat.format("Invalid value ''{0}'' for configuration ''{1}'' in {2}", value, configName, location); return ConnectionConfigurationInvalidException.newBuilder(message); } }
private static ConnectionConfigurationInvalidException.Builder invalidValueForConfig(final Object value, final String configName, final String location) { final String message = MessageFormat.format("Invalid value ''{0}'' for configuration ''{1}'' in {2}", value, configName, location); return ConnectionConfigurationInvalidException.newBuilder(message); } }
private void checkSourceAndTargetAreValid() { if (sources.isEmpty() && targets.isEmpty()) { throw ConnectionConfigurationInvalidException.newBuilder("Either a source or a target must be " + "specified in the configuration of a connection!").build(); } }
private void checkSourceAndTargetAreValid() { if (sources.isEmpty() && targets.isEmpty()) { throw ConnectionConfigurationInvalidException.newBuilder("Either a source or a target must be " + "specified in the configuration of a connection!").build(); } }
private DittoRuntimeExceptionBuilder<ConnectionConfigurationInvalidException> badFormat( final JsonPointer errorLocation, final String label, final String binaryFormat) { final String message = String.format("%s: bad format. " + "Expect PEM-encoded %s data specified by RFC-7468 starting with '-----BEGIN %s-----'", errorLocation.toString(), binaryFormat, label); return ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders); }
private DittoRuntimeExceptionBuilder<ConnectionConfigurationInvalidException> badFormat( final JsonPointer errorLocation, final String label, final String binaryFormat) { final String message = String.format("%s: bad format. " + "Expect PEM-encoded %s data specified by RFC-7468 starting with '-----BEGIN %s-----'", errorLocation.toString(), binaryFormat, label); return ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders); }
private static DittoRuntimeException emptyAddressesError(final String location, final DittoHeaders dittoHeaders) { final String message = location + ": addresses may not be empty."; return ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); } }
private static DittoRuntimeException emptyAddressesError(final String location, final DittoHeaders dittoHeaders) { final String message = location + ": addresses may not be empty."; return ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); } }
private static void validateAddress(final String address, final boolean wildcardAllowed, final DittoHeaders dittoHeaders) { validateMqttTopic(address, wildcardAllowed, errorMessage -> { final String message = MessageFormat.format(INVALID_TOPIC_FORMAT, address, errorMessage); return ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); }); }
private static void validateAddress(final String address, final boolean wildcardAllowed, final DittoHeaders dittoHeaders) { validateMqttTopic(address, wildcardAllowed, errorMessage -> { final String message = MessageFormat.format(INVALID_TOPIC_FORMAT, address, errorMessage); return ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); }); }
private <T> String validateTemplate(final String template, final Placeholder<T> placeholder, final DittoHeaders headers, final boolean allowUnresolved) { try { return PlaceholderFilter.validate(template, placeholder, allowUnresolved); } catch (final DittoRuntimeException exception) { throw ConnectionConfigurationInvalidException .newBuilder(MessageFormat.format(ENFORCEMENT_ERROR_MESSAGE, template, placeholder.getClass().getSimpleName())) .cause(exception) .dittoHeaders(headers) .build(); } } }
private <T> String validateTemplate(final String template, final Placeholder<T> placeholder, final DittoHeaders headers, final boolean allowUnresolved) { try { return PlaceholderFilter.validate(template, placeholder, allowUnresolved); } catch (final DittoRuntimeException exception) { throw ConnectionConfigurationInvalidException .newBuilder(MessageFormat.format(ENFORCEMENT_ERROR_MESSAGE, template, placeholder.getClass().getSimpleName())) .cause(exception) .dittoHeaders(headers) .build(); } } }
static RabbitMQTarget fromTargetAddress(final String targetAddress) { final Supplier<DittoRuntimeException> exceptionSupplier = () -> ConnectionConfigurationInvalidException.newBuilder( "The target address '" + targetAddress + "' must be specified " + "in the format 'exchange/routingKey'.") .build(); final String exchange = getExchangeFromTarget(targetAddress).orElseThrow(exceptionSupplier); final String routingKey = getRoutingKeyFromTarget(targetAddress).orElseThrow(exceptionSupplier); return new RabbitMQTarget(exchange, routingKey); }
static RabbitMQTarget fromTargetAddress(final String targetAddress) { final Supplier<DittoRuntimeException> exceptionSupplier = () -> ConnectionConfigurationInvalidException.newBuilder( "The target address '" + targetAddress + "' must be specified " + "in the format 'exchange/routingKey'.") .build(); final String exchange = getExchangeFromTarget(targetAddress).orElseThrow(exceptionSupplier); final String routingKey = getRoutingKeyFromTarget(targetAddress).orElseThrow(exceptionSupplier); return new RabbitMQTarget(exchange, routingKey); }
private static Connection validateConnection(final Connection connection) { try { final URI uri = URI.create(ConnectionBasedJmsConnectionFactory.buildAmqpConnectionUriFromConnection(connection)); ProviderFactory.create(uri); return connection; } catch (final Exception e) { final String errorMessageTemplate = "Failed to instantiate an amqp provider from the given configuration: {0}"; final String errorMessage = MessageFormat.format(errorMessageTemplate, e.getMessage()); throw ConnectionConfigurationInvalidException .newBuilder(errorMessage) .description(e.getMessage()) .cause(e) .build(); } }
@Override protected void validateTarget(final Target target, final DittoHeaders dittoHeaders, final Supplier<String> targetDescription) { if (!(target instanceof MqttTarget)) { final String message = MessageFormat.format("Target {0} must be of type MqttTarget.", targetDescription.get()); throw ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); } if (target.getHeaderMapping().isPresent()) { throw ConnectionConfigurationInvalidException.newBuilder("Header mapping is not supported for MQTT " + "targets.").dittoHeaders(dittoHeaders).build(); } final MqttTarget mqttTarget = (MqttTarget) target; validateTargetQoS(mqttTarget.getQos(), dittoHeaders, targetDescription); }
private static Connection validateConnection(final Connection connection) { try { final URI uri = URI.create(ConnectionBasedJmsConnectionFactory.buildAmqpConnectionUriFromConnection(connection)); ProviderFactory.create(uri); return connection; } catch (final Exception e) { final String errorMessageTemplate = "Failed to instantiate an amqp provider from the given configuration: {0}"; final String errorMessage = MessageFormat.format(errorMessageTemplate, e.getMessage()); throw ConnectionConfigurationInvalidException .newBuilder(errorMessage) .description(e.getMessage()) .cause(e) .build(); } }
@Override protected void validateTarget(final Target target, final DittoHeaders dittoHeaders, final Supplier<String> targetDescription) { if (!(target instanceof MqttTarget)) { final String message = MessageFormat.format("Target {0} must be of type MqttTarget.", targetDescription.get()); throw ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); } if (target.getHeaderMapping().isPresent()) { throw ConnectionConfigurationInvalidException.newBuilder("Header mapping is not supported for MQTT " + "targets.").dittoHeaders(dittoHeaders).build(); } final MqttTarget mqttTarget = (MqttTarget) target; validateTargetQoS(mqttTarget.getQos(), dittoHeaders, targetDescription); }
@Override protected void validateSource(final Source source, final DittoHeaders dittoHeaders, final Supplier<String> sourceDescription) { if (!(source instanceof MqttSource)) { final String message = MessageFormat.format("Source {0} must be of type MqttSource.", sourceDescription.get()); throw ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); } if (source.getHeaderMapping().isPresent()) { throw ConnectionConfigurationInvalidException.newBuilder("Header mapping is not supported for MQTT " + "sources.").dittoHeaders(dittoHeaders).build(); } final MqttSource mqttSource = (MqttSource) source; validateSourceQoS(mqttSource.getQos(), dittoHeaders, sourceDescription); validateSourceEnforcement(mqttSource.getEnforcement().orElse(null), dittoHeaders, sourceDescription); }
@Override protected void validateSource(final Source source, final DittoHeaders dittoHeaders, final Supplier<String> sourceDescription) { if (!(source instanceof MqttSource)) { final String message = MessageFormat.format("Source {0} must be of type MqttSource.", sourceDescription.get()); throw ConnectionConfigurationInvalidException.newBuilder(message) .dittoHeaders(dittoHeaders) .build(); } if (source.getHeaderMapping().isPresent()) { throw ConnectionConfigurationInvalidException.newBuilder("Header mapping is not supported for MQTT " + "sources.").dittoHeaders(dittoHeaders).build(); } final MqttSource mqttSource = (MqttSource) source; validateSourceQoS(mqttSource.getQos(), dittoHeaders, sourceDescription); validateSourceEnforcement(mqttSource.getEnforcement().orElse(null), dittoHeaders, sourceDescription); }