use of org.craftercms.studio.api.v2.exception.marketplace.MarketplaceUnreachableException in project studio by craftercms.
the class MarketplaceServiceInternalImpl method searchPlugins.
@Override
public Map<String, Object> searchPlugins(final String type, final String keywords, final boolean showIncompatible, final long offset, final long limit) throws MarketplaceException {
validate();
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url).path(Paths.PLUGIN_SEARCH).queryParam(Constants.PARAM_VERSION, version).queryParam(Constants.PARAM_EDITION, edition).queryParam(Constants.PARAM_SHOW_PENDING, showPending).queryParam(Constants.PARAM_SHOW_INCOMPATIBLE, showIncompatible).queryParam(Constants.PARAM_OFFSET, offset).queryParam(Constants.PARAM_LIMIT, limit);
if (StringUtils.isNotEmpty(type)) {
builder.queryParam(Constants.PARAM_TYPE, type);
}
if (StringUtils.isNotEmpty(keywords)) {
builder.queryParam(Constants.PARAM_KEYWORDS, keywords);
}
HttpEntity<Void> request = new HttpEntity<>(null, httpHeaders);
try {
ResponseEntity<Map<String, Object>> response = restTemplate.exchange(builder.build().toString(), HttpMethod.GET, request, new ParameterizedTypeReference<Map<String, Object>>() {
});
return response.getBody();
} catch (ResourceAccessException e) {
throw new MarketplaceUnreachableException(url, e);
}
}
use of org.craftercms.studio.api.v2.exception.marketplace.MarketplaceUnreachableException in project studio by craftercms.
the class MarketplaceServiceInternalImpl method getDescriptor.
protected Map<String, Object> getDescriptor(String id, Version version) throws MarketplaceException, BlueprintNotFoundException {
validate();
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url).path(Paths.GET_PLUGIN).pathSegment(id, String.format("%s.%s.%s", version.getMajor(), version.getMinor(), version.getPatch())).queryParam(Constants.PARAM_SHOW_PENDING, showPending);
HttpEntity<Void> request = new HttpEntity<>(null, httpHeaders);
try {
ResponseEntity<Map<String, Object>> response = restTemplate.exchange(builder.build().toString(), HttpMethod.GET, request, new ParameterizedTypeReference<Map<String, Object>>() {
});
return response.getBody();
} catch (ResourceAccessException e) {
throw new MarketplaceUnreachableException(url, e);
} catch (IllegalArgumentException e) {
throw new BlueprintNotFoundException(String.format("Blueprint not found in the Marketplace: %s %s.%s.%s", id, version.getMajor(), version.getMinor(), version.getPatch()));
}
}
Aggregations