Fixed the subscribe provider API that is being hit.
This commit is contained in:
parent
2e09f7923c
commit
4760bab964
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ public interface MarketplaceService {
|
|||
Mono<List<Provider>> getProviders(MultiValueMap<String, String> params);
|
||||
Mono<List<ApiTemplate>> getTemplates(MultiValueMap<String, String> params);
|
||||
Mono<List<String>> getCategories();
|
||||
Mono<Provider> subscribeAndUpdateStatisticsOfProvider(String providerId);
|
||||
Mono<Boolean> subscribeAndUpdateStatisticsOfProvider(String providerId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<List<Provider>> getProviders(MultiValueMap<String, String> 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<Provider> subscribeAndUpdateStatisticsOfProvider(String providerId) {
|
||||
public Mono<Boolean> subscribeAndUpdateStatisticsOfProvider(String providerId) {
|
||||
MultiValueMap<String, String> 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<String, String> params, String path) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user