use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class IdeaPluginDescriptorImpl method readExternal.
public void readExternal(@NotNull URL url) throws InvalidDataException, FileNotFoundException {
try {
Document document = JDOMUtil.loadDocument(url);
readExternal(document, url, JDOMXIncluder.DEFAULT_PATH_RESOLVER);
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
throw new InvalidDataException(e);
} catch (JDOMException e) {
throw new InvalidDataException(e);
}
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class JpsLoaderBase method loadRootElement.
protected static Element loadRootElement(final File file, final JpsMacroExpander macroExpander) {
try {
final Element element = tryLoadRootElement(file);
macroExpander.substitute(element, SystemInfo.isFileSystemCaseSensitive);
return element;
} catch (JDOMException e) {
throw new CannotLoadJpsModelException(file, "Cannot parse xml file " + file.getAbsolutePath() + ": " + e.getMessage(), e);
} catch (IOException e) {
throw new CannotLoadJpsModelException(file, "Cannot read file " + file.getAbsolutePath() + ": " + e.getMessage(), e);
}
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class MavenIndicesManager method loadUserArchetypes.
private void loadUserArchetypes() {
try {
Path file = getUserArchetypesFile();
if (!PathKt.exists(file)) {
return;
}
// Store artifact to set to remove duplicate created by old IDEA (https://youtrack.jetbrains.com/issue/IDEA-72105)
Collection<MavenArchetype> result = new LinkedHashSet<>();
List<Element> children = JdomKt.loadElement(file).getChildren(ELEMENT_ARCHETYPE);
for (int i = children.size() - 1; i >= 0; i--) {
Element each = children.get(i);
String groupId = each.getAttributeValue(ELEMENT_GROUP_ID);
String artifactId = each.getAttributeValue(ELEMENT_ARTIFACT_ID);
String version = each.getAttributeValue(ELEMENT_VERSION);
String repository = each.getAttributeValue(ELEMENT_REPOSITORY);
String description = each.getAttributeValue(ELEMENT_DESCRIPTION);
if (StringUtil.isEmptyOrSpaces(groupId) || StringUtil.isEmptyOrSpaces(artifactId) || StringUtil.isEmptyOrSpaces(version)) {
continue;
}
result.add(new MavenArchetype(groupId, artifactId, version, repository, description));
}
ArrayList<MavenArchetype> listResult = new ArrayList<>(result);
Collections.reverse(listResult);
myUserArchetypes = listResult;
} catch (IOException | JDOMException e) {
MavenLog.LOG.warn(e);
}
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class YouTrackRepository method getIssues.
public Task[] getIssues(@Nullable String request, int max, long since) throws Exception {
String query = getDefaultSearch();
if (StringUtil.isNotEmpty(request)) {
query += " " + request;
}
String requestUrl = "/rest/project/issues/?filter=" + encodeUrl(query) + "&max=" + max + "&updatedAfter" + since;
HttpMethod method = doREST(requestUrl, false);
try {
InputStream stream = method.getResponseBodyAsStream();
// todo workaround for http://youtrack.jetbrains.net/issue/JT-7984
String s = StreamUtil.readText(stream, CharsetToolkit.UTF8_CHARSET);
for (int i = 0; i < s.length(); i++) {
if (!XMLChar.isValid(s.charAt(i))) {
s = s.replace(s.charAt(i), ' ');
}
}
Element element;
try {
//InputSource source = new InputSource(stream);
//source.setEncoding("UTF-8");
//element = new SAXBuilder(false).build(source).getRootElement();
element = new SAXBuilder(false).build(new StringReader(s)).getRootElement();
} catch (JDOMException e) {
LOG.error("Can't parse YouTrack response for " + requestUrl, e);
throw e;
}
if ("error".equals(element.getName())) {
throw new Exception("Error from YouTrack for " + requestUrl + ": '" + element.getText() + "'");
}
List<Element> children = element.getChildren("issue");
final List<Task> tasks = ContainerUtil.mapNotNull(children, (NullableFunction<Element, Task>) o -> createIssue(o));
return tasks.toArray(new Task[tasks.size()]);
} finally {
method.releaseConnection();
}
}
use of org.jdom.JDOMException in project intellij-community by JetBrains.
the class DotProjectFileHelper method saveDotProjectFile.
public static void saveDotProjectFile(@NotNull Module module, @NotNull String storageRoot) throws IOException {
try {
Document doc;
if (ModuleType.get(module) instanceof JavaModuleType) {
doc = JDOMUtil.loadDocument(DotProjectFileHelper.class.getResource("template.project.xml"));
} else {
doc = JDOMUtil.loadDocument(DotProjectFileHelper.class.getResource("template.empty.project.xml"));
}
doc.getRootElement().getChild(EclipseXml.NAME_TAG).setText(module.getName());
final File projectFile = new File(storageRoot, EclipseXml.PROJECT_FILE);
if (!FileUtil.createIfDoesntExist(projectFile)) {
return;
}
EclipseJDOMUtil.output(doc.getRootElement(), projectFile, module.getProject());
ApplicationManager.getApplication().runWriteAction(() -> {
LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(projectFile.getPath()));
});
} catch (JDOMException e) {
LOG.error(e);
}
}
Aggregations