This project has retired. For details please refer to its Attic page.
ArchivaRuntimeConfiguration xref
View Javadoc
1   package org.apache.archiva.configuration;
2   
3   /*
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
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import java.util.ArrayList;
23  import java.util.Arrays;
24  import java.util.List;
25  
26  /**
27   * 
28   *         The runtime configuration.
29   *       
30   * 
31   * @version $Revision$ $Date$
32   */
33  @SuppressWarnings( "all" )
34  public class ArchivaRuntimeConfiguration
35      implements java.io.Serializable
36  {
37  
38        //--------------------------/
39       //- Class/Member Variables -/
40      //--------------------------/
41  
42      /**
43       * the url failure cache configuration.
44       */
45      private CacheConfiguration urlFailureCacheConfiguration;
46  
47      /**
48       * the FileLocking configuration.
49       */
50      private FileLockConfiguration fileLockConfiguration;
51  
52      /**
53       * The base directory where the archiva data is stored. If not
54       * set, the appserver.base is used.
55       */
56      private String dataDirectory;
57  
58      /**
59       * The base directory for local storage of repository data. If
60       * not set, it's ${dataDirectory}/repositories.
61       */
62      private String repositoryBaseDirectory;
63  
64      /**
65       * The base directory for local storage of remote repository
66       * data. If not set, it's ${dataDirectory}/remotes.
67       */
68      private String remoteRepositoryBaseDirectory;
69  
70      /**
71       * The base directory for local storage of repository group files.
72       * If not set, it's ${dataDirectory}/groups
73       */
74      private String repositoryGroupBaseDirectory;
75  
76      /**
77       * The default language used for setting internationalized
78       * strings.
79       */
80      private String defaultLanguage = "en-US";
81  
82      /**
83       * Comma separated list of language patterns. Sorted by
84       * priority descending. Used for display of internationalized
85       * strings.
86       */
87      private String languageRange = "en,fr,de";
88  
89      /**
90       * List of checksum types (algorithms) that should be applied to repository artifacts.
91       */
92      private List<String> checksumTypes = new ArrayList(Arrays.asList("MD5","SHA1","SHA256"));
93  
94  
95        //-----------/
96       //- Methods -/
97      //-----------/
98  
99      /**
100      * Get the base directory where the archiva data is stored. If
101      * not set, the appserver.base is used.
102      * 
103      * @return String
104      */
105     public String getDataDirectory()
106     {
107         return this.dataDirectory;
108     } //-- String getDataDirectory()
109 
110     /**
111      * Get the default language used for setting internationalized
112      * strings.
113      * 
114      * @return String
115      */
116     public String getDefaultLanguage()
117     {
118         return this.defaultLanguage;
119     } //-- String getDefaultLanguage()
120 
121     /**
122      * Get the FileLocking configuration.
123      * 
124      * @return FileLockConfiguration
125      */
126     public FileLockConfiguration getFileLockConfiguration()
127     {
128         return this.fileLockConfiguration;
129     } //-- FileLockConfiguration getFileLockConfiguration()
130 
131     /**
132      * Get comma separated list of language patterns. Sorted by
133      * priority descending. Used for display of internationalized
134      * strings.
135      * 
136      * @return String
137      */
138     public String getLanguageRange()
139     {
140         return this.languageRange;
141     } //-- String getLanguageRange()
142 
143     /**
144      * Get the base directory for local storage of remote
145      * repository data. If not set, it's ${dataDirectory}/remotes.
146      * 
147      * @return String
148      */
149     public String getRemoteRepositoryBaseDirectory()
150     {
151         return this.remoteRepositoryBaseDirectory;
152     } //-- String getRemoteRepositoryBaseDirectory()
153 
154     /**
155      * Get the base directory for local storage of repository data.
156      * If not set, it's ${dataDirectory}/repositories.
157      * 
158      * @return String
159      */
160     public String getRepositoryBaseDirectory()
161     {
162         return this.repositoryBaseDirectory;
163     } //-- String getRepositoryBaseDirectory()
164 
165     /**
166      * Get the base directory for local storage of repository group data.
167      * If not set it's ${dataDirectory}/groups
168      *
169      * @return The path to the directory. Either a absolute path, or a path
170      * relative to ${dataDirectory}
171      */
172     public String getRepositoryGroupBaseDirectory() {
173         return this.repositoryGroupBaseDirectory;
174     }
175 
176     /**
177      * Get the url failure cache configuration.
178      * 
179      * @return CacheConfiguration
180      */
181     public CacheConfiguration getUrlFailureCacheConfiguration()
182     {
183         return this.urlFailureCacheConfiguration;
184     } //-- CacheConfiguration getUrlFailureCacheConfiguration()
185 
186     /**
187      * Set the base directory where the archiva data is stored. If
188      * not set, the appserver.base is used.
189      * 
190      * @param dataDirectory
191      */
192     public void setDataDirectory( String dataDirectory )
193     {
194         this.dataDirectory = dataDirectory;
195     } //-- void setDataDirectory( String )
196 
197     /**
198      * Set the default language used for setting internationalized
199      * strings.
200      * 
201      * @param defaultLanguage
202      */
203     public void setDefaultLanguage( String defaultLanguage )
204     {
205         this.defaultLanguage = defaultLanguage;
206     } //-- void setDefaultLanguage( String )
207 
208     /**
209      * Set the FileLocking configuration.
210      * 
211      * @param fileLockConfiguration
212      */
213     public void setFileLockConfiguration( FileLockConfiguration fileLockConfiguration )
214     {
215         this.fileLockConfiguration = fileLockConfiguration;
216     } //-- void setFileLockConfiguration( FileLockConfiguration )
217 
218     /**
219      * Set comma separated list of language patterns. Sorted by
220      * priority descending. Used for display of internationalized
221      * strings.
222      * 
223      * @param languageRange
224      */
225     public void setLanguageRange( String languageRange )
226     {
227         this.languageRange = languageRange;
228     } //-- void setLanguageRange( String )
229 
230     /**
231      * Set the base directory for local storage of remote
232      * repository data. If not set, it's ${dataDirectory}/remotes.
233      * 
234      * @param remoteRepositoryBaseDirectory
235      */
236     public void setRemoteRepositoryBaseDirectory( String remoteRepositoryBaseDirectory )
237     {
238         this.remoteRepositoryBaseDirectory = remoteRepositoryBaseDirectory;
239     } //-- void setRemoteRepositoryBaseDirectory( String )
240 
241     /**
242      * Set the base directory for local storage of repository data.
243      * If not set, it's ${dataDirectory}/repositories.
244      * 
245      * @param repositoryBaseDirectory
246      */
247     public void setRepositoryBaseDirectory( String repositoryBaseDirectory )
248     {
249         this.repositoryBaseDirectory = repositoryBaseDirectory;
250     } //-- void setRepositoryBaseDirectory( String )
251 
252 
253     public void setRepositoryGroupBaseDirectory(String repositoryGroupBaseDirectory) {
254         this.repositoryGroupBaseDirectory = repositoryGroupBaseDirectory;
255     }
256 
257     /**
258      * Set the url failure cache configuration.
259      * 
260      * @param urlFailureCacheConfiguration
261      */
262     public void setUrlFailureCacheConfiguration( CacheConfiguration urlFailureCacheConfiguration )
263     {
264         this.urlFailureCacheConfiguration = urlFailureCacheConfiguration;
265     } //-- void setUrlFailureCacheConfiguration( CacheConfiguration )
266 
267 
268     /**
269      * Returns the list of checksum types to generate
270      * @return
271      */
272     public List<String> getChecksumTypes()
273     {
274         if ( this.checksumTypes == null )
275         {
276             this.checksumTypes = new java.util.ArrayList<String>();
277         }
278 
279         return this.checksumTypes;
280     }
281 
282     /**
283      * Adds a checksum type
284      * @param type
285      */
286     public void addChecksumType(String type) {
287 
288         if (!getChecksumTypes().contains(type)) {
289             getChecksumTypes().add(type);
290         }
291     }
292 
293     /**
294      * Removes a checksum type
295      * @param type
296      */
297     public void removeChecksumType(String type) {
298         getChecksumTypes().remove(type);
299     }
300 
301     /**
302      * Set all checksum types
303      * @param checksumTypes
304      */
305     public void setChecksumTypes(List<String> checksumTypes) {
306         if (checksumTypes!=null) {
307             getChecksumTypes().clear();
308             getChecksumTypes().addAll(checksumTypes);
309         }
310     }
311 
312 }