From 4760bab964e263e5bd906128df9a80cf9cfdc905 Mon Sep 17 00:00:00 2001 From: Trisha Anand Date: Thu, 2 Apr 2020 18:24:03 +0530 Subject: [PATCH] Fixed the subscribe provider API that is being hit. --- .../appsmith/server/exceptions/AppsmithError.java | 1 - .../appsmith/server/services/ItemServiceImpl.java | 3 ++- .../server/services/MarketplaceService.java | 2 +- .../server/services/MarketplaceServiceImpl.java | 15 ++++++--------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java index d898992001..a3965be32b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/AppsmithError.java @@ -24,7 +24,6 @@ public enum AppsmithError { NO_CONFIGURATION_FOUND_IN_ACTION(400, 4016, "No action configuration found. Please configure it and try again."), NAME_CLASH_NOT_ALLOWED_IN_REFACTOR(400, 4017, "The new name {1} already exists in the current page. Choose another name."), PAGE_DOESNT_BELONG_TO_APPLICATION(400, 4018, "Page {0} does not belong to the application {1}"), - PAGINATED_API_PAGE_SIZE_MISSING(400, 4019, "This is a paginated API. Page and size are mandatory paramters"), NO_DSL_FOUND_IN_PAGE(400, 4020, "The page {0} doesn't have a DSL. This is an unexpected state"), UNAUTHORIZED_DOMAIN(401, 4019, "Invalid email domain provided. Please sign in with a valid work email ID"), INVALID_PASSWORD_RESET(400, 4020, "Unable to reset the password. Please initiate a request via 'forgot password' link to reset your password"), diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ItemServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ItemServiceImpl.java index ad672f31aa..404fbf7cad 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ItemServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ItemServiceImpl.java @@ -86,9 +86,10 @@ public class ItemServiceImpl implements ItemService { action.setCacheResponse(apiTemplate.getApiTemplateConfiguration().getSampleResponse().getBody().toString()); } + log.debug("Going to subscribe marketplace provider : {} and then create action", apiTemplate.getProviderId()); return marketplaceService // First hit the marketplace to update the statistics and to subscribe to the provider in case it hasn't - .subscribeAndUpdateStatisticsOfProvider(action.getProviderId()) + .subscribeAndUpdateStatisticsOfProvider(apiTemplate.getProviderId()) // Assume that we are only adding rapid api templates right now. Set the package to rapid-api forcibly /** TODO diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceService.java index 1e008af49c..e173d3fdfd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceService.java @@ -11,5 +11,5 @@ public interface MarketplaceService { Mono> getProviders(MultiValueMap params); Mono> getTemplates(MultiValueMap params); Mono> getCategories(); - Mono subscribeAndUpdateStatisticsOfProvider(String providerId); + Mono subscribeAndUpdateStatisticsOfProvider(String providerId); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java index 6917a14a83..283003aae0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/MarketplaceServiceImpl.java @@ -3,7 +3,6 @@ package com.appsmith.server.services; import com.appsmith.external.models.ApiTemplate; import com.appsmith.external.models.Provider; import com.appsmith.server.configurations.MarketplaceConfig; -import com.appsmith.server.constants.FieldName; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.fasterxml.jackson.core.JsonProcessingException; @@ -37,6 +36,8 @@ public class MarketplaceServiceImpl implements MarketplaceService { private static String CATEGORIES_PATH = PROVIDER_PATH + "/categories"; + private static String USE_PROVIDER_API = PROVIDER_PATH + "/use"; + private static String MARKETPLACE_USERNAME = "appsmith-server"; private static String MARKETPLACE_PASSWORD = "g:bj{64<$[k>hHBV"; @@ -58,10 +59,6 @@ public class MarketplaceServiceImpl implements MarketplaceService { @Override public Mono> getProviders(MultiValueMap params) { - if (params.getFirst(FieldName.PAGE) == null || params.getFirst(FieldName.SIZE) == null) { - return Mono.error(new AppsmithException(AppsmithError.PAGINATED_API_PAGE_SIZE_MISSING)); - } - URI uri = buildFullURI(params, PROVIDER_PATH); return webClient @@ -127,10 +124,10 @@ public class MarketplaceServiceImpl implements MarketplaceService { } @Override - public Mono subscribeAndUpdateStatisticsOfProvider(String providerId) { + public Mono subscribeAndUpdateStatisticsOfProvider(String providerId) { MultiValueMap params = new LinkedMultiValueMap<>(); params.add("id", providerId); - URI uri = buildFullURI(params, PROVIDER_PATH); + URI uri = buildFullURI(params, USE_PROVIDER_API); if (uri == null) { // Throw an internal server error because the URL is hard coded and must be correct @@ -138,10 +135,10 @@ public class MarketplaceServiceImpl implements MarketplaceService { } return webClient - .get() + .put() .uri(uri) .retrieve() - .bodyToMono(Provider.class); + .bodyToMono(Boolean.class); } private URI buildFullURI(MultiValueMap params, String path) {