Search in sources :

Example 1 with Namespace

use of org.jdom.Namespace in project libresonic by Libresonic.

the class LyricsService method parseSearchResult.

private LyricsInfo parseSearchResult(String xml) throws Exception {
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(new StringReader(xml));
    Element root = document.getRootElement();
    Namespace ns = root.getNamespace();
    String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
    String song = root.getChildText("LyricSong", ns);
    String artist = root.getChildText("LyricArtist", ns);
    return new LyricsInfo(lyric, artist, song);
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) StringReader(java.io.StringReader) Document(org.jdom.Document) Namespace(org.jdom.Namespace)

Example 2 with Namespace

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

the class FlexCompilerConfigFileUtilBase method removeLibs.

private static Collection<String> removeLibs(final Element rootElement, final boolean removeExternal, final boolean removeIncluded) {
    final Namespace namespace = rootElement.getNamespace();
    final Collection<String> result = new ArrayList<>();
    //noinspection unchecked
    for (Element compilerElement : rootElement.getChildren(COMPILER, namespace)) {
        if (removeExternal) {
            //noinspection unchecked
            for (Element externalLibraryPathElement : compilerElement.getChildren(EXTERNAL_LIBRARY_PATH, namespace)) {
                final Collection<Element> pathElementsToRemove = new ArrayList<>();
                //noinspection unchecked
                for (Element pathElement : externalLibraryPathElement.getChildren(PATH_ELEMENT, namespace)) {
                    final String path = pathElement.getText();
                    final String fileName = path.substring(FileUtil.toSystemIndependentName(path).lastIndexOf("/") + 1);
                    if (fileName.startsWith("playerglobal") || fileName.startsWith("airglobal")) {
                        continue;
                    }
                    result.add(path);
                    pathElementsToRemove.add(pathElement);
                }
                for (Element pathElement : pathElementsToRemove) {
                    externalLibraryPathElement.removeContent(pathElement);
                }
            }
        }
        if (removeIncluded) {
            //noinspection unchecked
            for (Element includeLibrariesElement : compilerElement.getChildren(INCLUDE_LIBRARIES, namespace)) {
                final Collection<Element> libraryElementsToRemove = new ArrayList<>();
                //noinspection unchecked
                for (Element libraryElement : includeLibrariesElement.getChildren(LIBRARY, namespace)) {
                    result.add(libraryElement.getText());
                    libraryElementsToRemove.add(libraryElement);
                }
                for (Element pathElement : libraryElementsToRemove) {
                    includeLibrariesElement.removeContent(pathElement);
                }
            }
        }
    }
    return result;
}
Also used : Element(org.jdom.Element) ArrayList(java.util.ArrayList) Namespace(org.jdom.Namespace)

Example 3 with Namespace

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

the class FlexCommonUtils method parseAirVersionFromDescriptorFile.

@Nullable
public static String parseAirVersionFromDescriptorFile(final String descriptorFilePath) {
    if (StringUtil.isEmpty(descriptorFilePath))
        return null;
    try {
        final Element rootElement = JDOMUtil.load(new File(descriptorFilePath));
        final String localName = rootElement.getName();
        final Namespace namespace = rootElement.getNamespace();
        if ("application".equals(localName) && namespace != null && namespace.getURI().startsWith(AIR_NAMESPACE_BASE)) {
            return namespace.getURI().substring(AIR_NAMESPACE_BASE.length());
        }
    } catch (JDOMException | IOException e) {
    /*unlucky*/
    }
    return null;
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) Element(org.jdom.Element) JDOMException(org.jdom.JDOMException) Namespace(org.jdom.Namespace) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with Namespace

use of org.jdom.Namespace in project intellij-community by JetBrains.

the class ExtensionsAreaImpl method extractEPName.

public static String extractEPName(final Element extensionElement) {
    String epName = extensionElement.getAttributeValue("point");
    if (epName == null) {
        final Element parentElement = extensionElement.getParentElement();
        final String ns = parentElement != null ? parentElement.getAttributeValue("defaultExtensionNs") : null;
        if (ns != null) {
            epName = ns + '.' + extensionElement.getName();
        } else {
            Namespace namespace = extensionElement.getNamespace();
            epName = namespace.getURI() + '.' + extensionElement.getName();
        }
    }
    return epName;
}
Also used : Element(org.jdom.Element) Namespace(org.jdom.Namespace)

Example 5 with Namespace

use of org.jdom.Namespace in project fabric8 by jboss-fuse.

the class StandaloneInstaller method updateAriesBlueprintCompatibility.

public int updateAriesBlueprintCompatibility() throws Exception {
    Namespace NS = Namespace.getNamespace("http://karaf.apache.org/xmlns/features/v1.2.0");
    File xmlFile = new File(karafBase, "system/org/apache/karaf/assemblies/features/standard/2.4.0.redhat-620133/standard-2.4.0.redhat-620133-features.xml");
    if (!xmlFile.exists()) {
        LOG.error("File not found: " + xmlFile);
        return 0;
    }
    SAXBuilder builder = new SAXBuilder();
    Document doc = (Document) builder.build(xmlFile);
    Element rootNode = doc.getRootElement();
    for (Element feature : findChildrenWith(rootNode, "feature", "name", "aries-blueprint", NS)) {
        // Is it not installed?
        String compatBundle = "mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0";
        if (findChildrenWithText(feature, "bundle", compatBundle, NS).isEmpty()) {
            Element bundle = new Element("bundle", NS).setText(compatBundle);
            bundle.setAttribute("start-level", "20");
            feature.addContent(bundle);
            XMLOutputter xmlOutput = new XMLOutputter();
            xmlOutput.setFormat(Format.getRawFormat());
            xmlOutput.output(doc, new FileWriter(xmlFile));
            LOG.info("Updated: " + xmlFile);
            return 1;
        }
    }
    return 0;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) Document(org.jdom.Document) Namespace(org.jdom.Namespace)

Aggregations

Namespace (org.jdom.Namespace)102 Element (org.jdom.Element)85 IOException (java.io.IOException)24 XConfiguration (org.apache.oozie.util.XConfiguration)19 StringReader (java.io.StringReader)15 Configuration (org.apache.hadoop.conf.Configuration)15 JDOMException (org.jdom.JDOMException)15 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)13 ArrayList (java.util.ArrayList)12 Path (org.apache.hadoop.fs.Path)11 Document (org.jdom.Document)11 List (java.util.List)9 File (java.io.File)7 HashMap (java.util.HashMap)6 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)6 SAXBuilder (org.jdom.input.SAXBuilder)6 XMLOutputter (org.jdom.output.XMLOutputter)6 Writer (java.io.Writer)5 Attribute (org.jdom.Attribute)5 Format (org.jdom.output.Format)5