1 package org.apache.archiva.repository.maven.mock.configuration;
3 import org.apache.archiva.components.registry.RegistryException;
4 import org.apache.archiva.components.registry.RegistryListener;
5 import org.apache.archiva.configuration.ArchivaConfiguration;
6 import org.apache.archiva.configuration.Configuration;
7 import org.apache.archiva.configuration.ConfigurationListener;
8 import org.apache.archiva.configuration.IndeterminateConfigurationException;
9 import org.apache.commons.lang3.StringUtils;
10 import org.springframework.stereotype.Service;
12 import java.nio.file.Path;
13 import java.nio.file.Paths;
14 import java.util.List;
15 import java.util.Locale;
18 * Licensed to the Apache Software Foundation (ASF) under one
19 * or more contributor license agreements. See the NOTICE file
20 * distributed with this work for additional information
21 * regarding copyright ownership. The ASF licenses this file
22 * to you under the Apache License, Version 2.0 (the
23 * "License"); you may not use this file except in compliance
24 * with the License. You may obtain a copy of the License at
26 * http://www.apache.org/licenses/LICENSE-2.0
27 * Unless required by applicable law or agreed to in writing,
28 * software distributed under the License is distributed on an
29 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
30 * KIND, either express or implied. See the License for the
31 * specific language governing permissions and limitations
35 @Service("archivaConfiguration#test")
36 public class TestConfiguration
37 implements ArchivaConfiguration
39 private Configuration configuration;
42 public Configuration getConfiguration()
48 public void save( Configuration configuration )
49 throws RegistryException, IndeterminateConfigurationException
51 this.configuration = configuration;
55 public boolean isDefaulted()
61 public void addListener( ConfigurationListener listener )
67 public void removeListener( ConfigurationListener listener )
73 public void addChangeListener( RegistryListener listener )
79 public void removeChangeListener( RegistryListener listener )
91 public Locale getDefaultLocale( )
93 return Locale.getDefault();
97 public List<Locale.LanguageRange> getLanguagePriorities( )
99 return Locale.LanguageRange.parse("en,fr,de");
103 public Path getAppServerBaseDir() {
104 if (System.getProperties().containsKey("appserver.base")) {
105 return Paths.get(System.getProperty("appserver.base"));
107 return Paths.get("");
112 public Path getRepositoryBaseDir() {
113 return getDataDirectory().resolve("");
117 public Path getRemoteRepositoryBaseDir() {
118 return getDataDirectory().resolve("remotes");
122 public Path getRepositoryGroupBaseDir() {
123 return getDataDirectory().resolve("groups");
127 public Path getDataDirectory() {
128 if (configuration!=null && configuration.getArchivaRuntimeConfiguration()!=null &&
129 StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
130 return Paths.get(configuration.getArchivaRuntimeConfiguration().getDataDirectory());
132 return getAppServerBaseDir().resolve("data");