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.Registry;
22 import org.apache.archiva.components.registry.RegistryException;
23 import org.apache.archiva.components.registry.RegistryListener;
24 import org.apache.archiva.configuration.ArchivaConfiguration;
25 import org.apache.archiva.configuration.Configuration;
26 import org.apache.archiva.configuration.ConfigurationListener;
27 import org.apache.archiva.configuration.IndeterminateConfigurationException;
28 import org.apache.archiva.configuration.RepositoryScanningConfiguration;
29 import org.apache.commons.lang3.StringUtils;
30 import org.springframework.stereotype.Service;
32 import java.nio.file.Path;
33 import java.nio.file.Paths;
34 import java.util.List;
35 import java.util.Locale;
37 @Service("archivaConfiguration#mocked")
38 public class StubConfiguration
39 implements ArchivaConfiguration
41 private Configuration configuration = new Configuration();
44 configuration.setRepositoryScanning( new RepositoryScanningConfiguration() );
48 public Configuration getConfiguration()
54 public void save( Configuration configuration )
55 throws RegistryException, IndeterminateConfigurationException
57 this.configuration = configuration;
61 public void save( Configuration configuration, String eventTag ) throws RegistryException, IndeterminateConfigurationException
63 this.configuration = configuration;
67 public boolean isDefaulted()
73 public void addListener( ConfigurationListener listener )
75 // throw new UnsupportedOperationException();
79 public void removeListener( ConfigurationListener listener )
81 throw new UnsupportedOperationException();
85 public void addChangeListener( RegistryListener listener )
87 // throw new UnsupportedOperationException();
91 public void removeChangeListener( RegistryListener listener )
93 throw new UnsupportedOperationException();
103 public Locale getDefaultLocale( )
105 return Locale.getDefault();
109 public List<Locale.LanguageRange> getLanguagePriorities( )
111 return Locale.LanguageRange.parse( "en,fr,de" );
115 public Path getAppServerBaseDir() {
116 if (System.getProperties().containsKey("appserver.base")) {
117 return Paths.get(System.getProperty("appserver.base"));
119 return Paths.get("");
124 public Path getRepositoryBaseDir() {
125 return getDataDirectory().resolve("repositories");
129 public Path getRemoteRepositoryBaseDir() {
130 return getDataDirectory().resolve("remotes");
134 public Path getRepositoryGroupBaseDir( )
136 return getDataDirectory().resolve("group");
140 public Path getDataDirectory() {
141 if (configuration!=null && configuration.getArchivaRuntimeConfiguration()!=null && StringUtils.isNotEmpty(configuration.getArchivaRuntimeConfiguration().getDataDirectory())) {
142 Path dataDir = Paths.get(configuration.getArchivaRuntimeConfiguration().getDataDirectory());
143 if (dataDir.isAbsolute()) {
146 return getAppServerBaseDir().resolve(dataDir);
149 return getAppServerBaseDir().resolve("data");
155 public Registry getRegistry( )