Merge branch 'bug/marketplace-integration-add-to-page' into 'release'
After migrating the database to marketplace, add new template to page stopped working. Fixing that by fetching the provider from marketplace service. See merge request theappsmith/internal-tools-server!279
This commit is contained in:
commit
d955dfd8bf
|
|
@ -66,7 +66,7 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
|
||||||
private final DatasourceContextService datasourceContextService;
|
private final DatasourceContextService datasourceContextService;
|
||||||
private final PluginExecutorHelper pluginExecutorHelper;
|
private final PluginExecutorHelper pluginExecutorHelper;
|
||||||
private final SessionUserService sessionUserService;
|
private final SessionUserService sessionUserService;
|
||||||
private final ProviderService providerService;
|
private final MarketplaceService marketplaceService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ActionServiceImpl(Scheduler scheduler,
|
public ActionServiceImpl(Scheduler scheduler,
|
||||||
|
|
@ -82,7 +82,7 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
|
||||||
DatasourceContextService datasourceContextService,
|
DatasourceContextService datasourceContextService,
|
||||||
PluginExecutorHelper pluginExecutorHelper,
|
PluginExecutorHelper pluginExecutorHelper,
|
||||||
SessionUserService sessionUserService,
|
SessionUserService sessionUserService,
|
||||||
ProviderService providerService) {
|
MarketplaceService marketplaceService) {
|
||||||
super(scheduler, validator, mongoConverter, reactiveMongoTemplate, repository, analyticsService);
|
super(scheduler, validator, mongoConverter, reactiveMongoTemplate, repository, analyticsService);
|
||||||
this.repository = repository;
|
this.repository = repository;
|
||||||
this.datasourceService = datasourceService;
|
this.datasourceService = datasourceService;
|
||||||
|
|
@ -92,7 +92,7 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
|
||||||
this.datasourceContextService = datasourceContextService;
|
this.datasourceContextService = datasourceContextService;
|
||||||
this.pluginExecutorHelper = pluginExecutorHelper;
|
this.pluginExecutorHelper = pluginExecutorHelper;
|
||||||
this.sessionUserService = sessionUserService;
|
this.sessionUserService = sessionUserService;
|
||||||
this.providerService = providerService;
|
this.marketplaceService = marketplaceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean validateActionName(String name) {
|
private Boolean validateActionName(String name) {
|
||||||
|
|
@ -556,8 +556,8 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
|
||||||
Mono<Action> providerUpdateMono = null;
|
Mono<Action> providerUpdateMono = null;
|
||||||
if ((action.getTemplateId() != null) && (action.getProviderId() != null)) {
|
if ((action.getTemplateId() != null) && (action.getProviderId() != null)) {
|
||||||
|
|
||||||
providerUpdateMono = providerService
|
providerUpdateMono = marketplaceService
|
||||||
.getById(action.getProviderId())
|
.getProviderById(action.getProviderId())
|
||||||
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "Provider")))
|
.switchIfEmpty(Mono.error(new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, "Provider")))
|
||||||
.map(provider -> {
|
.map(provider -> {
|
||||||
ActionProvider actionProvider = new ActionProvider();
|
ActionProvider actionProvider = new ActionProvider();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.appsmith.server.services;
|
package com.appsmith.server.services;
|
||||||
|
|
||||||
import com.appsmith.external.models.ApiTemplate;
|
import com.appsmith.external.models.ApiTemplate;
|
||||||
|
import com.appsmith.external.models.Provider;
|
||||||
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
@ -12,4 +13,5 @@ public interface MarketplaceService {
|
||||||
Mono<List<ApiTemplate>> getTemplates(MultiValueMap<String, String> params);
|
Mono<List<ApiTemplate>> getTemplates(MultiValueMap<String, String> params);
|
||||||
Mono<List<String>> getCategories();
|
Mono<List<String>> getCategories();
|
||||||
Mono<Boolean> subscribeAndUpdateStatisticsOfProvider(String providerId);
|
Mono<Boolean> subscribeAndUpdateStatisticsOfProvider(String providerId);
|
||||||
|
Mono<Provider> getProviderById(String id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.appsmith.server.services;
|
package com.appsmith.server.services;
|
||||||
|
|
||||||
import com.appsmith.external.models.ApiTemplate;
|
import com.appsmith.external.models.ApiTemplate;
|
||||||
|
import com.appsmith.external.models.Provider;
|
||||||
import com.appsmith.server.configurations.MarketplaceConfig;
|
import com.appsmith.server.configurations.MarketplaceConfig;
|
||||||
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
||||||
import com.appsmith.server.exceptions.AppsmithError;
|
import com.appsmith.server.exceptions.AppsmithError;
|
||||||
|
|
@ -141,6 +142,28 @@ public class MarketplaceServiceImpl implements MarketplaceService {
|
||||||
.bodyToMono(Boolean.class);
|
.bodyToMono(Boolean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Provider> getProviderById(String id) {
|
||||||
|
URI uri = buildFullURI(null, PROVIDER_PATH + "/" + id);
|
||||||
|
|
||||||
|
return webClient
|
||||||
|
.get()
|
||||||
|
.uri(uri)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String.class)
|
||||||
|
.flatMap(stringBody -> {
|
||||||
|
Provider provider = null;
|
||||||
|
try {
|
||||||
|
provider = objectMapper.readValue(stringBody, Provider.class);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return Mono.error(new AppsmithException(AppsmithError.JSON_PROCESSING_ERROR, e));
|
||||||
|
}
|
||||||
|
return Mono.just(provider);
|
||||||
|
})
|
||||||
|
.timeout(Duration.ofMillis(timeoutInMillis))
|
||||||
|
.doOnError(error -> Mono.error(new AppsmithException(AppsmithError.MARKETPLACE_TIMEOUT)));
|
||||||
|
}
|
||||||
|
|
||||||
private URI buildFullURI(MultiValueMap<String, String> params, String path) {
|
private URI buildFullURI(MultiValueMap<String, String> params, String path) {
|
||||||
UriComponentsBuilder uriBuilder = UriComponentsBuilder.newInstance();
|
UriComponentsBuilder uriBuilder = UriComponentsBuilder.newInstance();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user