| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.repository.internal; |
| 21 |
|
|
| 22 |
|
import java.net.URI; |
| 23 |
|
import java.net.URISyntaxException; |
| 24 |
|
import java.util.ArrayList; |
| 25 |
|
import java.util.Collection; |
| 26 |
|
import java.util.Collections; |
| 27 |
|
import java.util.HashMap; |
| 28 |
|
import java.util.List; |
| 29 |
|
import java.util.Map; |
| 30 |
|
|
| 31 |
|
import org.apache.commons.lang3.StringUtils; |
| 32 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
| 33 |
|
import org.slf4j.Logger; |
| 34 |
|
import org.slf4j.LoggerFactory; |
| 35 |
|
import org.xwiki.extension.Extension; |
| 36 |
|
import org.xwiki.extension.RemoteExtension; |
| 37 |
|
import org.xwiki.extension.internal.ExtensionFactory; |
| 38 |
|
import org.xwiki.extension.rating.RatingExtension; |
| 39 |
|
import org.xwiki.extension.repository.ExtensionRepositoryDescriptor; |
| 40 |
|
import org.xwiki.model.EntityType; |
| 41 |
|
import org.xwiki.model.reference.EntityReference; |
| 42 |
|
|
| |
|
| 90.4% |
Uncovered Elements: 8 (83) |
Complexity: 18 |
Complexity Density: 0.29 |
|
| 43 |
|
public class XWikiRepositoryModel |
| 44 |
|
{ |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
public static final String EXTENSION_CLASSNAME = "ExtensionCode.ExtensionClass"; |
| 48 |
|
|
| 49 |
|
public static final String AVERAGERATING_CLASSNAME = "XWiki.AverageRatingsClass"; |
| 50 |
|
|
| 51 |
|
public static final String EXTENSIONVERSION_CLASSNAME = "ExtensionCode.ExtensionVersionClass"; |
| 52 |
|
|
| 53 |
|
public static final String EXTENSIONDEPENDENCY_CLASSNAME = "ExtensionCode.ExtensionDependencyClass"; |
| 54 |
|
|
| 55 |
|
public static final String EXTENSIONPROXY_CLASSNAME = "ExtensionCode.ExtensionProxyClass"; |
| 56 |
|
|
| 57 |
|
public static final EntityReference EXTENSION_CLASSREFERENCE = new EntityReference("ExtensionClass", |
| 58 |
|
EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 59 |
|
|
| 60 |
|
public static final EntityReference EXTENSIONVERSION_CLASSREFERENCE = new EntityReference("ExtensionVersionClass", |
| 61 |
|
EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 62 |
|
|
| 63 |
|
public static final EntityReference EXTENSIONDEPENDENCY_CLASSREFERENCE = new EntityReference( |
| 64 |
|
"ExtensionDependencyClass", EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 65 |
|
|
| 66 |
|
public static final EntityReference EXTENSIONPROXY_CLASSREFERENCE = new EntityReference("ExtensionProxyClass", |
| 67 |
|
EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 68 |
|
|
| 69 |
|
public static final EntityReference EXTENSION_TEMPLATEREFERENCE = new EntityReference("ExtensionTemplate", |
| 70 |
|
EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 71 |
|
|
| 72 |
|
public static final String CONFIGURATION_CLASSNAME = "ExtensionCode.RepositoryConfigClass"; |
| 73 |
|
|
| 74 |
|
public static final EntityReference CONFIGURATION_CLASSREFERENCE = new EntityReference("RepositoryConfigClass", |
| 75 |
|
EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 76 |
|
|
| 77 |
|
public static final EntityReference CONFIGURATION_REFERENCE = new EntityReference("RepositoryConfig", |
| 78 |
|
EntityType.DOCUMENT, new EntityReference("ExtensionCode", EntityType.SPACE)); |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
public static final String PROP_EXTENSION_ID = "id"; |
| 83 |
|
|
| 84 |
|
public static final String PROP_EXTENSION_TYPE = "type"; |
| 85 |
|
|
| 86 |
|
public static final String PROP_EXTENSION_LICENSENAME = "licenseName"; |
| 87 |
|
|
| 88 |
|
public static final String PROP_EXTENSION_SUMMARY = "summary"; |
| 89 |
|
|
| 90 |
|
public static final String PROP_EXTENSION_DESCRIPTION = "description"; |
| 91 |
|
|
| 92 |
|
public static final String PROP_EXTENSION_NAME = "name"; |
| 93 |
|
|
| 94 |
|
public static final String PROP_EXTENSION_WEBSITE = "website"; |
| 95 |
|
|
| 96 |
|
public static final String PROP_EXTENSION_AUTHORS = "authors"; |
| 97 |
|
|
| 98 |
|
public static final String PROP_EXTENSION_FEATURES = "features"; |
| 99 |
|
|
| 100 |
|
public static final String PROP_EXTENSION_CATEGORY = "category"; |
| 101 |
|
|
| 102 |
|
|
| 103 |
|
@since |
| 104 |
|
|
| 105 |
|
public static final String PROP_EXTENSION_RECOMMENDED = "recommended"; |
| 106 |
|
|
| 107 |
|
public static final String PROP_EXTENSION_ALLOWEDNAMESPACES = "allowednamespaces"; |
| 108 |
|
|
| 109 |
|
public static final String PROP_EXTENSION_ALLOWEDNAMESPACES_EMPTY = "allowednamespaces_empty"; |
| 110 |
|
|
| 111 |
|
public static final String PROP_EXTENSION_SCMURL = "source"; |
| 112 |
|
|
| 113 |
|
public static final String PROP_EXTENSION_SCMCONNECTION = "scmconnection"; |
| 114 |
|
|
| 115 |
|
public static final String PROP_EXTENSION_SCMDEVCONNECTION = "scmdevconnection"; |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
@since |
| 119 |
|
|
| 120 |
|
public static final String PROP_EXTENSION_ISSUEMANAGEMENT_SYSTEM = "issueManagementSystem"; |
| 121 |
|
|
| 122 |
|
|
| 123 |
|
@since |
| 124 |
|
|
| 125 |
|
public static final String PROP_EXTENSION_ISSUEMANAGEMENT_URL = "issueManagementURL"; |
| 126 |
|
|
| 127 |
|
public static final String PROP_EXTENSION_PROPERTIES = "properties"; |
| 128 |
|
|
| 129 |
|
public static final String PROP_VERSION_ID = "id"; |
| 130 |
|
|
| 131 |
|
public static final String PROP_VERSION_VERSION = "version"; |
| 132 |
|
|
| 133 |
|
public static final String PROP_VERSION_DOWNLOAD = "download"; |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
@since |
| 137 |
|
|
| 138 |
|
public static final String PROP_VERSION_FEATURES = "features"; |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
@since |
| 142 |
|
|
| 143 |
|
public static final String PROP_VERSION_REPOSITORIES = "repositories"; |
| 144 |
|
|
| 145 |
|
public static final String PROP_DEPENDENCY_EXTENSIONVERSION = "extensionVersion"; |
| 146 |
|
|
| 147 |
|
public static final String PROP_DEPENDENCY_ID = "id"; |
| 148 |
|
|
| 149 |
|
public static final String PROP_DEPENDENCY_CONSTRAINT = "constraint"; |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
@since |
| 153 |
|
|
| 154 |
|
public static final String PROP_DEPENDENCY_REPOSITORIES = PROP_VERSION_REPOSITORIES; |
| 155 |
|
|
| 156 |
|
public static final String PROP_PROXY_REPOSITORYID = "repositoryId"; |
| 157 |
|
|
| 158 |
|
public static final String PROP_PROXY_REPOSITORYTYPE = "repositoryType"; |
| 159 |
|
|
| 160 |
|
public static final String PROP_PROXY_REPOSITORYURI = "repositoryURI"; |
| 161 |
|
|
| 162 |
|
public static final String PROP_PROXY_AUTOUPDATE = "autoUpdate"; |
| 163 |
|
|
| 164 |
|
public static final String PROP_CONFIGURATION_DEFAULTIDPREFIX = "defaultIdPrefix"; |
| 165 |
|
|
| 166 |
|
public static final String PROP_CONFIGURATION_VALIDTYPEs = "validTypes"; |
| 167 |
|
|
| 168 |
|
public static final String PROP_RATING_TOTALVOTES = "nbvotes"; |
| 169 |
|
|
| 170 |
|
public static final String PROP_RATING_AVERAGEVOTE = "averagevote"; |
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
public static final String PROP_EXTENSION_LASTVERSION = "lastVersion"; |
| 175 |
|
|
| 176 |
|
public static final String PROP_EXTENSION_VALIDEXTENSION = "validExtension"; |
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
@since |
| 182 |
|
|
| 183 |
|
public static final String PROPSUFFIX_EMPTYCOLLECTION = "_empty"; |
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
public static final String SOLRPROP_EXTENSION_VALIDEXTENSION = |
| 188 |
|
toExtensionClassSolrPropertyName(PROP_EXTENSION_VALIDEXTENSION, "boolean"); |
| 189 |
|
|
| 190 |
|
public static final String SOLR_STRING = "string"; |
| 191 |
|
|
| 192 |
|
public static final String SOLR_INTEGER = "int"; |
| 193 |
|
|
| 194 |
|
public static final String SOLR_BOOLEAN = "boolean"; |
| 195 |
|
|
| 196 |
|
public static final Map<String, SolrField> SOLR_FIELDS = new HashMap<>(); |
| 197 |
|
|
| |
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 3 |
Complexity Density: 1.5 |
|
| 198 |
|
public static class ExtensionSolrField extends SolrField |
| 199 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 200 |
57 |
public ExtensionSolrField(String name, Float boostValue)... |
| 201 |
|
{ |
| 202 |
57 |
this(name, SOLR_STRING, boostValue); |
| 203 |
|
} |
| 204 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 205 |
60 |
public ExtensionSolrField(String name, String type, Float boostValue)... |
| 206 |
|
{ |
| 207 |
60 |
super(toExtensionClassSolrPropertyName(name, type), toExtensionClassSolrOrderPropertyName(name, type), |
| 208 |
60 |
type != null ? toExtensionClassSolrPropertyName(name) : null, boostValue); |
| 209 |
|
} |
| 210 |
|
} |
| 211 |
|
|
| |
|
| 50% |
Uncovered Elements: 3 (6) |
Complexity: 3 |
Complexity Density: 1.5 |
|
| 212 |
|
public static class RatingSolrField extends SolrField |
| 213 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 214 |
0 |
public RatingSolrField(String name, Float boostValue)... |
| 215 |
|
{ |
| 216 |
0 |
this(name, SOLR_STRING, boostValue); |
| 217 |
|
} |
| 218 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 219 |
6 |
public RatingSolrField(String name, String type, Float boostValue)... |
| 220 |
|
{ |
| 221 |
6 |
super(toAverageRatingClassSolrPropertyName(name, type), |
| 222 |
|
toAverageRatingClassSolrOrderPropertyName(name, type), |
| 223 |
6 |
type != null ? toAverageRatingClassSolrPropertyName(name) : null, boostValue); |
| 224 |
|
} |
| 225 |
|
} |
| 226 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 227 |
|
public static class SolrField |
| 228 |
|
{ |
| 229 |
|
public final String name; |
| 230 |
|
|
| 231 |
|
public final String orderName; |
| 232 |
|
|
| 233 |
|
public final String boostName; |
| 234 |
|
|
| 235 |
|
public final Float boostValue; |
| 236 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 237 |
69 |
public SolrField(String name, String orderName, String boostName, Float boostValue)... |
| 238 |
|
{ |
| 239 |
69 |
this.name = name; |
| 240 |
69 |
this.orderName = orderName; |
| 241 |
69 |
this.boostName = boostName; |
| 242 |
69 |
this.boostValue = boostValue; |
| 243 |
|
} |
| 244 |
|
} |
| 245 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 1 |
Complexity Density: 0.03 |
|
| 246 |
3 |
static {... |
| 247 |
3 |
SOLR_FIELDS.put(Extension.FIELD_ID, new ExtensionSolrField(PROP_EXTENSION_ID, 10.0f)); |
| 248 |
3 |
SOLR_FIELDS.put(Extension.FIELD_FEATURE, new ExtensionSolrField(PROP_EXTENSION_FEATURES, 9.0f)); |
| 249 |
3 |
SOLR_FIELDS.put(Extension.FIELD_FEATURES, SOLR_FIELDS.get(Extension.FIELD_FEATURE)); |
| 250 |
3 |
SOLR_FIELDS.put(Extension.FIELD_NAME, new ExtensionSolrField(PROP_EXTENSION_NAME, 8.0f)); |
| 251 |
3 |
SOLR_FIELDS.put(Extension.FIELD_TYPE, new ExtensionSolrField(PROP_EXTENSION_TYPE, 8.0f)); |
| 252 |
3 |
SOLR_FIELDS.put(Extension.FIELD_CATEGORY, new ExtensionSolrField(PROP_EXTENSION_CATEGORY, 7.0f)); |
| 253 |
3 |
SOLR_FIELDS.put(Extension.FIELD_SUMMARY, new ExtensionSolrField(PROP_EXTENSION_SUMMARY, 6.0f)); |
| 254 |
|
|
| 255 |
|
|
| 256 |
3 |
SOLR_FIELDS.put(Extension.FIELD_DESCRIPTION, new SolrField(PROP_EXTENSION_DESCRIPTION, null, null, 5.0f)); |
| 257 |
|
|
| 258 |
|
|
| 259 |
3 |
SOLR_FIELDS.put(Extension.FIELD_AUTHOR, new ExtensionSolrField(PROP_EXTENSION_AUTHORS, null)); |
| 260 |
3 |
SOLR_FIELDS.put(Extension.FIELD_AUTHORS, SOLR_FIELDS.get(Extension.FIELD_AUTHOR)); |
| 261 |
3 |
SOLR_FIELDS.put(Extension.FIELD_VERSION, new ExtensionSolrField(PROP_EXTENSION_LASTVERSION, null)); |
| 262 |
3 |
SOLR_FIELDS.put(Extension.FIELD_LICENSE, new ExtensionSolrField(PROP_EXTENSION_LICENSENAME, null)); |
| 263 |
3 |
SOLR_FIELDS.put(Extension.FIELD_LICENSES, SOLR_FIELDS.get(Extension.FIELD_LICENSE)); |
| 264 |
3 |
SOLR_FIELDS.put(Extension.FIELD_SCM, new ExtensionSolrField(PROP_EXTENSION_SCMURL, null)); |
| 265 |
3 |
SOLR_FIELDS.put(PROP_EXTENSION_SCMCONNECTION, new ExtensionSolrField(PROP_EXTENSION_SCMCONNECTION, null)); |
| 266 |
3 |
SOLR_FIELDS.put(PROP_EXTENSION_SCMDEVCONNECTION, new ExtensionSolrField(PROP_EXTENSION_SCMDEVCONNECTION, null)); |
| 267 |
3 |
SOLR_FIELDS.put(PROP_EXTENSION_ISSUEMANAGEMENT_SYSTEM, |
| 268 |
|
new ExtensionSolrField(PROP_EXTENSION_ISSUEMANAGEMENT_SYSTEM, null)); |
| 269 |
3 |
SOLR_FIELDS.put(PROP_EXTENSION_ISSUEMANAGEMENT_URL, |
| 270 |
|
new ExtensionSolrField(PROP_EXTENSION_ISSUEMANAGEMENT_URL, null)); |
| 271 |
3 |
SOLR_FIELDS.put(Extension.FIELD_WEBSITE, new ExtensionSolrField(PROP_EXTENSION_WEBSITE, null)); |
| 272 |
3 |
SOLR_FIELDS.put(Extension.FIELD_NAMESPACES, new ExtensionSolrField(PROP_EXTENSION_ALLOWEDNAMESPACES, null)); |
| 273 |
3 |
SOLR_FIELDS.put(PROP_EXTENSION_ALLOWEDNAMESPACES_EMPTY, |
| 274 |
|
new ExtensionSolrField(PROP_EXTENSION_ALLOWEDNAMESPACES_EMPTY, null)); |
| 275 |
3 |
SOLR_FIELDS.put(Extension.FIELD_ALLOWEDNAMESPACE, SOLR_FIELDS.get(Extension.FIELD_NAMESPACES)); |
| 276 |
3 |
SOLR_FIELDS.put(Extension.FIELD_ALLOWEDNAMESPACES, SOLR_FIELDS.get(Extension.FIELD_NAMESPACES)); |
| 277 |
3 |
SOLR_FIELDS.put(Extension.FIELD_REPOSITORIES, new ExtensionSolrField(PROP_VERSION_REPOSITORIES, null)); |
| 278 |
3 |
SOLR_FIELDS.put(Extension.FIELD_PROPERTIES, new ExtensionSolrField(PROP_EXTENSION_PROPERTIES, null)); |
| 279 |
|
|
| 280 |
|
|
| 281 |
3 |
SOLR_FIELDS.put(RatingExtension.FIELD_TOTAL_VOTES, new RatingSolrField(PROP_RATING_TOTALVOTES, "int", null)); |
| 282 |
3 |
SOLR_FIELDS.put("votes", SOLR_FIELDS.get(PROP_RATING_TOTALVOTES)); |
| 283 |
3 |
SOLR_FIELDS.put(RatingExtension.FIELD_AVERAGE_VOTE, |
| 284 |
|
new RatingSolrField(PROP_RATING_AVERAGEVOTE, "float", null)); |
| 285 |
3 |
SOLR_FIELDS.put("vote", SOLR_FIELDS.get(PROP_RATING_AVERAGEVOTE)); |
| 286 |
|
|
| 287 |
|
|
| 288 |
3 |
SOLR_FIELDS.put(RemoteExtension.FIELD_RECOMMENDED, |
| 289 |
|
new ExtensionSolrField(PROP_EXTENSION_RECOMMENDED, SOLR_BOOLEAN, null)); |
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(XWikiRepositoryModel.class); |
| 296 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 297 |
183 |
public static String toExtensionClassSolrPropertyName(String propertyName)... |
| 298 |
|
{ |
| 299 |
183 |
return "property." + EXTENSION_CLASSNAME + '.' + propertyName; |
| 300 |
|
} |
| 301 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 302 |
63 |
public static String toExtensionClassSolrPropertyName(String propertyName, String type)... |
| 303 |
|
{ |
| 304 |
63 |
return toExtensionClassSolrPropertyName(propertyName) + '_' + type; |
| 305 |
|
} |
| 306 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 307 |
60 |
public static String toExtensionClassSolrOrderPropertyName(String propertyName, String type)... |
| 308 |
|
{ |
| 309 |
60 |
return toExtensionClassSolrPropertyName(propertyName) + "_sort" + StringUtils.capitalize(type); |
| 310 |
|
} |
| 311 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 312 |
18 |
public static String toAverageRatingClassSolrPropertyName(String propertyName)... |
| 313 |
|
{ |
| 314 |
18 |
return "property." + AVERAGERATING_CLASSNAME + '.' + propertyName; |
| 315 |
|
} |
| 316 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 317 |
6 |
public static String toAverageRatingClassSolrPropertyName(String propertyName, String type)... |
| 318 |
|
{ |
| 319 |
6 |
return toAverageRatingClassSolrPropertyName(propertyName) + '_' + type; |
| 320 |
|
} |
| 321 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 322 |
6 |
public static String toAverageRatingClassSolrOrderPropertyName(String propertyName, String type)... |
| 323 |
|
{ |
| 324 |
6 |
return toAverageRatingClassSolrPropertyName(propertyName) + "_sort" + StringUtils.capitalize(type); |
| 325 |
|
} |
| 326 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 327 |
260 |
public static String toSolrField(String restField)... |
| 328 |
|
{ |
| 329 |
260 |
SolrField field = SOLR_FIELDS.get(restField); |
| 330 |
|
|
| 331 |
260 |
if (field == null) { |
| 332 |
0 |
return null; |
| 333 |
|
} |
| 334 |
|
|
| 335 |
260 |
return field.name; |
| 336 |
|
} |
| 337 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 338 |
74 |
public static String toSolrOrderField(String restField)... |
| 339 |
|
{ |
| 340 |
74 |
SolrField field = SOLR_FIELDS.get(restField); |
| 341 |
|
|
| 342 |
74 |
if (field == null) { |
| 343 |
0 |
return null; |
| 344 |
|
} |
| 345 |
|
|
| 346 |
74 |
return field.orderName; |
| 347 |
|
} |
| 348 |
|
|
| 349 |
|
|
| 350 |
|
@since |
| 351 |
|
|
| |
|
| 70% |
Uncovered Elements: 3 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 352 |
3 |
public static List<ExtensionRepositoryDescriptor> toRepositoryDescriptors(Collection<String> stringRepositories,... |
| 353 |
|
ExtensionFactory factory) |
| 354 |
|
{ |
| 355 |
3 |
if (stringRepositories == null) { |
| 356 |
0 |
return Collections.emptyList(); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
3 |
List<ExtensionRepositoryDescriptor> reposiories = new ArrayList<>(stringRepositories.size()); |
| 360 |
|
|
| 361 |
3 |
for (String stringRepository : stringRepositories) { |
| 362 |
3 |
try { |
| 363 |
3 |
reposiories.add(toRepositoryDescriptor(stringRepository, factory)); |
| 364 |
|
} catch (URISyntaxException e) { |
| 365 |
0 |
LOGGER.warn("Failed to parse repository descriptor [{}]", stringRepository, |
| 366 |
|
ExceptionUtils.getRootCauseMessage(e)); |
| 367 |
|
} |
| 368 |
|
} |
| 369 |
|
|
| 370 |
3 |
return reposiories; |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
|
| 374 |
|
@since |
| 375 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 376 |
9 |
public static ExtensionRepositoryDescriptor toRepositoryDescriptor(String repository, ExtensionFactory factory)... |
| 377 |
|
throws URISyntaxException |
| 378 |
|
{ |
| 379 |
9 |
int index; |
| 380 |
|
|
| 381 |
|
|
| 382 |
9 |
String id = repository.substring(0, index = repository.indexOf(':')); |
| 383 |
|
|
| 384 |
|
|
| 385 |
9 |
String type = repository.substring(index + 1, index = repository.indexOf(':', index + 1)); |
| 386 |
|
|
| 387 |
|
|
| 388 |
9 |
URI uri = new URI(repository.substring(index + 1, repository.length())); |
| 389 |
|
|
| 390 |
9 |
return factory.getExtensionRepositoryDescriptor(id, type, uri); |
| 391 |
|
} |
| 392 |
|
|
| 393 |
|
|
| 394 |
|
@since |
| 395 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 396 |
24 |
public static List<String> toStringList(Collection<ExtensionRepositoryDescriptor> repositories)... |
| 397 |
|
{ |
| 398 |
24 |
List<String> stringRepositories = new ArrayList<>(repositories.size()); |
| 399 |
|
|
| 400 |
24 |
for (ExtensionRepositoryDescriptor repository : repositories) { |
| 401 |
9 |
stringRepositories.add(toString(repository)); |
| 402 |
|
} |
| 403 |
|
|
| 404 |
24 |
return stringRepositories; |
| 405 |
|
} |
| 406 |
|
|
| 407 |
|
|
| 408 |
|
@since |
| 409 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 410 |
9 |
public static String toString(ExtensionRepositoryDescriptor repository)... |
| 411 |
|
{ |
| 412 |
9 |
return repository != null ? StringUtils.defaultString(repository.getId()) + ':' + repository.getType() + ':' |
| 413 |
|
+ repository.getURI().toString() : null; |
| 414 |
|
} |
| 415 |
|
} |