List of usage examples for org.jdom2 Element getNamespace
public Namespace getNamespace()
From source file:org.artifactory.version.converter.v1410.GcSystemPropertyConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.info(/* w w w .j a v a2 s . c om*/ "Converting garbage collector system property to a cron expression based configuration descriptor."); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element gcConfigCronExpElement = new Element("cronExp", namespace); gcConfigCronExpElement.setText("0 0 /4 * * ?"); Element gcConfigElement = new Element("gcConfig", namespace); gcConfigElement.addContent(gcConfigCronExpElement); rootElement.addContent(gcConfigElement); log.info("Finished converting the garbage collector system property."); }
From source file:org.artifactory.version.converter.v1412.IndexerCronExpPropertyConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.info("Converting indexer indexingIntervalHours property to a cron expression based " + "configuration descriptor."); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element indexerElement = rootElement.getChild("indexer", namespace); if (indexerElement != null) { // Remove indexingIntervalHours property Element indexingIntervalHours = indexerElement.getChild("indexingIntervalHours", namespace); int intervalElementIndex = indexerElement.indexOf(indexingIntervalHours); if (indexingIntervalHours != null) { indexingIntervalHours.detach(); // Add cron expression property Element cronExpElement = new Element("cronExp", namespace); cronExpElement.setText("0 23 5 * * ?"); indexerElement.addContent(intervalElementIndex, cronExpElement); }/*from www. j av a 2s.co m*/ } log.info("Finished converting the indexer indexingIntervalHours property."); }
From source file:org.artifactory.version.converter.v1414.ArchiveBrowsingConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element securityElement = rootElement.getChild("security", namespace); if (securityElement != null) { Element archiveBrowsingEnabledElement = securityElement.getChild("archiveBrowsingEnabled", namespace); if (archiveBrowsingEnabledElement != null) { archiveBrowsingEnabledElement.detach(); }/*from w w w . j av a 2 s . c om*/ } }
From source file:org.artifactory.version.converter.v1414.AssumedOfflineConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.debug("Converting failedRetrievalCachePeriodSecs"); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element remoteRepositoriesElement = rootElement.getChild("remoteRepositories", namespace); if (remoteRepositoriesElement == null) { log.debug("No remote repository exists"); return;/* w w w . j a v a 2 s. c o m*/ } List remoteRepositories = remoteRepositoriesElement.getChildren(); for (Object o : remoteRepositories) { Element remoteRepo = (Element) o; Element failedRetrievalElement = remoteRepo.getChild("failedRetrievalCachePeriodSecs", namespace); if (failedRetrievalElement != null) { failedRetrievalElement.setName("assumedOfflinePeriodSecs"); failedRetrievalElement.setText("300"); } } log.debug("Finished converting failedRetrievalCachePeriodSecs"); }
From source file:org.artifactory.version.converter.v1414.CleanupConfigConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.debug(/*from ww w .ja va 2s .co m*/ "Converting artifacts cleanup system property to a cron expression based configuration descriptor."); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); // Create cron expression element with random times from 04:00AM to 05:59AM Element cronExpElement = new Element("cronExp", namespace); int minutes = RandomUtils.nextInt(60); // 0-59 int hours = RandomUtils.nextInt(2) + 4; // 4-5 cronExpElement.setText("0 " + minutes + " " + hours + " * * ?"); Element cleanupElement = new Element("cleanupConfig", namespace); cleanupElement.addContent(cronExpElement); rootElement.addContent(cleanupElement); log.debug("Finished converting the artifacts cleanup system property."); }
From source file:org.artifactory.version.converter.v142.RepoIncludeExcludePatternsConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Namespace ns = root.getNamespace(); Element localReposElement = root.getChild("localRepositories", ns); List localRepos = localReposElement == null ? null : localReposElement.getChildren("localRepository", ns); Element remotelReposElement = root.getChild("remoteRepositories", ns); List remoteRepos = remotelReposElement == null ? null : remotelReposElement.getChildren("remoteRepository", ns); movePatternsElements(localRepos, ns); movePatternsElements(remoteRepos, ns); }
From source file:org.artifactory.version.converter.v143.RemoteChecksumPolicyConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element root = doc.getRootElement(); Namespace ns = root.getNamespace(); Element remoteReposElement = root.getChild("remoteRepositories", ns); if (remoteReposElement != null) { List remoteRepos = remoteReposElement.getChildren("remoteRepository", ns); for (Object remoteRepoObj : remoteRepos) { Element remoteRepo = (Element) remoteRepoObj; Element checksumPolicy = remoteRepo.getChild("checksumPolicyType", ns); if (checksumPolicy != null) { checksumPolicy.setName("remoteRepoChecksumPolicyType"); }//from w ww . j a v a 2 s .c o m } } }
From source file:org.artifactory.version.converter.v144.MultiLdapXmlConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element securityElement = rootElement.getChild("security", namespace); if (securityElement != null) { Element ldapSettings = securityElement.getChild("ldapSettings", namespace); if (ldapSettings != null) { String firstLdapKey = null; String ldapKeyToUse = null; List ldapSettingList = ldapSettings.getChildren("ldapSetting", namespace); if (ldapSettingList != null && !ldapSettingList.isEmpty()) { for (Object ldapSettingObject : ldapSettingList) { Element ldapSetting = (Element) ldapSettingObject; Element key = ldapSetting.getChild("key", namespace); if (firstLdapKey == null) { firstLdapKey = key.getValue(); }/*from ww w . ja v a2s .c om*/ Element enabledElement = ldapSetting.getChild("enabled", namespace); if (Boolean.parseBoolean(enabledElement.getValue())) { ldapKeyToUse = ldapSetting.getChild("key", namespace).getValue(); } } } if (ldapKeyToUse == null && firstLdapKey != null) { ldapKeyToUse = firstLdapKey; } if (ldapKeyToUse != null) { Element ldapGroupSettings = securityElement.getChild("ldapGroupSettings", namespace); if (ldapGroupSettings != null) { List ldapGroupList = ldapGroupSettings.getChildren("ldapGroupSetting", namespace); if (ldapGroupList != null && !ldapGroupList.isEmpty()) { for (Object ldapGroupSettingObject : ldapGroupList) { Element ldapGroupSetting = (Element) ldapGroupSettingObject; Element enabledLdapElement = new Element("enabledLdap", namespace); enabledLdapElement.setText(ldapKeyToUse); Element enabledContent = ldapGroupSetting.getChild("enabled", namespace); int index = ldapGroupSetting.indexOf(enabledContent); ldapGroupSetting.addContent(index, enabledLdapElement); ldapGroupSetting.removeContent(enabledContent); } } } } } } }
From source file:org.artifactory.version.converter.v144.ServerIdXmlConverter.java
License:Open Source License
@Override public void convert(Document doc) { Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); Element addons = rootElement.getChild("addons", namespace); if (addons != null) { Element serverId = addons.getChild("serverId", namespace); if (serverId != null) { serverId.detach();/* ww w .j a va2 s .c o m*/ } } }
From source file:org.artifactory.version.converter.v147.DefaultRepoLayoutConverter.java
License:Open Source License
@Override public void convert(Document doc) { log.info("Starting the default repository layout conversion"); Element rootElement = doc.getRootElement(); Namespace namespace = rootElement.getNamespace(); log.debug("Adding default global layouts"); Element repoLayoutsElement = new Element("repoLayouts", namespace); repoLayoutsElement.addContent(getMaven2DefaultLayout(namespace)); repoLayoutsElement.addContent(getIvyDefaultLayout(namespace)); repoLayoutsElement.addContent(getGradleDefaultLayout(namespace)); repoLayoutsElement.addContent(getMaven1DefaultLayout(namespace)); rootElement.addContent(repoLayoutsElement); log.debug("Converting local repositories"); Element localRepositoriesElement = rootElement.getChild("localRepositories", namespace); if (localRepositoriesElement != null) { List<Element> localRepositoryElements = localRepositoriesElement.getChildren("localRepository", namespace);// w w w .ja va2 s. co m if (localRepositoryElements != null && !localRepositoryElements.isEmpty()) { for (Element localRepositoryElement : localRepositoryElements) { appendRepoLayoutRef(localRepositoryElement, namespace); removeRepoType(localRepositoryElement, false, namespace); } } } log.debug("Converting remote repositories"); Element remoteRepositoriesElement = rootElement.getChild("remoteRepositories", namespace); if (remoteRepositoriesElement != null) { List<Element> remoteRepositoryElements = remoteRepositoriesElement.getChildren("remoteRepository", namespace); if (remoteRepositoryElements != null && !remoteRepositoryElements.isEmpty()) { for (Element remoteRepositoryElement : remoteRepositoryElements) { appendRepoLayoutRef(remoteRepositoryElement, namespace); removeRepoType(remoteRepositoryElement, true, namespace); } } } log.debug("Converting virtual repositories"); Element virtualRepositoriesElement = rootElement.getChild("virtualRepositories", namespace); if (virtualRepositoriesElement != null) { List<Element> virtualRepositoryElements = virtualRepositoriesElement.getChildren("virtualRepository", namespace); if (virtualRepositoryElements != null && !virtualRepositoryElements.isEmpty()) { for (Element virtualRepositoryElement : virtualRepositoryElements) { removeRepoType(virtualRepositoryElement, false, namespace); } } } log.info("Ending the default repository layout conversion."); }