1package org.apache.archiva.repository.maven2;
23/*4 * Licensed to the Apache Software Foundation (ASF) under one5 * or more contributor license agreements. See the NOTICE file6 * distributed with this work for additional information7 * regarding copyright ownership. The ASF licenses this file8 * to you under the Apache License, Version 2.0 (the9 * "License"); you may not use this file except in compliance10 * with the License. You may obtain a copy of the License at11 *12 * http://www.apache.org/licenses/LICENSE-2.013 *14 * Unless required by applicable law or agreed to in writing,15 * software distributed under the License is distributed on an16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY17 * KIND, either express or implied. See the License for the18 * specific language governing permissions and limitations19 * under the License.20 */2122import org.apache.archiva.common.filelock.DefaultFileLockManager;
23import org.apache.archiva.common.filelock.FileLockManager;
24import org.apache.archiva.repository.*;
25import org.apache.archiva.repository.base.AbstractRepositoryGroup;
26import org.apache.archiva.repository.storage.FilesystemStorage;
27import org.apache.archiva.repository.features.IndexCreationFeature;
28import org.slf4j.Logger;
29import org.slf4j.LoggerFactory;
3031import java.io.IOException;
32import java.nio.file.Path;
33import java.util.Locale;
3435publicclassMavenRepositoryGroupextends AbstractRepositoryGroup implements EditableRepositoryGroup {
3637privatestaticfinal RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
38new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
39new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
40new String[] {},
41new String[] {IndexCreationFeature.class.getName()},
42 false,
43 false,
44 false,
45 false,
46 false
47 );
4849privatefinal Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class);
5051private IndexCreationFeature indexCreationFeature;
525354publicMavenRepositoryGroup(String id, String name, FilesystemStorage storage) {
55super(RepositoryType.MAVEN, id, name, storage);
56 init();
57 }
5859publicMavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) {
60super(primaryLocale, RepositoryType.MAVEN, id, name, storage);
61 init();
62 }
6364private Path getRepositoryPath() {
65return getStorage().getAsset("").getFilePath();
66 }
6768privatevoid init() {
69 setCapabilities(CAPABILITIES);
70this.indexCreationFeature = new IndexCreationFeature(this, this);
71 addFeature( this.indexCreationFeature );
72 }
7374publicstaticMavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException {
75 FileLockManager lockManager = new DefaultFileLockManager();
76 FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
77returnnewMavenRepositoryGroup(id, name, storage);
78 }
79 }