1 package org.apache.archiva.repository.maven;
3 import org.apache.archiva.common.filelock.DefaultFileLockManager;
4 import org.apache.archiva.common.filelock.FileLockManager;
5 import org.apache.archiva.repository.ReleaseScheme;
6 import org.apache.archiva.repository.RemoteRepository;
7 import org.apache.archiva.repository.RepositoryCapabilities;
8 import org.apache.archiva.repository.RepositoryType;
9 import org.apache.archiva.repository.StandardCapabilities;
10 import org.apache.archiva.repository.UnsupportedFeatureException;
11 import org.apache.archiva.repository.base.AbstractRemoteRepository;
12 import org.apache.archiva.repository.features.IndexCreationFeature;
13 import org.apache.archiva.repository.features.RemoteIndexFeature;
14 import org.apache.archiva.repository.features.RepositoryFeature;
15 import org.apache.archiva.repository.storage.fs.FilesystemStorage;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 import java.io.IOException;
20 import java.nio.file.Path;
21 import java.util.Locale;
24 * Licensed to the Apache Software Foundation (ASF) under one
25 * or more contributor license agreements. See the NOTICE file
26 * distributed with this work for additional information
27 * regarding copyright ownership. The ASF licenses this file
28 * to you under the Apache License, Version 2.0 (the
29 * "License"); you may not use this file except in compliance
30 * with the License. You may obtain a copy of the License at
32 * http://www.apache.org/licenses/LICENSE-2.0
34 * Unless required by applicable law or agreed to in writing,
35 * software distributed under the License is distributed on an
36 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
37 * KIND, either express or implied. See the License for the
38 * specific language governing permissions and limitations
43 * Maven2 remote repository implementation
45 public class MavenRemoteRepository extends AbstractRemoteRepository
46 implements RemoteRepository
49 Logger log = LoggerFactory.getLogger(MavenRemoteRepository.class);
51 final private RemoteIndexFeature remoteIndexFeature = new RemoteIndexFeature();
52 final private IndexCreationFeature indexCreationFeature;
54 private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
55 new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
56 new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
58 new String[] {RemoteIndexFeature.class.getName(), IndexCreationFeature.class.getName()},
66 public MavenRemoteRepository(String id, String name, FilesystemStorage storage)
68 super( RepositoryType.MAVEN, id, name, storage );
69 this.indexCreationFeature = new IndexCreationFeature(this, this);
73 public MavenRemoteRepository( Locale primaryLocale, String id, String name, FilesystemStorage storage )
75 super( primaryLocale, RepositoryType.MAVEN, id, name, storage );
76 this.indexCreationFeature = new IndexCreationFeature(this, this);
80 public boolean hasIndex( )
82 return remoteIndexFeature.hasIndex();
86 public RepositoryCapabilities getCapabilities( )
91 @SuppressWarnings( "unchecked" )
93 public <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException
95 if (RemoteIndexFeature.class.equals( clazz )) {
96 return (RepositoryFeature<T>) remoteIndexFeature;
97 } else if (IndexCreationFeature.class.equals(clazz)) {
98 return (RepositoryFeature<T>) indexCreationFeature;
100 throw new UnsupportedFeatureException( );
105 public <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz )
107 if ( RemoteIndexFeature.class.equals(clazz) || IndexCreationFeature.class.equals(clazz)) {
115 public String toString() {
116 return super.toString()+", remoteIndexFeature="+remoteIndexFeature.toString()+", indexCreationFeature="+indexCreationFeature.toString();
119 public static MavenRemoteRepository newLocalInstance(String id, String name, Path basePath) throws IOException {
120 FileLockManager lockManager = new DefaultFileLockManager();
121 FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
122 return new MavenRemoteRepository(id, name, storage);