Example usage for org.jdom2 Element getNamespace

List of usage examples for org.jdom2 Element getNamespace

Introduction

In this page you can find the example usage for org.jdom2 Element getNamespace.

Prototype

public Namespace getNamespace() 

Source Link

Document

Returns the element's Namespace .

Usage

From source file:org.artifactory.version.converter.v147.JfrogRemoteRepoUrlConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();
    Element repositories = rootElement.getChild("remoteRepositories", namespace);
    if (repositories != null) {
        List remoteRepos = repositories.getChildren("remoteRepository", namespace);
        if (remoteRepos != null && !remoteRepos.isEmpty()) {
            for (Object remoteRepo : remoteRepos) {
                Element remoteRepoElement = (Element) remoteRepo;
                Element url = remoteRepoElement.getChild("url", namespace);
                if (url != null) {
                    String urlText = url.getText();
                    if (OLD_JFROG_LIBS.equals(urlText)) {
                        url.setText(NEW_JFROG_LIBS);
                    } else if (OLD_JFROG_PLUGINS.equals(urlText)) {
                        url.setText(NEW_JFROG_PLUGINS);
                    }/*from   w w  w. j a  v  a2  s. c  o m*/
                }
            }
        }
    }
}

From source file:org.artifactory.version.converter.v147.UnusedArtifactCleanupSwitchConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Starting the unused artifact cleanup switch conversion");

    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();

    log.debug("Converting remote repositories");
    Element remoteRepositoriesElement = rootElement.getChild("remoteRepositories", namespace);
    if (remoteRepositoriesElement != null) {
        List<Element> remoteRepositoryElements = remoteRepositoriesElement.getChildren("remoteRepository",
                namespace);//  w w  w. j  a  v  a  2  s  .com
        if (remoteRepositoryElements != null && !remoteRepositoryElements.isEmpty()) {

            for (Element remoteRepositoryElement : remoteRepositoryElements) {
                log.debug("Removing unused artifact cleanup switch from '{}'",
                        remoteRepositoryElement.getChild("key", namespace).getText());

                remoteRepositoryElement.removeChild("unusedArtifactsCleanupEnabled", namespace);
            }
        }
    }

    log.info("Ending the unused artifact cleanup switch conversion");
}

From source file:org.artifactory.version.converter.v149.ReplicationElementNameConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Starting to convert old remote repository replication configurations.");
    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();
    Element replications = rootElement.getChild("replications", namespace);
    if (replications != null) {
        replications.setName("remoteReplications");

        List<Element> replicationList = replications.getChildren("replication", namespace);
        if (replicationList != null) {
            for (Element replication : replicationList) {
                replication.setName("remoteReplication");
            }//from w ww.j a v a 2 s.  c om
        }
    }
    log.info("Finished converting old remote repository replication configurations.");
}

From source file:org.artifactory.version.converter.v152.BlackDuckProxyConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Converting BlackDuck intergration proxy settings");
    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();

    Element defaultProxy = findDefaultProxy(rootElement, namespace);
    Element externalProviders = rootElement.getChild("externalProviders", namespace);
    if (externalProviders == null) {
        return;//from ww  w .  ja v a  2  s .c o m
    }
    Element blackDuckConf = externalProviders.getChild("blackduck", namespace);
    if (defaultProxy != null && blackDuckConf != null) {
        if (blackDuckConf.getChild("proxyRef") != null) {
            return;
        }
        Element proxyTag = new Element("proxyRef", namespace);
        proxyTag.setText(defaultProxy.getChildText("key", namespace));
        blackDuckConf.addContent(proxyTag);
    }
}

From source file:org.artifactory.version.converter.v153.VirtualCacheCleanupConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Adding default virtual cache cleanup");
    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();

    if (rootElement.getChild("virtualCacheCleanupConfig") != null)
        return;//from   ww w .j a va  2  s  .  c o m
    Element cleanupConfig = rootElement.getChild("cleanupConfig", namespace);
    Element virtualCacheCleanupConfig = new Element("virtualCacheCleanupConfig", namespace);
    Element cronExp = new Element("cronExp", namespace);
    cronExp.setText("0 12 5 * * ?");
    virtualCacheCleanupConfig.addContent(cronExp);
    rootElement.addContent(rootElement.indexOf(cleanupConfig) + 1, virtualCacheCleanupConfig);
}

From source file:org.artifactory.version.converter.v160.AddonsDefaultLayoutConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Starting the default addons repository layout conversion");
    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();

    log.debug("Adding default addons global layouts");
    Element repoLayoutsElement = rootElement.getChild("repoLayouts", namespace);
    addNuGetDefaultLayout(repoLayoutsElement, namespace);
    addNpmDefaultLayout(repoLayoutsElement, namespace);
    addBowerDefaultLayout(repoLayoutsElement, namespace);
    addVcsDefaultLayout(repoLayoutsElement, namespace);
    addSbtDefaultLayout(repoLayoutsElement, namespace);
    addSimpleDefaultLayout(repoLayoutsElement, namespace);

    log.info("Ending the default addons repository layout conversion");
}

From source file:org.artifactory.version.converter.v160.MavenIndexerConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Converting maven indexer to included repositories");

    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();

    Element indexer = rootElement.getChild("indexer", namespace);
    if (indexer != null) {
        Element excludedRepositories = indexer.getChild("excludedRepositories", namespace);
        if (excludedRepositories != null) {
            replaceExcludedWithIncluded(rootElement, namespace, indexer, excludedRepositories);
        }//from   ww  w  .  jav a  2  s.c o  m
    }

    log.info("Finished converting maven indexer to included repositories");
}

From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java

License:Open Source License

@Override
public void convert(Document doc) {
    log.info("Converting repositories to a single package type");

    Element rootElement = doc.getRootElement();
    Namespace namespace = rootElement.getNamespace();

    Element localRepos = rootElement.getChild("localRepositories", namespace);
    if (localRepos != null) {
        convertLocalRepos(localRepos.getChildren());
    }/*from w w w  .j a va2  s  .  c  om*/

    Element remoteRepos = rootElement.getChild("remoteRepositories", namespace);
    if (remoteRepos != null) {
        convertRemoteRepos(remoteRepos.getChildren());
    }

    Element virtualRepos = rootElement.getChild("virtualRepositories", namespace);
    if (virtualRepos != null) {
        convertVirtualRepos(virtualRepos.getChildren());
    }

    log.info("Finished Converting repositories to a single package type");
}

From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java

License:Open Source License

private void convertLocalRepos(List<Element> repos) {
    if (repos == null || repos.isEmpty()) {
        return;//w ww . jav  a 2  s. co  m
    }

    for (Element repo : repos) {
        List<RepoType> repoTypes = Lists.newArrayList();
        fillSharedTypes(repoTypes, repo, false);
        addType(repoTypes, repo, RepoType.YUM, false);
        String repoKey = repo.getChildText("key", repo.getNamespace());
        convertToSingleRepoType(repo, repoKey, repoTypes, false);
    }

}

From source file:org.artifactory.version.converter.v160.SingleRepoTypeConverter.java

License:Open Source License

private void convertRemoteRepos(List<Element> repos) {
    if (repos == null || repos.isEmpty()) {
        return;// ww w.ja  va 2 s .  c o m
    }

    for (Element repo : repos) {
        List<RepoType> repoTypes = Lists.newArrayList();
        fillSharedTypes(repoTypes, repo, false);
        if (!repoTypes.contains(RepoType.Bower)) {
            // Bower + VCS = Bower repository
            addType(repoTypes, repo, RepoType.VCS, false);
        }
        String repoKey = repo.getChildText("key", repo.getNamespace());
        convertToSingleRepoType(repo, repoKey, repoTypes, false);
    }
}