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
22 import org.apache.archiva.redback.components.registry.RegistryException;
23 import org.apache.archiva.redback.components.registry.RegistryListener;
24 import org.apache.commons.lang.StringUtils;
25 import org.springframework.stereotype.Service;
27 import java.nio.file.Path;
28 import java.nio.file.Paths;
29 import java.util.List;
30 import java.util.Locale;
32 @Service("archivaConfiguration#mocked")
33 public class StubConfiguration
34 implements ArchivaConfiguration
36 private Configuration configuration;
39 public Configuration getConfiguration()
45 public void save( Configuration configuration )
46 throws RegistryException, IndeterminateConfigurationException
48 this.configuration = configuration;
52 public boolean isDefaulted()
58 public void addListener( ConfigurationListener listener )
60 throw new UnsupportedOperationException();
64 public void removeListener( ConfigurationListener listener )
66 throw new UnsupportedOperationException();
70 public void addChangeListener( RegistryListener listener )
72 throw new UnsupportedOperationException();
76 public void removeChangeListener( RegistryListener listener )
78 throw new UnsupportedOperationException();
88 public Locale getDefaultLocale( )
90 return Locale.getDefault();
94 public List<Locale.LanguageRange> getLanguagePriorities( )
96 return Locale.LanguageRange.parse( "en,fr,de" );
100 public Path getAppServerBaseDir() {
101 if (System.getProperties().containsKey("appserver.base")) {
102 return Paths.get(System.getProperty("appserver.base"));
104 return Paths.get("");
109 public Path getRepositoryBaseDir() {
110 return getDataDirectory().resolve("repositories");
114 public Path getRemoteRepositoryBaseDir() {
115 return getDataDirectory().resolve("remotes");
119 public Path getRepositoryGroupBaseDir( )
121 return getDataDirectory().resolve("group");
125 public Path getDataDirectory() {
126 if (configuration!=null && StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
127 Path dataDir = Paths.get(configuration.getArchivaRuntimeConfiguration().getDataDirectory());
128 if (dataDir.isAbsolute()) {
131 return getAppServerBaseDir().resolve(dataDir);
134 return getAppServerBaseDir().resolve("data");