1 package org.apache.archiva.configuration;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
23 * Class Configuration.
25 * @version $Revision$ $Date$
27 @SuppressWarnings( "all" )
28 public class Configuration
29 implements java.io.Serializable
32 //--------------------------/
33 //- Class/Member Variables -/
34 //--------------------------/
37 * This is the version of the configuration format.
39 private String version = "3.0.0";
42 * The type of the metadata storage. Allowed values: jcr, file,
45 private String metadataStore = "jcr";
48 * Field repositoryGroups.
50 private java.util.List<RepositoryGroupConfiguration> repositoryGroups;
53 * Field managedRepositories.
55 private java.util.List<ManagedRepositoryConfiguration> managedRepositories;
58 * Field remoteRepositories.
60 private java.util.List<RemoteRepositoryConfiguration> remoteRepositories;
63 * Field proxyConnectors.
65 private java.util.List<ProxyConnectorConfiguration> proxyConnectors;
68 * Field networkProxies.
70 private java.util.List<NetworkProxyConfiguration> networkProxies;
73 * Field legacyArtifactPaths.
75 private java.util.List<LegacyArtifactPath> legacyArtifactPaths;
79 * The repository scanning configuration.
82 private RepositoryScanningConfiguration repositoryScanning;
86 * The webapp configuration.
89 private WebappConfiguration webapp;
93 * The organisation info.
96 private OrganisationInformation organisationInfo;
100 * The NetworkConfiguration .
103 private NetworkConfiguration networkConfiguration;
106 * The RedbackRuntimeConfiguration.
108 private RedbackRuntimeConfiguration redbackRuntimeConfiguration;
111 * The ArchivaRuntimeConfiguration.
113 private ArchivaRuntimeConfiguration archivaRuntimeConfiguration;
116 * Field proxyConnectorRuleConfigurations.
118 private java.util.List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations;
121 * Archiva default settings.
123 private ArchivaDefaultConfiguration archivaDefaultConfiguration;
126 * Field modelEncoding.
128 private String modelEncoding = "UTF-8";
136 * Method addLegacyArtifactPath.
138 * @param legacyArtifactPath
140 public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
142 getLegacyArtifactPaths().add( legacyArtifactPath );
143 } //-- void addLegacyArtifactPath( LegacyArtifactPath )
146 * Method addManagedRepository.
148 * @param managedRepositoryConfiguration
150 public void addManagedRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration )
152 getManagedRepositories().add( managedRepositoryConfiguration );
153 } //-- void addManagedRepository( ManagedRepositoryConfiguration )
156 * Method addNetworkProxy.
158 * @param networkProxyConfiguration
160 public void addNetworkProxy( NetworkProxyConfiguration networkProxyConfiguration )
162 getNetworkProxies().add( networkProxyConfiguration );
163 } //-- void addNetworkProxy( NetworkProxyConfiguration )
166 * Method addProxyConnector.
168 * @param proxyConnectorConfiguration
170 public void addProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration )
172 getProxyConnectors().add( proxyConnectorConfiguration );
173 } //-- void addProxyConnector( ProxyConnectorConfiguration )
176 * Method addProxyConnectorRuleConfiguration.
178 * @param proxyConnectorRuleConfiguration
180 public void addProxyConnectorRuleConfiguration( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration )
182 getProxyConnectorRuleConfigurations().add( proxyConnectorRuleConfiguration );
183 } //-- void addProxyConnectorRuleConfiguration( ProxyConnectorRuleConfiguration )
186 * Method addRemoteRepository.
188 * @param remoteRepositoryConfiguration
190 public void addRemoteRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration )
192 getRemoteRepositories().add( remoteRepositoryConfiguration );
193 } //-- void addRemoteRepository( RemoteRepositoryConfiguration )
196 * Method addRepositoryGroup.
198 * @param repositoryGroupConfiguration
200 public void addRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration )
202 getRepositoryGroups().add( repositoryGroupConfiguration );
203 } //-- void addRepositoryGroup( RepositoryGroupConfiguration )
206 * Get archiva default settings.
208 * @return ArchivaDefaultConfiguration
210 public ArchivaDefaultConfiguration getArchivaDefaultConfiguration()
212 return this.archivaDefaultConfiguration;
213 } //-- ArchivaDefaultConfiguration getArchivaDefaultConfiguration()
216 * Get the ArchivaRuntimeConfiguration.
218 * @return ArchivaRuntimeConfiguration
220 public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
222 return this.archivaRuntimeConfiguration;
223 } //-- ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
226 * Method getLegacyArtifactPaths.
230 public java.util.List<LegacyArtifactPath> getLegacyArtifactPaths()
232 if ( this.legacyArtifactPaths == null )
234 this.legacyArtifactPaths = new java.util.ArrayList<LegacyArtifactPath>();
237 return this.legacyArtifactPaths;
238 } //-- java.util.List<LegacyArtifactPath> getLegacyArtifactPaths()
241 * Method getManagedRepositories.
245 public java.util.List<ManagedRepositoryConfiguration> getManagedRepositories()
247 if ( this.managedRepositories == null )
249 this.managedRepositories = new java.util.ArrayList<ManagedRepositoryConfiguration>();
252 return this.managedRepositories;
253 } //-- java.util.List<ManagedRepositoryConfiguration> getManagedRepositories()
256 * Get the type of the metadata storage. Allowed values: jcr,
261 public String getMetadataStore()
263 return this.metadataStore;
264 } //-- String getMetadataStore()
267 * Get the modelEncoding field.
271 public String getModelEncoding()
273 return this.modelEncoding;
274 } //-- String getModelEncoding()
277 * Get the NetworkConfiguration .
279 * @return NetworkConfiguration
281 public NetworkConfiguration getNetworkConfiguration()
283 return this.networkConfiguration;
284 } //-- NetworkConfiguration getNetworkConfiguration()
287 * Method getNetworkProxies.
291 public java.util.List<NetworkProxyConfiguration> getNetworkProxies()
293 if ( this.networkProxies == null )
295 this.networkProxies = new java.util.ArrayList<NetworkProxyConfiguration>();
298 return this.networkProxies;
299 } //-- java.util.List<NetworkProxyConfiguration> getNetworkProxies()
302 * Get the organisation info.
304 * @return OrganisationInformation
306 public OrganisationInformation getOrganisationInfo()
308 return this.organisationInfo;
309 } //-- OrganisationInformation getOrganisationInfo()
312 * Method getProxyConnectorRuleConfigurations.
316 public java.util.List<ProxyConnectorRuleConfiguration> getProxyConnectorRuleConfigurations()
318 if ( this.proxyConnectorRuleConfigurations == null )
320 this.proxyConnectorRuleConfigurations = new java.util.ArrayList<ProxyConnectorRuleConfiguration>();
323 return this.proxyConnectorRuleConfigurations;
324 } //-- java.util.List<ProxyConnectorRuleConfiguration> getProxyConnectorRuleConfigurations()
327 * Method getProxyConnectors.
331 public java.util.List<ProxyConnectorConfiguration> getProxyConnectors()
333 if ( this.proxyConnectors == null )
335 this.proxyConnectors = new java.util.ArrayList<ProxyConnectorConfiguration>();
338 return this.proxyConnectors;
339 } //-- java.util.List<ProxyConnectorConfiguration> getProxyConnectors()
342 * Get the RedbackRuntimeConfiguration.
344 * @return RedbackRuntimeConfiguration
346 public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
348 return this.redbackRuntimeConfiguration;
349 } //-- RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
352 * Method getRemoteRepositories.
356 public java.util.List<RemoteRepositoryConfiguration> getRemoteRepositories()
358 if ( this.remoteRepositories == null )
360 this.remoteRepositories = new java.util.ArrayList<RemoteRepositoryConfiguration>();
363 return this.remoteRepositories;
364 } //-- java.util.List<RemoteRepositoryConfiguration> getRemoteRepositories()
367 * Method getRepositoryGroups.
371 public java.util.List<RepositoryGroupConfiguration> getRepositoryGroups()
373 if ( this.repositoryGroups == null )
375 this.repositoryGroups = new java.util.ArrayList<RepositoryGroupConfiguration>();
378 return this.repositoryGroups;
379 } //-- java.util.List<RepositoryGroupConfiguration> getRepositoryGroups()
382 * Get the repository scanning configuration.
384 * @return RepositoryScanningConfiguration
386 public RepositoryScanningConfiguration getRepositoryScanning()
388 return this.repositoryScanning;
389 } //-- RepositoryScanningConfiguration getRepositoryScanning()
392 * Get this is the version of the configuration format.
396 public String getVersion()
399 } //-- String getVersion()
402 * Get the webapp configuration.
404 * @return WebappConfiguration
406 public WebappConfiguration getWebapp()
409 } //-- WebappConfiguration getWebapp()
412 * Method removeLegacyArtifactPath.
414 * @param legacyArtifactPath
416 public void removeLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath )
418 getLegacyArtifactPaths().remove( legacyArtifactPath );
419 } //-- void removeLegacyArtifactPath( LegacyArtifactPath )
422 * Method removeManagedRepository.
424 * @param managedRepositoryConfiguration
426 public void removeManagedRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration )
428 getManagedRepositories().remove( managedRepositoryConfiguration );
429 } //-- void removeManagedRepository( ManagedRepositoryConfiguration )
432 * Method removeNetworkProxy.
434 * @param networkProxyConfiguration
436 public void removeNetworkProxy( NetworkProxyConfiguration networkProxyConfiguration )
438 getNetworkProxies().remove( networkProxyConfiguration );
439 } //-- void removeNetworkProxy( NetworkProxyConfiguration )
442 * Method removeProxyConnector.
444 * @param proxyConnectorConfiguration
446 public void removeProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration )
448 getProxyConnectors().remove( proxyConnectorConfiguration );
449 } //-- void removeProxyConnector( ProxyConnectorConfiguration )
452 * Method removeProxyConnectorRuleConfiguration.
454 * @param proxyConnectorRuleConfiguration
456 public void removeProxyConnectorRuleConfiguration( ProxyConnectorRuleConfiguration proxyConnectorRuleConfiguration )
458 getProxyConnectorRuleConfigurations().remove( proxyConnectorRuleConfiguration );
459 } //-- void removeProxyConnectorRuleConfiguration( ProxyConnectorRuleConfiguration )
462 * Method removeRemoteRepository.
464 * @param remoteRepositoryConfiguration
466 public void removeRemoteRepository( RemoteRepositoryConfiguration remoteRepositoryConfiguration )
468 getRemoteRepositories().remove( remoteRepositoryConfiguration );
469 } //-- void removeRemoteRepository( RemoteRepositoryConfiguration )
472 * Method removeRepositoryGroup.
474 * @param repositoryGroupConfiguration
476 public void removeRepositoryGroup( RepositoryGroupConfiguration repositoryGroupConfiguration )
478 getRepositoryGroups().remove( repositoryGroupConfiguration );
479 } //-- void removeRepositoryGroup( RepositoryGroupConfiguration )
482 * Set archiva default settings.
484 * @param archivaDefaultConfiguration
486 public void setArchivaDefaultConfiguration( ArchivaDefaultConfiguration archivaDefaultConfiguration )
488 this.archivaDefaultConfiguration = archivaDefaultConfiguration;
489 } //-- void setArchivaDefaultConfiguration( ArchivaDefaultConfiguration )
492 * Set the ArchivaRuntimeConfiguration.
494 * @param archivaRuntimeConfiguration
496 public void setArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
498 this.archivaRuntimeConfiguration = archivaRuntimeConfiguration;
499 } //-- void setArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration )
502 * Set the list of custom legacy path to artifact.
504 * @param legacyArtifactPaths
506 public void setLegacyArtifactPaths( java.util.List<LegacyArtifactPath> legacyArtifactPaths )
508 this.legacyArtifactPaths = legacyArtifactPaths;
509 } //-- void setLegacyArtifactPaths( java.util.List )
512 * Set the list of repositories that this archiva instance
515 * @param managedRepositories
517 public void setManagedRepositories( java.util.List<ManagedRepositoryConfiguration> managedRepositories )
519 this.managedRepositories = managedRepositories;
520 } //-- void setManagedRepositories( java.util.List )
523 * Set the type of the metadata storage. Allowed values: jcr,
526 * @param metadataStore
528 public void setMetadataStore( String metadataStore )
530 this.metadataStore = metadataStore;
531 } //-- void setMetadataStore( String )
534 * Set the modelEncoding field.
536 * @param modelEncoding
538 public void setModelEncoding( String modelEncoding )
540 this.modelEncoding = modelEncoding;
541 } //-- void setModelEncoding( String )
544 * Set the NetworkConfiguration .
546 * @param networkConfiguration
548 public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
550 this.networkConfiguration = networkConfiguration;
551 } //-- void setNetworkConfiguration( NetworkConfiguration )
554 * Set the list of network proxies to use for outgoing
557 * @param networkProxies
559 public void setNetworkProxies( java.util.List<NetworkProxyConfiguration> networkProxies )
561 this.networkProxies = networkProxies;
562 } //-- void setNetworkProxies( java.util.List )
565 * Set the organisation info.
567 * @param organisationInfo
569 public void setOrganisationInfo( OrganisationInformation organisationInfo )
571 this.organisationInfo = organisationInfo;
572 } //-- void setOrganisationInfo( OrganisationInformation )
575 * Set the list of ProxyConnectorRuleConfigurations.
577 * @param proxyConnectorRuleConfigurations
579 public void setProxyConnectorRuleConfigurations( java.util.List<ProxyConnectorRuleConfiguration> proxyConnectorRuleConfigurations )
581 this.proxyConnectorRuleConfigurations = proxyConnectorRuleConfigurations;
582 } //-- void setProxyConnectorRuleConfigurations( java.util.List )
585 * Set the list of proxy connectors for this archiva instance.
587 * @param proxyConnectors
589 public void setProxyConnectors( java.util.List<ProxyConnectorConfiguration> proxyConnectors )
591 this.proxyConnectors = proxyConnectors;
592 } //-- void setProxyConnectors( java.util.List )
595 * Set the RedbackRuntimeConfiguration.
597 * @param redbackRuntimeConfiguration
599 public void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
601 this.redbackRuntimeConfiguration = redbackRuntimeConfiguration;
602 } //-- void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration )
605 * Set the list of repositories that this archiva can retrieve
606 * from or publish to.
608 * @param remoteRepositories
610 public void setRemoteRepositories( java.util.List<RemoteRepositoryConfiguration> remoteRepositories )
612 this.remoteRepositories = remoteRepositories;
613 } //-- void setRemoteRepositories( java.util.List )
616 * Set the list of repository groups.
618 * @param repositoryGroups
620 public void setRepositoryGroups( java.util.List<RepositoryGroupConfiguration> repositoryGroups )
622 this.repositoryGroups = repositoryGroups;
623 } //-- void setRepositoryGroups( java.util.List )
626 * Set the repository scanning configuration.
628 * @param repositoryScanning
630 public void setRepositoryScanning( RepositoryScanningConfiguration repositoryScanning )
632 this.repositoryScanning = repositoryScanning;
633 } //-- void setRepositoryScanning( RepositoryScanningConfiguration )
636 * Set this is the version of the configuration format.
640 public void setVersion( String version )
642 this.version = version;
643 } //-- void setVersion( String )
646 * Set the webapp configuration.
650 public void setWebapp( WebappConfiguration webapp )
652 this.webapp = webapp;
653 } //-- void setWebapp( WebappConfiguration )
656 private java.util.Map<String, java.util.List<String>> repositoryToGroupMap;
658 public java.util.Map<String, java.util.List<String>> getRepositoryToGroupMap()
660 if ( repositoryGroups != null )
662 java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
664 for ( RepositoryGroupConfiguration group : (java.util.List<RepositoryGroupConfiguration>) repositoryGroups )
666 for ( String repositoryId : (java.util.List<String>) group.getRepositories() )
668 java.util.List<String> groups = map.get( repositoryId );
669 if ( groups == null )
671 groups = new java.util.ArrayList<String>();
672 map.put( repositoryId, groups );
674 groups.add( group.getId() );
678 repositoryToGroupMap = map;
680 return repositoryToGroupMap;
683 public java.util.Map<String, RepositoryGroupConfiguration> getRepositoryGroupsAsMap()
685 java.util.Map<String, RepositoryGroupConfiguration> map = new java.util.HashMap<String, RepositoryGroupConfiguration>();
686 if ( repositoryGroups != null )
688 for ( RepositoryGroupConfiguration group : (java.util.List<RepositoryGroupConfiguration>) repositoryGroups )
690 map.put( group.getId(), group );
696 public RepositoryGroupConfiguration findRepositoryGroupById( String id )
698 if ( repositoryGroups != null )
700 for ( RepositoryGroupConfiguration group : (java.util.List<RepositoryGroupConfiguration>) repositoryGroups )
702 if ( group.getId().equals( id ) )
711 private java.util.Map<String, java.util.List<String>> groupToRepositoryMap;
713 public java.util.Map<String, java.util.List<String>> getGroupToRepositoryMap()
715 if ( repositoryGroups != null && managedRepositories != null )
717 java.util.Map<String, java.util.List<String>> map = new java.util.HashMap<String, java.util.List<String>>();
719 for ( ManagedRepositoryConfiguration repo : (java.util.List<ManagedRepositoryConfiguration>) managedRepositories )
721 for ( RepositoryGroupConfiguration group : (java.util.List<RepositoryGroupConfiguration>) repositoryGroups )
723 if ( !group.getRepositories().contains( repo.getId() ) )
725 String groupId = group.getId();
726 java.util.List<String> repos = map.get( groupId );
729 repos = new java.util.ArrayList<String>();
730 map.put( groupId, repos );
732 repos.add( repo.getId() );
736 groupToRepositoryMap = map;
738 return groupToRepositoryMap;
742 public java.util.Map<String, NetworkProxyConfiguration> getNetworkProxiesAsMap()
744 java.util.Map<String, NetworkProxyConfiguration> map = new java.util.HashMap<String, NetworkProxyConfiguration>();
745 if ( networkProxies != null )
747 for ( java.util.Iterator<NetworkProxyConfiguration> i = networkProxies.iterator(); i.hasNext(); )
749 NetworkProxyConfiguration proxy = i.next();
750 map.put( proxy.getId(), proxy );
756 public java.util.Map<String, java.util.List<ProxyConnectorConfiguration>> getProxyConnectorAsMap()
758 java.util.Map<String, java.util.List<ProxyConnectorConfiguration>> proxyConnectorMap =
759 new java.util.HashMap<String, java.util.List<ProxyConnectorConfiguration>>();
761 if( proxyConnectors != null )
763 java.util.Iterator<ProxyConnectorConfiguration> it = proxyConnectors.iterator();
764 while ( it.hasNext() )
766 ProxyConnectorConfiguration proxyConfig = it.next();
767 String key = proxyConfig.getSourceRepoId();
769 java.util.List<ProxyConnectorConfiguration> connectors = proxyConnectorMap.get( key );
770 if ( connectors == null )
772 connectors = new java.util.ArrayList<ProxyConnectorConfiguration>();
773 proxyConnectorMap.put( key, connectors );
776 connectors.add( proxyConfig );
777 java.util.Collections.sort( connectors,
778 org.apache.archiva.configuration.functors.ProxyConnectorConfigurationOrderComparator.getInstance() );
782 return proxyConnectorMap;
785 public java.util.Map<String, RemoteRepositoryConfiguration> getRemoteRepositoriesAsMap()
787 java.util.Map<String, RemoteRepositoryConfiguration> map = new java.util.HashMap<String, RemoteRepositoryConfiguration>();
788 if ( remoteRepositories != null )
790 for ( java.util.Iterator<RemoteRepositoryConfiguration> i = remoteRepositories.iterator(); i.hasNext(); )
792 RemoteRepositoryConfiguration repo = i.next();
793 map.put( repo.getId(), repo );
799 public RemoteRepositoryConfiguration findRemoteRepositoryById( String id )
801 if ( remoteRepositories != null )
803 for ( java.util.Iterator<RemoteRepositoryConfiguration> i = remoteRepositories.iterator(); i.hasNext(); )
805 RemoteRepositoryConfiguration repo = i.next();
806 if ( repo.getId().equals( id ) )
815 public java.util.Map<String, ManagedRepositoryConfiguration> getManagedRepositoriesAsMap()
817 java.util.Map<String, ManagedRepositoryConfiguration> map = new java.util.HashMap<String, ManagedRepositoryConfiguration>();
818 if ( managedRepositories != null )
820 for ( java.util.Iterator<ManagedRepositoryConfiguration> i = managedRepositories.iterator(); i.hasNext(); )
822 ManagedRepositoryConfiguration repo = i.next();
823 map.put( repo.getId(), repo );
829 public ManagedRepositoryConfiguration findManagedRepositoryById( String id )
831 if ( managedRepositories != null )
833 for ( java.util.Iterator<ManagedRepositoryConfiguration> i = managedRepositories.iterator(); i.hasNext(); )
835 ManagedRepositoryConfiguration repo = i.next();
836 if ( repo.getId().equals( id ) )