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.redback.components.registry.Registry;
28 // Model class imports
29 import org.apache.archiva.configuration.Configuration;
30 import org.apache.archiva.configuration.AbstractRepositoryConfiguration;
31 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
32 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
33 import org.apache.archiva.configuration.LegacyArtifactPath;
34 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
35 import org.apache.archiva.configuration.RepositoryCheckPath;
36 import org.apache.archiva.configuration.AbstractRepositoryConnectorConfiguration;
37 import org.apache.archiva.configuration.ProxyConnectorRuleConfiguration;
38 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
39 import org.apache.archiva.configuration.SyncConnectorConfiguration;
40 import org.apache.archiva.configuration.NetworkProxyConfiguration;
41 import org.apache.archiva.configuration.RepositoryScanningConfiguration;
42 import org.apache.archiva.configuration.FileType;
43 import org.apache.archiva.configuration.OrganisationInformation;
44 import org.apache.archiva.configuration.WebappConfiguration;
45 import org.apache.archiva.configuration.UserInterfaceOptions;
46 import org.apache.archiva.configuration.NetworkConfiguration;
47 import org.apache.archiva.configuration.ArchivaRuntimeConfiguration;
48 import org.apache.archiva.configuration.RedbackRuntimeConfiguration;
49 import org.apache.archiva.configuration.ArchivaDefaultConfiguration;
50 import org.apache.archiva.configuration.LdapConfiguration;
51 import org.apache.archiva.configuration.FileLockConfiguration;
52 import org.apache.archiva.configuration.CacheConfiguration;
53 import org.apache.archiva.configuration.LdapGroupMapping;
59 * Generate Plexus Registry output mechanism for model 'Configuration'.
61 public class ConfigurationRegistryWriter
63 public void write( Configuration model, Registry registry )
65 writeConfiguration( "", model, registry );
68 private void writeConfiguration( String prefix, Configuration value, Registry registry )
72 if ( value.getVersion() != null
75 String version = "version";
76 registry.setString( prefix + version, value.getVersion() );
78 if ( value.getMetadataStore() != null && !value.getMetadataStore().equals( "jcr" )
81 String metadataStore = "metadataStore";
82 registry.setString( prefix + metadataStore, value.getMetadataStore() );
84 if ( value.getRepositoryGroups() != null && value.getRepositoryGroups().size() > 0
87 registry.removeSubset( prefix + "repositoryGroups" );
90 for ( Iterator iter = value.getRepositoryGroups().iterator(); iter.hasNext(); count++ )
92 String name = "repositoryGroups.repositoryGroup(" + count + ")";
93 RepositoryGroupConfiguration o = ( RepositoryGroupConfiguration ) iter.next();
94 writeRepositoryGroupConfiguration( prefix + name + ".", o, registry );
97 if ( value.getManagedRepositories() != null && value.getManagedRepositories().size() > 0
100 registry.removeSubset( prefix + "managedRepositories" );
103 for ( Iterator iter = value.getManagedRepositories().iterator(); iter.hasNext(); count++ )
105 String name = "managedRepositories.managedRepository(" + count + ")";
106 ManagedRepositoryConfiguration o = ( ManagedRepositoryConfiguration ) iter.next();
107 writeManagedRepositoryConfiguration( prefix + name + ".", o, registry );
110 if ( value.getRemoteRepositories() != null && value.getRemoteRepositories().size() > 0
113 registry.removeSubset( prefix + "remoteRepositories" );
116 for ( Iterator iter = value.getRemoteRepositories().iterator(); iter.hasNext(); count++ )
118 String name = "remoteRepositories.remoteRepository(" + count + ")";
119 RemoteRepositoryConfiguration o = ( RemoteRepositoryConfiguration ) iter.next();
120 writeRemoteRepositoryConfiguration( prefix + name + ".", o, registry );
123 if ( value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
126 registry.removeSubset( prefix + "proxyConnectors" );
129 for ( Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++ )
131 String name = "proxyConnectors.proxyConnector(" + count + ")";
132 ProxyConnectorConfiguration o = ( ProxyConnectorConfiguration ) iter.next();
133 writeProxyConnectorConfiguration( prefix + name + ".", o, registry );
136 if ( value.getNetworkProxies() != null && value.getNetworkProxies().size() > 0
139 registry.removeSubset( prefix + "networkProxies" );
142 for ( Iterator iter = value.getNetworkProxies().iterator(); iter.hasNext(); count++ )
144 String name = "networkProxies.networkProxy(" + count + ")";
145 NetworkProxyConfiguration o = ( NetworkProxyConfiguration ) iter.next();
146 writeNetworkProxyConfiguration( prefix + name + ".", o, registry );
149 if ( value.getLegacyArtifactPaths() != null && value.getLegacyArtifactPaths().size() > 0
152 registry.removeSubset( prefix + "legacyArtifactPaths" );
155 for ( Iterator iter = value.getLegacyArtifactPaths().iterator(); iter.hasNext(); count++ )
157 String name = "legacyArtifactPaths.legacyArtifactPath(" + count + ")";
158 LegacyArtifactPath o = ( LegacyArtifactPath ) iter.next();
159 writeLegacyArtifactPath( prefix + name + ".", o, registry );
162 if ( value.getRepositoryScanning() != null
165 writeRepositoryScanningConfiguration( prefix + "repositoryScanning.", value.getRepositoryScanning(), registry );
167 if ( value.getWebapp() != null
170 writeWebappConfiguration( prefix + "webapp.", value.getWebapp(), registry );
172 if ( value.getOrganisationInfo() != null
175 writeOrganisationInformation( prefix + "organisationInfo.", value.getOrganisationInfo(), registry );
177 if ( value.getNetworkConfiguration() != null
180 writeNetworkConfiguration( prefix + "networkConfiguration.", value.getNetworkConfiguration(), registry );
182 if ( value.getRedbackRuntimeConfiguration() != null
185 writeRedbackRuntimeConfiguration( prefix + "redbackRuntimeConfiguration.", value.getRedbackRuntimeConfiguration(), registry );
187 if ( value.getArchivaRuntimeConfiguration() != null
190 writeArchivaRuntimeConfiguration( prefix + "archivaRuntimeConfiguration.", value.getArchivaRuntimeConfiguration(), registry );
192 if ( value.getProxyConnectorRuleConfigurations() != null && value.getProxyConnectorRuleConfigurations().size() > 0
195 registry.removeSubset( prefix + "proxyConnectorRuleConfigurations" );
198 for ( Iterator iter = value.getProxyConnectorRuleConfigurations().iterator(); iter.hasNext(); count++ )
200 String name = "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration(" + count + ")";
201 ProxyConnectorRuleConfiguration o = ( ProxyConnectorRuleConfiguration ) iter.next();
202 writeProxyConnectorRuleConfiguration( prefix + name + ".", o, registry );
205 if ( value.getArchivaDefaultConfiguration() != null
208 writeArchivaDefaultConfiguration( prefix + "archivaDefaultConfiguration.", value.getArchivaDefaultConfiguration(), registry );
213 private void writeAbstractRepositoryConfiguration( String prefix, AbstractRepositoryConfiguration value, Registry registry )
217 if ( value.getId() != null
221 registry.setString( prefix + id, value.getId() );
223 if ( value.getType() != null && !value.getType().equals( "MAVEN" )
226 String type = "type";
227 registry.setString( prefix + type, value.getType() );
229 if ( value.getName() != null
232 String name = "name";
233 registry.setString( prefix + name, value.getName() );
235 if ( value.getLayout() != null && !value.getLayout().equals( "default" )
238 String layout = "layout";
239 registry.setString( prefix + layout, value.getLayout() );
241 if ( value.getIndexDir() != null && !value.getIndexDir().equals( "" )
244 String indexDir = "indexDir";
245 registry.setString( prefix + indexDir, value.getIndexDir() );
247 if ( value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals( "" )
250 String packedIndexDir = "packedIndexDir";
251 registry.setString( prefix + packedIndexDir, value.getPackedIndexDir() );
253 if ( value.getDescription() != null && !value.getDescription().equals( "" )
256 String description = "description";
257 registry.setString( prefix + description, value.getDescription() );
262 private void writeRemoteRepositoryConfiguration( String prefix, RemoteRepositoryConfiguration value, Registry registry )
266 if ( value.getUrl() != null
270 registry.setString( prefix + url, value.getUrl() );
272 if ( value.getUsername() != null
275 String username = "username";
276 registry.setString( prefix + username, value.getUsername() );
278 if ( value.getPassword() != null
281 String password = "password";
282 registry.setString( prefix + password, value.getPassword() );
284 if ( value.getTimeout() != 60
287 String timeout = "timeout";
288 registry.setInt( prefix + timeout, value.getTimeout() );
290 if ( value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals( "0 0 08 ? * SUN" )
293 String refreshCronExpression = "refreshCronExpression";
294 registry.setString( prefix + refreshCronExpression, value.getRefreshCronExpression() );
296 String downloadRemoteIndex = "downloadRemoteIndex";
297 registry.setBoolean( prefix + downloadRemoteIndex, value.isDownloadRemoteIndex() );
298 if ( value.getRemoteIndexUrl() != null
301 String remoteIndexUrl = "remoteIndexUrl";
302 registry.setString( prefix + remoteIndexUrl, value.getRemoteIndexUrl() );
304 if ( value.getRemoteDownloadNetworkProxyId() != null
307 String remoteDownloadNetworkProxyId = "remoteDownloadNetworkProxyId";
308 registry.setString( prefix + remoteDownloadNetworkProxyId, value.getRemoteDownloadNetworkProxyId() );
310 if ( value.getRemoteDownloadTimeout() != 300
313 String remoteDownloadTimeout = "remoteDownloadTimeout";
314 registry.setInt( prefix + remoteDownloadTimeout, value.getRemoteDownloadTimeout() );
316 String downloadRemoteIndexOnStartup = "downloadRemoteIndexOnStartup";
317 registry.setBoolean( prefix + downloadRemoteIndexOnStartup, value.isDownloadRemoteIndexOnStartup() );
318 if ( value.getExtraParameters() != null && value.getExtraParameters().size() > 0
321 registry.removeSubset( prefix + "extraParameters" );
323 for ( Iterator iter = value.getExtraParameters().keySet().iterator(); iter.hasNext(); )
325 String key = (String) iter.next();
326 String v = (String) value.getExtraParameters().get( key );
328 registry.setString( prefix + "extraParameters." + key, v );
331 if ( value.getExtraHeaders() != null && value.getExtraHeaders().size() > 0
334 registry.removeSubset( prefix + "extraHeaders" );
336 for ( Iterator iter = value.getExtraHeaders().keySet().iterator(); iter.hasNext(); )
338 String key = (String) iter.next();
339 String v = (String) value.getExtraHeaders().get( key );
341 registry.setString( prefix + "extraHeaders." + key, v );
344 if ( value.getCheckPath() != null
347 String checkPath = "checkPath";
348 registry.setString( prefix + checkPath, value.getCheckPath() );
350 if ( value.getId() != null
354 registry.setString( prefix + id, value.getId() );
356 if ( value.getType() != null && !value.getType().equals( "MAVEN" )
359 String type = "type";
360 registry.setString( prefix + type, value.getType() );
362 if ( value.getName() != null
365 String name = "name";
366 registry.setString( prefix + name, value.getName() );
368 if ( value.getLayout() != null && !value.getLayout().equals( "default" )
371 String layout = "layout";
372 registry.setString( prefix + layout, value.getLayout() );
374 if ( value.getIndexDir() != null && !value.getIndexDir().equals( "" )
377 String indexDir = "indexDir";
378 registry.setString( prefix + indexDir, value.getIndexDir() );
380 if ( value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals( "" )
383 String packedIndexDir = "packedIndexDir";
384 registry.setString( prefix + packedIndexDir, value.getPackedIndexDir() );
386 if ( value.getDescription() != null && !value.getDescription().equals( "" )
389 String description = "description";
390 registry.setString( prefix + description, value.getDescription() );
395 private void writeManagedRepositoryConfiguration( String prefix, ManagedRepositoryConfiguration value, Registry registry )
399 if ( value.getLocation() != null
402 String location = "location";
403 registry.setString( prefix + location, value.getLocation() );
405 String releases = "releases";
406 registry.setBoolean( prefix + releases, value.isReleases() );
407 String blockRedeployments = "blockRedeployments";
408 registry.setBoolean( prefix + blockRedeployments, value.isBlockRedeployments() );
409 String snapshots = "snapshots";
410 registry.setBoolean( prefix + snapshots, value.isSnapshots() );
411 String scanned = "scanned";
412 registry.setBoolean( prefix + scanned, value.isScanned() );
413 if ( value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals( "0 0 * * * ?" )
416 String refreshCronExpression = "refreshCronExpression";
417 registry.setString( prefix + refreshCronExpression, value.getRefreshCronExpression() );
419 if ( value.getRetentionCount() != 2
422 String retentionCount = "retentionCount";
423 registry.setInt( prefix + retentionCount, value.getRetentionCount() );
425 if ( value.getRetentionPeriod() != 100
428 String retentionPeriod = "retentionPeriod";
429 registry.setInt( prefix + retentionPeriod, value.getRetentionPeriod() );
431 String deleteReleasedSnapshots = "deleteReleasedSnapshots";
432 registry.setBoolean( prefix + deleteReleasedSnapshots, value.isDeleteReleasedSnapshots() );
433 String skipPackedIndexCreation = "skipPackedIndexCreation";
434 registry.setBoolean( prefix + skipPackedIndexCreation, value.isSkipPackedIndexCreation() );
435 String stageRepoNeeded = "stageRepoNeeded";
436 registry.setBoolean( prefix + stageRepoNeeded, value.isStageRepoNeeded() );
437 if ( value.getId() != null
441 registry.setString( prefix + id, value.getId() );
443 if ( value.getType() != null && !value.getType().equals( "MAVEN" )
446 String type = "type";
447 registry.setString( prefix + type, value.getType() );
449 if ( value.getName() != null
452 String name = "name";
453 registry.setString( prefix + name, value.getName() );
455 if ( value.getLayout() != null && !value.getLayout().equals( "default" )
458 String layout = "layout";
459 registry.setString( prefix + layout, value.getLayout() );
461 if ( value.getIndexDir() != null && !value.getIndexDir().equals( "" )
464 String indexDir = "indexDir";
465 registry.setString( prefix + indexDir, value.getIndexDir() );
467 if ( value.getPackedIndexDir() != null && !value.getPackedIndexDir().equals( "" )
470 String packedIndexDir = "packedIndexDir";
471 registry.setString( prefix + packedIndexDir, value.getPackedIndexDir() );
473 if ( value.getDescription() != null && !value.getDescription().equals( "" )
476 String description = "description";
477 registry.setString( prefix + description, value.getDescription() );
482 private void writeLegacyArtifactPath( String prefix, LegacyArtifactPath value, Registry registry )
486 if ( value.getPath() != null
489 String path = "path";
490 registry.setString( prefix + path, value.getPath() );
492 if ( value.getArtifact() != null
495 String artifact = "artifact";
496 registry.setString( prefix + artifact, value.getArtifact() );
501 private void writeRepositoryGroupConfiguration( String prefix, RepositoryGroupConfiguration value, Registry registry )
505 if ( value.getId() != null
509 registry.setString( prefix + id, value.getId() );
511 if ( value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals( ".indexer" )
514 String mergedIndexPath = "mergedIndexPath";
515 registry.setString( prefix + mergedIndexPath, value.getMergedIndexPath() );
517 if ( value.getMergedIndexTtl() != 30
520 String mergedIndexTtl = "mergedIndexTtl";
521 registry.setInt( prefix + mergedIndexTtl, value.getMergedIndexTtl() );
523 if ( value.getCronExpression() != null && !value.getCronExpression().equals( "" )
526 String cronExpression = "cronExpression";
527 registry.setString( prefix + cronExpression, value.getCronExpression() );
529 if ( value.getRepositories() != null && value.getRepositories().size() > 0
532 registry.removeSubset( prefix + "repositories" );
535 for ( Iterator iter = value.getRepositories().iterator(); iter.hasNext(); count++ )
537 String name = "repositories.repository(" + count + ")";
538 String repository = ( String ) iter.next();
539 registry.setString( prefix + name, repository );
545 private void writeRepositoryCheckPath( String prefix, RepositoryCheckPath value, Registry registry )
549 if ( value.getUrl() != null
553 registry.setString( prefix + url, value.getUrl() );
555 if ( value.getPath() != null
558 String path = "path";
559 registry.setString( prefix + path, value.getPath() );
564 private void writeAbstractRepositoryConnectorConfiguration( String prefix, AbstractRepositoryConnectorConfiguration value, Registry registry )
568 if ( value.getSourceRepoId() != null
571 String sourceRepoId = "sourceRepoId";
572 registry.setString( prefix + sourceRepoId, value.getSourceRepoId() );
574 if ( value.getTargetRepoId() != null
577 String targetRepoId = "targetRepoId";
578 registry.setString( prefix + targetRepoId, value.getTargetRepoId() );
580 if ( value.getProxyId() != null
583 String proxyId = "proxyId";
584 registry.setString( prefix + proxyId, value.getProxyId() );
586 if ( value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
589 registry.removeSubset( prefix + "blackListPatterns" );
592 for ( Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++ )
594 String name = "blackListPatterns.blackListPattern(" + count + ")";
595 String blackListPattern = ( String ) iter.next();
596 registry.setString( prefix + name, blackListPattern );
599 if ( value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
602 registry.removeSubset( prefix + "whiteListPatterns" );
605 for ( Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++ )
607 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
608 String whiteListPattern = ( String ) iter.next();
609 registry.setString( prefix + name, whiteListPattern );
612 if ( value.getPolicies() != null && value.getPolicies().size() > 0
615 registry.removeSubset( prefix + "policies" );
617 for ( Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); )
619 String key = (String) iter.next();
620 String v = (String) value.getPolicies().get( key );
622 registry.setString( prefix + "policies." + key, v );
625 if ( value.getProperties() != null && value.getProperties().size() > 0
628 registry.removeSubset( prefix + "properties" );
630 for ( Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); )
632 String key = (String) iter.next();
633 String v = (String) value.getProperties().get( key );
635 registry.setString( prefix + "properties." + key, v );
638 String disabled = "disabled";
639 registry.setBoolean( prefix + disabled, value.isDisabled() );
643 private void writeProxyConnectorRuleConfiguration( String prefix, ProxyConnectorRuleConfiguration value, Registry registry )
647 if ( value.getRuleType() != null
650 String ruleType = "ruleType";
651 registry.setString( prefix + ruleType, value.getRuleType() );
653 if ( value.getPattern() != null
656 String pattern = "pattern";
657 registry.setString( prefix + pattern, value.getPattern() );
659 if ( value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
662 registry.removeSubset( prefix + "proxyConnectors" );
665 for ( Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++ )
667 String name = "proxyConnectors.proxyConnector(" + count + ")";
668 ProxyConnectorConfiguration o = ( ProxyConnectorConfiguration ) iter.next();
669 writeProxyConnectorConfiguration( prefix + name + ".", o, registry );
675 private void writeProxyConnectorConfiguration( String prefix, ProxyConnectorConfiguration value, Registry registry )
679 if ( value.getOrder() != 0
682 String order = "order";
683 registry.setInt( prefix + order, value.getOrder() );
685 if ( value.getSourceRepoId() != null
688 String sourceRepoId = "sourceRepoId";
689 registry.setString( prefix + sourceRepoId, value.getSourceRepoId() );
691 if ( value.getTargetRepoId() != null
694 String targetRepoId = "targetRepoId";
695 registry.setString( prefix + targetRepoId, value.getTargetRepoId() );
697 if ( value.getProxyId() != null
700 String proxyId = "proxyId";
701 registry.setString( prefix + proxyId, value.getProxyId() );
703 if ( value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
706 registry.removeSubset( prefix + "blackListPatterns" );
709 for ( Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++ )
711 String name = "blackListPatterns.blackListPattern(" + count + ")";
712 String blackListPattern = ( String ) iter.next();
713 registry.setString( prefix + name, blackListPattern );
716 if ( value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
719 registry.removeSubset( prefix + "whiteListPatterns" );
722 for ( Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++ )
724 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
725 String whiteListPattern = ( String ) iter.next();
726 registry.setString( prefix + name, whiteListPattern );
729 if ( value.getPolicies() != null && value.getPolicies().size() > 0
732 registry.removeSubset( prefix + "policies" );
734 for ( Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); )
736 String key = (String) iter.next();
737 String v = (String) value.getPolicies().get( key );
739 registry.setString( prefix + "policies." + key, v );
742 if ( value.getProperties() != null && value.getProperties().size() > 0
745 registry.removeSubset( prefix + "properties" );
747 for ( Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); )
749 String key = (String) iter.next();
750 String v = (String) value.getProperties().get( key );
752 registry.setString( prefix + "properties." + key, v );
755 String disabled = "disabled";
756 registry.setBoolean( prefix + disabled, value.isDisabled() );
760 private void writeSyncConnectorConfiguration( String prefix, SyncConnectorConfiguration value, Registry registry )
764 if ( value.getCronExpression() != null && !value.getCronExpression().equals( "0 0 * * * ?" )
767 String cronExpression = "cronExpression";
768 registry.setString( prefix + cronExpression, value.getCronExpression() );
770 if ( value.getMethod() != null && !value.getMethod().equals( "rsync" )
773 String method = "method";
774 registry.setString( prefix + method, value.getMethod() );
776 if ( value.getSourceRepoId() != null
779 String sourceRepoId = "sourceRepoId";
780 registry.setString( prefix + sourceRepoId, value.getSourceRepoId() );
782 if ( value.getTargetRepoId() != null
785 String targetRepoId = "targetRepoId";
786 registry.setString( prefix + targetRepoId, value.getTargetRepoId() );
788 if ( value.getProxyId() != null
791 String proxyId = "proxyId";
792 registry.setString( prefix + proxyId, value.getProxyId() );
794 if ( value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
797 registry.removeSubset( prefix + "blackListPatterns" );
800 for ( Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++ )
802 String name = "blackListPatterns.blackListPattern(" + count + ")";
803 String blackListPattern = ( String ) iter.next();
804 registry.setString( prefix + name, blackListPattern );
807 if ( value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
810 registry.removeSubset( prefix + "whiteListPatterns" );
813 for ( Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++ )
815 String name = "whiteListPatterns.whiteListPattern(" + count + ")";
816 String whiteListPattern = ( String ) iter.next();
817 registry.setString( prefix + name, whiteListPattern );
820 if ( value.getPolicies() != null && value.getPolicies().size() > 0
823 registry.removeSubset( prefix + "policies" );
825 for ( Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); )
827 String key = (String) iter.next();
828 String v = (String) value.getPolicies().get( key );
830 registry.setString( prefix + "policies." + key, v );
833 if ( value.getProperties() != null && value.getProperties().size() > 0
836 registry.removeSubset( prefix + "properties" );
838 for ( Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); )
840 String key = (String) iter.next();
841 String v = (String) value.getProperties().get( key );
843 registry.setString( prefix + "properties." + key, v );
846 String disabled = "disabled";
847 registry.setBoolean( prefix + disabled, value.isDisabled() );
851 private void writeNetworkProxyConfiguration( String prefix, NetworkProxyConfiguration value, Registry registry )
855 if ( value.getId() != null
859 registry.setString( prefix + id, value.getId() );
861 if ( value.getProtocol() != null && !value.getProtocol().equals( "http" )
864 String protocol = "protocol";
865 registry.setString( prefix + protocol, value.getProtocol() );
867 if ( value.getHost() != null
870 String host = "host";
871 registry.setString( prefix + host, value.getHost() );
873 if ( value.getPort() != 8080
876 String port = "port";
877 registry.setInt( prefix + port, value.getPort() );
879 if ( value.getUsername() != null
882 String username = "username";
883 registry.setString( prefix + username, value.getUsername() );
885 if ( value.getPassword() != null
888 String password = "password";
889 registry.setString( prefix + password, value.getPassword() );
891 String useNtlm = "useNtlm";
892 registry.setBoolean( prefix + useNtlm, value.isUseNtlm() );
896 private void writeRepositoryScanningConfiguration( String prefix, RepositoryScanningConfiguration value, Registry registry )
900 if ( value.getFileTypes() != null && value.getFileTypes().size() > 0
903 registry.removeSubset( prefix + "fileTypes" );
906 for ( Iterator iter = value.getFileTypes().iterator(); iter.hasNext(); count++ )
908 String name = "fileTypes.fileType(" + count + ")";
909 FileType o = ( FileType ) iter.next();
910 writeFileType( prefix + name + ".", o, registry );
913 if ( value.getKnownContentConsumers() != null && value.getKnownContentConsumers().size() > 0
916 registry.removeSubset( prefix + "knownContentConsumers" );
919 for ( Iterator iter = value.getKnownContentConsumers().iterator(); iter.hasNext(); count++ )
921 String name = "knownContentConsumers.knownContentConsumer(" + count + ")";
922 String knownContentConsumer = ( String ) iter.next();
923 registry.setString( prefix + name, knownContentConsumer );
926 if ( value.getInvalidContentConsumers() != null && value.getInvalidContentConsumers().size() > 0
929 registry.removeSubset( prefix + "invalidContentConsumers" );
932 for ( Iterator iter = value.getInvalidContentConsumers().iterator(); iter.hasNext(); count++ )
934 String name = "invalidContentConsumers.invalidContentConsumer(" + count + ")";
935 String invalidContentConsumer = ( String ) iter.next();
936 registry.setString( prefix + name, invalidContentConsumer );
942 private void writeFileType( String prefix, FileType value, Registry registry )
946 if ( value.getId() != null
950 registry.setString( prefix + id, value.getId() );
952 if ( value.getPatterns() != null && value.getPatterns().size() > 0
955 registry.removeSubset( prefix + "patterns" );
958 for ( Iterator iter = value.getPatterns().iterator(); iter.hasNext(); count++ )
960 String name = "patterns.pattern(" + count + ")";
961 String pattern = ( String ) iter.next();
962 registry.setString( prefix + name, pattern );
968 private void writeOrganisationInformation( String prefix, OrganisationInformation value, Registry registry )
972 if ( value.getName() != null
975 String name = "name";
976 registry.setString( prefix + name, value.getName() );
978 if ( value.getUrl() != null
982 registry.setString( prefix + url, value.getUrl() );
984 if ( value.getLogoLocation() != null
987 String logoLocation = "logoLocation";
988 registry.setString( prefix + logoLocation, value.getLogoLocation() );
993 private void writeWebappConfiguration( String prefix, WebappConfiguration value, Registry registry )
997 if ( value.getUi() != null
1000 writeUserInterfaceOptions( prefix + "ui.", value.getUi(), registry );
1005 private void writeUserInterfaceOptions( String prefix, UserInterfaceOptions value, Registry registry )
1007 if ( value != null )
1009 String showFindArtifacts = "showFindArtifacts";
1010 registry.setBoolean( prefix + showFindArtifacts, value.isShowFindArtifacts() );
1011 String appletFindEnabled = "appletFindEnabled";
1012 registry.setBoolean( prefix + appletFindEnabled, value.isAppletFindEnabled() );
1013 String disableEasterEggs = "disableEasterEggs";
1014 registry.setBoolean( prefix + disableEasterEggs, value.isDisableEasterEggs() );
1015 if ( value.getApplicationUrl() != null
1018 String applicationUrl = "applicationUrl";
1019 registry.setString( prefix + applicationUrl, value.getApplicationUrl() );
1021 String disableRegistration = "disableRegistration";
1022 registry.setBoolean( prefix + disableRegistration, value.isDisableRegistration() );
1026 private void writeNetworkConfiguration( String prefix, NetworkConfiguration value, Registry registry )
1028 if ( value != null )
1030 if ( value.getMaxTotal() != 30
1033 String maxTotal = "maxTotal";
1034 registry.setInt( prefix + maxTotal, value.getMaxTotal() );
1036 if ( value.getMaxTotalPerHost() != 30
1039 String maxTotalPerHost = "maxTotalPerHost";
1040 registry.setInt( prefix + maxTotalPerHost, value.getMaxTotalPerHost() );
1042 String usePooling = "usePooling";
1043 registry.setBoolean( prefix + usePooling, value.isUsePooling() );
1047 private void writeArchivaRuntimeConfiguration( String prefix, ArchivaRuntimeConfiguration value, Registry registry )
1049 if ( value != null )
1051 if ( value.getUrlFailureCacheConfiguration() != null
1054 writeCacheConfiguration( prefix + "urlFailureCacheConfiguration.", value.getUrlFailureCacheConfiguration(), registry );
1056 if ( value.getFileLockConfiguration() != null
1059 writeFileLockConfiguration( prefix + "fileLockConfiguration.", value.getFileLockConfiguration(), registry );
1061 if ( value.getDataDirectory() != null
1064 String dataDirectory = "dataDirectory";
1065 registry.setString( prefix + dataDirectory, value.getDataDirectory() );
1067 if ( value.getRepositoryBaseDirectory() != null
1070 String repositoryBaseDirectory = "repositoryBaseDirectory";
1071 registry.setString( prefix + repositoryBaseDirectory, value.getRepositoryBaseDirectory() );
1073 if ( value.getRemoteRepositoryBaseDirectory() != null
1076 String remoteRepositoryBaseDirectory = "remoteRepositoryBaseDirectory";
1077 registry.setString( prefix + remoteRepositoryBaseDirectory, value.getRemoteRepositoryBaseDirectory() );
1079 if ( value.getDefaultLanguage() != null && !value.getDefaultLanguage().equals( "en-US" )
1082 String defaultLanguage = "defaultLanguage";
1083 registry.setString( prefix + defaultLanguage, value.getDefaultLanguage() );
1085 if ( value.getLanguageRange() != null && !value.getLanguageRange().equals( "en,fr,de" )
1088 String languageRange = "languageRange";
1089 registry.setString( prefix + languageRange, value.getLanguageRange() );
1094 private void writeRedbackRuntimeConfiguration( String prefix, RedbackRuntimeConfiguration value, Registry registry )
1096 if ( value != null )
1098 String migratedFromRedbackConfiguration = "migratedFromRedbackConfiguration";
1099 registry.setBoolean( prefix + migratedFromRedbackConfiguration, value.isMigratedFromRedbackConfiguration() );
1100 if ( value.getUserManagerImpls() != null && value.getUserManagerImpls().size() > 0
1103 registry.removeSubset( prefix + "userManagerImpls" );
1106 for ( Iterator iter = value.getUserManagerImpls().iterator(); iter.hasNext(); count++ )
1108 String name = "userManagerImpls.userManagerImpl(" + count + ")";
1109 String userManagerImpl = ( String ) iter.next();
1110 registry.setString( prefix + name, userManagerImpl );
1113 if ( value.getRbacManagerImpls() != null && value.getRbacManagerImpls().size() > 0
1116 registry.removeSubset( prefix + "rbacManagerImpls" );
1119 for ( Iterator iter = value.getRbacManagerImpls().iterator(); iter.hasNext(); count++ )
1121 String name = "rbacManagerImpls.rbacManagerImpl(" + count + ")";
1122 String rbacManagerImpl = ( String ) iter.next();
1123 registry.setString( prefix + name, rbacManagerImpl );
1126 if ( value.getLdapConfiguration() != null
1129 writeLdapConfiguration( prefix + "ldapConfiguration.", value.getLdapConfiguration(), registry );
1131 if ( value.getLdapGroupMappings() != null && value.getLdapGroupMappings().size() > 0
1134 registry.removeSubset( prefix + "ldapGroupMappings" );
1137 for ( Iterator iter = value.getLdapGroupMappings().iterator(); iter.hasNext(); count++ )
1139 String name = "ldapGroupMappings.ldapGroupMapping(" + count + ")";
1140 LdapGroupMapping o = ( LdapGroupMapping ) iter.next();
1141 writeLdapGroupMapping( prefix + name + ".", o, registry );
1144 if ( value.getConfigurationProperties() != null && value.getConfigurationProperties().size() > 0
1147 registry.removeSubset( prefix + "configurationProperties" );
1149 for ( Iterator iter = value.getConfigurationProperties().keySet().iterator(); iter.hasNext(); )
1151 String key = (String) iter.next();
1152 String v = (String) value.getConfigurationProperties().get( key );
1154 registry.setString( prefix + "configurationProperties." + key, v );
1157 String useUsersCache = "useUsersCache";
1158 registry.setBoolean( prefix + useUsersCache, value.isUseUsersCache() );
1159 if ( value.getUsersCacheConfiguration() != null
1162 writeCacheConfiguration( prefix + "usersCacheConfiguration.", value.getUsersCacheConfiguration(), registry );
1167 private void writeArchivaDefaultConfiguration( String prefix, ArchivaDefaultConfiguration value, Registry registry )
1169 if ( value != null )
1171 if ( value.getDefaultCheckPaths() != null && value.getDefaultCheckPaths().size() > 0
1174 registry.removeSubset( prefix + "defaultCheckPaths" );
1177 for ( Iterator iter = value.getDefaultCheckPaths().iterator(); iter.hasNext(); count++ )
1179 String name = "defaultCheckPaths.defaultCheckPath(" + count + ")";
1180 RepositoryCheckPath o = ( RepositoryCheckPath ) iter.next();
1181 writeRepositoryCheckPath( prefix + name + ".", o, registry );
1187 private void writeLdapConfiguration( String prefix, LdapConfiguration value, Registry registry )
1189 if ( value != null )
1191 if ( value.getHostName() != null
1194 String hostName = "hostName";
1195 registry.setString( prefix + hostName, value.getHostName() );
1197 if ( value.getPort() != 0
1200 String port = "port";
1201 registry.setInt( prefix + port, value.getPort() );
1204 registry.setBoolean( prefix + ssl, value.isSsl() );
1205 if ( value.getBaseDn() != null
1208 String baseDn = "baseDn";
1209 registry.setString( prefix + baseDn, value.getBaseDn() );
1211 if ( value.getBaseGroupsDn() != null
1214 String baseGroupsDn = "baseGroupsDn";
1215 registry.setString( prefix + baseGroupsDn, value.getBaseGroupsDn() );
1217 if ( value.getContextFactory() != null
1220 String contextFactory = "contextFactory";
1221 registry.setString( prefix + contextFactory, value.getContextFactory() );
1223 if ( value.getBindDn() != null
1226 String bindDn = "bindDn";
1227 registry.setString( prefix + bindDn, value.getBindDn() );
1229 if ( value.getPassword() != null
1232 String password = "password";
1233 registry.setString( prefix + password, value.getPassword() );
1235 if ( value.getAuthenticationMethod() != null
1238 String authenticationMethod = "authenticationMethod";
1239 registry.setString( prefix + authenticationMethod, value.getAuthenticationMethod() );
1241 String bindAuthenticatorEnabled = "bindAuthenticatorEnabled";
1242 registry.setBoolean( prefix + bindAuthenticatorEnabled, value.isBindAuthenticatorEnabled() );
1243 String writable = "writable";
1244 registry.setBoolean( prefix + writable, value.isWritable() );
1245 String useRoleNameAsGroup = "useRoleNameAsGroup";
1246 registry.setBoolean( prefix + useRoleNameAsGroup, value.isUseRoleNameAsGroup() );
1247 if ( value.getExtraProperties() != null && value.getExtraProperties().size() > 0
1250 registry.removeSubset( prefix + "extraProperties" );
1252 for ( Iterator iter = value.getExtraProperties().keySet().iterator(); iter.hasNext(); )
1254 String key = (String) iter.next();
1255 String v = (String) value.getExtraProperties().get( key );
1257 registry.setString( prefix + "extraProperties." + key, v );
1263 private void writeFileLockConfiguration( String prefix, FileLockConfiguration value, Registry registry )
1265 if ( value != null )
1267 String skipLocking = "skipLocking";
1268 registry.setBoolean( prefix + skipLocking, value.isSkipLocking() );
1269 if ( value.getLockingTimeout() != 0
1272 String lockingTimeout = "lockingTimeout";
1273 registry.setInt( prefix + lockingTimeout, value.getLockingTimeout() );
1278 private void writeCacheConfiguration( String prefix, CacheConfiguration value, Registry registry )
1280 if ( value != null )
1282 if ( value.getTimeToIdleSeconds() != -1
1285 String timeToIdleSeconds = "timeToIdleSeconds";
1286 registry.setInt( prefix + timeToIdleSeconds, value.getTimeToIdleSeconds() );
1288 if ( value.getTimeToLiveSeconds() != -1
1291 String timeToLiveSeconds = "timeToLiveSeconds";
1292 registry.setInt( prefix + timeToLiveSeconds, value.getTimeToLiveSeconds() );
1294 if ( value.getMaxElementsInMemory() != -1
1297 String maxElementsInMemory = "maxElementsInMemory";
1298 registry.setInt( prefix + maxElementsInMemory, value.getMaxElementsInMemory() );
1300 if ( value.getMaxElementsOnDisk() != -1
1303 String maxElementsOnDisk = "maxElementsOnDisk";
1304 registry.setInt( prefix + maxElementsOnDisk, value.getMaxElementsOnDisk() );
1309 private void writeLdapGroupMapping( String prefix, LdapGroupMapping value, Registry registry )
1311 if ( value != null )
1313 if ( value.getGroup() != null
1316 String group = "group";
1317 registry.setString( prefix + group, value.getGroup() );
1319 if ( value.getRoleNames() != null && value.getRoleNames().size() > 0
1322 registry.removeSubset( prefix + "roleNames" );
1325 for ( Iterator iter = value.getRoleNames().iterator(); iter.hasNext(); count++ )
1327 String name = "roleNames.roleName(" + count + ")";
1328 String roleName = ( String ) iter.next();
1329 registry.setString( prefix + name, roleName );