This project has retired. For details please refer to its Attic page.
MavenRepositoryGroup xref
View Javadoc
1   package org.apache.archiva.repository.maven2;
2   
3   /*
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
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
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
19   * under the License.
20   */
21  
22  import org.apache.archiva.common.filelock.DefaultFileLockManager;
23  import org.apache.archiva.common.filelock.FileLockManager;
24  import org.apache.archiva.repository.*;
25  import org.apache.archiva.repository.base.AbstractRepositoryGroup;
26  import org.apache.archiva.repository.storage.FilesystemStorage;
27  import org.apache.archiva.repository.features.IndexCreationFeature;
28  import org.slf4j.Logger;
29  import org.slf4j.LoggerFactory;
30  
31  import java.io.IOException;
32  import java.nio.file.Path;
33  import java.util.Locale;
34  
35  public class MavenRepositoryGroup extends AbstractRepositoryGroup implements EditableRepositoryGroup {
36  
37      private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
38              new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
39              new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT},
40              new String[] {},
41              new String[] {IndexCreationFeature.class.getName()},
42              false,
43              false,
44              false,
45              false,
46              false
47      );
48  
49      private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class);
50  
51      private IndexCreationFeature indexCreationFeature;
52  
53  
54      public MavenRepositoryGroup(String id, String name, FilesystemStorage storage) {
55          super(RepositoryType.MAVEN, id, name, storage);
56          init();
57      }
58  
59      public MavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) {
60          super(primaryLocale, RepositoryType.MAVEN, id, name, storage);
61          init();
62      }
63  
64      private Path getRepositoryPath() {
65          return getStorage().getAsset("").getFilePath();
66      }
67  
68      private void init() {
69          setCapabilities(CAPABILITIES);
70          this.indexCreationFeature = new IndexCreationFeature(this, this);
71          addFeature( this.indexCreationFeature );
72      }
73  
74      public static MavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException {
75          FileLockManager lockManager = new DefaultFileLockManager();
76          FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
77          return new MavenRepositoryGroup(id, name, storage);
78      }
79  }