1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.repository.aether.internal; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import javax.inject.Inject; |
27 |
|
import javax.inject.Named; |
28 |
|
import javax.inject.Provider; |
29 |
|
import javax.inject.Singleton; |
30 |
|
|
31 |
|
import org.codehaus.plexus.PlexusContainer; |
32 |
|
import org.codehaus.plexus.component.repository.exception.ComponentLookupException; |
33 |
|
import org.eclipse.aether.RepositorySystem; |
34 |
|
import org.eclipse.aether.repository.RemoteRepository; |
35 |
|
import org.xwiki.component.annotation.Component; |
36 |
|
import org.xwiki.component.manager.ComponentManager; |
37 |
|
import org.xwiki.component.phase.Initializable; |
38 |
|
import org.xwiki.component.phase.InitializationException; |
39 |
|
import org.xwiki.extension.ExtensionManagerConfiguration; |
40 |
|
import org.xwiki.extension.repository.AbstractExtensionRepositoryFactory; |
41 |
|
import org.xwiki.extension.repository.ExtensionRepository; |
42 |
|
import org.xwiki.extension.repository.ExtensionRepositoryDescriptor; |
43 |
|
import org.xwiki.extension.repository.ExtensionRepositoryException; |
44 |
|
import org.xwiki.extension.repository.ExtensionRepositoryManager; |
45 |
|
|
46 |
|
|
47 |
|
@version |
48 |
|
@since |
49 |
|
|
50 |
|
@Component |
51 |
|
@Singleton |
52 |
|
@Named("maven") |
|
|
| 92.3% |
Uncovered Elements: 2 (26) |
Complexity: 8 |
Complexity Density: 0.44 |
|
53 |
|
public class AetherExtensionRepositoryFactory extends AbstractExtensionRepositoryFactory implements Initializable |
54 |
|
{ |
55 |
|
@Inject |
56 |
|
private ComponentManager componentManager; |
57 |
|
|
58 |
|
@Inject |
59 |
|
private Provider<PlexusContainer> plexusProvider; |
60 |
|
|
61 |
|
@Inject |
62 |
|
private ExtensionManagerConfiguration configuration; |
63 |
|
|
64 |
|
@Inject |
65 |
|
private Provider<ExtensionRepositoryManager> repositoryManagerProvider; |
66 |
|
|
67 |
|
private RepositorySystem repositorySystem; |
68 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
69 |
25 |
@Override... |
70 |
|
public void initialize() throws InitializationException |
71 |
|
{ |
72 |
25 |
try { |
73 |
25 |
this.repositorySystem = this.plexusProvider.get().lookup(RepositorySystem.class); |
74 |
|
} catch (ComponentLookupException e) { |
75 |
0 |
throw new InitializationException("Failed to lookup RepositorySystem", e); |
76 |
|
} |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
79 |
126 |
public XWikiRepositorySystemSession createRepositorySystemSession()... |
80 |
|
{ |
81 |
126 |
XWikiRepositorySystemSession session = new XWikiRepositorySystemSession(this.repositorySystem); |
82 |
|
|
83 |
126 |
session.setUserAgent(this.configuration.getUserAgent()); |
84 |
|
|
85 |
126 |
return session; |
86 |
|
} |
87 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
88 |
46 |
@Override... |
89 |
|
public ExtensionRepository createRepository(ExtensionRepositoryDescriptor repositoryDescriptor) |
90 |
|
throws ExtensionRepositoryException |
91 |
|
{ |
92 |
46 |
try { |
93 |
46 |
return new AetherExtensionRepository(repositoryDescriptor, this, this.plexusProvider.get(), |
94 |
|
this.componentManager); |
95 |
|
} catch (Exception e) { |
96 |
0 |
throw new ExtensionRepositoryException("Failed to create repository [" + repositoryDescriptor + "]", e); |
97 |
|
} |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
100 |
51 |
List<RemoteRepository> getAllMavenRepositories(RemoteRepository firstRepository)... |
101 |
|
{ |
102 |
51 |
Collection<ExtensionRepository> extensionRepositories = this.repositoryManagerProvider.get().getRepositories(); |
103 |
|
|
104 |
51 |
List<RemoteRepository> reposirories = new ArrayList<RemoteRepository>(extensionRepositories.size()); |
105 |
|
|
106 |
|
|
107 |
51 |
reposirories.add(firstRepository); |
108 |
|
|
109 |
|
|
110 |
51 |
for (ExtensionRepository extensionRepository : extensionRepositories) { |
111 |
92 |
if (extensionRepository instanceof AetherExtensionRepository) { |
112 |
90 |
RemoteRepository repository = ((AetherExtensionRepository) extensionRepository).getRemoteRepository(); |
113 |
|
|
114 |
90 |
if (firstRepository != repository) { |
115 |
39 |
reposirories.add(repository); |
116 |
|
} |
117 |
|
} |
118 |
|
} |
119 |
|
|
120 |
51 |
return reposirories; |
121 |
|
} |
122 |
|
} |