This project has retired. For details please refer to its
Attic page.
MavenManagedRepository xref
1 package org.apache.archiva.repository.maven2;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.archiva.common.filelock.DefaultFileLockManager;
23 import org.apache.archiva.common.filelock.FileLockManager;
24 import org.apache.archiva.indexer.ArchivaIndexingContext;
25 import org.apache.archiva.repository.*;
26 import org.apache.archiva.repository.base.AbstractManagedRepository;
27 import org.apache.archiva.repository.storage.FilesystemStorage;
28 import org.apache.archiva.repository.content.maven2.MavenRepositoryRequestInfo;
29 import org.apache.archiva.repository.features.ArtifactCleanupFeature;
30 import org.apache.archiva.repository.features.IndexCreationFeature;
31 import org.apache.archiva.repository.features.RepositoryFeature;
32 import org.apache.archiva.repository.features.StagingRepositoryFeature;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
35
36 import java.io.IOException;
37 import java.nio.file.Path;
38 import java.util.Locale;
39
40
41
42
43 public class MavenManagedRepository extends AbstractManagedRepository
44 {
45
46 private static final Logger log = LoggerFactory.getLogger( MavenManagedRepository.class );
47
48 public static final String DEFAULT_LAYOUT = "default";
49 public static final String LEGACY_LAYOUT = "legacy";
50 private ArtifactCleanupFeatureture.html#ArtifactCleanupFeature">ArtifactCleanupFeature artifactCleanupFeature = new ArtifactCleanupFeature( );
51 private IndexCreationFeature indexCreationFeature;
52 private StagingRepositoryFeaturere.html#StagingRepositoryFeature">StagingRepositoryFeature stagingRepositoryFeature = new StagingRepositoryFeature( );
53
54
55
56 private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities(
57 new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT },
58 new String[] { DEFAULT_LAYOUT, LEGACY_LAYOUT},
59 new String[] {},
60 new String[] {ArtifactCleanupFeature.class.getName(), IndexCreationFeature.class.getName(),
61 StagingRepositoryFeature.class.getName()},
62 true,
63 true,
64 true,
65 true,
66 false
67 );
68
69 public MavenManagedRepository(String id, String name, FilesystemStorage storage)
70 {
71
72 super( RepositoryType.MAVEN, id, name, storage);
73 this.indexCreationFeature = new IndexCreationFeature(this, this);
74 setLocation(storage.getAsset("").getFilePath().toUri());
75 }
76
77 public MavenManagedRepository( Locale primaryLocale, String id, String name, FilesystemStorage storage )
78 {
79 super( primaryLocale, RepositoryType.MAVEN, id, name, storage );
80 setLocation(storage.getAsset("").getFilePath().toUri());
81 }
82
83 @Override
84 public RepositoryCapabilities getCapabilities( )
85 {
86 return CAPABILITIES;
87 }
88
89
90 @SuppressWarnings( "unchecked" )
91 @Override
92 public <T extends RepositoryFeature<T>> RepositoryFeature<T> getFeature( Class<T> clazz ) throws UnsupportedFeatureException
93 {
94 if (ArtifactCleanupFeature.class.equals( clazz ))
95 {
96 return (RepositoryFeature<T>) artifactCleanupFeature;
97 } else if (IndexCreationFeature.class.equals(clazz)) {
98 return (RepositoryFeature<T>) indexCreationFeature;
99 } else if (StagingRepositoryFeature.class.equals(clazz)) {
100 return (RepositoryFeature<T>) stagingRepositoryFeature;
101 } else {
102 throw new UnsupportedFeatureException( );
103 }
104 }
105
106 @Override
107 public <T extends RepositoryFeature<T>> boolean supportsFeature( Class<T> clazz )
108 {
109 if (ArtifactCleanupFeature.class.equals(clazz) ||
110 IndexCreationFeature.class.equals(clazz) ||
111 StagingRepositoryFeature.class.equals(clazz)) {
112 return true;
113 }
114 return false;
115 }
116
117 @Override
118 public boolean hasIndex( )
119 {
120 return indexCreationFeature.hasIndex();
121 }
122
123 @Override
124 public RepositoryRequestInfo getRequestInfo() {
125 return new MavenRepositoryRequestInfo(this);
126 }
127
128 public static MavenManagedRepository newLocalInstance(String id, String name, Path basePath) throws IOException {
129 FileLockManager lockManager = new DefaultFileLockManager();
130 FilesystemStorage/FilesystemStorage.html#FilesystemStorage">FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
131 return new MavenManagedRepository(id, name, storage);
132 }
133
134 @Override
135 public void setIndexingContext(ArchivaIndexingContext context) {
136 super.setIndexingContext(context);
137 }
138
139 }