Search in sources :

Example 36 with JDOMException

use of org.jdom.JDOMException in project voldemort by voldemort.

the class StoreDefinitionsMapper method readStoreList.

public List<StoreDefinition> readStoreList(Reader input, boolean verifySchema) {
    try {
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(input);
        if (verifySchema) {
            Validator validator = schema.newValidator();
            validator.validate(new JDOMSource(doc));
        }
        Element root = doc.getRootElement();
        if (!root.getName().equals(STORES_ELMT))
            throw new MappingException("Invalid root element: " + doc.getRootElement().getName());
        List<StoreDefinition> stores = new ArrayList<StoreDefinition>();
        for (Object store : root.getChildren(STORE_ELMT)) stores.add(readStore((Element) store));
        for (Object view : root.getChildren(VIEW_ELMT)) stores.add(readView((Element) view, stores));
        return stores;
    } catch (JDOMException e) {
        throw new MappingException(e);
    } catch (SAXException e) {
        throw new MappingException(e);
    } catch (IOException e) {
        throw new MappingException(e);
    }
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) ArrayList(java.util.ArrayList) JDOMSource(org.jdom.transform.JDOMSource) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) SAXException(org.xml.sax.SAXException) StoreDefinition(voldemort.store.StoreDefinition) Validator(javax.xml.validation.Validator)

Example 37 with JDOMException

use of org.jdom.JDOMException in project android by JetBrains.

the class ExternalRepository method doRefreshFor.

private void doRefreshFor(@NotNull final String groupId, @NotNull final String artifactId) {
    String url = String.format(URL_TEMPLATE, groupId.replaceAll("\\.", "/"), artifactId);
    Document document;
    try {
        document = JDOMUtil.loadDocument(URI.create(url).toURL());
    } catch (JDOMException e) {
        LOG.warn(String.format("Unexpected exception occurred on attempt to parse document from %s (checking the latest version " + "for artifact '%s:%s')", url, groupId, artifactId));
        return;
    } catch (IOException e) {
        LOG.warn(String.format("Unexpected I/O exception occurred on attempt to check the latest version for artifact '%s:%s' at " + "external repository (url %s)", groupId, artifactId, url));
        return;
    }
    Element versioning = document.getRootElement().getChild(MAVEN_METADATA_VERSIONING);
    if (versioning == null) {
        LOG.warn(String.format("Can't check the latest version for artifact '%s:%s'. Reason: artifact metadata info downloaded from " + "%s has unknown format - expected to find a <%s> element under a root element but it's not there", groupId, artifactId, url, MAVEN_METADATA_VERSIONING));
        return;
    }
    Element latest = versioning.getChild(MAVEN_METADATA_LATEST);
    if (latest == null) {
        LOG.warn(String.format("Can't check the latest version for artifact '%s:%s'. Reason: artifact metadata info downloaded from " + "%s has unknown format - expected to find a <%s> element under a <%s> element but it's not there", groupId, artifactId, url, MAVEN_METADATA_LATEST, MAVEN_METADATA_VERSIONING));
        return;
    }
    try {
        GradleVersion version = GradleVersion.parse(latest.getText());
        myLatestVersionCache.put(Pair.create(groupId, artifactId), version);
    } catch (NumberFormatException e) {
        LOG.warn(String.format("Can't check the latest version for artifact '%s:%s'. Reason: artifact metadata info downloaded from " + "%s has unknown version format - '%s'", groupId, artifactId, url, latest.getText()));
    }
}
Also used : Element(org.jdom.Element) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) GradleVersion(com.android.ide.common.repository.GradleVersion)

Example 38 with JDOMException

use of org.jdom.JDOMException in project intellij-plugins by JetBrains.

the class FlexmojosSdkAdditionalData method setupFlexCompilerClasspath.

void setupFlexCompilerClasspath(final VirtualFile compilerPomFile, final String repositoryRootPath) {
    myFlexCompilerClasspath.clear();
    try {
        final Element rootElement = JDOMUtil.load(compilerPomFile.getInputStream());
        if (!rootElement.getName().equals("project"))
            return;
        for (final Object dependenciesElement : rootElement.getChildren("dependencies", rootElement.getNamespace())) {
            for (final Object dependencyElement : ((Element) dependenciesElement).getChildren("dependency", rootElement.getNamespace())) {
                final String groupId = ((Element) dependencyElement).getChildText("groupId", rootElement.getNamespace());
                final String artifactId = ((Element) dependencyElement).getChildText("artifactId", rootElement.getNamespace());
                final String version = ((Element) dependencyElement).getChildText("version", rootElement.getNamespace());
                addClasspathEntry(repositoryRootPath, groupId, artifactId, version);
            }
        }
    } catch (IOException ignored) {
    /*ignore*/
    } catch (JDOMException ignored) {
    /*ignore*/
    }
}
Also used : Element(org.jdom.Element) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException)

Example 39 with JDOMException

use of org.jdom.JDOMException in project android by JetBrains.

the class ImportModuleTask method perform.

@Override
public Exception perform() {
    final Module[] moduleWrapper = { null };
    final Exception exception = ApplicationManager.getApplication().runWriteAction(new Computable<Exception>() {

        @Override
        public Exception compute() {
            try {
                moduleWrapper[0] = ModuleManager.getInstance(myProject).loadModule(myModuleFilePath);
            } catch (InvalidDataException e) {
                return e;
            } catch (IOException e) {
                return e;
            } catch (JDOMException e) {
                return e;
            } catch (ModuleWithNameAlreadyExists e) {
                return e;
            }
            return null;
        }
    });
    if (exception != null) {
        return exception;
    }
    assert moduleWrapper[0] != null;
    if (AndroidFacet.getInstance(moduleWrapper[0]) == null) {
        AndroidUtils.addAndroidFacetInWriteAction(moduleWrapper[0], myContentRoot, true);
    }
    AndroidSdkUtils.setupAndroidPlatformIfNecessary(moduleWrapper[0], false);
    setDepModule(moduleWrapper[0]);
    return null;
}
Also used : ModuleWithNameAlreadyExists(com.intellij.openapi.module.ModuleWithNameAlreadyExists) InvalidDataException(com.intellij.openapi.util.InvalidDataException) IOException(java.io.IOException) Module(com.intellij.openapi.module.Module) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) InvalidDataException(com.intellij.openapi.util.InvalidDataException) JDOMException(org.jdom.JDOMException)

Example 40 with JDOMException

use of org.jdom.JDOMException in project intellij-plugins by JetBrains.

the class JabberFacadeImpl method getServers.

public String[] getServers() {
    SAXBuilder saxBuilder = new SAXBuilder();
    try {
        Document document = saxBuilder.build(getClass().getResource("servers.xml"));
        Element rootElement = document.getRootElement();
        List children = rootElement.getChildren("item", rootElement.getNamespace());
        List<String> result = new ArrayList<>();
        for (Object aChildren : children) {
            Element element = (Element) aChildren;
            result.add(element.getAttributeValue("jid"));
        }
        return ArrayUtil.toStringArray(result);
    } catch (JDOMException e) {
        LOG.error(e.getMessage(), e);
    } catch (IOException e) {
        LOG.error(e.getMessage(), e);
    }
    return new String[] { "jabber.org" };
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException)

Aggregations

JDOMException (org.jdom.JDOMException)72 IOException (java.io.IOException)59 Element (org.jdom.Element)46 Document (org.jdom.Document)27 SAXBuilder (org.jdom.input.SAXBuilder)20 File (java.io.File)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Nullable (org.jetbrains.annotations.Nullable)11 NotNull (org.jetbrains.annotations.NotNull)10 StringReader (java.io.StringReader)9 THashMap (gnu.trove.THashMap)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 InvalidDataException (com.intellij.openapi.util.InvalidDataException)5 Path (java.nio.file.Path)4 Logger (com.intellij.openapi.diagnostic.Logger)3 Project (com.intellij.openapi.project.Project)3 StringWriter (java.io.StringWriter)3 Format (org.jdom.output.Format)3 XMLOutputter (org.jdom.output.XMLOutputter)3