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 void save( Configuration configuration, String eventTag ) throws RegistryException, IndeterminateConfigurationException
62 this.configuration = configuration;
66 public boolean isDefaulted()
72 public void addListener( ConfigurationListener listener )
74 // throw new UnsupportedOperationException();
78 public void removeListener( ConfigurationListener listener )
80 throw new UnsupportedOperationException();
84 public void addChangeListener( RegistryListener listener )
86 // throw new UnsupportedOperationException();
90 public void removeChangeListener( RegistryListener listener )
92 throw new UnsupportedOperationException();
102 public Locale getDefaultLocale( )
104 return Locale.getDefault();
108 public List<Locale.LanguageRange> getLanguagePriorities( )
110 return Locale.LanguageRange.parse( "en,fr,de" );
114 public Path getAppServerBaseDir() {
115 if (System.getProperties().containsKey("appserver.base")) {
116 return Paths.get(System.getProperty("appserver.base"));
118 return Paths.get("");
123 public Path getRepositoryBaseDir() {
124 return getDataDirectory().resolve("repositories");
128 public Path getRemoteRepositoryBaseDir() {
129 return getDataDirectory().resolve("remotes");
133 public Path getRepositoryGroupBaseDir( )
135 return getDataDirectory().resolve("group");
139 public Path getDataDirectory() {
140 if (configuration!=null && configuration.getArchivaRuntimeConfiguration()!=null && StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
141 Path dataDir = Paths.get(configuration.getArchivaRuntimeConfiguration().getDataDirectory());
142 if (dataDir.isAbsolute()) {
145 return getAppServerBaseDir().resolve(dataDir);
148 return getAppServerBaseDir().resolve("data");