This project has retired. For details please refer to its Attic page.
BasicManagedRepository xref
View Javadoc
1   package org.apache.archiva.repository.base;
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.ReleaseScheme;
25  import org.apache.archiva.repository.RepositoryCapabilities;
26  import org.apache.archiva.repository.RepositoryRequestInfo;
27  import org.apache.archiva.repository.RepositoryType;
28  import org.apache.archiva.repository.StandardCapabilities;
29  import org.apache.archiva.repository.storage.FilesystemStorage;
30  import org.apache.archiva.repository.storage.RepositoryStorage;
31  import org.apache.archiva.repository.features.ArtifactCleanupFeature;
32  import org.apache.archiva.repository.features.IndexCreationFeature;
33  import org.apache.archiva.repository.features.StagingRepositoryFeature;
34  import org.slf4j.Logger;
35  import org.slf4j.LoggerFactory;
36  
37  import java.io.IOException;
38  import java.nio.file.Path;
39  import java.util.Locale;
40  
41  /**
42   *
43   * Just a helper class, mainly used for unit tests.
44   *
45   *
46   */
47  public class BasicManagedRepository extends AbstractManagedRepository
48  
49  {
50      Logger log = LoggerFactory.getLogger(BasicManagedRepository.class);
51      ArtifactCleanupFeatureture.html#ArtifactCleanupFeature">ArtifactCleanupFeature artifactCleanupFeature = new ArtifactCleanupFeature(  );
52      StagingRepositoryFeaturere.html#StagingRepositoryFeature">StagingRepositoryFeature stagingRepositoryFeature = new StagingRepositoryFeature( );
53  
54      static final StandardCapabilitiesities.html#StandardCapabilities">StandardCapabilities CAPABILITIES = new StandardCapabilities( new ReleaseScheme[] {
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  );
60  
61      public BasicManagedRepository( String id, String name, RepositoryStorage repositoryStorage )
62      {
63          super( RepositoryType.MAVEN, id, name, repositoryStorage );
64          initFeatures();
65      }
66  
67      public BasicManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage repositoryStorage )
68      {
69          super( primaryLocale, type, id, name, repositoryStorage);
70          initFeatures();
71      }
72  
73      private void initFeatures() {
74          IndexCreationFeatureeature.html#IndexCreationFeature">IndexCreationFeature indexCreationFeature = new IndexCreationFeature(this, this);
75          addFeature( artifactCleanupFeature );
76          addFeature( indexCreationFeature );
77          addFeature( stagingRepositoryFeature );
78      }
79  
80      @Override
81      public boolean hasIndex( )
82      {
83          return true;
84      }
85  
86      @Override
87      public RepositoryCapabilities getCapabilities( )
88      {
89          return CAPABILITIES;
90      }
91  
92  
93      @Override
94      public RepositoryRequestInfo getRequestInfo() {
95          return null;
96      }
97  
98      /**
99       * Creates a filesystem based repository instance. The path is built by basePath/repository-id
100      *
101      * @param id The repository id
102      * @param name The name of the repository
103      * @param repositoryPath The path to the repository
104      * @return The repository instance
105      * @throws IOException
106      */
107     public static BasicManagedRepository newFilesystemInstance(String id, String name, Path repositoryPath) throws IOException {
108         FileLockManager lockManager = new DefaultFileLockManager();
109         FilesystemStorage/FilesystemStorage.html#FilesystemStorage">FilesystemStorage storage = new FilesystemStorage(repositoryPath, lockManager);
110         return new BasicManagedRepository(id, name, storage);
111     }
112 
113 }