1 package org.apache.archiva.repository.maven.mock.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
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.components.registry.RegistryException;
22 import org.apache.archiva.components.registry.RegistryListener;
23 import org.apache.archiva.configuration.ArchivaConfiguration;
24 import org.apache.archiva.configuration.Configuration;
25 import org.apache.archiva.configuration.ConfigurationListener;
26 import org.apache.archiva.configuration.IndeterminateConfigurationException;
27 import org.apache.archiva.configuration.RepositoryScanningConfiguration;
28 import org.apache.commons.lang3.StringUtils;
29 import org.springframework.stereotype.Service;
31 import java.nio.file.Path;
32 import java.nio.file.Paths;
33 import java.util.List;
34 import java.util.Locale;
36 @Service("archivaConfiguration#mocked")
37 public class StubConfiguration
38 implements ArchivaConfiguration
40 private Configuration configuration = new Configuration();
43 configuration.setRepositoryScanning( new RepositoryScanningConfiguration() );
47 public Configuration getConfiguration()
53 public void save( Configuration configuration )
54 throws RegistryException, IndeterminateConfigurationException
56 this.configuration = configuration;
60 public boolean isDefaulted()
66 public void addListener( ConfigurationListener listener )
68 // throw new UnsupportedOperationException();
72 public void removeListener( ConfigurationListener listener )
74 throw new UnsupportedOperationException();
78 public void addChangeListener( RegistryListener listener )
80 // throw new UnsupportedOperationException();
84 public void removeChangeListener( RegistryListener listener )
86 throw new UnsupportedOperationException();
96 public Locale getDefaultLocale( )
98 return Locale.getDefault();
102 public List<Locale.LanguageRange> getLanguagePriorities( )
104 return Locale.LanguageRange.parse( "en,fr,de" );
108 public Path getAppServerBaseDir() {
109 if (System.getProperties().containsKey("appserver.base")) {
110 return Paths.get(System.getProperty("appserver.base"));
112 return Paths.get("");
117 public Path getRepositoryBaseDir() {
118 return getDataDirectory().resolve("repositories");
122 public Path getRemoteRepositoryBaseDir() {
123 return getDataDirectory().resolve("remotes");
127 public Path getRepositoryGroupBaseDir( )
129 return getDataDirectory().resolve("group");
133 public Path getDataDirectory() {
134 if (configuration!=null && configuration.getArchivaRuntimeConfiguration()!=null && StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
135 Path dataDir = Paths.get(configuration.getArchivaRuntimeConfiguration().getDataDirectory());
136 if (dataDir.isAbsolute()) {
139 return getAppServerBaseDir().resolve(dataDir);
142 return getAppServerBaseDir().resolve("data");