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.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.getName() != null) {
423 registry.setString(prefix + "name", value.getName());
425 if (value.getType() != null) {
426 registry.setString(prefix + "type", value.getType());
428 if (value.getLocation()!=null) {
429 registry.setString( prefix+"location", value.getType( ) );
431 if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer")
433 String mergedIndexPath = "mergedIndexPath";
434 registry.setString(prefix + mergedIndexPath, value.getMergedIndexPath());
436 if (value.getMergedIndexTtl() != 30
438 String mergedIndexTtl = "mergedIndexTtl";
439 registry.setInt(prefix + mergedIndexTtl, value.getMergedIndexTtl());
441 if (value.getCronExpression() != null && !value.getCronExpression().equals("")
443 String cronExpression = "cronExpression";
444 registry.setString(prefix + cronExpression, value.getCronExpression());
446 if (value.getRepositories() != null && value.getRepositories().size() > 0
448 registry.removeSubset(prefix + "repositories");
451 for (Iterator iter = value.getRepositories().iterator(); iter.hasNext(); count++) {
452 String name = "repositories.repository(" + count + ")";
453 String repository = (String) iter.next();
454 registry.setString(prefix + name, repository);
460 private void writeRepositoryCheckPath(String prefix, RepositoryCheckPath value, Registry registry) {
462 if (value.getUrl() != null
465 registry.setString(prefix + url, value.getUrl());
467 if (value.getPath() != null
469 String path = "path";
470 registry.setString(prefix + path, value.getPath());
475 private void writeAbstractRepositoryConnectorConfiguration(String prefix, AbstractRepositoryConnectorConfiguration value, Registry registry) {
477 if (value.getSourceRepoId() != null
479 String sourceRepoId = "sourceRepoId";
480 registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
482 if (value.getTargetRepoId() != null
484 String targetRepoId = "targetRepoId";
485 registry.setString(prefix + targetRepoId, value.getTargetRepoId());
487 if (value.getProxyId() != null
489 String proxyId = "proxyId";
490 registry.setString(prefix + proxyId, value.getProxyId());
492 if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
494 registry.removeSubset(prefix + "blackListPatterns");
497 for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
498 String name = "blackListPatterns.blackListPattern(" + count + ")";
499 String blackListPattern = (String) iter.next();
500 registry.setString(prefix + name, blackListPattern);
503 if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
505 registry.removeSubset(prefix + "whiteListPatterns");
508 for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
509 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
510 String whiteListPattern = (String) iter.next();
511 registry.setString(prefix + name, whiteListPattern);
514 if (value.getPolicies() != null && value.getPolicies().size() > 0
516 registry.removeSubset(prefix + "policies");
518 for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
519 String key = (String) iter.next();
520 String v = (String) value.getPolicies().get(key);
522 registry.setString(prefix + "policies." + key, v);
525 if (value.getProperties() != null && value.getProperties().size() > 0
527 registry.removeSubset(prefix + "properties");
529 for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
530 String key = (String) iter.next();
531 String v = (String) value.getProperties().get(key);
533 registry.setString(prefix + "properties." + key, v);
536 String disabled = "disabled";
537 registry.setBoolean(prefix + disabled, value.isDisabled());
541 private void writeProxyConnectorRuleConfiguration(String prefix, ProxyConnectorRuleConfiguration value, Registry registry) {
543 if (value.getRuleType() != null
545 String ruleType = "ruleType";
546 registry.setString(prefix + ruleType, value.getRuleType());
548 if (value.getPattern() != null
550 String pattern = "pattern";
551 registry.setString(prefix + pattern, value.getPattern());
553 if (value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
555 registry.removeSubset(prefix + "proxyConnectors");
558 for (Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++) {
559 String name = "proxyConnectors.proxyConnector(" + count + ")";
560 ProxyConnectorConfiguration o = (ProxyConnectorConfiguration) iter.next();
561 writeProxyConnectorConfiguration(prefix + name + ".", o, registry);
567 private void writeProxyConnectorConfiguration(String prefix, ProxyConnectorConfiguration value, Registry registry) {
569 if (value.getOrder() != 0
571 String order = "order";
572 registry.setInt(prefix + order, value.getOrder());
574 if (value.getSourceRepoId() != null
576 String sourceRepoId = "sourceRepoId";
577 registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
579 if (value.getTargetRepoId() != null
581 String targetRepoId = "targetRepoId";
582 registry.setString(prefix + targetRepoId, value.getTargetRepoId());
584 if (value.getProxyId() != null
586 String proxyId = "proxyId";
587 registry.setString(prefix + proxyId, value.getProxyId());
589 if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
591 registry.removeSubset(prefix + "blackListPatterns");
594 for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
595 String name = "blackListPatterns.blackListPattern(" + count + ")";
596 String blackListPattern = (String) iter.next();
597 registry.setString(prefix + name, blackListPattern);
600 if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
602 registry.removeSubset(prefix + "whiteListPatterns");
605 for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
606 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
607 String whiteListPattern = (String) iter.next();
608 registry.setString(prefix + name, whiteListPattern);
611 if (value.getPolicies() != null && value.getPolicies().size() > 0
613 registry.removeSubset(prefix + "policies");
615 for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
616 String key = (String) iter.next();
617 String v = (String) value.getPolicies().get(key);
619 registry.setString(prefix + "policies." + key, v);
622 if (value.getProperties() != null && value.getProperties().size() > 0
624 registry.removeSubset(prefix + "properties");
626 for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
627 String key = (String) iter.next();
628 String v = (String) value.getProperties().get(key);
630 registry.setString(prefix + "properties." + key, v);
633 String disabled = "disabled";
634 registry.setBoolean(prefix + disabled, value.isDisabled());
638 private void writeSyncConnectorConfiguration(String prefix, SyncConnectorConfiguration value, Registry registry) {
640 if (value.getCronExpression() != null && !value.getCronExpression().equals("0 0 * * * ?")
642 String cronExpression = "cronExpression";
643 registry.setString(prefix + cronExpression, value.getCronExpression());
645 if (value.getMethod() != null && !value.getMethod().equals("rsync")
647 String method = "method";
648 registry.setString(prefix + method, value.getMethod());
650 if (value.getSourceRepoId() != null
652 String sourceRepoId = "sourceRepoId";
653 registry.setString(prefix + sourceRepoId, value.getSourceRepoId());
655 if (value.getTargetRepoId() != null
657 String targetRepoId = "targetRepoId";
658 registry.setString(prefix + targetRepoId, value.getTargetRepoId());
660 if (value.getProxyId() != null
662 String proxyId = "proxyId";
663 registry.setString(prefix + proxyId, value.getProxyId());
665 if (value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
667 registry.removeSubset(prefix + "blackListPatterns");
670 for (Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++) {
671 String name = "blackListPatterns.blackListPattern(" + count + ")";
672 String blackListPattern = (String) iter.next();
673 registry.setString(prefix + name, blackListPattern);
676 if (value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
678 registry.removeSubset(prefix + "whiteListPatterns");
681 for (Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++) {
682 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
683 String whiteListPattern = (String) iter.next();
684 registry.setString(prefix + name, whiteListPattern);
687 if (value.getPolicies() != null && value.getPolicies().size() > 0
689 registry.removeSubset(prefix + "policies");
691 for (Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); ) {
692 String key = (String) iter.next();
693 String v = (String) value.getPolicies().get(key);
695 registry.setString(prefix + "policies." + key, v);
698 if (value.getProperties() != null && value.getProperties().size() > 0
700 registry.removeSubset(prefix + "properties");
702 for (Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); ) {
703 String key = (String) iter.next();
704 String v = (String) value.getProperties().get(key);
706 registry.setString(prefix + "properties." + key, v);
709 String disabled = "disabled";
710 registry.setBoolean(prefix + disabled, value.isDisabled());
714 private void writeNetworkProxyConfiguration(String prefix, NetworkProxyConfiguration value, Registry registry) {
716 if (value.getId() != null
719 registry.setString(prefix + id, value.getId());
721 if (value.getProtocol() != null && !value.getProtocol().equals("http")
723 String protocol = "protocol";
724 registry.setString(prefix + protocol, value.getProtocol());
726 if (value.getHost() != null
728 String host = "host";
729 registry.setString(prefix + host, value.getHost());
731 if (value.getPort() != 8080
733 String port = "port";
734 registry.setInt(prefix + port, value.getPort());
736 if (value.getUsername() != null
738 String username = "username";
739 registry.setString(prefix + username, value.getUsername());
741 if (value.getPassword() != null
743 String password = "password";
744 registry.setString(prefix + password, value.getPassword());
746 String useNtlm = "useNtlm";
747 registry.setBoolean(prefix + useNtlm, value.isUseNtlm());
751 private void writeRepositoryScanningConfiguration(String prefix, RepositoryScanningConfiguration value, Registry registry) {
753 if (value.getFileTypes() != null && value.getFileTypes().size() > 0
755 registry.removeSubset(prefix + "fileTypes");
758 for (Iterator iter = value.getFileTypes().iterator(); iter.hasNext(); count++) {
759 String name = "fileTypes.fileType(" + count + ")";
760 FileType o = (FileType) iter.next();
761 writeFileType(prefix + name + ".", o, registry);
764 if (value.getKnownContentConsumers() != null && value.getKnownContentConsumers().size() > 0
766 registry.removeSubset(prefix + "knownContentConsumers");
769 for (Iterator iter = value.getKnownContentConsumers().iterator(); iter.hasNext(); count++) {
770 String name = "knownContentConsumers.knownContentConsumer(" + count + ")";
771 String knownContentConsumer = (String) iter.next();
772 registry.setString(prefix + name, knownContentConsumer);
775 if (value.getInvalidContentConsumers() != null && value.getInvalidContentConsumers().size() > 0
777 registry.removeSubset(prefix + "invalidContentConsumers");
780 for (Iterator iter = value.getInvalidContentConsumers().iterator(); iter.hasNext(); count++) {
781 String name = "invalidContentConsumers.invalidContentConsumer(" + count + ")";
782 String invalidContentConsumer = (String) iter.next();
783 registry.setString(prefix + name, invalidContentConsumer);
789 private void writeFileType(String prefix, FileType value, Registry registry) {
791 if (value.getId() != null
794 registry.setString(prefix + id, value.getId());
796 if (value.getPatterns() != null && value.getPatterns().size() > 0
798 registry.removeSubset(prefix + "patterns");
801 for (Iterator iter = value.getPatterns().iterator(); iter.hasNext(); count++) {
802 String name = "patterns.pattern(" + count + ")";
803 String pattern = (String) iter.next();
804 registry.setString(prefix + name, pattern);
810 private void writeOrganisationInformation(String prefix, OrganisationInformation value, Registry registry) {
812 if (value.getName() != null
814 String name = "name";
815 registry.setString(prefix + name, value.getName());
817 if (value.getUrl() != null
820 registry.setString(prefix + url, value.getUrl());
822 if (value.getLogoLocation() != null
824 String logoLocation = "logoLocation";
825 registry.setString(prefix + logoLocation, value.getLogoLocation());
830 private void writeWebappConfiguration(String prefix, WebappConfiguration value, Registry registry) {
832 if (value.getUi() != null
834 writeUserInterfaceOptions(prefix + "ui.", value.getUi(), registry);
839 private void writeUserInterfaceOptions(String prefix, UserInterfaceOptions value, Registry registry) {
841 String showFindArtifacts = "showFindArtifacts";
842 registry.setBoolean(prefix + showFindArtifacts, value.isShowFindArtifacts());
843 String appletFindEnabled = "appletFindEnabled";
844 registry.setBoolean(prefix + appletFindEnabled, value.isAppletFindEnabled());
845 String disableEasterEggs = "disableEasterEggs";
846 registry.setBoolean(prefix + disableEasterEggs, value.isDisableEasterEggs());
847 if (value.getApplicationUrl() != null
849 String applicationUrl = "applicationUrl";
850 registry.setString(prefix + applicationUrl, value.getApplicationUrl());
852 String disableRegistration = "disableRegistration";
853 registry.setBoolean(prefix + disableRegistration, value.isDisableRegistration());
857 private void writeNetworkConfiguration(String prefix, NetworkConfiguration value, Registry registry) {
859 if (value.getMaxTotal() != 30
861 String maxTotal = "maxTotal";
862 registry.setInt(prefix + maxTotal, value.getMaxTotal());
864 if (value.getMaxTotalPerHost() != 30
866 String maxTotalPerHost = "maxTotalPerHost";
867 registry.setInt(prefix + maxTotalPerHost, value.getMaxTotalPerHost());
869 String usePooling = "usePooling";
870 registry.setBoolean(prefix + usePooling, value.isUsePooling());
874 private void writeArchivaRuntimeConfiguration(String prefix, ArchivaRuntimeConfiguration value, Registry registry) {
876 if (value.getUrlFailureCacheConfiguration() != null
878 writeCacheConfiguration(prefix + "urlFailureCacheConfiguration.", value.getUrlFailureCacheConfiguration(), registry);
880 if (value.getFileLockConfiguration() != null
882 writeFileLockConfiguration(prefix + "fileLockConfiguration.", value.getFileLockConfiguration(), registry);
884 if (value.getDataDirectory() != null
886 String dataDirectory = "dataDirectory";
887 registry.setString(prefix + dataDirectory, value.getDataDirectory());
889 if (value.getRepositoryBaseDirectory() != null
891 String repositoryBaseDirectory = "repositoryBaseDirectory";
892 registry.setString(prefix + repositoryBaseDirectory, value.getRepositoryBaseDirectory());
894 if (value.getRemoteRepositoryBaseDirectory() != null
896 String remoteRepositoryBaseDirectory = "remoteRepositoryBaseDirectory";
897 registry.setString(prefix + remoteRepositoryBaseDirectory, value.getRemoteRepositoryBaseDirectory());
899 if (value.getRepositoryGroupBaseDirectory() != null
901 String repositoryGroupBaseDirectory = "repositoryGroupBaseDirectory";
902 registry.setString(prefix + repositoryGroupBaseDirectory, value.getRepositoryGroupBaseDirectory());
905 if (value.getDefaultLanguage() != null && !value.getDefaultLanguage().equals("en-US")
907 String defaultLanguage = "defaultLanguage";
908 registry.setString(prefix + defaultLanguage, value.getDefaultLanguage());
910 if (value.getLanguageRange() != null && !value.getLanguageRange().equals("en,fr,de")
912 String languageRange = "languageRange";
913 registry.setString(prefix + languageRange, value.getLanguageRange());
915 writeList(registry, value.getChecksumTypes(), prefix+"checksumTypes", "type");
919 private void writeRedbackRuntimeConfiguration(String prefix, RedbackRuntimeConfiguration value, Registry registry) {
921 String migratedFromRedbackConfiguration = "migratedFromRedbackConfiguration";
922 registry.setBoolean(prefix + migratedFromRedbackConfiguration, value.isMigratedFromRedbackConfiguration());
923 if (value.getUserManagerImpls() != null && value.getUserManagerImpls().size() > 0
925 registry.removeSubset(prefix + "userManagerImpls");
928 for (Iterator iter = value.getUserManagerImpls().iterator(); iter.hasNext(); count++) {
929 String name = "userManagerImpls.userManagerImpl(" + count + ")";
930 String userManagerImpl = (String) iter.next();
931 registry.setString(prefix + name, userManagerImpl);
934 if (value.getRbacManagerImpls() != null && value.getRbacManagerImpls().size() > 0
936 registry.removeSubset(prefix + "rbacManagerImpls");
939 for (Iterator iter = value.getRbacManagerImpls().iterator(); iter.hasNext(); count++) {
940 String name = "rbacManagerImpls.rbacManagerImpl(" + count + ")";
941 String rbacManagerImpl = (String) iter.next();
942 registry.setString(prefix + name, rbacManagerImpl);
945 if (value.getLdapConfiguration() != null
947 writeLdapConfiguration(prefix + "ldapConfiguration.", value.getLdapConfiguration(), registry);
949 if (value.getLdapGroupMappings() != null && value.getLdapGroupMappings().size() > 0
951 registry.removeSubset(prefix + "ldapGroupMappings");
954 for (Iterator iter = value.getLdapGroupMappings().iterator(); iter.hasNext(); count++) {
955 String name = "ldapGroupMappings.ldapGroupMapping(" + count + ")";
956 LdapGroupMapping o = (LdapGroupMapping) iter.next();
957 writeLdapGroupMapping(prefix + name + ".", o, registry);
960 if (value.getConfigurationProperties() != null && value.getConfigurationProperties().size() > 0
962 registry.removeSubset(prefix + "configurationProperties");
964 for (Iterator iter = value.getConfigurationProperties().keySet().iterator(); iter.hasNext(); ) {
965 String key = (String) iter.next();
966 String v = (String) value.getConfigurationProperties().get(key);
968 registry.setString(prefix + "configurationProperties." + key, v);
971 String useUsersCache = "useUsersCache";
972 registry.setBoolean(prefix + useUsersCache, value.isUseUsersCache());
973 if (value.getUsersCacheConfiguration() != null
975 writeCacheConfiguration(prefix + "usersCacheConfiguration.", value.getUsersCacheConfiguration(), registry);
980 private void writeArchivaDefaultConfiguration(String prefix, ArchivaDefaultConfiguration value, Registry registry) {
982 if (value.getDefaultCheckPaths() != null && value.getDefaultCheckPaths().size() > 0
984 registry.removeSubset(prefix + "defaultCheckPaths");
987 for (Iterator iter = value.getDefaultCheckPaths().iterator(); iter.hasNext(); count++) {
988 String name = "defaultCheckPaths.defaultCheckPath(" + count + ")";
989 RepositoryCheckPath o = (RepositoryCheckPath) iter.next();
990 writeRepositoryCheckPath(prefix + name + ".", o, registry);
996 private void writeLdapConfiguration(String prefix, LdapConfiguration value, Registry registry) {
998 if (value.getHostName() != null
1000 String hostName = "hostName";
1001 registry.setString(prefix + hostName, value.getHostName());
1003 if (value.getPort() != 0
1005 String port = "port";
1006 registry.setInt(prefix + port, value.getPort());
1009 registry.setBoolean(prefix + ssl, value.isSsl());
1010 if (value.getBaseDn() != null
1012 String baseDn = "baseDn";
1013 registry.setString(prefix + baseDn, value.getBaseDn());
1015 if (value.getBaseGroupsDn() != null
1017 String baseGroupsDn = "baseGroupsDn";
1018 registry.setString(prefix + baseGroupsDn, value.getBaseGroupsDn());
1020 if (value.getContextFactory() != null
1022 String contextFactory = "contextFactory";
1023 registry.setString(prefix + contextFactory, value.getContextFactory());
1025 if (value.getBindDn() != null
1027 String bindDn = "bindDn";
1028 registry.setString(prefix + bindDn, value.getBindDn());
1030 if (value.getPassword() != null
1032 String password = "password";
1033 registry.setString(prefix + password, value.getPassword());
1035 if (value.getAuthenticationMethod() != null
1037 String authenticationMethod = "authenticationMethod";
1038 registry.setString(prefix + authenticationMethod, value.getAuthenticationMethod());
1040 String bindAuthenticatorEnabled = "bindAuthenticatorEnabled";
1041 registry.setBoolean(prefix + bindAuthenticatorEnabled, value.isBindAuthenticatorEnabled());
1042 String writable = "writable";
1043 registry.setBoolean(prefix + writable, value.isWritable());
1044 String useRoleNameAsGroup = "useRoleNameAsGroup";
1045 registry.setBoolean(prefix + useRoleNameAsGroup, value.isUseRoleNameAsGroup());
1046 if (value.getExtraProperties() != null && value.getExtraProperties().size() > 0
1048 registry.removeSubset(prefix + "extraProperties");
1050 for (Iterator iter = value.getExtraProperties().keySet().iterator(); iter.hasNext(); ) {
1051 String key = (String) iter.next();
1052 String v = (String) value.getExtraProperties().get(key);
1054 registry.setString(prefix + "extraProperties." + key, v);
1060 private void writeFileLockConfiguration(String prefix, FileLockConfiguration value, Registry registry) {
1061 if (value != null) {
1062 String skipLocking = "skipLocking";
1063 registry.setBoolean(prefix + skipLocking, value.isSkipLocking());
1064 if (value.getLockingTimeout() != 0
1066 String lockingTimeout = "lockingTimeout";
1067 registry.setInt(prefix + lockingTimeout, value.getLockingTimeout());
1072 private void writeCacheConfiguration(String prefix, CacheConfiguration value, Registry registry) {
1073 if (value != null) {
1074 if (value.getTimeToIdleSeconds() != -1
1076 String timeToIdleSeconds = "timeToIdleSeconds";
1077 registry.setInt(prefix + timeToIdleSeconds, value.getTimeToIdleSeconds());
1079 if (value.getTimeToLiveSeconds() != -1
1081 String timeToLiveSeconds = "timeToLiveSeconds";
1082 registry.setInt(prefix + timeToLiveSeconds, value.getTimeToLiveSeconds());
1084 if (value.getMaxElementsInMemory() != -1
1086 String maxElementsInMemory = "maxElementsInMemory";
1087 registry.setInt(prefix + maxElementsInMemory, value.getMaxElementsInMemory());
1089 if (value.getMaxElementsOnDisk() != -1
1091 String maxElementsOnDisk = "maxElementsOnDisk";
1092 registry.setInt(prefix + maxElementsOnDisk, value.getMaxElementsOnDisk());
1097 private void writeLdapGroupMapping(String prefix, LdapGroupMapping value, Registry registry) {
1098 if (value != null) {
1099 if (value.getGroup() != null
1101 String group = "group";
1102 registry.setString(prefix + group, value.getGroup());
1104 if (value.getRoleNames() != null && value.getRoleNames().size() > 0
1106 registry.removeSubset(prefix + "roleNames");
1109 for (Iterator iter = value.getRoleNames().iterator(); iter.hasNext(); count++) {
1110 String name = "roleNames.roleName(" + count + ")";
1111 String roleName = (String) iter.next();
1112 registry.setString(prefix + name, roleName);