void (@NotNull final ProgressIndicator indicator) { String artifactUrl = null; SourceSearcher[] searchers = {new MavenCentralSourceSearcher(), new SonatypeSourceSearcher()}; for (SourceSearcher searcher : searchers) { try { artifactUrl = searcher.findSourceJar(indicator, artifactId, version, jar); } catch (SourceSearchException e) { LOG.warn(e); final String title = JavaUiBundle.message("internet.attach.source.provider.action.notification.title.downloading.failed"); showMessage(title, e.getMessage(), NotificationType.ERROR); continue; } if (artifactUrl != null) break; } if (artifactUrl == null) { showMessage(JavaUiBundle.message("internet.attach.source.provider.action.notification.title.sources.not.found"), JavaUiBundle.message("internet.attach.source.provider.action.notification.content.sources.for.jar.not.found", jarName), NotificationType.WARNING); return; } if (!(libSourceDir.isDirectory() || libSourceDir.mkdirs())) { showMessage(JavaUiBundle.message("internet.attach.source.provider.action.notification.title.downloading.failed"), JavaUiBundle.message("internet.attach.source.provider.action.notification.content.failed.to.create.directory", libSourceDir), NotificationType.ERROR); return; } try { File tmpDownload = FileUtil.createTempFile(libSourceDir, "download.", ".tmp", false, false); HttpRequests.request(artifactUrl).saveToFile(tmpDownload, indicator); if (!sourceFile.exists() && !tmpDownload.renameTo(sourceFile)) { LOG.warn("Failed to rename file " + tmpDownload + " to " + sourceFileName); } } catch (IOException e) { LOG.warn(e); showMessage(JavaUiBundle.message("internet.attach.source.provider.action.notification.title.downloading.failed"), JavaUiBundle.message("internet.attach.source.provider.action.notification.content.connection.problem"), NotificationType.ERROR); } }