import com.intellij.openapi.application.impl.ApplicationInfoImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.updateSettings.impl.UpdateSettings;
import com.intellij.openapi.util.BuildNumber;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.io.HttpRequests;
public static List<IdeaPluginDescriptor> loadPlugins(@Nullable String repositoryUrl,
@Nullable BuildNumber buildnumber,
@Nullable final ProgressIndicator indicator) throws IOException {
+ boolean forceHttps = repositoryUrl == null && UpdateSettings.getInstance().SECURE_CONNECTION;
+ return loadPlugins(repositoryUrl, buildnumber, forceHttps, indicator);
+ }
+
+ @NotNull
+ public static List<IdeaPluginDescriptor> loadPlugins(@Nullable String repositoryUrl,
+ @Nullable BuildNumber buildnumber,
+ boolean forceHttps,
+ @Nullable final ProgressIndicator indicator) throws IOException {
final URIBuilder uriBuilder;
final File pluginListFile;
try {
indicator.setText2(IdeBundle.message("progress.connecting.to.plugin.manager", uriBuilder.getHost()));
}
- return process(repositoryUrl, HttpRequests.request(uriBuilder.toString()).connect(new HttpRequests.RequestProcessor<List<IdeaPluginDescriptor>>() {
+ HttpRequests.RequestBuilder request = HttpRequests.request(uriBuilder.toString()).forceHttps(forceHttps);
+ return process(repositoryUrl, request.connect(new HttpRequests.RequestProcessor<List<IdeaPluginDescriptor>>() {
@Override
public List<IdeaPluginDescriptor> process(@NotNull HttpRequests.Request request) throws IOException {
if (indicator != null) {
private static void doUpdateAndShowResult(@Nullable final Project project,
final boolean enableLink,
final boolean manualCheck,
- @NotNull UpdateSettings updateSettings,
+ @NotNull final UpdateSettings updateSettings,
@Nullable ProgressIndicator indicator,
@Nullable final ActionCallback callback) {
// check platform update
}
incompatiblePlugins = buildNumber != null ? new HashSet<IdeaPluginDescriptor>() : null;
- updatedPlugins = checkPluginsUpdate(manualCheck, indicator, incompatiblePlugins, buildNumber);
+ updatedPlugins = checkPluginsUpdate(manualCheck, updateSettings, indicator, incompatiblePlugins, buildNumber);
}
// show result
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
- showUpdateResult(project, result, updatedPlugins, incompatiblePlugins, enableLink, manualCheck);
+ showUpdateResult(project, result, updateSettings, updatedPlugins, incompatiblePlugins, enableLink, manualCheck);
if (callback != null) {
callback.setDone();
}
String updateUrl = uriBuilder.toString();
LogUtil.debug(LOG, "load update xml (UPDATE_URL='%s')", updateUrl);
- info = HttpRequests.request(updateUrl).connect(new HttpRequests.RequestProcessor<UpdatesInfo>() {
+ info = HttpRequests.request(updateUrl).forceHttps(settings.SECURE_CONNECTION).connect(new HttpRequests.RequestProcessor<UpdatesInfo>() {
@Override
public UpdatesInfo process(@NotNull HttpRequests.Request request) throws IOException {
try {
}
private static Collection<PluginDownloader> checkPluginsUpdate(boolean manualCheck,
+ @NotNull UpdateSettings updateSettings,
@Nullable ProgressIndicator indicator,
@Nullable Collection<IdeaPluginDescriptor> incompatiblePlugins,
@Nullable BuildNumber buildNumber) {
outer:
for (String host : hosts) {
try {
- List<IdeaPluginDescriptor> list = RepositoryHelper.loadPlugins(host, buildNumber, indicator);
+ boolean forceHttps = host == null && updateSettings.SECURE_CONNECTION;
+ List<IdeaPluginDescriptor> list = RepositoryHelper.loadPlugins(host, buildNumber, forceHttps, indicator);
for (IdeaPluginDescriptor descriptor : list) {
PluginId id = descriptor.getPluginId();
if (updateable.containsKey(id)) {
updateable.remove(id);
state.onDescriptorDownload(descriptor);
PluginDownloader downloader = PluginDownloader.createDownloader(descriptor, host, buildNumber);
+ downloader.setForceHttps(forceHttps);
checkAndPrepareToInstall(downloader, state, toUpdate, incompatiblePlugins, indicator);
if (updateable.isEmpty()) {
break outer;
private static void showUpdateResult(@Nullable final Project project,
final CheckForUpdateResult checkForUpdateResult,
+ final UpdateSettings updateSettings,
final Collection<PluginDownloader> updatedPlugins,
- final Collection<IdeaPluginDescriptor> incompatiblePlugins,
+ final Collection<IdeaPluginDescriptor> incompatiblePlugins,
final boolean enableLink,
final boolean alwaysShowResults) {
final UpdateChannel channelToPropose = checkForUpdateResult.getChannelToPropose();
Runnable runnable = new Runnable() {
@Override
public void run() {
- new UpdateInfoDialog(updatedChannel, enableLink, updatedPlugins, incompatiblePlugins).show();
+ new UpdateInfoDialog(updatedChannel, enableLink, updateSettings.SECURE_CONNECTION, updatedPlugins, incompatiblePlugins).show();
}
};
return installed;
}
- public static DownloadPatchResult downloadAndInstallPatch(final BuildInfo newVersion) {
+ public static DownloadPatchResult downloadAndInstallPatch(final PatchInfo patch, final BuildNumber toBuild, final boolean forceHttps) {
final DownloadPatchResult[] result = new DownloadPatchResult[]{DownloadPatchResult.CANCELED};
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
@Override
public void run() {
try {
- doDownloadAndInstallPatch(newVersion, ProgressManager.getInstance().getProgressIndicator());
+ ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
+ doDownloadAndInstallPatch(patch, toBuild, forceHttps, indicator);
result[0] = DownloadPatchResult.SUCCESS;
}
- catch (final IOException e) {
+ catch (IOException e) {
LOG.info(e);
result[0] = DownloadPatchResult.FAILED;
Notifications.Bus.notify(new Notification("Updater", "Failed to download patch file", e.getMessage(), NotificationType.ERROR));
return result[0];
}
- private static void doDownloadAndInstallPatch(BuildInfo newVersion, final ProgressIndicator indicator) throws IOException {
- PatchInfo patch = newVersion.findPatchForCurrentBuild();
- if (patch == null) throw new IOException("No patch is available for current version");
-
+ private static void doDownloadAndInstallPatch(PatchInfo patch,
+ BuildNumber toBuild,
+ boolean forceHttps,
+ final ProgressIndicator indicator) throws IOException {
String productCode = ApplicationInfo.getInstance().getBuild().getProductCode();
String fromBuildNumber = patch.getFromBuild().asStringWithoutProductCode();
- String toBuildNumber = newVersion.getNumber().asStringWithoutProductCode();
+ String toBuildNumber = toBuild.asStringWithoutProductCode();
String bundledJdk = "";
String jdkMacRedist = System.getProperty("idea.java.redist");
String fileName = productCode + "-" + fromBuildNumber + "-" + toBuildNumber + "-patch" + bundledJdk + osSuffix + ".jar";
String url = new URL(new URL(getPatchesUrl()), fileName).toString();
- File tempFile = HttpRequests.request(url).connect(new HttpRequests.RequestProcessor<File>() {
+ File tempFile = HttpRequests.request(url).gzip(false).forceHttps(forceHttps).connect(new HttpRequests.RequestProcessor<File>() {
@Override
public File process(@NotNull HttpRequests.Request request) throws IOException {
File tempFile = FileUtil.createTempFile("ij.platform.", ".patch", true);
*/
class UpdateInfoDialog extends AbstractUpdateDialog {
private final UpdateChannel myUpdatedChannel;
+ private final boolean myForceHttps;
private final Collection<PluginDownloader> myUpdatedPlugins;
private final BuildInfo myLatestBuild;
private final PatchInfo myPatch;
protected UpdateInfoDialog(@NotNull UpdateChannel channel,
boolean enableLink,
+ boolean forceHttps,
Collection<PluginDownloader> updatedPlugins,
Collection<IdeaPluginDescriptor> incompatiblePlugins) {
super(enableLink);
myUpdatedChannel = channel;
+ myForceHttps = forceHttps;
myUpdatedPlugins = updatedPlugins;
myLatestBuild = channel.getLatestBuild();
myPatch = myLatestBuild != null ? myLatestBuild.findPatchForCurrentBuild() : null;
init();
if (incompatiblePlugins != null && !incompatiblePlugins.isEmpty()) {
- final boolean onePluginFound = incompatiblePlugins.size() == 1;
- String incompatibilityError = "Incompatible with new version plugin";
- incompatibilityError += (onePluginFound ? " is" : "s are") + " detected: ";
- incompatibilityError += onePluginFound ? "" : "<br>";
- incompatibilityError += StringUtil.join(incompatiblePlugins, new Function<IdeaPluginDescriptor, String>() {
+ String list = StringUtil.join(incompatiblePlugins, new Function<IdeaPluginDescriptor, String>() {
@Override
public String fun(IdeaPluginDescriptor downloader) {
return downloader.getName();
}
}, "<br/>");
- setErrorText(incompatibilityError);
+ setErrorText(IdeBundle.message("updates.incompatible.plugins.found", incompatiblePlugins, list));
}
}
}
private void downloadPatch(final boolean canRestart) {
- final UpdateChecker.DownloadPatchResult result = UpdateChecker.downloadAndInstallPatch(myLatestBuild);
+ final UpdateChecker.DownloadPatchResult result = UpdateChecker.downloadAndInstallPatch(myPatch, myLatestBuild.getNumber(), myForceHttps);
if (result == UpdateChecker.DownloadPatchResult.SUCCESS) {
if (myUpdatedPlugins != null && !myUpdatedPlugins.isEmpty()) {
new PluginUpdateInfoDialog(getContentPanel(), myUpdatedPlugins, true){