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; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Inject; |
26 |
|
|
27 |
|
import org.xwiki.extension.Extension; |
28 |
|
import org.xwiki.extension.ExtensionDependency; |
29 |
|
import org.xwiki.extension.ExtensionId; |
30 |
|
import org.xwiki.extension.ResolveException; |
31 |
|
import org.xwiki.extension.repository.internal.RepositoryUtils; |
32 |
|
import org.xwiki.extension.repository.result.IterableResult; |
33 |
|
import org.xwiki.extension.repository.search.ExtensionQuery; |
34 |
|
import org.xwiki.extension.repository.search.ExtensionQuery.COMPARISON; |
35 |
|
import org.xwiki.extension.repository.search.ExtensionQuery.Filter; |
36 |
|
import org.xwiki.extension.repository.search.SearchException; |
37 |
|
import org.xwiki.extension.version.Version; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
@version |
44 |
|
@since |
45 |
|
|
|
|
| 21.4% |
Uncovered Elements: 22 (28) |
Complexity: 11 |
Complexity Density: 0.65 |
|
46 |
|
public abstract class AbstractFilteredExtensionRepository extends AbstractAdvancedSearchableExtensionRepository |
47 |
|
{ |
48 |
|
@Inject |
49 |
|
private ExtensionRepositoryManager repositories; |
50 |
|
|
51 |
|
private List<Filter> filters = new ArrayList<>(); |
52 |
|
|
53 |
|
|
54 |
|
@param |
55 |
|
@param |
56 |
|
@param |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
1 |
public void addFilter(String field, Object value, COMPARISON comparison)... |
59 |
|
{ |
60 |
1 |
this.filters.add(new Filter(field, value, comparison)); |
61 |
|
} |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
63 |
0 |
@Override... |
64 |
|
public Extension resolve(ExtensionId extensionId) throws ResolveException |
65 |
|
{ |
66 |
0 |
for (ExtensionRepository remoteRepository : this.repositories.getRepositories()) { |
67 |
0 |
Extension extension = remoteRepository.resolve(extensionId); |
68 |
|
|
69 |
0 |
if (extension != null && RepositoryUtils.matches(this.filters, extension)) { |
70 |
0 |
return extension; |
71 |
|
} |
72 |
|
} |
73 |
|
|
74 |
0 |
return null; |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
77 |
0 |
@Override... |
78 |
|
public Extension resolve(ExtensionDependency extensionDependency) throws ResolveException |
79 |
|
{ |
80 |
0 |
for (ExtensionRepository remoteRepository : this.repositories.getRepositories()) { |
81 |
0 |
Extension extension = remoteRepository.resolve(extensionDependency); |
82 |
|
|
83 |
0 |
if (extension != null && RepositoryUtils.matches(this.filters, extension)) { |
84 |
0 |
return extension; |
85 |
|
} |
86 |
|
} |
87 |
|
|
88 |
0 |
return null; |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
@Override... |
92 |
|
public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException |
93 |
|
{ |
94 |
|
|
95 |
0 |
return null; |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0 |
@Override... |
99 |
|
public boolean isFilterable() |
100 |
|
{ |
101 |
0 |
return this.repositories.isFilterable(); |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
104 |
0 |
@Override... |
105 |
|
public boolean isSortable() |
106 |
|
{ |
107 |
0 |
return this.repositories.isSortable(); |
108 |
|
} |
109 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
110 |
13 |
@Override... |
111 |
|
public IterableResult<Extension> search(ExtensionQuery inputQuery) throws SearchException |
112 |
|
{ |
113 |
13 |
ExtensionQuery query = new ExtensionQuery(inputQuery); |
114 |
|
|
115 |
13 |
query.addFilters(this.filters); |
116 |
|
|
117 |
13 |
return this.repositories.search(query); |
118 |
|
} |
119 |
|
} |