001    
002    package org.apache.archiva.configuration.io.registry;
003    
004    import org.apache.archiva.redback.components.registry.Registry;
005    
006    // Util imports
007    import java.util.*;
008    
009    // Model class imports
010    import org.apache.archiva.configuration.Configuration;
011    import org.apache.archiva.configuration.AbstractRepositoryConfiguration;
012    import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
013    import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
014    import org.apache.archiva.configuration.V1RepositoryConfiguration;
015    import org.apache.archiva.configuration.LegacyArtifactPath;
016    import org.apache.archiva.configuration.RepositoryGroupConfiguration;
017    import org.apache.archiva.configuration.AbstractRepositoryConnectorConfiguration;
018    import org.apache.archiva.configuration.ProxyConnectorRuleConfiguration;
019    import org.apache.archiva.configuration.ProxyConnectorConfiguration;
020    import org.apache.archiva.configuration.SyncConnectorConfiguration;
021    import org.apache.archiva.configuration.NetworkProxyConfiguration;
022    import org.apache.archiva.configuration.RepositoryScanningConfiguration;
023    import org.apache.archiva.configuration.FileType;
024    import org.apache.archiva.configuration.OrganisationInformation;
025    import org.apache.archiva.configuration.WebappConfiguration;
026    import org.apache.archiva.configuration.UserInterfaceOptions;
027    import org.apache.archiva.configuration.NetworkConfiguration;
028    import org.apache.archiva.configuration.ArchivaRuntimeConfiguration;
029    import org.apache.archiva.configuration.RedbackRuntimeConfiguration;
030    import org.apache.archiva.configuration.LdapConfiguration;
031    import org.apache.archiva.configuration.CacheConfiguration;
032    import org.apache.archiva.configuration.LdapGroupMapping;
033    
034    
035    
036    
037    /**
038     * Generate Plexus Registry output mechanism for model 'Configuration'.
039     */
040    public class ConfigurationRegistryWriter
041    {
042        public void write( Configuration model, Registry registry )
043        {
044            writeConfiguration( "", model, registry );
045        }
046    
047        private void writeConfiguration( String prefix, Configuration value, Registry registry )
048        {
049            if ( value != null )
050            {
051                      if ( value.getVersion() != null
052     )
053                {
054                          String version = "version";
055                    registry.setString( prefix + version, value.getVersion() );
056                      }
057                      if ( value.getRepositories() != null && value.getRepositories().size() > 0
058     )
059                {
060                    registry.removeSubset( prefix + "repositories" );
061    
062                    int count = 0;
063                    for ( Iterator iter = value.getRepositories().iterator(); iter.hasNext(); count++ )
064                    {
065                        String name = "repositories.repository(" + count + ")";
066                        V1RepositoryConfiguration o = ( V1RepositoryConfiguration ) iter.next();
067                        writeV1RepositoryConfiguration( prefix + name + ".", o, registry );
068                    }
069                }
070                if ( value.getRepositoryGroups() != null && value.getRepositoryGroups().size() > 0
071     )
072                {
073                    registry.removeSubset( prefix + "repositoryGroups" );
074    
075                    int count = 0;
076                    for ( Iterator iter = value.getRepositoryGroups().iterator(); iter.hasNext(); count++ )
077                    {
078                        String name = "repositoryGroups.repositoryGroup(" + count + ")";
079                        RepositoryGroupConfiguration o = ( RepositoryGroupConfiguration ) iter.next();
080                        writeRepositoryGroupConfiguration( prefix + name + ".", o, registry );
081                    }
082                }
083                if ( value.getManagedRepositories() != null && value.getManagedRepositories().size() > 0
084     )
085                {
086                    registry.removeSubset( prefix + "managedRepositories" );
087    
088                    int count = 0;
089                    for ( Iterator iter = value.getManagedRepositories().iterator(); iter.hasNext(); count++ )
090                    {
091                        String name = "managedRepositories.managedRepository(" + count + ")";
092                        ManagedRepositoryConfiguration o = ( ManagedRepositoryConfiguration ) iter.next();
093                        writeManagedRepositoryConfiguration( prefix + name + ".", o, registry );
094                    }
095                }
096                if ( value.getRemoteRepositories() != null && value.getRemoteRepositories().size() > 0
097     )
098                {
099                    registry.removeSubset( prefix + "remoteRepositories" );
100    
101                    int count = 0;
102                    for ( Iterator iter = value.getRemoteRepositories().iterator(); iter.hasNext(); count++ )
103                    {
104                        String name = "remoteRepositories.remoteRepository(" + count + ")";
105                        RemoteRepositoryConfiguration o = ( RemoteRepositoryConfiguration ) iter.next();
106                        writeRemoteRepositoryConfiguration( prefix + name + ".", o, registry );
107                    }
108                }
109                if ( value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
110     )
111                {
112                    registry.removeSubset( prefix + "proxyConnectors" );
113    
114                    int count = 0;
115                    for ( Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++ )
116                    {
117                        String name = "proxyConnectors.proxyConnector(" + count + ")";
118                        ProxyConnectorConfiguration o = ( ProxyConnectorConfiguration ) iter.next();
119                        writeProxyConnectorConfiguration( prefix + name + ".", o, registry );
120                    }
121                }
122                if ( value.getNetworkProxies() != null && value.getNetworkProxies().size() > 0
123     )
124                {
125                    registry.removeSubset( prefix + "networkProxies" );
126    
127                    int count = 0;
128                    for ( Iterator iter = value.getNetworkProxies().iterator(); iter.hasNext(); count++ )
129                    {
130                        String name = "networkProxies.networkProxy(" + count + ")";
131                        NetworkProxyConfiguration o = ( NetworkProxyConfiguration ) iter.next();
132                        writeNetworkProxyConfiguration( prefix + name + ".", o, registry );
133                    }
134                }
135                if ( value.getLegacyArtifactPaths() != null && value.getLegacyArtifactPaths().size() > 0
136     )
137                {
138                    registry.removeSubset( prefix + "legacyArtifactPaths" );
139    
140                    int count = 0;
141                    for ( Iterator iter = value.getLegacyArtifactPaths().iterator(); iter.hasNext(); count++ )
142                    {
143                        String name = "legacyArtifactPaths.legacyArtifactPath(" + count + ")";
144                        LegacyArtifactPath o = ( LegacyArtifactPath ) iter.next();
145                        writeLegacyArtifactPath( prefix + name + ".", o, registry );
146                    }
147                }
148                if ( value.getRepositoryScanning() != null
149     )
150                {
151                    writeRepositoryScanningConfiguration( prefix + "repositoryScanning.", value.getRepositoryScanning(), registry );
152                }
153                if ( value.getWebapp() != null
154     )
155                {
156                    writeWebappConfiguration( prefix + "webapp.", value.getWebapp(), registry );
157                }
158                if ( value.getOrganisationInfo() != null
159     )
160                {
161                    writeOrganisationInformation( prefix + "organisationInfo.", value.getOrganisationInfo(), registry );
162                }
163                if ( value.getNetworkConfiguration() != null
164     )
165                {
166                    writeNetworkConfiguration( prefix + "networkConfiguration.", value.getNetworkConfiguration(), registry );
167                }
168                if ( value.getRedbackRuntimeConfiguration() != null
169     )
170                {
171                    writeRedbackRuntimeConfiguration( prefix + "redbackRuntimeConfiguration.", value.getRedbackRuntimeConfiguration(), registry );
172                }
173                if ( value.getArchivaRuntimeConfiguration() != null
174     )
175                {
176                    writeArchivaRuntimeConfiguration( prefix + "archivaRuntimeConfiguration.", value.getArchivaRuntimeConfiguration(), registry );
177                }
178                if ( value.getProxyConnectorRuleConfigurations() != null && value.getProxyConnectorRuleConfigurations().size() > 0
179     )
180                {
181                    registry.removeSubset( prefix + "proxyConnectorRuleConfigurations" );
182    
183                    int count = 0;
184                    for ( Iterator iter = value.getProxyConnectorRuleConfigurations().iterator(); iter.hasNext(); count++ )
185                    {
186                        String name = "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration(" + count + ")";
187                        ProxyConnectorRuleConfiguration o = ( ProxyConnectorRuleConfiguration ) iter.next();
188                        writeProxyConnectorRuleConfiguration( prefix + name + ".", o, registry );
189                    }
190                }
191            }
192        }
193        
194        private void writeAbstractRepositoryConfiguration( String prefix, AbstractRepositoryConfiguration value, Registry registry )
195        {
196            if ( value != null )
197            {
198                      if ( value.getId() != null
199     )
200                {
201                          String id = "id";
202                    registry.setString( prefix + id, value.getId() );
203                      }
204                            if ( value.getName() != null
205     )
206                {
207                          String name = "name";
208                    registry.setString( prefix + name, value.getName() );
209                      }
210                            if ( value.getLayout() != null && !value.getLayout().equals( "default" )
211     )
212                {
213                          String layout = "layout";
214                    registry.setString( prefix + layout, value.getLayout() );
215                      }
216                            if ( value.getIndexDir() != null
217     )
218                {
219                          String indexDir = "indexDir";
220                    registry.setString( prefix + indexDir, value.getIndexDir() );
221                      }
222                            if ( value.getDescription() != null
223     )
224                {
225                          String description = "description";
226                    registry.setString( prefix + description, value.getDescription() );
227                      }
228                  }
229        }
230        
231        private void writeRemoteRepositoryConfiguration( String prefix, RemoteRepositoryConfiguration value, Registry registry )
232        {
233            if ( value != null )
234            {
235                      if ( value.getUrl() != null
236     )
237                {
238                          String url = "url";
239                    registry.setString( prefix + url, value.getUrl() );
240                      }
241                            if ( value.getUsername() != null
242     )
243                {
244                          String username = "username";
245                    registry.setString( prefix + username, value.getUsername() );
246                      }
247                            if ( value.getPassword() != null
248     )
249                {
250                          String password = "password";
251                    registry.setString( prefix + password, value.getPassword() );
252                      }
253                            if ( value.getTimeout() != 60
254     )
255                {
256                          String timeout = "timeout";
257                    registry.setInt( prefix + timeout, value.getTimeout() );
258                      }
259                            if ( value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals( "0 0 08 ? * SUN" )
260     )
261                {
262                          String refreshCronExpression = "refreshCronExpression";
263                    registry.setString( prefix + refreshCronExpression, value.getRefreshCronExpression() );
264                      }
265                                String downloadRemoteIndex = "downloadRemoteIndex";
266                    registry.setBoolean( prefix + downloadRemoteIndex, value.isDownloadRemoteIndex() );
267                            if ( value.getRemoteIndexUrl() != null
268     )
269                {
270                          String remoteIndexUrl = "remoteIndexUrl";
271                    registry.setString( prefix + remoteIndexUrl, value.getRemoteIndexUrl() );
272                      }
273                            if ( value.getRemoteDownloadNetworkProxyId() != null
274     )
275                {
276                          String remoteDownloadNetworkProxyId = "remoteDownloadNetworkProxyId";
277                    registry.setString( prefix + remoteDownloadNetworkProxyId, value.getRemoteDownloadNetworkProxyId() );
278                      }
279                            if ( value.getRemoteDownloadTimeout() != 300
280     )
281                {
282                          String remoteDownloadTimeout = "remoteDownloadTimeout";
283                    registry.setInt( prefix + remoteDownloadTimeout, value.getRemoteDownloadTimeout() );
284                      }
285                                String downloadRemoteIndexOnStartup = "downloadRemoteIndexOnStartup";
286                    registry.setBoolean( prefix + downloadRemoteIndexOnStartup, value.isDownloadRemoteIndexOnStartup() );
287                      if ( value.getExtraParameters() != null && value.getExtraParameters().size() > 0
288     )
289                {
290                    registry.removeSubset( prefix + "extraParameters" );
291                    
292                    for ( Iterator iter = value.getExtraParameters().keySet().iterator(); iter.hasNext(); )
293                    {
294                        String key = (String) iter.next();
295                        String v = (String) value.getExtraParameters().get( key );
296    
297                        registry.setString( prefix + "extraParameters." + key, v );
298                    }
299                }
300                if ( value.getExtraHeaders() != null && value.getExtraHeaders().size() > 0
301     )
302                {
303                    registry.removeSubset( prefix + "extraHeaders" );
304                    
305                    for ( Iterator iter = value.getExtraHeaders().keySet().iterator(); iter.hasNext(); )
306                    {
307                        String key = (String) iter.next();
308                        String v = (String) value.getExtraHeaders().get( key );
309    
310                        registry.setString( prefix + "extraHeaders." + key, v );
311                    }
312                }
313                      if ( value.getId() != null
314     )
315                {
316                          String id = "id";
317                    registry.setString( prefix + id, value.getId() );
318                      }
319                            if ( value.getName() != null
320     )
321                {
322                          String name = "name";
323                    registry.setString( prefix + name, value.getName() );
324                      }
325                            if ( value.getLayout() != null && !value.getLayout().equals( "default" )
326     )
327                {
328                          String layout = "layout";
329                    registry.setString( prefix + layout, value.getLayout() );
330                      }
331                            if ( value.getIndexDir() != null
332     )
333                {
334                          String indexDir = "indexDir";
335                    registry.setString( prefix + indexDir, value.getIndexDir() );
336                      }
337                            if ( value.getDescription() != null
338     )
339                {
340                          String description = "description";
341                    registry.setString( prefix + description, value.getDescription() );
342                      }
343                  }
344        }
345        
346        private void writeManagedRepositoryConfiguration( String prefix, ManagedRepositoryConfiguration value, Registry registry )
347        {
348            if ( value != null )
349            {
350                      if ( value.getLocation() != null
351     )
352                {
353                          String location = "location";
354                    registry.setString( prefix + location, value.getLocation() );
355                      }
356                                String releases = "releases";
357                    registry.setBoolean( prefix + releases, value.isReleases() );
358                                String blockRedeployments = "blockRedeployments";
359                    registry.setBoolean( prefix + blockRedeployments, value.isBlockRedeployments() );
360                                String snapshots = "snapshots";
361                    registry.setBoolean( prefix + snapshots, value.isSnapshots() );
362                                String scanned = "scanned";
363                    registry.setBoolean( prefix + scanned, value.isScanned() );
364                            if ( value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals( "0 0 * * * ?" )
365     )
366                {
367                          String refreshCronExpression = "refreshCronExpression";
368                    registry.setString( prefix + refreshCronExpression, value.getRefreshCronExpression() );
369                      }
370                            if ( value.getRetentionCount() != 2
371     )
372                {
373                          String retentionCount = "retentionCount";
374                    registry.setInt( prefix + retentionCount, value.getRetentionCount() );
375                      }
376                            if ( value.getDaysOlder() != 100
377     )
378                {
379                          String daysOlder = "daysOlder";
380                    registry.setInt( prefix + daysOlder, value.getDaysOlder() );
381                      }
382                                String deleteReleasedSnapshots = "deleteReleasedSnapshots";
383                    registry.setBoolean( prefix + deleteReleasedSnapshots, value.isDeleteReleasedSnapshots() );
384                                String skipPackedIndexCreation = "skipPackedIndexCreation";
385                    registry.setBoolean( prefix + skipPackedIndexCreation, value.isSkipPackedIndexCreation() );
386                                String stageRepoNeeded = "stageRepoNeeded";
387                    registry.setBoolean( prefix + stageRepoNeeded, value.isStageRepoNeeded() );
388                            if ( value.getId() != null
389     )
390                {
391                          String id = "id";
392                    registry.setString( prefix + id, value.getId() );
393                      }
394                            if ( value.getName() != null
395     )
396                {
397                          String name = "name";
398                    registry.setString( prefix + name, value.getName() );
399                      }
400                            if ( value.getLayout() != null && !value.getLayout().equals( "default" )
401     )
402                {
403                          String layout = "layout";
404                    registry.setString( prefix + layout, value.getLayout() );
405                      }
406                            if ( value.getIndexDir() != null
407     )
408                {
409                          String indexDir = "indexDir";
410                    registry.setString( prefix + indexDir, value.getIndexDir() );
411                      }
412                            if ( value.getDescription() != null
413     )
414                {
415                          String description = "description";
416                    registry.setString( prefix + description, value.getDescription() );
417                      }
418                  }
419        }
420        
421        private void writeV1RepositoryConfiguration( String prefix, V1RepositoryConfiguration value, Registry registry )
422        {
423            if ( value != null )
424            {
425                      if ( value.getUrl() != null
426     )
427                {
428                          String url = "url";
429                    registry.setString( prefix + url, value.getUrl() );
430                      }
431                                String indexed = "indexed";
432                    registry.setBoolean( prefix + indexed, value.isIndexed() );
433                            if ( value.getLocation() != null
434     )
435                {
436                          String location = "location";
437                    registry.setString( prefix + location, value.getLocation() );
438                      }
439                                String releases = "releases";
440                    registry.setBoolean( prefix + releases, value.isReleases() );
441                                String blockRedeployments = "blockRedeployments";
442                    registry.setBoolean( prefix + blockRedeployments, value.isBlockRedeployments() );
443                                String snapshots = "snapshots";
444                    registry.setBoolean( prefix + snapshots, value.isSnapshots() );
445                                String scanned = "scanned";
446                    registry.setBoolean( prefix + scanned, value.isScanned() );
447                            if ( value.getRefreshCronExpression() != null && !value.getRefreshCronExpression().equals( "0 0 * * * ?" )
448     )
449                {
450                          String refreshCronExpression = "refreshCronExpression";
451                    registry.setString( prefix + refreshCronExpression, value.getRefreshCronExpression() );
452                      }
453                            if ( value.getRetentionCount() != 2
454     )
455                {
456                          String retentionCount = "retentionCount";
457                    registry.setInt( prefix + retentionCount, value.getRetentionCount() );
458                      }
459                            if ( value.getDaysOlder() != 100
460     )
461                {
462                          String daysOlder = "daysOlder";
463                    registry.setInt( prefix + daysOlder, value.getDaysOlder() );
464                      }
465                                String deleteReleasedSnapshots = "deleteReleasedSnapshots";
466                    registry.setBoolean( prefix + deleteReleasedSnapshots, value.isDeleteReleasedSnapshots() );
467                                String skipPackedIndexCreation = "skipPackedIndexCreation";
468                    registry.setBoolean( prefix + skipPackedIndexCreation, value.isSkipPackedIndexCreation() );
469                                String stageRepoNeeded = "stageRepoNeeded";
470                    registry.setBoolean( prefix + stageRepoNeeded, value.isStageRepoNeeded() );
471                            if ( value.getId() != null
472     )
473                {
474                          String id = "id";
475                    registry.setString( prefix + id, value.getId() );
476                      }
477                            if ( value.getName() != null
478     )
479                {
480                          String name = "name";
481                    registry.setString( prefix + name, value.getName() );
482                      }
483                            if ( value.getLayout() != null && !value.getLayout().equals( "default" )
484     )
485                {
486                          String layout = "layout";
487                    registry.setString( prefix + layout, value.getLayout() );
488                      }
489                            if ( value.getIndexDir() != null
490     )
491                {
492                          String indexDir = "indexDir";
493                    registry.setString( prefix + indexDir, value.getIndexDir() );
494                      }
495                            if ( value.getDescription() != null
496     )
497                {
498                          String description = "description";
499                    registry.setString( prefix + description, value.getDescription() );
500                      }
501                  }
502        }
503        
504        private void writeLegacyArtifactPath( String prefix, LegacyArtifactPath value, Registry registry )
505        {
506            if ( value != null )
507            {
508                      if ( value.getPath() != null
509     )
510                {
511                          String path = "path";
512                    registry.setString( prefix + path, value.getPath() );
513                      }
514                            if ( value.getArtifact() != null
515     )
516                {
517                          String artifact = "artifact";
518                    registry.setString( prefix + artifact, value.getArtifact() );
519                      }
520                  }
521        }
522        
523        private void writeRepositoryGroupConfiguration( String prefix, RepositoryGroupConfiguration value, Registry registry )
524        {
525            if ( value != null )
526            {
527                      if ( value.getId() != null
528     )
529                {
530                          String id = "id";
531                    registry.setString( prefix + id, value.getId() );
532                      }
533                            if ( value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals( "/.indexer" )
534     )
535                {
536                          String mergedIndexPath = "mergedIndexPath";
537                    registry.setString( prefix + mergedIndexPath, value.getMergedIndexPath() );
538                      }
539                            if ( value.getMergedIndexTtl() != 30
540     )
541                {
542                          String mergedIndexTtl = "mergedIndexTtl";
543                    registry.setInt( prefix + mergedIndexTtl, value.getMergedIndexTtl() );
544                      }
545                      if ( value.getRepositories() != null && value.getRepositories().size() > 0
546     )
547                {
548                    registry.removeSubset( prefix + "repositories" );
549    
550                    int count = 0;
551                    for ( Iterator iter = value.getRepositories().iterator(); iter.hasNext(); count++ )
552                    {
553                        String name = "repositories.repository(" + count + ")";
554                        String repository = ( String ) iter.next();
555                        registry.setString( prefix + name, repository );
556                    }
557                }
558            }
559        }
560        
561        private void writeAbstractRepositoryConnectorConfiguration( String prefix, AbstractRepositoryConnectorConfiguration value, Registry registry )
562        {
563            if ( value != null )
564            {
565                      if ( value.getSourceRepoId() != null
566     )
567                {
568                          String sourceRepoId = "sourceRepoId";
569                    registry.setString( prefix + sourceRepoId, value.getSourceRepoId() );
570                      }
571                            if ( value.getTargetRepoId() != null
572     )
573                {
574                          String targetRepoId = "targetRepoId";
575                    registry.setString( prefix + targetRepoId, value.getTargetRepoId() );
576                      }
577                            if ( value.getProxyId() != null
578     )
579                {
580                          String proxyId = "proxyId";
581                    registry.setString( prefix + proxyId, value.getProxyId() );
582                      }
583                      if ( value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
584     )
585                {
586                    registry.removeSubset( prefix + "blackListPatterns" );
587    
588                    int count = 0;
589                    for ( Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++ )
590                    {
591                        String name = "blackListPatterns.blackListPattern(" + count + ")";
592                        String blackListPattern = ( String ) iter.next();
593                        registry.setString( prefix + name, blackListPattern );
594                    }
595                }
596                if ( value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
597     )
598                {
599                    registry.removeSubset( prefix + "whiteListPatterns" );
600    
601                    int count = 0;
602                    for ( Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++ )
603                    {
604                        String name = "whiteListPatterns.whiteListPattern(" + count + ")";
605                        String whiteListPattern = ( String ) iter.next();
606                        registry.setString( prefix + name, whiteListPattern );
607                    }
608                }
609                if ( value.getPolicies() != null && value.getPolicies().size() > 0
610     )
611                {
612                    registry.removeSubset( prefix + "policies" );
613                    
614                    for ( Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); )
615                    {
616                        String key = (String) iter.next();
617                        String v = (String) value.getPolicies().get( key );
618    
619                        registry.setString( prefix + "policies." + key, v );
620                    }
621                }
622                if ( value.getProperties() != null && value.getProperties().size() > 0
623     )
624                {
625                    registry.removeSubset( prefix + "properties" );
626                    
627                    for ( Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); )
628                    {
629                        String key = (String) iter.next();
630                        String v = (String) value.getProperties().get( key );
631    
632                        registry.setString( prefix + "properties." + key, v );
633                    }
634                }
635                          String disabled = "disabled";
636                    registry.setBoolean( prefix + disabled, value.isDisabled() );
637                  }
638        }
639        
640        private void writeProxyConnectorRuleConfiguration( String prefix, ProxyConnectorRuleConfiguration value, Registry registry )
641        {
642            if ( value != null )
643            {
644                      if ( value.getRuleType() != null
645     )
646                {
647                          String ruleType = "ruleType";
648                    registry.setString( prefix + ruleType, value.getRuleType() );
649                      }
650                            if ( value.getPattern() != null
651     )
652                {
653                          String pattern = "pattern";
654                    registry.setString( prefix + pattern, value.getPattern() );
655                      }
656                      if ( value.getProxyConnectors() != null && value.getProxyConnectors().size() > 0
657     )
658                {
659                    registry.removeSubset( prefix + "proxyConnectors" );
660    
661                    int count = 0;
662                    for ( Iterator iter = value.getProxyConnectors().iterator(); iter.hasNext(); count++ )
663                    {
664                        String name = "proxyConnectors.proxyConnector(" + count + ")";
665                        ProxyConnectorConfiguration o = ( ProxyConnectorConfiguration ) iter.next();
666                        writeProxyConnectorConfiguration( prefix + name + ".", o, registry );
667                    }
668                }
669            }
670        }
671        
672        private void writeProxyConnectorConfiguration( String prefix, ProxyConnectorConfiguration value, Registry registry )
673        {
674            if ( value != null )
675            {
676                      if ( value.getOrder() != 0
677     )
678                {
679                          String order = "order";
680                    registry.setInt( prefix + order, value.getOrder() );
681                      }
682                            if ( value.getSourceRepoId() != null
683     )
684                {
685                          String sourceRepoId = "sourceRepoId";
686                    registry.setString( prefix + sourceRepoId, value.getSourceRepoId() );
687                      }
688                            if ( value.getTargetRepoId() != null
689     )
690                {
691                          String targetRepoId = "targetRepoId";
692                    registry.setString( prefix + targetRepoId, value.getTargetRepoId() );
693                      }
694                            if ( value.getProxyId() != null
695     )
696                {
697                          String proxyId = "proxyId";
698                    registry.setString( prefix + proxyId, value.getProxyId() );
699                      }
700                      if ( value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
701     )
702                {
703                    registry.removeSubset( prefix + "blackListPatterns" );
704    
705                    int count = 0;
706                    for ( Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++ )
707                    {
708                        String name = "blackListPatterns.blackListPattern(" + count + ")";
709                        String blackListPattern = ( String ) iter.next();
710                        registry.setString( prefix + name, blackListPattern );
711                    }
712                }
713                if ( value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
714     )
715                {
716                    registry.removeSubset( prefix + "whiteListPatterns" );
717    
718                    int count = 0;
719                    for ( Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++ )
720                    {
721                        String name = "whiteListPatterns.whiteListPattern(" + count + ")";
722                        String whiteListPattern = ( String ) iter.next();
723                        registry.setString( prefix + name, whiteListPattern );
724                    }
725                }
726                if ( value.getPolicies() != null && value.getPolicies().size() > 0
727     )
728                {
729                    registry.removeSubset( prefix + "policies" );
730                    
731                    for ( Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); )
732                    {
733                        String key = (String) iter.next();
734                        String v = (String) value.getPolicies().get( key );
735    
736                        registry.setString( prefix + "policies." + key, v );
737                    }
738                }
739                if ( value.getProperties() != null && value.getProperties().size() > 0
740     )
741                {
742                    registry.removeSubset( prefix + "properties" );
743                    
744                    for ( Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); )
745                    {
746                        String key = (String) iter.next();
747                        String v = (String) value.getProperties().get( key );
748    
749                        registry.setString( prefix + "properties." + key, v );
750                    }
751                }
752                          String disabled = "disabled";
753                    registry.setBoolean( prefix + disabled, value.isDisabled() );
754                  }
755        }
756        
757        private void writeSyncConnectorConfiguration( String prefix, SyncConnectorConfiguration value, Registry registry )
758        {
759            if ( value != null )
760            {
761                      if ( value.getCronExpression() != null && !value.getCronExpression().equals( "0 0 * * * ?" )
762     )
763                {
764                          String cronExpression = "cronExpression";
765                    registry.setString( prefix + cronExpression, value.getCronExpression() );
766                      }
767                            if ( value.getMethod() != null && !value.getMethod().equals( "rsync" )
768     )
769                {
770                          String method = "method";
771                    registry.setString( prefix + method, value.getMethod() );
772                      }
773                            if ( value.getSourceRepoId() != null
774     )
775                {
776                          String sourceRepoId = "sourceRepoId";
777                    registry.setString( prefix + sourceRepoId, value.getSourceRepoId() );
778                      }
779                            if ( value.getTargetRepoId() != null
780     )
781                {
782                          String targetRepoId = "targetRepoId";
783                    registry.setString( prefix + targetRepoId, value.getTargetRepoId() );
784                      }
785                            if ( value.getProxyId() != null
786     )
787                {
788                          String proxyId = "proxyId";
789                    registry.setString( prefix + proxyId, value.getProxyId() );
790                      }
791                      if ( value.getBlackListPatterns() != null && value.getBlackListPatterns().size() > 0
792     )
793                {
794                    registry.removeSubset( prefix + "blackListPatterns" );
795    
796                    int count = 0;
797                    for ( Iterator iter = value.getBlackListPatterns().iterator(); iter.hasNext(); count++ )
798                    {
799                        String name = "blackListPatterns.blackListPattern(" + count + ")";
800                        String blackListPattern = ( String ) iter.next();
801                        registry.setString( prefix + name, blackListPattern );
802                    }
803                }
804                if ( value.getWhiteListPatterns() != null && value.getWhiteListPatterns().size() > 0
805     )
806                {
807                    registry.removeSubset( prefix + "whiteListPatterns" );
808    
809                    int count = 0;
810                    for ( Iterator iter = value.getWhiteListPatterns().iterator(); iter.hasNext(); count++ )
811                    {
812                        String name = "whiteListPatterns.whiteListPattern(" + count + ")";
813                        String whiteListPattern = ( String ) iter.next();
814                        registry.setString( prefix + name, whiteListPattern );
815                    }
816                }
817                if ( value.getPolicies() != null && value.getPolicies().size() > 0
818     )
819                {
820                    registry.removeSubset( prefix + "policies" );
821                    
822                    for ( Iterator iter = value.getPolicies().keySet().iterator(); iter.hasNext(); )
823                    {
824                        String key = (String) iter.next();
825                        String v = (String) value.getPolicies().get( key );
826    
827                        registry.setString( prefix + "policies." + key, v );
828                    }
829                }
830                if ( value.getProperties() != null && value.getProperties().size() > 0
831     )
832                {
833                    registry.removeSubset( prefix + "properties" );
834                    
835                    for ( Iterator iter = value.getProperties().keySet().iterator(); iter.hasNext(); )
836                    {
837                        String key = (String) iter.next();
838                        String v = (String) value.getProperties().get( key );
839    
840                        registry.setString( prefix + "properties." + key, v );
841                    }
842                }
843                          String disabled = "disabled";
844                    registry.setBoolean( prefix + disabled, value.isDisabled() );
845                  }
846        }
847        
848        private void writeNetworkProxyConfiguration( String prefix, NetworkProxyConfiguration value, Registry registry )
849        {
850            if ( value != null )
851            {
852                      if ( value.getId() != null
853     )
854                {
855                          String id = "id";
856                    registry.setString( prefix + id, value.getId() );
857                      }
858                            if ( value.getProtocol() != null && !value.getProtocol().equals( "http" )
859     )
860                {
861                          String protocol = "protocol";
862                    registry.setString( prefix + protocol, value.getProtocol() );
863                      }
864                            if ( value.getHost() != null
865     )
866                {
867                          String host = "host";
868                    registry.setString( prefix + host, value.getHost() );
869                      }
870                            if ( value.getPort() != 8080
871     )
872                {
873                          String port = "port";
874                    registry.setInt( prefix + port, value.getPort() );
875                      }
876                            if ( value.getUsername() != null
877     )
878                {
879                          String username = "username";
880                    registry.setString( prefix + username, value.getUsername() );
881                      }
882                            if ( value.getPassword() != null
883     )
884                {
885                          String password = "password";
886                    registry.setString( prefix + password, value.getPassword() );
887                      }
888                                String useNtlm = "useNtlm";
889                    registry.setBoolean( prefix + useNtlm, value.isUseNtlm() );
890                  }
891        }
892        
893        private void writeRepositoryScanningConfiguration( String prefix, RepositoryScanningConfiguration value, Registry registry )
894        {
895            if ( value != null )
896            {
897                if ( value.getFileTypes() != null && value.getFileTypes().size() > 0
898     )
899                {
900                    registry.removeSubset( prefix + "fileTypes" );
901    
902                    int count = 0;
903                    for ( Iterator iter = value.getFileTypes().iterator(); iter.hasNext(); count++ )
904                    {
905                        String name = "fileTypes.fileType(" + count + ")";
906                        FileType o = ( FileType ) iter.next();
907                        writeFileType( prefix + name + ".", o, registry );
908                    }
909                }
910                if ( value.getKnownContentConsumers() != null && value.getKnownContentConsumers().size() > 0
911     )
912                {
913                    registry.removeSubset( prefix + "knownContentConsumers" );
914    
915                    int count = 0;
916                    for ( Iterator iter = value.getKnownContentConsumers().iterator(); iter.hasNext(); count++ )
917                    {
918                        String name = "knownContentConsumers.knownContentConsumer(" + count + ")";
919                        String knownContentConsumer = ( String ) iter.next();
920                        registry.setString( prefix + name, knownContentConsumer );
921                    }
922                }
923                if ( value.getInvalidContentConsumers() != null && value.getInvalidContentConsumers().size() > 0
924     )
925                {
926                    registry.removeSubset( prefix + "invalidContentConsumers" );
927    
928                    int count = 0;
929                    for ( Iterator iter = value.getInvalidContentConsumers().iterator(); iter.hasNext(); count++ )
930                    {
931                        String name = "invalidContentConsumers.invalidContentConsumer(" + count + ")";
932                        String invalidContentConsumer = ( String ) iter.next();
933                        registry.setString( prefix + name, invalidContentConsumer );
934                    }
935                }
936            }
937        }
938        
939        private void writeFileType( String prefix, FileType value, Registry registry )
940        {
941            if ( value != null )
942            {
943                      if ( value.getId() != null
944     )
945                {
946                          String id = "id";
947                    registry.setString( prefix + id, value.getId() );
948                      }
949                      if ( value.getPatterns() != null && value.getPatterns().size() > 0
950     )
951                {
952                    registry.removeSubset( prefix + "patterns" );
953    
954                    int count = 0;
955                    for ( Iterator iter = value.getPatterns().iterator(); iter.hasNext(); count++ )
956                    {
957                        String name = "patterns.pattern(" + count + ")";
958                        String pattern = ( String ) iter.next();
959                        registry.setString( prefix + name, pattern );
960                    }
961                }
962            }
963        }
964        
965        private void writeOrganisationInformation( String prefix, OrganisationInformation value, Registry registry )
966        {
967            if ( value != null )
968            {
969                      if ( value.getName() != null
970     )
971                {
972                          String name = "name";
973                    registry.setString( prefix + name, value.getName() );
974                      }
975                            if ( value.getUrl() != null
976     )
977                {
978                          String url = "url";
979                    registry.setString( prefix + url, value.getUrl() );
980                      }
981                            if ( value.getLogoLocation() != null
982     )
983                {
984                          String logoLocation = "logoLocation";
985                    registry.setString( prefix + logoLocation, value.getLogoLocation() );
986                      }
987                  }
988        }
989        
990        private void writeWebappConfiguration( String prefix, WebappConfiguration value, Registry registry )
991        {
992            if ( value != null )
993            {
994                if ( value.getUi() != null
995     )
996                {
997                    writeUserInterfaceOptions( prefix + "ui.", value.getUi(), registry );
998                }
999            }
1000        }
1001        
1002        private void writeUserInterfaceOptions( String prefix, UserInterfaceOptions value, Registry registry )
1003        {
1004            if ( value != null )
1005            {
1006                          String showFindArtifacts = "showFindArtifacts";
1007                    registry.setBoolean( prefix + showFindArtifacts, value.isShowFindArtifacts() );
1008                                String appletFindEnabled = "appletFindEnabled";
1009                    registry.setBoolean( prefix + appletFindEnabled, value.isAppletFindEnabled() );
1010                                String disableEasterEggs = "disableEasterEggs";
1011                    registry.setBoolean( prefix + disableEasterEggs, value.isDisableEasterEggs() );
1012                            if ( value.getApplicationUrl() != null
1013     )
1014                {
1015                          String applicationUrl = "applicationUrl";
1016                    registry.setString( prefix + applicationUrl, value.getApplicationUrl() );
1017                      }
1018                                String disableRegistration = "disableRegistration";
1019                    registry.setBoolean( prefix + disableRegistration, value.isDisableRegistration() );
1020                  }
1021        }
1022        
1023        private void writeNetworkConfiguration( String prefix, NetworkConfiguration value, Registry registry )
1024        {
1025            if ( value != null )
1026            {
1027                      if ( value.getMaxTotal() != 30
1028     )
1029                {
1030                          String maxTotal = "maxTotal";
1031                    registry.setInt( prefix + maxTotal, value.getMaxTotal() );
1032                      }
1033                            if ( value.getMaxTotalPerHost() != 30
1034     )
1035                {
1036                          String maxTotalPerHost = "maxTotalPerHost";
1037                    registry.setInt( prefix + maxTotalPerHost, value.getMaxTotalPerHost() );
1038                      }
1039                                String usePooling = "usePooling";
1040                    registry.setBoolean( prefix + usePooling, value.isUsePooling() );
1041                  }
1042        }
1043        
1044        private void writeArchivaRuntimeConfiguration( String prefix, ArchivaRuntimeConfiguration value, Registry registry )
1045        {
1046            if ( value != null )
1047            {
1048                if ( value.getUrlFailureCacheConfiguration() != null
1049     )
1050                {
1051                    writeCacheConfiguration( prefix + "urlFailureCacheConfiguration.", value.getUrlFailureCacheConfiguration(), registry );
1052                }
1053            }
1054        }
1055        
1056        private void writeRedbackRuntimeConfiguration( String prefix, RedbackRuntimeConfiguration value, Registry registry )
1057        {
1058            if ( value != null )
1059            {
1060                          String migratedFromRedbackConfiguration = "migratedFromRedbackConfiguration";
1061                    registry.setBoolean( prefix + migratedFromRedbackConfiguration, value.isMigratedFromRedbackConfiguration() );
1062                      if ( value.getUserManagerImpls() != null && value.getUserManagerImpls().size() > 0
1063     )
1064                {
1065                    registry.removeSubset( prefix + "userManagerImpls" );
1066    
1067                    int count = 0;
1068                    for ( Iterator iter = value.getUserManagerImpls().iterator(); iter.hasNext(); count++ )
1069                    {
1070                        String name = "userManagerImpls.userManagerImpl(" + count + ")";
1071                        String userManagerImpl = ( String ) iter.next();
1072                        registry.setString( prefix + name, userManagerImpl );
1073                    }
1074                }
1075                if ( value.getRbacManagerImpls() != null && value.getRbacManagerImpls().size() > 0
1076     )
1077                {
1078                    registry.removeSubset( prefix + "rbacManagerImpls" );
1079    
1080                    int count = 0;
1081                    for ( Iterator iter = value.getRbacManagerImpls().iterator(); iter.hasNext(); count++ )
1082                    {
1083                        String name = "rbacManagerImpls.rbacManagerImpl(" + count + ")";
1084                        String rbacManagerImpl = ( String ) iter.next();
1085                        registry.setString( prefix + name, rbacManagerImpl );
1086                    }
1087                }
1088                if ( value.getLdapConfiguration() != null
1089     )
1090                {
1091                    writeLdapConfiguration( prefix + "ldapConfiguration.", value.getLdapConfiguration(), registry );
1092                }
1093                if ( value.getLdapGroupMappings() != null && value.getLdapGroupMappings().size() > 0
1094     )
1095                {
1096                    registry.removeSubset( prefix + "ldapGroupMappings" );
1097    
1098                    int count = 0;
1099                    for ( Iterator iter = value.getLdapGroupMappings().iterator(); iter.hasNext(); count++ )
1100                    {
1101                        String name = "ldapGroupMappings.ldapGroupMapping(" + count + ")";
1102                        LdapGroupMapping o = ( LdapGroupMapping ) iter.next();
1103                        writeLdapGroupMapping( prefix + name + ".", o, registry );
1104                    }
1105                }
1106                if ( value.getConfigurationProperties() != null && value.getConfigurationProperties().size() > 0
1107     )
1108                {
1109                    registry.removeSubset( prefix + "configurationProperties" );
1110                    
1111                    for ( Iterator iter = value.getConfigurationProperties().keySet().iterator(); iter.hasNext(); )
1112                    {
1113                        String key = (String) iter.next();
1114                        String v = (String) value.getConfigurationProperties().get( key );
1115    
1116                        registry.setString( prefix + "configurationProperties." + key, v );
1117                    }
1118                }
1119                          String useUsersCache = "useUsersCache";
1120                    registry.setBoolean( prefix + useUsersCache, value.isUseUsersCache() );
1121                      if ( value.getUsersCacheConfiguration() != null
1122     )
1123                {
1124                    writeCacheConfiguration( prefix + "usersCacheConfiguration.", value.getUsersCacheConfiguration(), registry );
1125                }
1126            }
1127        }
1128        
1129        private void writeLdapConfiguration( String prefix, LdapConfiguration value, Registry registry )
1130        {
1131            if ( value != null )
1132            {
1133                      if ( value.getHostName() != null
1134     )
1135                {
1136                          String hostName = "hostName";
1137                    registry.setString( prefix + hostName, value.getHostName() );
1138                      }
1139                            if ( value.getPort() != 0
1140     )
1141                {
1142                          String port = "port";
1143                    registry.setInt( prefix + port, value.getPort() );
1144                      }
1145                                String ssl = "ssl";
1146                    registry.setBoolean( prefix + ssl, value.isSsl() );
1147                            if ( value.getBaseDn() != null
1148     )
1149                {
1150                          String baseDn = "baseDn";
1151                    registry.setString( prefix + baseDn, value.getBaseDn() );
1152                      }
1153                            if ( value.getBaseGroupsDn() != null
1154     )
1155                {
1156                          String baseGroupsDn = "baseGroupsDn";
1157                    registry.setString( prefix + baseGroupsDn, value.getBaseGroupsDn() );
1158                      }
1159                            if ( value.getContextFactory() != null
1160     )
1161                {
1162                          String contextFactory = "contextFactory";
1163                    registry.setString( prefix + contextFactory, value.getContextFactory() );
1164                      }
1165                            if ( value.getBindDn() != null
1166     )
1167                {
1168                          String bindDn = "bindDn";
1169                    registry.setString( prefix + bindDn, value.getBindDn() );
1170                      }
1171                            if ( value.getPassword() != null
1172     )
1173                {
1174                          String password = "password";
1175                    registry.setString( prefix + password, value.getPassword() );
1176                      }
1177                            if ( value.getAuthenticationMethod() != null
1178     )
1179                {
1180                          String authenticationMethod = "authenticationMethod";
1181                    registry.setString( prefix + authenticationMethod, value.getAuthenticationMethod() );
1182                      }
1183                                String bindAuthenticatorEnabled = "bindAuthenticatorEnabled";
1184                    registry.setBoolean( prefix + bindAuthenticatorEnabled, value.isBindAuthenticatorEnabled() );
1185                                String writable = "writable";
1186                    registry.setBoolean( prefix + writable, value.isWritable() );
1187                                String useRoleNameAsGroup = "useRoleNameAsGroup";
1188                    registry.setBoolean( prefix + useRoleNameAsGroup, value.isUseRoleNameAsGroup() );
1189                      if ( value.getExtraProperties() != null && value.getExtraProperties().size() > 0
1190     )
1191                {
1192                    registry.removeSubset( prefix + "extraProperties" );
1193                    
1194                    for ( Iterator iter = value.getExtraProperties().keySet().iterator(); iter.hasNext(); )
1195                    {
1196                        String key = (String) iter.next();
1197                        String v = (String) value.getExtraProperties().get( key );
1198    
1199                        registry.setString( prefix + "extraProperties." + key, v );
1200                    }
1201                }
1202            }
1203        }
1204        
1205        private void writeCacheConfiguration( String prefix, CacheConfiguration value, Registry registry )
1206        {
1207            if ( value != null )
1208            {
1209                      if ( value.getTimeToIdleSeconds() != -1
1210     )
1211                {
1212                          String timeToIdleSeconds = "timeToIdleSeconds";
1213                    registry.setInt( prefix + timeToIdleSeconds, value.getTimeToIdleSeconds() );
1214                      }
1215                            if ( value.getTimeToLiveSeconds() != -1
1216     )
1217                {
1218                          String timeToLiveSeconds = "timeToLiveSeconds";
1219                    registry.setInt( prefix + timeToLiveSeconds, value.getTimeToLiveSeconds() );
1220                      }
1221                            if ( value.getMaxElementsInMemory() != -1
1222     )
1223                {
1224                          String maxElementsInMemory = "maxElementsInMemory";
1225                    registry.setInt( prefix + maxElementsInMemory, value.getMaxElementsInMemory() );
1226                      }
1227                            if ( value.getMaxElementsOnDisk() != -1
1228     )
1229                {
1230                          String maxElementsOnDisk = "maxElementsOnDisk";
1231                    registry.setInt( prefix + maxElementsOnDisk, value.getMaxElementsOnDisk() );
1232                      }
1233                  }
1234        }
1235        
1236        private void writeLdapGroupMapping( String prefix, LdapGroupMapping value, Registry registry )
1237        {
1238            if ( value != null )
1239            {
1240                      if ( value.getGroup() != null
1241     )
1242                {
1243                          String group = "group";
1244                    registry.setString( prefix + group, value.getGroup() );
1245                      }
1246                      if ( value.getRoleNames() != null && value.getRoleNames().size() > 0
1247     )
1248                {
1249                    registry.removeSubset( prefix + "roleNames" );
1250    
1251                    int count = 0;
1252                    for ( Iterator iter = value.getRoleNames().iterator(); iter.hasNext(); count++ )
1253                    {
1254                        String name = "roleNames.roleName(" + count + ")";
1255                        String roleName = ( String ) iter.next();
1256                        registry.setString( prefix + name, roleName );
1257                    }
1258                }
1259            }
1260        }
1261        
1262    }