Revert "Merge branch 'feature/embedded-datasource' into 'release'"
This reverts commit 35b49833615d88bc484207670b8ddf645f70d1ad, reversing changes made to 29bee80c426b4c469bf8e774b7febf4f63b196b4.
This commit is contained in:
parent
df2d7d2b3d
commit
786aca059e
|
|
@ -8,6 +8,7 @@ import lombok.Getter;
|
|||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.core.index.CompoundIndex;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ public class Action extends BaseDomain {
|
|||
|
||||
String name;
|
||||
|
||||
@Transient
|
||||
Datasource datasource;
|
||||
|
||||
@JsonIgnore
|
||||
|
|
|
|||
|
|
@ -213,8 +213,8 @@ public class ActionServiceImpl extends BaseService<ActionRepository, Action, Str
|
|||
|
||||
Mono<Datasource> datasourceMono;
|
||||
if (action.getDatasource().getId() == null) {
|
||||
datasourceMono = Mono.just(action.getDatasource())
|
||||
.flatMap(datasourceService::validateDatasource);
|
||||
//No data source exists. The action is also trying to create the data source.
|
||||
datasourceMono = datasourceService.create(action.getDatasource());
|
||||
} else {
|
||||
//Data source already exists. Find the same.
|
||||
datasourceMono = datasourceService.findById(action.getDatasource().getId())
|
||||
|
|
|
|||
|
|
@ -33,13 +33,10 @@ public class CurlImporterService extends BaseApiImporter {
|
|||
private static final String headerRegex = "\\-H\\s+\\'(.+?)\\'";
|
||||
private static final String methodRegex = "\\-X\\s+(.+?)\\b";
|
||||
private static final String bodyRegex = "\\-d\\s+\\'(.+?)\\'";
|
||||
private static final String pluginName = "RestTemplatePluginExecutor";
|
||||
private final ActionService actionService;
|
||||
private final PluginService pluginService;
|
||||
|
||||
public CurlImporterService(ActionService actionService, PluginService pluginService) {
|
||||
public CurlImporterService(ActionService actionService) {
|
||||
this.actionService = actionService;
|
||||
this.pluginService = pluginService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -134,21 +131,14 @@ public class CurlImporterService extends BaseApiImporter {
|
|||
}
|
||||
action.setActionConfiguration(actionConfiguration);
|
||||
datasource.setDatasourceConfiguration(datasourceConfiguration);
|
||||
action.setDatasource(datasource);
|
||||
action.setName(name);
|
||||
action.setPageId(pageId);
|
||||
|
||||
// Set the default values for datasource (plugin, name) and then create the action
|
||||
// with embedded datasource
|
||||
return pluginService.findByName(pluginName)
|
||||
.map(plugin -> {
|
||||
datasource.setName(datasourceConfiguration.getUrl());
|
||||
datasource.setPluginId(plugin.getId());
|
||||
return datasource;
|
||||
})
|
||||
.map(datasource1 -> {
|
||||
action.setDatasource(datasource1);
|
||||
return action;
|
||||
})
|
||||
.flatMap(actionService::create);
|
||||
/**
|
||||
* TODO
|
||||
* Instead of save, call create to allow of validation & setup of default values.
|
||||
*/
|
||||
return actionService.save(action);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,4 @@ public interface DatasourceService extends CrudService<Datasource, String> {
|
|||
Mono<Datasource> findById(String id);
|
||||
|
||||
Set<String> extractKeysFromDatasource(Datasource datasource);
|
||||
|
||||
Mono<Datasource> validateDatasource(Datasource datasource);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,8 +87,7 @@ public class DatasourceServiceImpl extends BaseService<DatasourceRepository, Dat
|
|||
.flatMap(this::validateAndSaveDatasourceToRepository);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Datasource> validateDatasource(Datasource datasource) {
|
||||
private Mono<Datasource> validateAndSaveDatasourceToRepository(Datasource datasource) {
|
||||
Set<String> invalids = new HashSet<>();
|
||||
Mono<User> userMono = sessionUserService.getCurrentUser();
|
||||
|
||||
|
|
@ -142,13 +141,8 @@ public class DatasourceServiceImpl extends BaseService<DatasourceRepository, Dat
|
|||
}
|
||||
datasource1.setInvalids(invalids);
|
||||
return Mono.just(datasource1);
|
||||
});
|
||||
}
|
||||
|
||||
private Mono<Datasource> validateAndSaveDatasourceToRepository(Datasource datasource) {
|
||||
return Mono.just(datasource)
|
||||
.flatMap(this::validateDatasource)
|
||||
.flatMap(repository::save);
|
||||
})
|
||||
.flatMap(super::create);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -358,15 +358,12 @@ public class LayoutActionServiceImpl implements LayoutActionService {
|
|||
Boolean actionUpdateRequired = false;
|
||||
ActionConfiguration actionConfiguration = action.getActionConfiguration();
|
||||
Set<String> jsonPathKeys = action.getJsonPathKeys();
|
||||
|
||||
if (jsonPathKeys != null || !jsonPathKeys.isEmpty()) {
|
||||
// Since json path keys actually contain the entire inline js function instead of just the widget/action
|
||||
// name, we can not simply use the set.contains(obj) function. We need to iterate over all the keys
|
||||
// in the set and see if the old name is a substring of the json path key.
|
||||
for (String key : jsonPathKeys) {
|
||||
if (key.contains(oldName)) {
|
||||
actionUpdateRequired = true;
|
||||
}
|
||||
// Since json path keys actually contain the entire inline js function instead of just the widget/action
|
||||
// name, we can not simply use the set.contains(obj) function. We need to iterate over all the keys
|
||||
// in the set and see if the old name is a substring of the json path key.
|
||||
for (String key : jsonPathKeys) {
|
||||
if (key.contains(oldName)) {
|
||||
actionUpdateRequired = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
spring.data.mongodb.auto-index-creation=false
|
||||
|
|
@ -1,36 +1,41 @@
|
|||
package com.appsmith.server.services;
|
||||
|
||||
import com.appsmith.server.domains.Action;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
//@RunWith(SpringRunner.class)
|
||||
//@SpringBootTest
|
||||
//@Slf4j
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Slf4j
|
||||
public class CurlParserServiceTest {
|
||||
@Autowired
|
||||
CurlImporterService curlImporterService;
|
||||
|
||||
/**
|
||||
* TODO Make the test case run
|
||||
* Currently the test case doesnt run because the import now requires the rest api plugin during create. This is because
|
||||
* the datasource needs to be validated (which is done at a plugin level). No current fix exists to mock out the
|
||||
* plugin as of now.
|
||||
*/
|
||||
// @Test
|
||||
// public void testParser() {
|
||||
// String command = "curl -X GET http://localhost:8080/api/v1/actions?name=something -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Authorization: Basic YXBpX3VzZXI6OHVBQDsmbUI6Y252Tn57Iw==' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/json' -H 'Cookie: SESSION=97c5def4-4f72-45aa-96fe-e8a9f5ade0b5,SESSION=97c5def4-4f72-45aa-96fe-e8a9f5ade0b5; SESSION=' -H 'Host: localhost:8080' -H 'Postman-Token: 16e4b6bc-2c7a-4ab1-a127-bca382dfc0f0,a6655daa-db07-4c5e-aca3-3fd505bd230d' -H 'User-Agent: PostmanRuntime/7.20.1' -H 'cache-control: no-cache' -d '{someJson}' ";
|
||||
// Mono<Action> action = curlImporterService.importAction(command, "pageId", "actionName");
|
||||
// StepVerifier
|
||||
// .create(action)
|
||||
// .assertNext(action1 -> {
|
||||
// assertThat(action1).isNotNull();
|
||||
// assertThat(action1.getDatasource()).isNotNull();
|
||||
// assertThat(action1.getDatasource().getDatasourceConfiguration()).isNotNull();
|
||||
// assertThat(action1.getDatasource().getDatasourceConfiguration().getUrl()).isEqualTo("http://localhost:8080/api/v1/actions");
|
||||
// assertThat(action1.getActionConfiguration().getHeaders().size()).isEqualTo(11);
|
||||
// assertThat(action1.getActionConfiguration().getQueryParameters().size()).isEqualTo(1);
|
||||
// assertThat(action1.getActionConfiguration().getHttpMethod()).isEqualTo(HttpMethod.GET);
|
||||
// assertThat(action1.getActionConfiguration().getBody()).isEqualTo("{someJson}");
|
||||
// })
|
||||
// .verifyComplete();
|
||||
// }
|
||||
@Test
|
||||
public void testParser() {
|
||||
String command = "curl -X GET http://localhost:8080/api/v1/actions?name=something -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Authorization: Basic YXBpX3VzZXI6OHVBQDsmbUI6Y252Tn57Iw==' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/json' -H 'Cookie: SESSION=97c5def4-4f72-45aa-96fe-e8a9f5ade0b5,SESSION=97c5def4-4f72-45aa-96fe-e8a9f5ade0b5; SESSION=' -H 'Host: localhost:8080' -H 'Postman-Token: 16e4b6bc-2c7a-4ab1-a127-bca382dfc0f0,a6655daa-db07-4c5e-aca3-3fd505bd230d' -H 'User-Agent: PostmanRuntime/7.20.1' -H 'cache-control: no-cache' -d '{someJson}' ";
|
||||
Mono<Action> action = curlImporterService.importAction(command, "pageId", "actionName");
|
||||
StepVerifier
|
||||
.create(action)
|
||||
.assertNext(action1 -> {
|
||||
assertThat(action1).isNotNull();
|
||||
assertThat(action1.getDatasource()).isNotNull();
|
||||
assertThat(action1.getDatasource().getDatasourceConfiguration()).isNotNull();
|
||||
assertThat(action1.getDatasource().getDatasourceConfiguration().getUrl()).isEqualTo("http://localhost:8080/api/v1/actions");
|
||||
assertThat(action1.getActionConfiguration().getHeaders().size()).isEqualTo(11);
|
||||
assertThat(action1.getActionConfiguration().getQueryParameters().size()).isEqualTo(1);
|
||||
assertThat(action1.getActionConfiguration().getHttpMethod()).isEqualTo(HttpMethod.GET);
|
||||
assertThat(action1.getActionConfiguration().getBody()).isEqualTo("{someJson}");
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user