001package org.apache.archiva.repository.maven2; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.common.filelock.DefaultFileLockManager; 023import org.apache.archiva.common.filelock.FileLockManager; 024import org.apache.archiva.repository.*; 025import org.apache.archiva.repository.base.AbstractRepositoryGroup; 026import org.apache.archiva.repository.storage.FilesystemStorage; 027import org.apache.archiva.repository.features.IndexCreationFeature; 028import org.slf4j.Logger; 029import org.slf4j.LoggerFactory; 030 031import java.io.IOException; 032import java.nio.file.Path; 033import java.util.Locale; 034 035public class MavenRepositoryGroup extends AbstractRepositoryGroup implements EditableRepositoryGroup { 036 037 private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities( 038 new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT }, 039 new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT}, 040 new String[] {}, 041 new String[] {IndexCreationFeature.class.getName()}, 042 false, 043 false, 044 false, 045 false, 046 false 047 ); 048 049 private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class); 050 051 private IndexCreationFeature indexCreationFeature; 052 053 054 public MavenRepositoryGroup(String id, String name, FilesystemStorage storage) { 055 super(RepositoryType.MAVEN, id, name, storage); 056 init(); 057 } 058 059 public MavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) { 060 super(primaryLocale, RepositoryType.MAVEN, id, name, storage); 061 init(); 062 } 063 064 private Path getRepositoryPath() { 065 return getStorage().getAsset("").getFilePath(); 066 } 067 068 private void init() { 069 setCapabilities(CAPABILITIES); 070 this.indexCreationFeature = new IndexCreationFeature(this, this); 071 addFeature( this.indexCreationFeature ); 072 } 073 074 public static MavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException { 075 FileLockManager lockManager = new DefaultFileLockManager(); 076 FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager); 077 return new MavenRepositoryGroup(id, name, storage); 078 } 079}