1 package org.apache.archiva.repository.maven;
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
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.common.filelock.DefaultFileLockManager;
23 import org.apache.archiva.common.filelock.FileLockManager;
24 import org.apache.archiva.repository.EditableRepositoryGroup;
25 import org.apache.archiva.repository.ReleaseScheme;
26 import org.apache.archiva.repository.RepositoryCapabilities;
27 import org.apache.archiva.repository.RepositoryType;
28 import org.apache.archiva.repository.StandardCapabilities;
29 import org.apache.archiva.repository.base.AbstractRepositoryGroup;
30 import org.apache.archiva.repository.features.IndexCreationFeature;
31 import org.apache.archiva.repository.storage.fs.FilesystemStorage;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 import java.io.IOException;
36 import java.nio.file.Path;
37 import java.util.Locale;
39 public class MavenRepositoryGroup extends AbstractRepositoryGroup implements EditableRepositoryGroup {
41 private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
42 new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
43 new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
45 new String[] {IndexCreationFeature.class.getName()},
53 private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class);
55 private IndexCreationFeature indexCreationFeature;
58 public MavenRepositoryGroup(String id, String name, FilesystemStorage storage) {
59 super(RepositoryType.MAVEN, id, name, storage);
63 public MavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) {
64 super(primaryLocale, RepositoryType.MAVEN, id, name, storage);
68 private Path getRepositoryPath() {
69 return getStorage().getRoot().getFilePath();
73 setCapabilities(CAPABILITIES);
74 this.indexCreationFeature = new IndexCreationFeature(this, this);
75 addFeature( this.indexCreationFeature );
78 public static MavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException {
79 FileLockManager lockManager = new DefaultFileLockManager();
80 FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
81 return new MavenRepositoryGroup(id, name, storage);