mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-202846 Can not download source code for jar after updating 2018.3
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.jarFinder;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.xpath.XPath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -35,8 +34,7 @@ public class MavenCentralSourceSearcher extends SourceSearcher {
|
||||
url += "g:%22" + groupId + "%22%20AND%20";
|
||||
}
|
||||
url += "a:%22" + artifactId + "%22%20AND%20v:%22" + version + "%22%20AND%20l:%22sources%22";
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Element> artifactList = (List<Element>)XPath.newInstance("/response/result/doc/str[@name='g']").selectNodes(readDocumentCancelable(indicator, url));
|
||||
List<Element> artifactList = findElements("./result/doc/str[@name='g']", readElementCancelable(indicator, url));
|
||||
if (artifactList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -54,10 +52,6 @@ public class MavenCentralSourceSearcher extends SourceSearcher {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (JDOMException e) {
|
||||
LOG.warn(e);
|
||||
throw new SourceSearchException("Failed to parse response from server. See log for more details.");
|
||||
}
|
||||
catch (IOException e) {
|
||||
indicator.checkCanceled(); // Cause of IOException may be canceling of operation.
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.jarFinder;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.xpath.XPath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -37,13 +36,12 @@ public class SonatypeSourceSearcher extends SourceSearcher {
|
||||
url += ("&g=" + groupId);
|
||||
}
|
||||
|
||||
List<Element> artifactList = (List<Element>)XPath.newInstance("/searchNGResponse/data/artifact").selectNodes(readDocumentCancelable(indicator, url));
|
||||
List<Element> artifactList = findElements("./data/artifact", readElementCancelable(indicator, url));
|
||||
if (artifactList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Element element;
|
||||
|
||||
if (artifactList.size() == 1) {
|
||||
element = artifactList.get(0);
|
||||
}
|
||||
@@ -52,9 +50,7 @@ public class SonatypeSourceSearcher extends SourceSearcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Element> artifactHintList =
|
||||
(List<Element>)XPath.newInstance("artifactHits/artifactHit/artifactLinks/artifactLink/classifier[text()='sources']/../../..")
|
||||
.selectNodes(element);
|
||||
List<Element> artifactHintList = findElements("artifactHits/artifactHit/artifactLinks/artifactLink/classifier[text()='sources']/../../..", element);
|
||||
if (artifactHintList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -68,10 +64,6 @@ public class SonatypeSourceSearcher extends SourceSearcher {
|
||||
artifactId + "&v=" +
|
||||
version + "&e=jar&c=sources";
|
||||
}
|
||||
catch (JDOMException e) {
|
||||
LOG.warn(e);
|
||||
throw new SourceSearchException("Failed to parse response from server. See log for more details.");
|
||||
}
|
||||
catch (IOException e) {
|
||||
indicator.checkCanceled(); // Cause of IOException may be canceling of operation.
|
||||
|
||||
|
||||
@@ -9,11 +9,14 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.io.HttpRequests;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.filter2.Filters;
|
||||
import org.jdom.xpath.XPathFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
@@ -21,9 +24,15 @@ import java.util.jar.JarFile;
|
||||
* @author Sergey Evdokimov
|
||||
*/
|
||||
public abstract class SourceSearcher {
|
||||
|
||||
private static final String MAVEN_POM_ENTRY_PREFIX = "META-INF/maven/";
|
||||
|
||||
@NotNull
|
||||
protected static List<Element> findElements(@NotNull String expression, @NotNull Element element) {
|
||||
return XPathFactory.instance()
|
||||
.compile(expression, Filters.element())
|
||||
.evaluate(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param indicator
|
||||
* @param artifactId
|
||||
@@ -52,7 +61,7 @@ public abstract class SourceSearcher {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Element readDocumentCancelable(final ProgressIndicator indicator, String url) throws IOException {
|
||||
protected static Element readElementCancelable(final ProgressIndicator indicator, String url) throws IOException {
|
||||
return HttpRequests.request(url)
|
||||
.accept("application/xml")
|
||||
.connect(new HttpRequests.RequestProcessor<Element>() {
|
||||
@@ -88,7 +97,6 @@ public abstract class SourceSearcher {
|
||||
}
|
||||
|
||||
class SourceSearchException extends Exception {
|
||||
|
||||
SourceSearchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user