@Override public ConnectionValidationResult testConnection(Location location) { try { lazyComponentInitializer.initializeComponent(location); } catch (MuleRuntimeException e) { if (e.getCause() instanceof NoSuchComponentModelException) { throw new ObjectNotFoundException(location.toString()); } List<Throwable> causalChain = getCausalChain(e); return unknownFailureResponse(lastMessage(causalChain), e); } catch (Exception e) { return unknownFailureResponse(e.getCause().getMessage(), e); } return connectivityTestingService.testConnection(location); }
@Override public ConnectionValidationResult testConnection(Location location) { try { lazyComponentInitializer.initializeComponent(location); } catch (MuleRuntimeException e) { if (e.getCause() instanceof NoSuchComponentModelException) { throw new ObjectNotFoundException(location.toString()); } List<Throwable> causalChain = getCausalChain(e); return causalChain.stream() .filter(exception -> exception.getClass().equals(ConnectionException.class) && ((ConnectionException) exception).getErrorType().isPresent()) .map(exception -> failure(exception.getMessage(), ((ConnectionException) exception).getErrorType().get(), (Exception) exception)) .findFirst() .orElse(unknownFailureResponse(lastMessage(causalChain), e)); } catch (Exception e) { return unknownFailureResponse(e.getCause().getMessage(), e); } return connectivityTestingService.testConnection(location); }
/** * {@inheritDoc} */ @Override public ConnectionValidationResult testConnection(Location location) { Object connectivityTestingObject = locator.find(location).orElseThrow((() -> new ObjectNotFoundException("No object found with path: " + location))); for (ConnectivityTestingStrategy connectivityTestingStrategy : connectivityTestingStrategies) { if (connectivityTestingStrategy.accepts(connectivityTestingObject)) { try { return connectivityTestingStrategy.testConnectivity(connectivityTestingObject); } catch (Exception e) { return failure(e.getMessage(), e); } } } throw new UnsupportedConnectivityTestingObjectException( createStaticMessage("Could not do connectivity testing over object of type " + connectivityTestingObject.getClass().getName())); } }