1package org.apache.archiva.repository.base;
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.ReleaseScheme;
25import org.apache.archiva.repository.RepositoryCapabilities;
26import org.apache.archiva.repository.RepositoryRequestInfo;
27import org.apache.archiva.repository.RepositoryType;
28import org.apache.archiva.repository.StandardCapabilities;
29import org.apache.archiva.repository.storage.FilesystemStorage;
30import org.apache.archiva.repository.storage.RepositoryStorage;
31import org.apache.archiva.repository.features.ArtifactCleanupFeature;
32import org.apache.archiva.repository.features.IndexCreationFeature;
33import org.apache.archiva.repository.features.StagingRepositoryFeature;
34import org.slf4j.Logger;
35import org.slf4j.LoggerFactory;
3637import java.io.IOException;
38import java.nio.file.Path;
39import java.util.Locale;
4041/**42 *43 * Just a helper class, mainly used for unit tests.44 *45 *46 */47publicclassBasicManagedRepositoryextendsAbstractManagedRepository4849 {
50 Logger log = LoggerFactory.getLogger(BasicManagedRepository.class);
51ArtifactCleanupFeatureture.html#ArtifactCleanupFeature">ArtifactCleanupFeature artifactCleanupFeature = newArtifactCleanupFeature( );
52StagingRepositoryFeaturere.html#StagingRepositoryFeature">StagingRepositoryFeature stagingRepositoryFeature = newStagingRepositoryFeature( );
5354staticfinalStandardCapabilitiesities.html#StandardCapabilities">StandardCapabilities CAPABILITIES = newStandardCapabilities( newReleaseScheme[] {
55 ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT
56 }, new String[] {"default"}, new String[0], new String[] {
57 ArtifactCleanupFeature.class.toString(), IndexCreationFeature.class.toString(),
58 StagingRepositoryFeature.class.toString()
59 }, true, true, true, true, true );
6061publicBasicManagedRepository( String id, String name, RepositoryStorage repositoryStorage )
62 {
63super( RepositoryType.MAVEN, id, name, repositoryStorage );
64 initFeatures();
65 }
6667publicBasicManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage repositoryStorage )
68 {
69super( primaryLocale, type, id, name, repositoryStorage);
70 initFeatures();
71 }
7273privatevoid initFeatures() {
74IndexCreationFeatureeature.html#IndexCreationFeature">IndexCreationFeature indexCreationFeature = newIndexCreationFeature(this, this);
75 addFeature( artifactCleanupFeature );
76 addFeature( indexCreationFeature );
77 addFeature( stagingRepositoryFeature );
78 }
7980 @Override
81publicboolean hasIndex( )
82 {
83returntrue;
84 }
8586 @Override
87publicRepositoryCapabilities getCapabilities( )
88 {
89return CAPABILITIES;
90 }
919293 @Override
94publicRepositoryRequestInfo getRequestInfo() {
95returnnull;
96 }
9798/**99 * Creates a filesystem based repository instance. The path is built by basePath/repository-id100 *101 * @param id The repository id102 * @param name The name of the repository103 * @param repositoryPath The path to the repository104 * @return The repository instance105 * @throws IOException106 */107publicstaticBasicManagedRepository newFilesystemInstance(String id, String name, Path repositoryPath) throws IOException {
108FileLockManager lockManager = newDefaultFileLockManager();
109FilesystemStorage/FilesystemStorage.html#FilesystemStorage">FilesystemStorage storage = newFilesystemStorage(repositoryPath, lockManager);
110returnnewBasicManagedRepository(id, name, storage);
111 }
112113 }