diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ApiTemplate.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ApiTemplate.java index 03c7f64d1b..eeac8fb058 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ApiTemplate.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/ApiTemplate.java @@ -1,60 +1,17 @@ package com.appsmith.external.models; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import org.springframework.data.annotation.CreatedBy; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.LastModifiedBy; -import org.springframework.data.annotation.LastModifiedDate; -import org.springframework.data.annotation.Version; -import org.springframework.data.domain.Persistable; -import org.springframework.data.mongodb.core.index.Indexed; import org.springframework.data.mongodb.core.mapping.Document; -import java.time.Instant; - @Getter @Setter @ToString @NoArgsConstructor @Document -public class ApiTemplate implements Persistable { - - private static final long serialVersionUID = 7459916000501322517L; - - @Id - private String id; - - @JsonIgnore - @Indexed - @CreatedDate - protected Instant createdAt; - - @JsonIgnore - @LastModifiedDate - protected Instant updatedAt; - - @CreatedBy - protected String createdBy; - - @LastModifiedBy - protected String modifiedBy; - - protected Boolean deleted = false; - - @JsonIgnore - @Version - protected Long documentVersion; - - @JsonIgnore - @Override - public boolean isNew() { - return this.getId() == null; - } +public class ApiTemplate extends BaseDomain { // ApiTemplate fields below : String name; //API name here diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/BaseDomain.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java similarity index 85% rename from app/server/appsmith-server/src/main/java/com/appsmith/server/domains/BaseDomain.java rename to app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java index 800fb61c80..0685ab09dd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/BaseDomain.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/BaseDomain.java @@ -1,4 +1,4 @@ -package com.appsmith.server.domains; +package com.appsmith.external.models; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; @@ -15,7 +15,12 @@ import org.springframework.data.mongodb.core.index.Indexed; import java.time.Instant; -@Getter + +/** + * TODO : + * Move BaseDomain back to appsmith-server.domain. This is done temporarily to create templates and providers in the same database as the server + */ +@Getter @Setter @ToString public abstract class BaseDomain implements Persistable { diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Category.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Category.java new file mode 100644 index 0000000000..b923ba7346 --- /dev/null +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Category.java @@ -0,0 +1,20 @@ +package com.appsmith.external.models; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.springframework.data.mongodb.core.index.Indexed; +import org.springframework.data.mongodb.core.mapping.Document; + +@Getter +@Setter +@ToString +@NoArgsConstructor +@Document +public class Category extends BaseDomain { + + @Indexed(unique=true) + String name; //Category name here + +} diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Provider.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Provider.java index d5faf58f13..c9f4812a7c 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Provider.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/Provider.java @@ -1,21 +1,12 @@ package com.appsmith.external.models; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import org.springframework.data.annotation.CreatedBy; -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.Id; -import org.springframework.data.annotation.LastModifiedBy; -import org.springframework.data.annotation.LastModifiedDate; -import org.springframework.data.annotation.Version; -import org.springframework.data.domain.Persistable; import org.springframework.data.mongodb.core.index.Indexed; import org.springframework.data.mongodb.core.mapping.Document; -import java.time.Instant; import java.util.List; @Getter @@ -23,47 +14,24 @@ import java.util.List; @ToString @NoArgsConstructor @Document -public class Provider implements Persistable { +public class Provider extends BaseDomain { - private static final long serialVersionUID = 7459916000501322517L; - - @Id - private String id; - - @JsonIgnore - @Indexed - @CreatedDate - protected Instant createdAt; - - @JsonIgnore - @LastModifiedDate - protected Instant updatedAt; - - @CreatedBy - protected String createdBy; - - @LastModifiedBy - protected String modifiedBy; - - protected Boolean deleted = false; - - @JsonIgnore - @Version - protected Long documentVersion; - - @JsonIgnore - @Override - public boolean isNew() { - return this.getId() == null; - } - - // Provider details here + @Indexed(unique=true) String name; //Provider name here + String description; //Provider company's description here + String url; + String imageUrl; + String documentationUrl; //URL which points to the homepage of the documentations here + String credentialSteps; //How to generate/get the credentials to run the APIs which belong to this provider + List categories; //Category names here + Statistics statistics; //Cumulative statistics for all the APIs for this provider + + DatasourceConfiguration datasourceConfiguration; } diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java index 34e8ec7f96..e6e566e482 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java @@ -8,11 +8,12 @@ import reactor.core.publisher.Mono; public interface PluginExecutor extends ExtensionPoint { /** - * This function is used to execute the action. - * @param connection : This is the connection that is established to the data source. This connection is according - * to the parameters in Datasource Configuration + * This function is used to execute the action. + * + * @param connection : This is the connection that is established to the data source. This connection is according + * to the parameters in Datasource Configuration * @param datasourceConfiguration : These are the configurations which have been used to create a Datasource from a Plugin - * @param actionConfiguration : These are the configurations which have been used to create an Action from a Datasource. + * @param actionConfiguration : These are the configurations which have been used to create an Action from a Datasource. * @return ActionExecutionResult : This object is returned to the user which contains the result values from the execution. */ Mono execute(Object connection, DatasourceConfiguration datasourceConfiguration, ActionConfiguration actionConfiguration); @@ -20,6 +21,7 @@ public interface PluginExecutor extends ExtensionPoint { /** * This function is responsible for creating the connection to the data source and returning the connection variable * on success. For executing actions, this connection object would be passed for each function call. + * * @param datasourceConfiguration * @return Connection object */ @@ -27,6 +29,7 @@ public interface PluginExecutor extends ExtensionPoint { /** * This function is used to bring down/destroy the connection to the data source. + * * @param connection */ void datasourceDestroy(Object connection); diff --git a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java index 003de5d0c4..f55214cf02 100644 --- a/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java +++ b/app/server/appsmith-plugins/mongoPlugin/src/main/java/com/external/plugins/MongoPlugin.java @@ -38,10 +38,10 @@ public class MongoPlugin extends BasePlugin { * For reference on creating the json queries for Mongo please head to * https://docs.huihoo.com/mongodb/3.4/reference/command/index.html * - * @param connection : This is the connection that is established to the data source. This connection is according - * to the parameters in Datasource Configuration + * @param connection : This is the connection that is established to the data source. This connection is according + * to the parameters in Datasource Configuration * @param datasourceConfiguration : These are the configurations which have been used to create a Datasource from a Plugin - * @param actionConfiguration : These are the configurations which have been used to create an Action from a Datasource. + * @param actionConfiguration : These are the configurations which have been used to create an Action from a Datasource. * @return */ @Override @@ -55,7 +55,7 @@ public class MongoPlugin extends BasePlugin { return Mono.error(new Exception("Mongo Client is null.")); } - MongoClientURI mongoClientURI= new MongoClientURI(datasourceConfiguration.getUrl()); + MongoClientURI mongoClientURI = new MongoClientURI(datasourceConfiguration.getUrl()); String databaseName = datasourceConfiguration.getDatabaseName(); if (databaseName == null) { @@ -113,7 +113,7 @@ public class MongoPlugin extends BasePlugin { @Override public Object datasourceCreate(DatasourceConfiguration datasourceConfiguration) { - MongoClientURI mongoClientURI= new MongoClientURI(datasourceConfiguration.getUrl()); + MongoClientURI mongoClientURI = new MongoClientURI(datasourceConfiguration.getUrl()); return new MongoClient(mongoClientURI); } diff --git a/app/server/appsmith-plugins/pom.xml b/app/server/appsmith-plugins/pom.xml index 83d78130b7..11ebe088e9 100644 --- a/app/server/appsmith-plugins/pom.xml +++ b/app/server/appsmith-plugins/pom.xml @@ -7,7 +7,7 @@ integrated 1.0-SNAPSHOT - + 4.0.0 com.appsmith appsmith-plugins @@ -19,5 +19,5 @@ restApiPlugin mongoPlugin - + \ No newline at end of file diff --git a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java index dcd0306152..1c3636401e 100644 --- a/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java +++ b/app/server/appsmith-plugins/postgresPlugin/src/main/java/com/external/plugins/PostgresPlugin.java @@ -38,7 +38,7 @@ public class PostgresPlugin extends BasePlugin { /** * Postgres plugin receives the query as json of the following format : * { - * "cmd" : "select * from users;" + * "cmd" : "select * from users;" * } */ @@ -87,8 +87,8 @@ public class PostgresPlugin extends BasePlugin { // Create the connection conn = DriverManager.getConnection(datasourceConfiguration.getUrl(), - datasourceConfiguration.getAuthentication().getUsername(), - datasourceConfiguration.getAuthentication().getPassword()); + datasourceConfiguration.getAuthentication().getUsername(), + datasourceConfiguration.getAuthentication().getPassword()); return conn; } catch (ClassNotFoundException e) { log.error("", e); diff --git a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java index d701504536..121f471dda 100644 --- a/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java +++ b/app/server/appsmith-plugins/restApiPlugin/src/main/java/com/external/plugins/RestApiPlugin.java @@ -71,7 +71,7 @@ public class RestApiPlugin extends BasePlugin { URI uri = null; try { uri = createFinalUriWithQueryParams(url, actionConfiguration.getQueryParameters()); - System.out.println("Final URL is : "+ uri.toString()); + System.out.println("Final URL is : " + uri.toString()); } catch (URISyntaxException e) { e.printStackTrace(); return Mono.error(new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, e)); @@ -153,6 +153,13 @@ public class RestApiPlugin extends BasePlugin { ClientResponse response = (ClientResponse) res; if (response.statusCode().is3xxRedirection()) { String redirectUrl = response.headers().header("Location").get(0); + /** + * TODO + * In case the redirected URL is not absolute (complete), create the new URL using the relative path + * This particular scenario is seen in the URL : https://rickandmortyapi.com/api/character + * It redirects to partial URI : /api/character/ + * In this scenario we should convert the partial URI to complete URI + */ URI redirectUri = null; try { redirectUri = new URI(redirectUrl); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/MongoConfig.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/MongoConfig.java index d696bb5322..fbe76b0476 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/MongoConfig.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/MongoConfig.java @@ -9,7 +9,7 @@ import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRep /** * This configures the JPA Mongo repositories. The default base implementation is defined in {@link BaseRepositoryImpl}. * This is required to add default clauses for default JPA queries defined by Spring Data. - * + *

* The factoryBean class is also custom defined in order to add default clauses for soft delete for all custom JPA queries. * {@link SoftDeleteMongoRepositoryFactoryBean} for details. */ diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoQueryLookupStrategy.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoQueryLookupStrategy.java index d0d930100a..b414c4e434 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoQueryLookupStrategy.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoQueryLookupStrategy.java @@ -22,11 +22,10 @@ import static org.springframework.data.mongodb.core.query.Criteria.where; * This class overrides the default implementation in * {@link org.springframework.data.mongodb.repository.support.ReactiveMongoRepositoryFactory#getQueryLookupStrategy} * This custom implementation adds the query parameter to filter out any records marked with delete=true in the database - * + *

* Also refer to the custom Factory: {@link SoftDeleteMongoRepositoryFactory} and * custom FactoryBean: {@link SoftDeleteMongoRepositoryFactoryBean}. The annotation @EnableReactiveMongoRepositories in * {@link com.appsmith.server.configurations.CommonConfig} sets the Mongo factory bean to our custom bean instead of the default one - * */ public class SoftDeleteMongoQueryLookupStrategy implements QueryLookupStrategy { private final QueryLookupStrategy strategy; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoRepositoryFactoryBean.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoRepositoryFactoryBean.java index ac796356a3..a466d326f3 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoRepositoryFactoryBean.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/mongo/SoftDeleteMongoRepositoryFactoryBean.java @@ -10,6 +10,7 @@ import java.io.Serializable; /** * This factory bean class is set in the annotation @EnableReactiveMongoRepositories in {@link com.appsmith.server.configurations.CommonConfig} * which overrides the default factory bean {@link ReactiveMongoRepositoryFactoryBean} + * * @param * @param * @param diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Url.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Url.java index 49633cfcd8..f8d586e105 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Url.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/Url.java @@ -3,8 +3,8 @@ package com.appsmith.server.constants; public interface Url { String BASE_URL = "/api"; String VERSION = "/v1"; - String LOGIN_URL= BASE_URL + VERSION + "/login"; - String LOGOUT_URL= BASE_URL + VERSION + "/logout"; + String LOGIN_URL = BASE_URL + VERSION + "/login"; + String LOGOUT_URL = BASE_URL + VERSION + "/logout"; String WIDGET_URL = BASE_URL + VERSION + "/widgets"; String ORGANIZATION_URL = BASE_URL + VERSION + "/organizations"; String LAYOUT_URL = BASE_URL + VERSION + "/layouts"; @@ -25,4 +25,5 @@ public interface Url { String IMPORT_URL = BASE_URL + VERSION + "/import"; String PROVIDER_URL = BASE_URL + VERSION + "/providers"; String MARKETPLACE_URL = BASE_URL + VERSION + "/marketplace"; + String API_TEMPLATE_URL = BASE_URL + VERSION + "/templates"; } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApiTemplateController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApiTemplateController.java new file mode 100644 index 0000000000..61f40cf8bc --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ApiTemplateController.java @@ -0,0 +1,15 @@ +package com.appsmith.server.controllers; + +import com.appsmith.external.models.ApiTemplate; +import com.appsmith.server.constants.Url; +import com.appsmith.server.services.ApiTemplateService; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(Url.API_TEMPLATE_URL) +public class ApiTemplateController extends BaseController { + public ApiTemplateController(ApiTemplateService service) { + super(service); + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/BaseController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/BaseController.java index ee2aecdda1..8b54ff09a9 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/BaseController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/BaseController.java @@ -1,6 +1,6 @@ package com.appsmith.server.controllers; -import com.appsmith.server.domains.BaseDomain; +import com.appsmith.external.models.BaseDomain; import com.appsmith.server.dtos.ResponseDTO; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.services.CrudService; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ProviderController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ProviderController.java index b578f05ddd..7a422469dc 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ProviderController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ProviderController.java @@ -1,46 +1,16 @@ package com.appsmith.server.controllers; import com.appsmith.external.models.Provider; -import com.appsmith.external.models.Statistics; import com.appsmith.server.constants.Url; -import com.appsmith.server.dtos.ResponseDTO; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; +import com.appsmith.server.services.ProviderService; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -import java.util.ArrayList; -import java.util.List; @RestController @RequestMapping(Url.PROVIDER_URL) -public class ProviderController { +public class ProviderController extends BaseController { - @GetMapping - Mono>> fetchProviders(@RequestParam(required = false) String categoryName, @RequestParam(required = false) String pageNo) { - Provider provider = new Provider(); - List categories = new ArrayList<>(); - categories.add("Data"); - categories.add("Sports"); - provider.setCategories(categories); - provider.setName("New Sports Ltd"); - provider.setId("RandomSavedId"); - provider.setDescription("Some description here"); - provider.setUrl("http://url.com"); - provider.setImageUrl("http://image.url.com"); - provider.setDocumentationUrl("http://docu.url.com"); - Statistics statistics = new Statistics(); - statistics.setAverageLatency((long) 230); - statistics.setImports((long) 1000); - statistics.setSuccessRate(99.7); - provider.setStatistics(statistics); - provider.setCredentialSteps("Credential steps here"); - List providers = new ArrayList<>(); - providers.add(provider); - providers.add(provider); - return Mono.just(providers) - .map(resources -> new ResponseDTO<>(HttpStatus.OK.value(), resources, null)); + public ProviderController(ProviderService service) { + super(service); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/RestApiImportController.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/RestApiImportController.java index dc5a1fdfe3..23b0d60866 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/RestApiImportController.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/RestApiImportController.java @@ -5,7 +5,6 @@ import com.appsmith.server.constants.Url; import com.appsmith.server.domains.Action; import com.appsmith.server.domains.RestApiImporterType; import com.appsmith.server.dtos.ResponseDTO; -import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.services.ApiImporter; import com.appsmith.server.services.CurlImporterService; import com.appsmith.server.services.PostmanImporterService; @@ -41,7 +40,10 @@ public class RestApiImportController { @PostMapping @ResponseStatus(HttpStatus.CREATED) - public Mono> create(@Valid @RequestBody Object input, @RequestParam RestApiImporterType type) throws AppsmithException { + public Mono> create(@Valid @RequestBody Object input, + @RequestParam RestApiImporterType type, + @RequestParam String pageId, + @RequestParam String name) { log.debug("Going to import API"); ApiImporter service; @@ -53,13 +55,13 @@ public class RestApiImportController { throw new IllegalStateException("Unexpected value: " + type); } - return Mono.just(service.importAction(input)) + return service.importAction(input, pageId, name) .map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null)); } @PostMapping("/postman") @ResponseStatus(HttpStatus.CREATED) - public Mono> importPostmanCollection(@RequestBody Object input) { + public Mono> importPostmanCollection(@RequestBody Object input, @RequestParam String type) { return Mono.just(postmanImporterService.importPostmanCollection(input)) .map(created -> new ResponseDTO<>(HttpStatus.CREATED.value(), created, null)); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java index a61091b192..e1bb2e6fac 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Action.java @@ -1,6 +1,7 @@ package com.appsmith.server.domains; import com.appsmith.external.models.ActionConfiguration; +import com.appsmith.external.models.BaseDomain; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java index cdf5cefca5..0fff5ebfe0 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Application.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Collection.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Collection.java index c3b421b203..a2b8c2b07c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Collection.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Collection.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Config.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Config.java index f5436ee807..f628448a66 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Config.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Config.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Datasource.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Datasource.java index bbba7c78a9..72e0a1bc9c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Datasource.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Datasource.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import com.appsmith.external.models.DatasourceConfiguration; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Group.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Group.java index 41abd60d19..f11c51b541 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Group.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Group.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.Setter; import lombok.ToString; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Layout.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Layout.java index 92ca0402df..a81878e4c8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Layout.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Layout.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import com.appsmith.server.dtos.DslActionDTO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Organization.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Organization.java index f803e75ae3..0228a446ab 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Organization.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Organization.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationPlugin.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationPlugin.java index 7fc6e1266e..09454052cd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationPlugin.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationPlugin.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import com.appsmith.server.dtos.OrganizationPluginStatus; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationSetting.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationSetting.java index 1b7cf83d52..eacff33488 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationSetting.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/OrganizationSetting.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Page.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Page.java index 1c70caed73..e3727b5d1e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Page.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Page.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PasswordResetToken.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PasswordResetToken.java index 4252677e9b..d83f7fc0fd 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PasswordResetToken.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PasswordResetToken.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Permission.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Permission.java index e07c4e932c..a0f0f55100 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Permission.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Permission.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.Setter; import lombok.ToString; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java index 8f171ccd74..a113def4e5 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Plugin.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PropertyPane.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PropertyPane.java index afcfc415e2..e864686aca 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PropertyPane.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/PropertyPane.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Query.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Query.java index 066755d9a3..40c8c3f571 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Query.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Query.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Role.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Role.java index 84bf3b574f..eb116c018c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Role.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Role.java @@ -1,6 +1,7 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Setting.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Setting.java index fb944ca0cc..51cc19bab7 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Setting.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Setting.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/User.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/User.java index 4d2954bdbb..234e38bf5d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/User.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/User.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Widget.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Widget.java index 3ef63b6781..8750812e7b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Widget.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Widget.java @@ -1,5 +1,6 @@ package com.appsmith.server.domains; +import com.appsmith.external.models.BaseDomain; import com.appsmith.external.models.Property; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/GlobalExceptionHandler.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/GlobalExceptionHandler.java index 9260b66513..c1c388b228 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/GlobalExceptionHandler.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/exceptions/GlobalExceptionHandler.java @@ -104,6 +104,7 @@ public class GlobalExceptionHandler { return Mono.just(new ResponseDTO<>(appsmithError.getHttpErrorCode(), new ErrorDTO(appsmithError.getAppErrorCode(), appsmithError.getMessage()))); } + /** * This function catches the generic Exception class and is meant to be a catch all to ensure that we don't leak * any information to the client. Ideally, the function #catchAppsmithException should be used diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ActionRepository.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ActionRepository.java index 6d62775cae..e1cb852f8a 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ActionRepository.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ActionRepository.java @@ -5,7 +5,6 @@ import org.springframework.stereotype.Repository; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import java.util.List; import java.util.Set; @Repository diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ApiTemplateRepository.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ApiTemplateRepository.java new file mode 100644 index 0000000000..d4f745e6cc --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ApiTemplateRepository.java @@ -0,0 +1,6 @@ +package com.appsmith.server.repositories; + +import com.appsmith.external.models.ApiTemplate; + +public interface ApiTemplateRepository extends BaseRepository { +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/BaseRepositoryImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/BaseRepositoryImpl.java index 51692b8223..fb79a31e47 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/BaseRepositoryImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/BaseRepositoryImpl.java @@ -1,7 +1,7 @@ package com.appsmith.server.repositories; +import com.appsmith.external.models.BaseDomain; import com.appsmith.server.constants.FieldName; -import com.appsmith.server.domains.BaseDomain; import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.data.mongodb.core.ReactiveMongoOperations; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ProviderRepository.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ProviderRepository.java new file mode 100644 index 0000000000..7a82d13ed4 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/repositories/ProviderRepository.java @@ -0,0 +1,6 @@ +package com.appsmith.server.repositories; + +import com.appsmith.external.models.Provider; + +public interface ProviderRepository extends BaseRepository { +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/AnalyticsService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/AnalyticsService.java index b9137691d6..195b6e6477 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/AnalyticsService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/AnalyticsService.java @@ -1,6 +1,6 @@ package com.appsmith.server.services; -import com.appsmith.server.domains.BaseDomain; +import com.appsmith.external.models.BaseDomain; import com.appsmith.server.domains.User; import com.segment.analytics.Analytics; import com.segment.analytics.messages.IdentifyMessage; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiImporter.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiImporter.java index 2419aeac0d..6360252990 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiImporter.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiImporter.java @@ -1,9 +1,10 @@ package com.appsmith.server.services; import com.appsmith.server.domains.Action; +import reactor.core.publisher.Mono; public interface ApiImporter { - Action importAction(Object input); + Mono importAction(Object input, String pageId, String name); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiTemplateService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiTemplateService.java new file mode 100644 index 0000000000..3ebe9b820e --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiTemplateService.java @@ -0,0 +1,6 @@ +package com.appsmith.server.services; + +import com.appsmith.external.models.ApiTemplate; + +public interface ApiTemplateService extends CrudService { +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiTemplateServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiTemplateServiceImpl.java new file mode 100644 index 0000000000..e74d44e3e8 --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApiTemplateServiceImpl.java @@ -0,0 +1,23 @@ +package com.appsmith.server.services; + +import com.appsmith.external.models.ApiTemplate; +import com.appsmith.server.repositories.ApiTemplateRepository; +import org.springframework.data.mongodb.core.ReactiveMongoTemplate; +import org.springframework.data.mongodb.core.convert.MongoConverter; +import org.springframework.stereotype.Service; +import reactor.core.scheduler.Scheduler; + +import javax.validation.Validator; + +@Service +public class ApiTemplateServiceImpl extends BaseService implements ApiTemplateService { + + public ApiTemplateServiceImpl(Scheduler scheduler, + Validator validator, + MongoConverter mongoConverter, + ReactiveMongoTemplate reactiveMongoTemplate, + ApiTemplateRepository repository, + AnalyticsService analyticsService) { + super(scheduler, validator, mongoConverter, reactiveMongoTemplate, repository, analyticsService); + } +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseApiImporter.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseApiImporter.java index 39946a0ff3..85397eea27 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseApiImporter.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseApiImporter.java @@ -1,9 +1,10 @@ package com.appsmith.server.services; import com.appsmith.server.domains.Action; +import reactor.core.publisher.Mono; public abstract class BaseApiImporter implements ApiImporter { - public abstract Action importAction(Object input); + public abstract Mono importAction(Object input, String pageId, String name); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseService.java index 33c11ffcc5..6df89faf67 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/BaseService.java @@ -1,8 +1,8 @@ package com.appsmith.server.services; +import com.appsmith.external.models.BaseDomain; import com.appsmith.server.constants.AnalyticsEvents; import com.appsmith.server.constants.FieldName; -import com.appsmith.server.domains.BaseDomain; import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.appsmith.server.repositories.BaseRepository; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CrudService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CrudService.java index 8b87117e8d..e9084e217b 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CrudService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CrudService.java @@ -1,6 +1,6 @@ package com.appsmith.server.services; -import com.appsmith.server.domains.BaseDomain; +import com.appsmith.external.models.BaseDomain; import org.springframework.util.MultiValueMap; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CurlImporterService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CurlImporterService.java index 7c13f448b1..0f4bedccd8 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CurlImporterService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/CurlImporterService.java @@ -10,6 +10,7 @@ import org.apache.http.NameValuePair; import org.apache.http.client.utils.URLEncodedUtils; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Service; +import reactor.core.publisher.Mono; import java.net.URI; import java.net.URL; @@ -32,9 +33,14 @@ 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 final ActionService actionService; + + public CurlImporterService(ActionService actionService) { + this.actionService = actionService; + } @Override - public Action importAction(Object input) { + public Mono importAction(Object input, String pageId, String name) { String command = (String) input; Action action = new Action(); ActionConfiguration actionConfiguration = new ActionConfiguration(); @@ -126,6 +132,8 @@ public class CurlImporterService extends BaseApiImporter { action.setActionConfiguration(actionConfiguration); datasource.setDatasourceConfiguration(datasourceConfiguration); action.setDatasource(datasource); - return action; + action.setName(name); + action.setPageId(pageId); + return actionService.save(action); } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java index 07d063bbbd..0b1acff63d 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/OrganizationServiceImpl.java @@ -119,18 +119,18 @@ public class OrganizationServiceImpl extends BaseService groupService.createDefaultGroupsForOrg(org.getId()) - // Get only the group ids of the default groups to assign them to the user - .map(group -> group.getId()) - .collect(Collectors.toSet()) - .flatMap(groupIds -> { - // Set the default group Ids for the user - // Append the new organization's default groups to the existing ones belonging to the user - user.getGroupIds().addAll(groupIds); - // At this point the organization have been saved and the user has been added to the org. - // Now add the newly created organization to the newly created user. - return userOrganizationService.saveUser(user); - }) - .thenReturn(org) + // Get only the group ids of the default groups to assign them to the user + .map(group -> group.getId()) + .collect(Collectors.toSet()) + .flatMap(groupIds -> { + // Set the default group Ids for the user + // Append the new organization's default groups to the existing ones belonging to the user + user.getGroupIds().addAll(groupIds); + // At this point the organization have been saved and the user has been added to the org. + // Now add the newly created organization to the newly created user. + return userOrganizationService.saveUser(user); + }) + .thenReturn(org) ); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java index ee1613ebea..372c5deb43 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PageServiceImpl.java @@ -111,9 +111,9 @@ public class PageServiceImpl extends BaseService i }); return pageMono.map(deletedObj -> { - analyticsService.sendEvent(AnalyticsEvents.DELETE + "_" + deletedObj.getClass().getSimpleName().toUpperCase(), (Page) deletedObj); - return (Page) deletedObj; - }); + analyticsService.sendEvent(AnalyticsEvents.DELETE + "_" + deletedObj.getClass().getSimpleName().toUpperCase(), (Page) deletedObj); + return (Page) deletedObj; + }); } @Override diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PostmanImporterService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PostmanImporterService.java index 8d36f5aec4..223eb28662 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PostmanImporterService.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/PostmanImporterService.java @@ -10,15 +10,16 @@ import com.appsmith.server.domains.Datasource; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Service; +import reactor.core.publisher.Mono; import java.util.ArrayList; import java.util.List; @Service @Slf4j -public class PostmanImporterService extends BaseApiImporter{ +public class PostmanImporterService extends BaseApiImporter { @Override - public Action importAction(Object input) { + public Mono importAction(Object input, String pageId, String name) { Action action = new Action(); ActionConfiguration actionConfiguration = new ActionConfiguration(); Datasource datasource = new Datasource(); @@ -26,7 +27,9 @@ public class PostmanImporterService extends BaseApiImporter{ datasource.setDatasourceConfiguration(datasourceConfiguration); action.setDatasource(datasource); action.setActionConfiguration(actionConfiguration); - return action; + action.setPageId(pageId); + action.setName(name); + return Mono.just(action); } public TemplateCollection importPostmanCollection(Object input) { @@ -79,7 +82,7 @@ public class PostmanImporterService extends BaseApiImporter{ private TemplateCollection createTemplateCollection(String id) { ApiTemplate apiTemplate = createApiTemplate(); TemplateCollection templateCollection = new TemplateCollection(); - List apiTemplateIds ; + List apiTemplateIds; apiTemplateIds = new ArrayList<>(); List apiTemplateList; apiTemplateList = new ArrayList<>(); diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ProviderService.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ProviderService.java new file mode 100644 index 0000000000..b33acb0bbf --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ProviderService.java @@ -0,0 +1,6 @@ +package com.appsmith.server.services; + +import com.appsmith.external.models.Provider; + +public interface ProviderService extends CrudService { +} diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ProviderServiceImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ProviderServiceImpl.java new file mode 100644 index 0000000000..a9622a10ac --- /dev/null +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ProviderServiceImpl.java @@ -0,0 +1,23 @@ +package com.appsmith.server.services; + +import com.appsmith.external.models.Provider; +import com.appsmith.server.repositories.ProviderRepository; +import org.springframework.data.mongodb.core.ReactiveMongoTemplate; +import org.springframework.data.mongodb.core.convert.MongoConverter; +import org.springframework.stereotype.Service; +import reactor.core.scheduler.Scheduler; + +import javax.validation.Validator; + +@Service +public class ProviderServiceImpl extends BaseService implements ProviderService { + + public ProviderServiceImpl(Scheduler scheduler, + Validator validator, + MongoConverter mongoConverter, + ReactiveMongoTemplate reactiveMongoTemplate, + ProviderRepository repository, + AnalyticsService analyticsService) { + super(scheduler, validator, mongoConverter, reactiveMongoTemplate, repository, analyticsService); + } +} diff --git a/app/server/appsmith-server/src/main/resources/public/appsmith/authz/acl.rego b/app/server/appsmith-server/src/main/resources/public/appsmith/authz/acl.rego index 855f68224f..8be9f3b9ee 100644 --- a/app/server/appsmith-server/src/main/resources/public/appsmith/authz/acl.rego +++ b/app/server/appsmith-server/src/main/resources/public/appsmith/authz/acl.rego @@ -99,7 +99,11 @@ authenticated_operations = [ {"method": "GET", "resource": "providers", "permission": "read:providers"}, {"method": "PUT", "resource": "providers", "permission": "update:providers"}, - {"method": "GET", "resource": "marketplace", "permission": "read:marketplace"} + {"method": "GET", "resource": "marketplace", "permission": "read:marketplace"}, + + {"method": "POST", "resource": "templates", "permission": "create:templates"}, + {"method": "GET", "resource": "templates", "permission": "read:templates"}, + {"method": "PUT", "resource": "templates", "permission": "update:templates"} ] diff --git a/app/server/appsmith-server/src/main/resources/public/bundle.tar.gz b/app/server/appsmith-server/src/main/resources/public/bundle.tar.gz index 76fa0374c7..2940bd1063 100644 Binary files a/app/server/appsmith-server/src/main/resources/public/bundle.tar.gz and b/app/server/appsmith-server/src/main/resources/public/bundle.tar.gz differ diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlParserServiceTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlParserServiceTest.java index c1bcecd32a..50818790bc 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlParserServiceTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/CurlParserServiceTest.java @@ -23,9 +23,9 @@ public class CurlParserServiceTest { @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}' "; - Action action = curlImporterService.importAction(command); + Mono action = curlImporterService.importAction(command, "pageId", "actionName"); StepVerifier - .create(Mono.just(action)) + .create(action) .assertNext(action1 -> { assertThat(action1).isNotNull(); assertThat(action1.getDatasource()).isNotNull(); diff --git a/app/server/pom.xml b/app/server/pom.xml index d0137c758a..eaad8ae78e 100644 --- a/app/server/pom.xml +++ b/app/server/pom.xml @@ -1,5 +1,6 @@ - + org.springframework.boot