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