Search in sources :

Example 1 with ReviewListJson

use of org.eclipse.openvsx.json.ReviewListJson in project openvsx by eclipse.

the class RegistryAPITest method reviewsJson.

private String reviewsJson(Consumer<ReviewListJson> content) throws JsonProcessingException {
    var json = new ReviewListJson();
    json.reviews = new ArrayList<>();
    content.accept(json);
    return new ObjectMapper().writeValueAsString(json);
}
Also used : ReviewListJson(org.eclipse.openvsx.json.ReviewListJson) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ReviewListJson

use of org.eclipse.openvsx.json.ReviewListJson in project openvsx by eclipse.

the class LocalRegistryService method getReviews.

@Override
public ReviewListJson getReviews(String namespace, String extensionName) {
    var extension = repositories.findExtension(extensionName, namespace);
    if (extension == null || !extension.isActive())
        throw new NotFoundException();
    var list = new ReviewListJson();
    var serverUrl = UrlUtil.getBaseUrl();
    list.postUrl = createApiUrl(serverUrl, "api", extension.getNamespace().getName(), extension.getName(), "review");
    list.deleteUrl = createApiUrl(serverUrl, "api", extension.getNamespace().getName(), extension.getName(), "review", "delete");
    list.reviews = repositories.findActiveReviews(extension).map(extReview -> extReview.toReviewJson()).toList();
    return list;
}
Also used : ReviewListJson(org.eclipse.openvsx.json.ReviewListJson) NotFoundException(org.eclipse.openvsx.util.NotFoundException)

Aggregations

ReviewListJson (org.eclipse.openvsx.json.ReviewListJson)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 NotFoundException (org.eclipse.openvsx.util.NotFoundException)1