001package org.apache.archiva.configuration; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.util.ArrayList; 023import java.util.Arrays; 024import java.util.List; 025 026/** 027 * 028 * The runtime configuration. 029 * 030 * 031 * @version $Revision$ $Date$ 032 */ 033@SuppressWarnings( "all" ) 034public class ArchivaRuntimeConfiguration 035 implements java.io.Serializable 036{ 037 038 //--------------------------/ 039 //- Class/Member Variables -/ 040 //--------------------------/ 041 042 /** 043 * the url failure cache configuration. 044 */ 045 private CacheConfiguration urlFailureCacheConfiguration; 046 047 /** 048 * the FileLocking configuration. 049 */ 050 private FileLockConfiguration fileLockConfiguration; 051 052 /** 053 * The base directory where the archiva data is stored. If not 054 * set, the appserver.base is used. 055 */ 056 private String dataDirectory; 057 058 /** 059 * The base directory for local storage of repository data. If 060 * not set, it's ${dataDirectory}/repositories. 061 */ 062 private String repositoryBaseDirectory; 063 064 /** 065 * The base directory for local storage of remote repository 066 * data. If not set, it's ${dataDirectory}/remotes. 067 */ 068 private String remoteRepositoryBaseDirectory; 069 070 /** 071 * The base directory for local storage of repository group files. 072 * If not set, it's ${dataDirectory}/groups 073 */ 074 private String repositoryGroupBaseDirectory; 075 076 /** 077 * The default language used for setting internationalized 078 * strings. 079 */ 080 private String defaultLanguage = "en-US"; 081 082 /** 083 * Comma separated list of language patterns. Sorted by 084 * priority descending. Used for display of internationalized 085 * strings. 086 */ 087 private String languageRange = "en,fr,de"; 088 089 /** 090 * List of checksum types (algorithms) that should be applied to repository artifacts. 091 */ 092 private List<String> checksumTypes = new ArrayList(Arrays.asList("MD5","SHA1","SHA256")); 093 094 095 //-----------/ 096 //- Methods -/ 097 //-----------/ 098 099 /** 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}