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 void save( Configuration configuration, String eventTag ) throws RegistryException, IndeterminateConfigurationException
57 this.configuration = configuration;
61 public boolean isDefaulted()
67 public void addListener( ConfigurationListener listener )
73 public void removeListener( ConfigurationListener listener )
79 public void addChangeListener( RegistryListener listener )
85 public void removeChangeListener( RegistryListener listener )
97 public Locale getDefaultLocale( )
99 return Locale.getDefault();
103 public List<Locale.LanguageRange> getLanguagePriorities( )
105 return Locale.LanguageRange.parse("en,fr,de");
109 public Path getAppServerBaseDir() {
110 if (System.getProperties().containsKey("appserver.base")) {
111 return Paths.get(System.getProperty("appserver.base"));
113 return Paths.get("");
118 public Path getRepositoryBaseDir() {
119 return getDataDirectory().resolve("");
123 public Path getRemoteRepositoryBaseDir() {
124 return getDataDirectory().resolve("remotes");
128 public Path getRepositoryGroupBaseDir() {
129 return getDataDirectory().resolve("groups");
133 public Path getDataDirectory() {
134 if (configuration!=null && configuration.getArchivaRuntimeConfiguration()!=null &&
135 StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
136 return Paths.get(configuration.getArchivaRuntimeConfiguration().getDataDirectory());
138 return getAppServerBaseDir().resolve("data");