2 package org.apache.archiva.configuration.io.registry;
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
23 import org.apache.archiva.configuration.*;
24 import org.apache.archiva.redback.components.registry.Registry;
26 import java.util.Iterator;
27 import java.util.List;
30 // Model class imports
34 * Generate Plexus Registry output mechanism for model 'Configuration'.
36 public class ConfigurationRegistryWriter {
37 public void write(Configuration model, Registry registry) {
38 writeConfiguration("", model, registry);
41 private void writeList(Registry registry, List<String> subList, String subsetPath, String elementName) {
42 if (subList != null && subList.size() > 0
44 registry.removeSubset(subsetPath);
47 for (Iterator<String> iter = subList.iterator(); iter.hasNext(); count++) {
48 String name = subsetPath + "." + elementName + "(" + count + ")";
49 String value = iter.next();
50 registry.setString(name, value);
55 private void writeConfiguration(String prefix, Configuration value, Registry registry) {
57 if (value.getVersion() != null
59 String version = "version";
60 registry.setString(prefix + version, value.getVersion());
62 if (value.getMetadataStore() != null && !value.getMetadataStore().equals("jcr")
64 String metadataStore = "metadataStore";
65 registry.setString(prefix + metadataStore, value.getMetadataStore());
67 if (value.getRepositoryGroups() != null && value.getRepositoryGroups().size() > 0
69 registry.removeSubset(prefix + "repositoryGroups");
72 for (Iterator iter = value.getRepositoryGroups().iterator(); iter.hasNext(); count++) {
73 String name = "repositoryGroups.repositoryGroup(" + count + ")";
74 RepositoryGroupConfiguration o = (RepositoryGroupConfiguration) iter.next();
75 writeRepositoryGroupConfiguration(prefix + name + ".", o, registry);
78 if (value.getManagedRepositories() != null && value.getManagedRepositories().size() > 0
80 registry.removeSubset(prefix + "managedRepositories");
83 for (Iterator iter = value.getManagedRepositories().iterator(); iter.hasNext(); count++) {
84 String name = "managedRepositories.managedRepository(" + count + ")";
85 ManagedRepositoryConfiguration o = (ManagedRepositoryConfiguration) iter.next();
86 writeManagedRepositoryConfiguration(prefix + name + ".", o, registry);
89 if (value.getRemoteRepositories() != null && value.getRemoteRepositories().size() > 0
91 registry.removeSubset(prefix + "remoteRepositories");
94 for (Iterator iter = value.getRemoteRepositories().iterator(); iter.hasNext(); count++) {
95 String name = "remoteRepositories.remoteRepository(" + count + ")";
96 RemoteRepositoryConfiguration o = (RemoteRepositoryConfiguration) iter.next();
97 writeRemoteRepositoryConfiguration(prefix + name + ".", o, registry);
100 if (value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
102 registry.removeSubset(prefix + "proxyConnectors");
105 for (Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++) {
106 String name = "proxyConnectors.proxyConnector(" + count + ")";
107 ProxyConnectorConfiguration o = (ProxyConnectorConfiguration) iter.next();
108 writeProxyConnectorConfiguration(prefix + name + ".", o, registry);
111 if (value.getNetworkProxies() != null && value.getNetworkProxies().size() > 0
113 registry.removeSubset(prefix + "networkProxies");
116 for (Iterator iter = value.getNetworkProxies().iterator(); iter.hasNext(); count++) {
117 String name = "networkProxies.networkProxy(" + count + ")";
118 NetworkProxyConfiguration o = (NetworkProxyConfiguration) iter.next();
119 writeNetworkProxyConfiguration(prefix + name + ".", o, registry);
122 if (value.getLegacyArtifactPaths() != null && value.getLegacyArtifactPaths().size() > 0
124 registry.removeSubset(prefix + "legacyArtifactPaths");
127 for (Iterator iter = value.getLegacyArtifactPaths().iterator(); iter.hasNext(); count++) {
128 String name = "legacyArtifactPaths.legacyArtifactPath(" + count + ")";
129 LegacyArtifactPath o = (LegacyArtifactPath) iter.next();
130 writeLegacyArtifactPath(prefix + name + ".", o, registry);
133 if (value.getRepositoryScanning() != null
135 writeRepositoryScanningConfiguration(prefix + "repositoryScanning.", value.getRepositoryScanning(), registry);
137 if (value.getWebapp() != null
139 writeWebappConfiguration(prefix + "webapp.", value.getWebapp(), registry);
141 if (value.getOrganisationInfo() != null
143 writeOrganisationInformation(prefix + "organisationInfo.", value.getOrganisationInfo(), registry);
145 if (value.getNetworkConfiguration() != null
147 writeNetworkConfiguration(prefix + "networkConfiguration.", value.getNetworkConfiguration(), registry);
149 if (value.getRedbackRuntimeConfiguration() != null
151 writeRedbackRuntimeConfiguration(prefix + "redbackRuntimeConfiguration.", value.getRedbackRuntimeConfiguration(), registry);
153 if (value.getArchivaRuntimeConfiguration() != null
155 writeArchivaRuntimeConfiguration(prefix + "archivaRuntimeConfiguration.", value.getArchivaRuntimeConfiguration(), registry);
157 if (value.getProxyConnectorRuleConfigurations() != null && value.getProxyConnectorRuleConfigurations().size() > 0
159 registry.removeSubset(prefix + "proxyConnectorRuleConfigurations");
162 for (Iterator iter = value.getProxyConnectorRuleConfigurations().iterator(); iter.hasNext(); count++) {
163 String name = "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration(" + count + ")";
164 ProxyConnectorRuleConfiguration o = (ProxyConnectorRuleConfiguration) iter.next();
165 writeProxyConnectorRuleConfiguration(prefix + name + ".", o, registry);
168 if (value.getArchivaDefaultConfiguration() != null
170 writeArchivaDefaultConfiguration(prefix + "archivaDefaultConfiguration.", value.getArchivaDefaultConfiguration(), registry);
175 private void writeAbstractRepositoryConfiguration(String prefix, AbstractRepositoryConfiguration value, Registry registry) {
177 if (value.getId() != null
180 registry.setString(prefix + id, value.getId());
182 if (value.getType() != null && !value.getType().equals("MAVEN")
184 String type = "type";
185 registry.setString(prefix + type, value.getType());
187 if (value.getName() != null
189 String name = "name";
190 registry.setString(prefix + name, value.getName());
192 if (value.getLayout() != null && !value.getLayout().equals("default")
194 String layout = "layout";
195 registry.setString(prefix + layout, value.getLayout());
197 if (value.getIndexDir() != null && !value.getIndexDir().equals("")
199 String indexDir = "indexDir";
200 registry.setString(prefix + indexDir, value.getIndexDir());
202 if (value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals("")
204 String packedIndexDir = "packedIndexDir";
205 registry.setString(prefix + packedIndexDir, value.getPackedIndexDir());
207 if (value.getDescription() != null && !value.getDescription().equals("")
209 String description = "description";
210 registry.setString(prefix + description, value.getDescription());
215 private void writeRemoteRepositoryConfiguration(String prefix, RemoteRepositoryConfiguration value, Registry registry) {
217 if (value.getUrl() != null
220 registry.setString(prefix + url, value.getUrl());
222 if (value.getUsername() != null
224 String username = "username";
225 registry.setString(prefix + username, value.getUsername());
227 if (value.getPassword() != null
229 String password = "password";
230 registry.setString(prefix + password, value.getPassword());
232 if (value.getTimeout() != 60
234 String timeout = "timeout";
235 registry.setInt(prefix + timeout, value.getTimeout());
237 if (value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals("0 0 08 ? * SUN")
239 String refreshCronExpression = "refreshCronExpression";
240 registry.setString(prefix + refreshCronExpression, value.getRefreshCronExpression());
242 String downloadRemoteIndex = "downloadRemoteIndex";
243 registry.setBoolean(prefix + downloadRemoteIndex, value.isDownloadRemoteIndex());
244 if (value.getRemoteIndexUrl() != null
246 String remoteIndexUrl = "remoteIndexUrl";
247 registry.setString(prefix + remoteIndexUrl, value.getRemoteIndexUrl());
249 if (value.getRemoteDownloadNetworkProxyId() != null
251 String remoteDownloadNetworkProxyId = "remoteDownloadNetworkProxyId";
252 registry.setString(prefix + remoteDownloadNetworkProxyId, value.getRemoteDownloadNetworkProxyId());
254 if (value.getRemoteDownloadTimeout() != 300
256 String remoteDownloadTimeout = "remoteDownloadTimeout";
257 registry.setInt(prefix + remoteDownloadTimeout, value.getRemoteDownloadTimeout());
259 String downloadRemoteIndexOnStartup = "downloadRemoteIndexOnStartup";
260 registry.setBoolean(prefix + downloadRemoteIndexOnStartup, value.isDownloadRemoteIndexOnStartup());
261 if (value.getExtraParameters() != null && value.getExtraParameters().size() > 0
263 registry.removeSubset(prefix + "extraParameters");
265 for (Iterator iter = value.getExtraParameters().keySet().iterator(); iter.hasNext(); ) {
266 String key = (String) iter.next();
267 String v = (String) value.getExtraParameters().get(key);
269 registry.setString(prefix + "extraParameters." + key, v);
272 if (value.getExtraHeaders() != null && value.getExtraHeaders().size() > 0
274 registry.removeSubset(prefix + "extraHeaders");
276 for (Iterator iter = value.getExtraHeaders().keySet().iterator(); iter.hasNext(); ) {
277 String key = (String) iter.next();
278 String v = (String) value.getExtraHeaders().get(key);
280 registry.setString(prefix + "extraHeaders." + key, v);
283 if (value.getCheckPath() != null
285 String checkPath = "checkPath";
286 registry.setString(prefix + checkPath, value.getCheckPath());
288 if (value.getId() != null
291 registry.setString(prefix + id, value.getId());
293 if (value.getType() != null && !value.getType().equals("MAVEN")
295 String type = "type";
296 registry.setString(prefix + type, value.getType());
298 if (value.getName() != null
300 String name = "name";
301 registry.setString(prefix + name, value.getName());
303 if (value.getLayout() != null && !value.getLayout().equals("default")
305 String layout = "layout";
306 registry.setString(prefix + layout, value.getLayout());
308 if (value.getIndexDir() != null && !value.getIndexDir().equals("")
310 String indexDir = "indexDir";
311 registry.setString(prefix + indexDir, value.getIndexDir());
313 if (value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals("")
315 String packedIndexDir = "packedIndexDir";
316 registry.setString(prefix + packedIndexDir, value.getPackedIndexDir());
318 if (value.getDescription() != null && !value.getDescription().equals("")
320 String description = "description";
321 registry.setString(prefix + description, value.getDescription());
326 private void writeManagedRepositoryConfiguration(String prefix, ManagedRepositoryConfiguration value, Registry registry) {
328 if (value.getLocation() != null
330 String location = "location";
331 registry.setString(prefix + location, value.getLocation());
333 String releases = "releases";
334 registry.setBoolean(prefix + releases, value.isReleases());
335 String blockRedeployments = "blockRedeployments";
336 registry.setBoolean(prefix + blockRedeployments, value.isBlockRedeployments());
337 String snapshots = "snapshots";
338 registry.setBoolean(prefix + snapshots, value.isSnapshots());
339 String scanned = "scanned";
340 registry.setBoolean(prefix + scanned, value.isScanned());
341 if (value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals("0 0 * * * ?")
343 String refreshCronExpression = "refreshCronExpression";
344 registry.setString(prefix + refreshCronExpression, value.getRefreshCronExpression());
346 if (value.getRetentionCount() != 2
348 String retentionCount = "retentionCount";
349 registry.setInt(prefix + retentionCount, value.getRetentionCount());
351 if (value.getRetentionPeriod() != 100
353 String retentionPeriod = "retentionPeriod";
354 registry.setInt(prefix + retentionPeriod, value.getRetentionPeriod());
356 String deleteReleasedSnapshots = "deleteReleasedSnapshots";
357 registry.setBoolean(prefix + deleteReleasedSnapshots, value.isDeleteReleasedSnapshots());
358 String skipPackedIndexCreation = "skipPackedIndexCreation";
359 registry.setBoolean(prefix + skipPackedIndexCreation, value.isSkipPackedIndexCreation());
360 String stageRepoNeeded = "stageRepoNeeded";
361 registry.setBoolean(prefix + stageRepoNeeded, value.isStageRepoNeeded());
362 if (value.getId() != null
365 registry.setString(prefix + id, value.getId());
367 if (value.getType() != null && !value.getType().equals("MAVEN")
369 String type = "type";
370 registry.setString(prefix + type, value.getType());
372 if (value.getName() != null
374 String name = "name";
375 registry.setString(prefix + name, value.getName());
377 if (value.getLayout() != null && !value.getLayout().equals("default")
379 String layout = "layout";
380 registry.setString(prefix + layout, value.getLayout());
382 if (value.getIndexDir() != null && !value.getIndexDir().equals("")
384 String indexDir = "indexDir";
385 registry.setString(prefix + indexDir, value.getIndexDir());
387 if (value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals("")
389 String packedIndexDir = "packedIndexDir";
390 registry.setString(prefix + packedIndexDir, value.getPackedIndexDir());
392 if (value.getDescription() != null && !value.getDescription().equals("")
394 String description = "description";
395 registry.setString(prefix + description, value.getDescription());
400 private void writeLegacyArtifactPath(String prefix, LegacyArtifactPath value, Registry registry) {
402 if (value.getPath() != null
404 String path = "path";
405 registry.setString(prefix + path, value.getPath());
407 if (value.getArtifact() != null
409 String artifact = "artifact";
410 registry.setString(prefix + artifact, value.getArtifact());
415 private void writeRepositoryGroupConfiguration(String prefix, RepositoryGroupConfiguration value, Registry registry) {
417 if (value.getId() != null
420 registry.setString(prefix + id, value.getId());
422 if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer")
424 String mergedIndexPath = "mergedIndexPath";
425 registry.setString(prefix + mergedIndexPath, value.getMergedIndexPath());
427 if (value.getMergedIndexTtl() != 30
429 String mergedIndexTtl = "mergedIndexTtl";
430 registry.setInt(prefix + mergedIndexTtl, value.getMergedIndexTtl());
432 if (value.getCronExpression() != null && !value.getCronExpression().equals("")
434 String cronExpression = "cronExpression";
435 registry.setString(prefix + cronExpression, value.getCronExpression());
437 if (value.getRepositories() != null && value.getRepositories().size() > 0
439 registry.removeSubset(prefix + "repositories");
442 for (Iterator iter = value.getRepositories().iterator(); iter.hasNext(); count++) {
443 String name = "repositories.repository(" + count + ")";
444 String repository = (String) iter.next();
445 registry.setString(prefix + name, repository);
451 private void writeRepositoryCheckPath(String prefix, RepositoryCheckPath value, Registry registry) {
453 if (value.getUrl() != null
456 registry.setString(prefix + url, value.getUrl());
458 if (value.getPath() != null
460 String path = "path";
461 registry.setString(prefix + path, value.getPath());
466 private void writeAbstractRepositoryConnectorConfiguration(String prefix, AbstractRepositoryConnectorConfiguration value, Registry registry) {
468 if (value.getSourceRepoId() != null
470 String sourceRepoId = "sourceRepoId";
471 registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
473 if (value.getTargetRepoId() != null
475 String targetRepoId = "targetRepoId";
476 registry.setString(prefix + targetRepoId, value.getTargetRepoId());
478 if (value.getProxyId() != null
480 String proxyId = "proxyId";
481 registry.setString(prefix + proxyId, value.getProxyId());
483 if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
485 registry.removeSubset(prefix + "blackListPatterns");
488 for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
489 String name = "blackListPatterns.blackListPattern(" + count + ")";
490 String blackListPattern = (String) iter.next();
491 registry.setString(prefix + name, blackListPattern);
494 if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
496 registry.removeSubset(prefix + "whiteListPatterns");
499 for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
500 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
501 String whiteListPattern = (String) iter.next();
502 registry.setString(prefix + name, whiteListPattern);
505 if (value.getPolicies() != null && value.getPolicies().size() > 0
507 registry.removeSubset(prefix + "policies");
509 for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
510 String key = (String) iter.next();
511 String v = (String) value.getPolicies().get(key);
513 registry.setString(prefix + "policies." + key, v);
516 if (value.getProperties() != null && value.getProperties().size() > 0
518 registry.removeSubset(prefix + "properties");
520 for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
521 String key = (String) iter.next();
522 String v = (String) value.getProperties().get(key);
524 registry.setString(prefix + "properties." + key, v);
527 String disabled = "disabled";
528 registry.setBoolean(prefix + disabled, value.isDisabled());
532 private void writeProxyConnectorRuleConfiguration(String prefix, ProxyConnectorRuleConfiguration value, Registry registry) {
534 if (value.getRuleType() != null
536 String ruleType = "ruleType";
537 registry.setString(prefix + ruleType, value.getRuleType());
539 if (value.getPattern() != null
541 String pattern = "pattern";
542 registry.setString(prefix + pattern, value.getPattern());
544 if (value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
546 registry.removeSubset(prefix + "proxyConnectors");
549 for (Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++) {
550 String name = "proxyConnectors.proxyConnector(" + count + ")";
551 ProxyConnectorConfiguration o = (ProxyConnectorConfiguration) iter.next();
552 writeProxyConnectorConfiguration(prefix + name + ".", o, registry);
558 private void writeProxyConnectorConfiguration(String prefix, ProxyConnectorConfiguration value, Registry registry) {
560 if (value.getOrder() != 0
562 String order = "order";
563 registry.setInt(prefix + order, value.getOrder());
565 if (value.getSourceRepoId() != null
567 String sourceRepoId = "sourceRepoId";
568 registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
570 if (value.getTargetRepoId() != null
572 String targetRepoId = "targetRepoId";
573 registry.setString(prefix + targetRepoId, value.getTargetRepoId());
575 if (value.getProxyId() != null
577 String proxyId = "proxyId";
578 registry.setString(prefix + proxyId, value.getProxyId());
580 if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
582 registry.removeSubset(prefix + "blackListPatterns");
585 for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
586 String name = "blackListPatterns.blackListPattern(" + count + ")";
587 String blackListPattern = (String) iter.next();
588 registry.setString(prefix + name, blackListPattern);
591 if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
593 registry.removeSubset(prefix + "whiteListPatterns");
596 for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
597 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
598 String whiteListPattern = (String) iter.next();
599 registry.setString(prefix + name, whiteListPattern);
602 if (value.getPolicies() != null && value.getPolicies().size() > 0
604 registry.removeSubset(prefix + "policies");
606 for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
607 String key = (String) iter.next();
608 String v = (String) value.getPolicies().get(key);
610 registry.setString(prefix + "policies." + key, v);
613 if (value.getProperties() != null && value.getProperties().size() > 0
615 registry.removeSubset(prefix + "properties");
617 for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
618 String key = (String) iter.next();
619 String v = (String) value.getProperties().get(key);
621 registry.setString(prefix + "properties." + key, v);
624 String disabled = "disabled";
625 registry.setBoolean(prefix + disabled, value.isDisabled());
629 private void writeSyncConnectorConfiguration(String prefix, SyncConnectorConfiguration value, Registry registry) {
631 if (value.getCronExpression() != null && !value.getCronExpression().equals("0 0 * * * ?")
633 String cronExpression = "cronExpression";
634 registry.setString(prefix + cronExpression, value.getCronExpression());
636 if (value.getMethod() != null && !value.getMethod().equals("rsync")
638 String method = "method";
639 registry.setString(prefix + method, value.getMethod());
641 if (value.getSourceRepoId() != null
643 String sourceRepoId = "sourceRepoId";
644 registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
646 if (value.getTargetRepoId() != null
648 String targetRepoId = "targetRepoId";
649 registry.setString(prefix + targetRepoId, value.getTargetRepoId());
651 if (value.getProxyId() != null
653 String proxyId = "proxyId";
654 registry.setString(prefix + proxyId, value.getProxyId());
656 if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
658 registry.removeSubset(prefix + "blackListPatterns");
661 for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
662 String name = "blackListPatterns.blackListPattern(" + count + ")";
663 String blackListPattern = (String) iter.next();
664 registry.setString(prefix + name, blackListPattern);
667 if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
669 registry.removeSubset(prefix + "whiteListPatterns");
672 for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
673 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
674 String whiteListPattern = (String) iter.next();
675 registry.setString(prefix + name, whiteListPattern);
678 if (value.getPolicies() != null && value.getPolicies().size() > 0
680 registry.removeSubset(prefix + "policies");
682 for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
683 String key = (String) iter.next();
684 String v = (String) value.getPolicies().get(key);
686 registry.setString(prefix + "policies." + key, v);
689 if (value.getProperties() != null && value.getProperties().size() > 0
691 registry.removeSubset(prefix + "properties");
693 for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
694 String key = (String) iter.next();
695 String v = (String) value.getProperties().get(key);
697 registry.setString(prefix + "properties." + key, v);
700 String disabled = "disabled";
701 registry.setBoolean(prefix + disabled, value.isDisabled());
705 private void writeNetworkProxyConfiguration(String prefix, NetworkProxyConfiguration value, Registry registry) {
707 if (value.getId() != null
710 registry.setString(prefix + id, value.getId());
712 if (value.getProtocol() != null && !value.getProtocol().equals("http")
714 String protocol = "protocol";
715 registry.setString(prefix + protocol, value.getProtocol());
717 if (value.getHost() != null
719 String host = "host";
720 registry.setString(prefix + host, value.getHost());
722 if (value.getPort() != 8080
724 String port = "port";
725 registry.setInt(prefix + port, value.getPort());
727 if (value.getUsername() != null
729 String username = "username";
730 registry.setString(prefix + username, value.getUsername());
732 if (value.getPassword() != null
734 String password = "password";
735 registry.setString(prefix + password, value.getPassword());
737 String useNtlm = "useNtlm";
738 registry.setBoolean(prefix + useNtlm, value.isUseNtlm());
742 private void writeRepositoryScanningConfiguration(String prefix, RepositoryScanningConfiguration value, Registry registry) {
744 if (value.getFileTypes() != null && value.getFileTypes().size() > 0
746 registry.removeSubset(prefix + "fileTypes");
749 for (Iterator iter = value.getFileTypes().iterator(); iter.hasNext(); count++) {
750 String name = "fileTypes.fileType(" + count + ")";
751 FileType o = (FileType) iter.next();
752 writeFileType(prefix + name + ".", o, registry);
755 if (value.getKnownContentConsumers() != null && value.getKnownContentConsumers().size() > 0
757 registry.removeSubset(prefix + "knownContentConsumers");
760 for (Iterator iter = value.getKnownContentConsumers().iterator(); iter.hasNext(); count++) {
761 String name = "knownContentConsumers.knownContentConsumer(" + count + ")";
762 String knownContentConsumer = (String) iter.next();
763 registry.setString(prefix + name, knownContentConsumer);
766 if (value.getInvalidContentConsumers() != null && value.getInvalidContentConsumers().size() > 0
768 registry.removeSubset(prefix + "invalidContentConsumers");
771 for (Iterator iter = value.getInvalidContentConsumers().iterator(); iter.hasNext(); count++) {
772 String name = "invalidContentConsumers.invalidContentConsumer(" + count + ")";
773 String invalidContentConsumer = (String) iter.next();
774 registry.setString(prefix + name, invalidContentConsumer);
780 private void writeFileType(String prefix, FileType value, Registry registry) {
782 if (value.getId() != null
785 registry.setString(prefix + id, value.getId());
787 if (value.getPatterns() != null && value.getPatterns().size() > 0
789 registry.removeSubset(prefix + "patterns");
792 for (Iterator iter = value.getPatterns().iterator(); iter.hasNext(); count++) {
793 String name = "patterns.pattern(" + count + ")";
794 String pattern = (String) iter.next();
795 registry.setString(prefix + name, pattern);
801 private void writeOrganisationInformation(String prefix, OrganisationInformation value, Registry registry) {
803 if (value.getName() != null
805 String name = "name";
806 registry.setString(prefix + name, value.getName());
808 if (value.getUrl() != null
811 registry.setString(prefix + url, value.getUrl());
813 if (value.getLogoLocation() != null
815 String logoLocation = "logoLocation";
816 registry.setString(prefix + logoLocation, value.getLogoLocation());
821 private void writeWebappConfiguration(String prefix, WebappConfiguration value, Registry registry) {
823 if (value.getUi() != null
825 writeUserInterfaceOptions(prefix + "ui.", value.getUi(), registry);
830 private void writeUserInterfaceOptions(String prefix, UserInterfaceOptions value, Registry registry) {
832 String showFindArtifacts = "showFindArtifacts";
833 registry.setBoolean(prefix + showFindArtifacts, value.isShowFindArtifacts());
834 String appletFindEnabled = "appletFindEnabled";
835 registry.setBoolean(prefix + appletFindEnabled, value.isAppletFindEnabled());
836 String disableEasterEggs = "disableEasterEggs";
837 registry.setBoolean(prefix + disableEasterEggs, value.isDisableEasterEggs());
838 if (value.getApplicationUrl() != null
840 String applicationUrl = "applicationUrl";
841 registry.setString(prefix + applicationUrl, value.getApplicationUrl());
843 String disableRegistration = "disableRegistration";
844 registry.setBoolean(prefix + disableRegistration, value.isDisableRegistration());
848 private void writeNetworkConfiguration(String prefix, NetworkConfiguration value, Registry registry) {
850 if (value.getMaxTotal() != 30
852 String maxTotal = "maxTotal";
853 registry.setInt(prefix + maxTotal, value.getMaxTotal());
855 if (value.getMaxTotalPerHost() != 30
857 String maxTotalPerHost = "maxTotalPerHost";
858 registry.setInt(prefix + maxTotalPerHost, value.getMaxTotalPerHost());
860 String usePooling = "usePooling";
861 registry.setBoolean(prefix + usePooling, value.isUsePooling());
865 private void writeArchivaRuntimeConfiguration(String prefix, ArchivaRuntimeConfiguration value, Registry registry) {
867 if (value.getUrlFailureCacheConfiguration() != null
869 writeCacheConfiguration(prefix + "urlFailureCacheConfiguration.", value.getUrlFailureCacheConfiguration(), registry);
871 if (value.getFileLockConfiguration() != null
873 writeFileLockConfiguration(prefix + "fileLockConfiguration.", value.getFileLockConfiguration(), registry);
875 if (value.getDataDirectory() != null
877 String dataDirectory = "dataDirectory";
878 registry.setString(prefix + dataDirectory, value.getDataDirectory());
880 if (value.getRepositoryBaseDirectory() != null
882 String repositoryBaseDirectory = "repositoryBaseDirectory";
883 registry.setString(prefix + repositoryBaseDirectory, value.getRepositoryBaseDirectory());
885 if (value.getRemoteRepositoryBaseDirectory() != null
887 String remoteRepositoryBaseDirectory = "remoteRepositoryBaseDirectory";
888 registry.setString(prefix + remoteRepositoryBaseDirectory, value.getRemoteRepositoryBaseDirectory());
890 if (value.getDefaultLanguage() != null && !value.getDefaultLanguage().equals("en-US")
892 String defaultLanguage = "defaultLanguage";
893 registry.setString(prefix + defaultLanguage, value.getDefaultLanguage());
895 if (value.getLanguageRange() != null && !value.getLanguageRange().equals("en,fr,de")
897 String languageRange = "languageRange";
898 registry.setString(prefix + languageRange, value.getLanguageRange());
900 writeList(registry, value.getChecksumTypes(), prefix+"checksumTypes", "type");
904 private void writeRedbackRuntimeConfiguration(String prefix, RedbackRuntimeConfiguration value, Registry registry) {
906 String migratedFromRedbackConfiguration = "migratedFromRedbackConfiguration";
907 registry.setBoolean(prefix + migratedFromRedbackConfiguration, value.isMigratedFromRedbackConfiguration());
908 if (value.getUserManagerImpls() != null && value.getUserManagerImpls().size() > 0
910 registry.removeSubset(prefix + "userManagerImpls");
913 for (Iterator iter = value.getUserManagerImpls().iterator(); iter.hasNext(); count++) {
914 String name = "userManagerImpls.userManagerImpl(" + count + ")";
915 String userManagerImpl = (String) iter.next();
916 registry.setString(prefix + name, userManagerImpl);
919 if (value.getRbacManagerImpls() != null && value.getRbacManagerImpls().size() > 0
921 registry.removeSubset(prefix + "rbacManagerImpls");
924 for (Iterator iter = value.getRbacManagerImpls().iterator(); iter.hasNext(); count++) {
925 String name = "rbacManagerImpls.rbacManagerImpl(" + count + ")";
926 String rbacManagerImpl = (String) iter.next();
927 registry.setString(prefix + name, rbacManagerImpl);
930 if (value.getLdapConfiguration() != null
932 writeLdapConfiguration(prefix + "ldapConfiguration.", value.getLdapConfiguration(), registry);
934 if (value.getLdapGroupMappings() != null && value.getLdapGroupMappings().size() > 0
936 registry.removeSubset(prefix + "ldapGroupMappings");
939 for (Iterator iter = value.getLdapGroupMappings().iterator(); iter.hasNext(); count++) {
940 String name = "ldapGroupMappings.ldapGroupMapping(" + count + ")";
941 LdapGroupMapping o = (LdapGroupMapping) iter.next();
942 writeLdapGroupMapping(prefix + name + ".", o, registry);
945 if (value.getConfigurationProperties() != null && value.getConfigurationProperties().size() > 0
947 registry.removeSubset(prefix + "configurationProperties");
949 for (Iterator iter = value.getConfigurationProperties().keySet().iterator(); iter.hasNext(); ) {
950 String key = (String) iter.next();
951 String v = (String) value.getConfigurationProperties().get(key);
953 registry.setString(prefix + "configurationProperties." + key, v);
956 String useUsersCache = "useUsersCache";
957 registry.setBoolean(prefix + useUsersCache, value.isUseUsersCache());
958 if (value.getUsersCacheConfiguration() != null
960 writeCacheConfiguration(prefix + "usersCacheConfiguration.", value.getUsersCacheConfiguration(), registry);
965 private void writeArchivaDefaultConfiguration(String prefix, ArchivaDefaultConfiguration value, Registry registry) {
967 if (value.getDefaultCheckPaths() != null && value.getDefaultCheckPaths().size() > 0
969 registry.removeSubset(prefix + "defaultCheckPaths");
972 for (Iterator iter = value.getDefaultCheckPaths().iterator(); iter.hasNext(); count++) {
973 String name = "defaultCheckPaths.defaultCheckPath(" + count + ")";
974 RepositoryCheckPath o = (RepositoryCheckPath) iter.next();
975 writeRepositoryCheckPath(prefix + name + ".", o, registry);
981 private void writeLdapConfiguration(String prefix, LdapConfiguration value, Registry registry) {
983 if (value.getHostName() != null
985 String hostName = "hostName";
986 registry.setString(prefix + hostName, value.getHostName());
988 if (value.getPort() != 0
990 String port = "port";
991 registry.setInt(prefix + port, value.getPort());
994 registry.setBoolean(prefix + ssl, value.isSsl());
995 if (value.getBaseDn() != null
997 String baseDn = "baseDn";
998 registry.setString(prefix + baseDn, value.getBaseDn());
1000 if (value.getBaseGroupsDn() != null
1002 String baseGroupsDn = "baseGroupsDn";
1003 registry.setString(prefix + baseGroupsDn, value.getBaseGroupsDn());
1005 if (value.getContextFactory() != null
1007 String contextFactory = "contextFactory";
1008 registry.setString(prefix + contextFactory, value.getContextFactory());
1010 if (value.getBindDn() != null
1012 String bindDn = "bindDn";
1013 registry.setString(prefix + bindDn, value.getBindDn());
1015 if (value.getPassword() != null
1017 String password = "password";
1018 registry.setString(prefix + password, value.getPassword());
1020 if (value.getAuthenticationMethod() != null
1022 String authenticationMethod = "authenticationMethod";
1023 registry.setString(prefix + authenticationMethod, value.getAuthenticationMethod());
1025 String bindAuthenticatorEnabled = "bindAuthenticatorEnabled";
1026 registry.setBoolean(prefix + bindAuthenticatorEnabled, value.isBindAuthenticatorEnabled());
1027 String writable = "writable";
1028 registry.setBoolean(prefix + writable, value.isWritable());
1029 String useRoleNameAsGroup = "useRoleNameAsGroup";
1030 registry.setBoolean(prefix + useRoleNameAsGroup, value.isUseRoleNameAsGroup());
1031 if (value.getExtraProperties() != null && value.getExtraProperties().size() > 0
1033 registry.removeSubset(prefix + "extraProperties");
1035 for (Iterator iter = value.getExtraProperties().keySet().iterator(); iter.hasNext(); ) {
1036 String key = (String) iter.next();
1037 String v = (String) value.getExtraProperties().get(key);
1039 registry.setString(prefix + "extraProperties." + key, v);
1045 private void writeFileLockConfiguration(String prefix, FileLockConfiguration value, Registry registry) {
1046 if (value != null) {
1047 String skipLocking = "skipLocking";
1048 registry.setBoolean(prefix + skipLocking, value.isSkipLocking());
1049 if (value.getLockingTimeout() != 0
1051 String lockingTimeout = "lockingTimeout";
1052 registry.setInt(prefix + lockingTimeout, value.getLockingTimeout());
1057 private void writeCacheConfiguration(String prefix, CacheConfiguration value, Registry registry) {
1058 if (value != null) {
1059 if (value.getTimeToIdleSeconds() != -1
1061 String timeToIdleSeconds = "timeToIdleSeconds";
1062 registry.setInt(prefix + timeToIdleSeconds, value.getTimeToIdleSeconds());
1064 if (value.getTimeToLiveSeconds() != -1
1066 String timeToLiveSeconds = "timeToLiveSeconds";
1067 registry.setInt(prefix + timeToLiveSeconds, value.getTimeToLiveSeconds());
1069 if (value.getMaxElementsInMemory() != -1
1071 String maxElementsInMemory = "maxElementsInMemory";
1072 registry.setInt(prefix + maxElementsInMemory, value.getMaxElementsInMemory());
1074 if (value.getMaxElementsOnDisk() != -1
1076 String maxElementsOnDisk = "maxElementsOnDisk";
1077 registry.setInt(prefix + maxElementsOnDisk, value.getMaxElementsOnDisk());
1082 private void writeLdapGroupMapping(String prefix, LdapGroupMapping value, Registry registry) {
1083 if (value != null) {
1084 if (value.getGroup() != null
1086 String group = "group";
1087 registry.setString(prefix + group, value.getGroup());
1089 if (value.getRoleNames() != null && value.getRoleNames().size() > 0
1091 registry.removeSubset(prefix + "roleNames");
1094 for (Iterator iter = value.getRoleNames().iterator(); iter.hasNext(); count++) {
1095 String name = "roleNames.roleName(" + count + ")";
1096 String roleName = (String) iter.next();
1097 registry.setString(prefix + name, roleName);