chore: refactor export (#30521)
## Description Pr for making a common interface for exporting application, packages, and workflows A few interfaces and classes have been added to support the refactor as listed below: - `ExportableArtifact & ExportableArtifactCE` : the base interface which should be implemented by application, packages and workflows for exports. - `ExportServiceCE & ExportService` : This interface is for exporting implementation of `ExportableArtifacts`, the exported class would implement `ArtifactExchangeJson`. - `ContextBasedExportService` : This interface is designed to abstract out the common methods which each ArtifactExportService implementation should implement. - `ApplicationExportService` : this service implements ContextBasedExportService for export of applications # Fixes: <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced export functionality for applications and related entities, allowing users to export their applications to a standardized JSON format. - Implemented a new transactional interface for applications, enhancing the management and manipulation of application properties during export operations. - **Enhancements** - Renamed key terminologies to better reflect the broader scope of exportable and importable artifacts, aligning with the new export service capabilities. - **Bug Fixes** - Adjusted method parameters and logic to ensure consistent behavior in exporting and importing applications and their associated artifacts. - **Documentation** - Updated method names and references in the codebase to match the new terminology and functionality related to application and artifact exports. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
1d4cf0d2a4
commit
0c16ce02a0
|
|
@ -49,7 +49,7 @@ public class ActionCollectionExportableServiceCEImpl implements ExportableServic
|
|||
Optional<AclPermission> optionalPermission = Optional.ofNullable(actionPermission.getExportPermission(
|
||||
exportingMetaDTO.getIsGitSync(), exportingMetaDTO.getExportWithConfiguration()));
|
||||
Flux<ActionCollection> actionCollectionFlux = actionCollectionService.findByPageIdsForExport(
|
||||
exportingMetaDTO.getUnpublishedPages(), optionalPermission);
|
||||
exportingMetaDTO.getUnpublishedModulesOrPages(), optionalPermission);
|
||||
return actionCollectionFlux
|
||||
.collectList()
|
||||
.map(actionCollectionList -> {
|
||||
|
|
@ -80,11 +80,9 @@ public class ActionCollectionExportableServiceCEImpl implements ExportableServic
|
|||
boolean isActionCollectionUpdated = exportingMetaDTO.isClientSchemaMigrated()
|
||||
|| exportingMetaDTO.isServerSchemaMigrated()
|
||||
|| isPageUpdated
|
||||
|| exportingMetaDTO.getApplicationLastCommittedAt() == null
|
||||
|| exportingMetaDTO.getArtifactLastCommittedAt() == null
|
||||
|| actionCollectionUpdatedAt == null
|
||||
|| exportingMetaDTO
|
||||
.getApplicationLastCommittedAt()
|
||||
.isBefore(actionCollectionUpdatedAt);
|
||||
|| exportingMetaDTO.getArtifactLastCommittedAt().isBefore(actionCollectionUpdatedAt);
|
||||
if (isActionCollectionUpdated) {
|
||||
updatedActionCollectionSet.add(actionCollectionName);
|
||||
}
|
||||
|
|
@ -117,8 +115,9 @@ public class ActionCollectionExportableServiceCEImpl implements ExportableServic
|
|||
// be used to replace collectionIds in action
|
||||
if (actionCollection.getUnpublishedCollection() != null) {
|
||||
ActionCollectionDTO actionCollectionDTO = actionCollection.getUnpublishedCollection();
|
||||
actionCollectionDTO.setPageId(
|
||||
mappedExportableResourcesDTO.getPageIdToNameMap().get(actionCollectionDTO.getPageId() + EDIT));
|
||||
actionCollectionDTO.setPageId(mappedExportableResourcesDTO
|
||||
.getPageOrModuleIdToNameMap()
|
||||
.get(actionCollectionDTO.getPageId() + EDIT));
|
||||
actionCollectionDTO.setPluginId(
|
||||
mappedExportableResourcesDTO.getPluginMap().get(actionCollectionDTO.getPluginId()));
|
||||
|
||||
|
|
@ -131,8 +130,9 @@ public class ActionCollectionExportableServiceCEImpl implements ExportableServic
|
|||
}
|
||||
if (actionCollection.getPublishedCollection() != null) {
|
||||
ActionCollectionDTO actionCollectionDTO = actionCollection.getPublishedCollection();
|
||||
actionCollectionDTO.setPageId(
|
||||
mappedExportableResourcesDTO.getPageIdToNameMap().get(actionCollectionDTO.getPageId() + VIEW));
|
||||
actionCollectionDTO.setPageId(mappedExportableResourcesDTO
|
||||
.getPageOrModuleIdToNameMap()
|
||||
.get(actionCollectionDTO.getPageId() + VIEW));
|
||||
actionCollectionDTO.setPluginId(
|
||||
mappedExportableResourcesDTO.getPluginMap().get(actionCollectionDTO.getPluginId()));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
package com.appsmith.server.applications.exports;
|
||||
|
||||
public interface ApplicationExportService extends ApplicationExportServiceCE {}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.appsmith.server.applications.exports;
|
||||
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.exports.internal.ContextBasedExportService;
|
||||
|
||||
public interface ApplicationExportServiceCE extends ContextBasedExportService<Application, ApplicationJson> {}
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
package com.appsmith.server.applications.exports;
|
||||
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ApplicationPage;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.domains.GitApplicationMetadata;
|
||||
import com.appsmith.server.domains.NewAction;
|
||||
import com.appsmith.server.domains.NewPage;
|
||||
import com.appsmith.server.domains.Theme;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.exports.exportable.ExportableService;
|
||||
import com.appsmith.server.migrations.JsonSchemaVersions;
|
||||
import com.appsmith.server.solutions.ApplicationPermission;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
@Slf4j
|
||||
public class ApplicationExportServiceCEImpl implements ApplicationExportServiceCE {
|
||||
|
||||
private final ApplicationService applicationService;
|
||||
private final ApplicationPermission applicationPermission;
|
||||
private final ExportableService<NewPage> newPageExportableService;
|
||||
protected final ExportableService<NewAction> newActionExportableService;
|
||||
protected final ExportableService<ActionCollection> actionCollectionExportableService;
|
||||
private final ExportableService<Theme> themeExportableService;
|
||||
private final Map<String, String> applicationConstantsMap = new HashMap<>();
|
||||
|
||||
public ApplicationExportServiceCEImpl(
|
||||
ApplicationService applicationService,
|
||||
ApplicationPermission applicationPermission,
|
||||
ExportableService<NewPage> newPageExportableService,
|
||||
ExportableService<NewAction> newActionExportableService,
|
||||
ExportableService<ActionCollection> actionCollectionExportableService,
|
||||
ExportableService<Theme> themeExportableService) {
|
||||
this.applicationService = applicationService;
|
||||
this.newPageExportableService = newPageExportableService;
|
||||
this.newActionExportableService = newActionExportableService;
|
||||
this.actionCollectionExportableService = actionCollectionExportableService;
|
||||
this.themeExportableService = themeExportableService;
|
||||
this.applicationPermission = applicationPermission;
|
||||
applicationConstantsMap.putAll(
|
||||
Map.of(FieldName.ARTIFACT_CONTEXT, FieldName.APPLICATION, FieldName.ID, FieldName.APPLICATION_ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationJson createNewArtifactExchangeJson() {
|
||||
return new ApplicationJson();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AclPermission getArtifactExportPermission(Boolean isGitSync, Boolean exportWithConfiguration) {
|
||||
return applicationPermission.getExportPermission(isGitSync, exportWithConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Application> findExistingArtifactByIdAndBranchName(
|
||||
String artifactId, String branchName, AclPermission aclPermission) {
|
||||
// find the application with appropriate permission
|
||||
return applicationService
|
||||
.findByBranchNameAndDefaultApplicationId(branchName, artifactId, aclPermission)
|
||||
// Find the application without permissions if it is a template application
|
||||
.switchIfEmpty(
|
||||
Mono.defer(() -> applicationService.findByIdAndExportWithConfiguration(artifactId, TRUE)))
|
||||
.switchIfEmpty(Mono.error(
|
||||
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.APPLICATION_ID, artifactId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Application> findExistingArtifactForAnalytics(String artifactId) {
|
||||
return applicationService.findById(artifactId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getExportRelatedArtifactData(ArtifactExchangeJson artifactExchangeJson) {
|
||||
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
return Map.of(
|
||||
"pageCount",
|
||||
applicationJson.getPageList().size(),
|
||||
"actionCount",
|
||||
applicationJson.getActionList().size(),
|
||||
"JSObjectCount",
|
||||
applicationJson.getActionCollectionList().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getArtifactReadyForExport(
|
||||
ExportableArtifact exportableArtifact,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
ExportingMetaDTO exportingMetaDTO) {
|
||||
|
||||
Application application = (Application) exportableArtifact;
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
|
||||
GitApplicationMetadata gitApplicationMetadata = application.getGitApplicationMetadata();
|
||||
Instant applicationLastCommittedAt =
|
||||
gitApplicationMetadata != null ? gitApplicationMetadata.getLastCommittedAt() : null;
|
||||
boolean isClientSchemaMigrated = !JsonSchemaVersions.clientVersion.equals(application.getClientSchemaVersion());
|
||||
boolean isServerSchemaMigrated = !JsonSchemaVersions.serverVersion.equals(application.getServerSchemaVersion());
|
||||
|
||||
exportingMetaDTO.setArtifactLastCommittedAt(applicationLastCommittedAt);
|
||||
exportingMetaDTO.setClientSchemaMigrated(isClientSchemaMigrated);
|
||||
exportingMetaDTO.setServerSchemaMigrated(isServerSchemaMigrated);
|
||||
applicationJson.setExportedApplication(application);
|
||||
applicationJson.setUpdatedResources(new ConcurrentHashMap<>());
|
||||
|
||||
List<String> unpublishedPages =
|
||||
application.getPages().stream().map(ApplicationPage::getId).collect(Collectors.toList());
|
||||
|
||||
exportingMetaDTO.setUnpublishedModulesOrPages(unpublishedPages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getConstantsMap() {
|
||||
return applicationConstantsMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitizeArtifactSpecificExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
SerialiseArtifactObjective serialiseArtifactObjective) {
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
newPageExportableService.sanitizeEntities(
|
||||
exportingMetaDTO, mappedExportableResourcesDTO, applicationJson, serialiseArtifactObjective);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Void> generateArtifactSpecificExportables(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson) {
|
||||
return exportableArtifactMono.flatMapMany(exportableArtifact -> {
|
||||
Mono<Application> applicationMono = Mono.just((Application) exportableArtifact);
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
|
||||
// Directly updates required theme information in application json
|
||||
Mono<Void> themeExportablesMono = themeExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, applicationMono, applicationJson);
|
||||
|
||||
// Updates pageId to name map in exportable resources.
|
||||
// Also directly updates required pages information in application json
|
||||
Mono<Void> newPageExportablesMono = newPageExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, applicationMono, applicationJson);
|
||||
|
||||
return Flux.merge(newPageExportablesMono, themeExportablesMono);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Flux<Void> generateArtifactComponentDependentExportables(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson) {
|
||||
return exportableArtifactMono.flatMapMany(exportableArtifact -> {
|
||||
Mono<Application> applicationMono = Mono.just((Application) exportableArtifact);
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
|
||||
// Requires pageIdToNameMap, pluginMap.
|
||||
// Updates collectionId to name map in exportable resources.
|
||||
// Also directly updates required collection information in application json
|
||||
Mono<Void> actionCollectionExportablesMono = actionCollectionExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, applicationMono, applicationJson);
|
||||
|
||||
// Requires datasourceIdToNameMap, pageIdToNameMap, pluginMap, collectionIdToNameMap
|
||||
// Updates actionId to name map in exportable resources.
|
||||
// Also directly updates required collection information in application json
|
||||
Mono<Void> newActionExportablesMono = newActionExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, applicationMono, applicationJson);
|
||||
|
||||
Mono<Void> combinedActionExportablesMono = actionCollectionExportablesMono.then(newActionExportablesMono);
|
||||
|
||||
return combinedActionExportablesMono.flux();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.appsmith.server.applications.exports;
|
||||
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.NewAction;
|
||||
import com.appsmith.server.domains.NewPage;
|
||||
import com.appsmith.server.domains.Theme;
|
||||
import com.appsmith.server.exports.exportable.ExportableService;
|
||||
import com.appsmith.server.solutions.ApplicationPermission;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ApplicationExportServiceImpl extends ApplicationExportServiceCEImpl implements ApplicationExportService {
|
||||
|
||||
public ApplicationExportServiceImpl(
|
||||
ApplicationService applicationService,
|
||||
ApplicationPermission applicationPermission,
|
||||
ExportableService<NewPage> newPageExportableService,
|
||||
ExportableService<NewAction> newActionExportableService,
|
||||
ExportableService<ActionCollection> actionCollectionExportableService,
|
||||
ExportableService<Theme> themeExportableService) {
|
||||
super(
|
||||
applicationService,
|
||||
applicationPermission,
|
||||
newPageExportableService,
|
||||
newActionExportableService,
|
||||
actionCollectionExportableService,
|
||||
themeExportableService);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.appsmith.server.constants;
|
||||
|
||||
public enum SerialiseApplicationObjective {
|
||||
public enum SerialiseArtifactObjective {
|
||||
// For which purpose we are serialising the application from DB
|
||||
VERSION_CONTROL,
|
||||
SHARE,
|
||||
|
|
@ -3,6 +3,7 @@ package com.appsmith.server.controllers;
|
|||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.Url;
|
||||
import com.appsmith.server.controllers.ce.ApplicationControllerCE;
|
||||
import com.appsmith.server.exports.exportable.ExportService;
|
||||
import com.appsmith.server.exports.internal.ExportApplicationService;
|
||||
import com.appsmith.server.exports.internal.PartialExportService;
|
||||
import com.appsmith.server.fork.internal.ApplicationForkingService;
|
||||
|
|
@ -31,7 +32,8 @@ public class ApplicationController extends ApplicationControllerCE {
|
|||
ApplicationSnapshotService applicationSnapshotService,
|
||||
PartialExportService partialExportService,
|
||||
PartialImportService partialImportService,
|
||||
ImportService importService) {
|
||||
ImportService importService,
|
||||
ExportService exportService) {
|
||||
super(
|
||||
service,
|
||||
applicationPageService,
|
||||
|
|
@ -43,6 +45,7 @@ public class ApplicationController extends ApplicationControllerCE {
|
|||
applicationSnapshotService,
|
||||
partialExportService,
|
||||
partialImportService,
|
||||
importService);
|
||||
importService,
|
||||
exportService);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.appsmith.server.dtos.ResponseDTO;
|
|||
import com.appsmith.server.dtos.UserHomepageDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.exports.exportable.ExportService;
|
||||
import com.appsmith.server.exports.internal.ExportApplicationService;
|
||||
import com.appsmith.server.exports.internal.PartialExportService;
|
||||
import com.appsmith.server.fork.internal.ApplicationForkingService;
|
||||
|
|
@ -72,6 +73,7 @@ public class ApplicationControllerCE extends BaseController<ApplicationService,
|
|||
private final PartialExportService partialExportService;
|
||||
private final PartialImportService partialImportService;
|
||||
private final ImportService importService;
|
||||
private final ExportService exportService;
|
||||
|
||||
@Autowired
|
||||
public ApplicationControllerCE(
|
||||
|
|
@ -85,8 +87,10 @@ public class ApplicationControllerCE extends BaseController<ApplicationService,
|
|||
ApplicationSnapshotService applicationSnapshotService,
|
||||
PartialExportService partialExportService,
|
||||
PartialImportService partialImportService,
|
||||
ImportService importService) {
|
||||
ImportService importService,
|
||||
ExportService exportService) {
|
||||
super(service);
|
||||
this.exportService = exportService;
|
||||
this.applicationPageService = applicationPageService;
|
||||
this.applicationFetcher = applicationFetcher;
|
||||
this.applicationForkingService = applicationForkingService;
|
||||
|
|
@ -247,7 +251,7 @@ public class ApplicationControllerCE extends BaseController<ApplicationService,
|
|||
|
||||
return exportApplicationService.getApplicationFile(id, branchName).map(fetchedResource -> {
|
||||
HttpHeaders responseHeaders = fetchedResource.getHttpHeaders();
|
||||
Object applicationResource = fetchedResource.getApplicationResource();
|
||||
Object applicationResource = fetchedResource.getArtifactResource();
|
||||
return new ResponseEntity<>(applicationResource, responseHeaders, HttpStatus.OK);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,13 @@ import com.appsmith.external.models.DatasourceStorage;
|
|||
import com.appsmith.external.models.DecryptedSensitiveFields;
|
||||
import com.appsmith.external.models.OAuth2;
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.datasourcestorages.base.DatasourceStorageService;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import com.appsmith.server.exports.exportable.ExportableServiceCE;
|
||||
|
|
@ -102,6 +104,21 @@ public class DatasourceExportableServiceCEImpl implements ExportableServiceCE<Da
|
|||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> getExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
Boolean isContextAgnostic) {
|
||||
return exportableArtifactMono.flatMap(exportableArtifact -> {
|
||||
Mono<Application> applicationMono = Mono.just((Application) exportableArtifact);
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
return getExportableEntities(
|
||||
exportingMetaDTO, mappedExportableResourcesDTO, applicationMono, applicationJson);
|
||||
});
|
||||
}
|
||||
|
||||
private void removeSensitiveFields(DatasourceStorage datasourceStorage) {
|
||||
if (datasourceStorage.getDatasourceConfiguration() != null) {
|
||||
datasourceStorage.getDatasourceConfiguration().setAuthentication(null);
|
||||
|
|
@ -123,16 +140,27 @@ public class DatasourceExportableServiceCEImpl implements ExportableServiceCE<Da
|
|||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitizeEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
SerialiseArtifactObjective serialiseFor,
|
||||
Boolean isContextAgnositc) {
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
sanitizeEntities(exportingMetaDTO, mappedExportableResourcesDTO, applicationJson, serialiseFor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanitizeEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ApplicationJson applicationJson,
|
||||
SerialiseApplicationObjective serialiseFor) {
|
||||
SerialiseArtifactObjective serialiseFor) {
|
||||
// Save decrypted fields for datasources for internally used sample apps and templates
|
||||
// only when serialising for file sharing
|
||||
if (TRUE.equals(exportingMetaDTO.getExportWithConfiguration())
|
||||
&& SerialiseApplicationObjective.SHARE.equals(serialiseFor)) {
|
||||
&& SerialiseArtifactObjective.SHARE.equals(serialiseFor)) {
|
||||
// Save decrypted fields for datasources
|
||||
Map<String, DecryptedSensitiveFields> decryptedFields = new HashMap<>();
|
||||
applicationJson.getDatasourceList().forEach(datasourceStorage -> {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import static com.appsmith.server.helpers.DateUtils.ISO_FORMATTER;
|
|||
@NoArgsConstructor
|
||||
@QueryEntity
|
||||
@Document
|
||||
public class Application extends BaseDomain implements ImportableArtifact {
|
||||
public class Application extends BaseDomain implements ImportableArtifact, ExportableArtifact {
|
||||
|
||||
@NotNull @JsonView(Views.Public.class)
|
||||
String name;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
package com.appsmith.server.domains;
|
||||
|
||||
import com.appsmith.server.domains.ce.ExportableArtifactCE;
|
||||
|
||||
public interface ExportableArtifact extends ExportableArtifactCE {}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.appsmith.server.domains.ce;
|
||||
|
||||
public interface ExportableArtifactCE {
|
||||
|
||||
String getId();
|
||||
|
||||
String getName();
|
||||
|
||||
String getWorkspaceId();
|
||||
|
||||
Boolean getExportWithConfiguration();
|
||||
|
||||
void setExportWithConfiguration(Boolean bool);
|
||||
|
||||
void makePristine();
|
||||
|
||||
void sanitiseToExportDBObject();
|
||||
}
|
||||
|
|
@ -6,5 +6,5 @@ import org.springframework.http.HttpHeaders;
|
|||
@Data
|
||||
public class ExportFileDTO {
|
||||
HttpHeaders httpHeaders;
|
||||
Object applicationResource;
|
||||
Object artifactResource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@Builder(toBuilder = true)
|
||||
public class ExportingMetaDTO {
|
||||
String applicationId;
|
||||
String artifactId;
|
||||
String branchName;
|
||||
Boolean isGitSync;
|
||||
Boolean exportWithConfiguration;
|
||||
|
||||
Instant applicationLastCommittedAt;
|
||||
Instant artifactLastCommittedAt;
|
||||
boolean isClientSchemaMigrated;
|
||||
boolean isServerSchemaMigrated;
|
||||
|
||||
List<String> unpublishedPages;
|
||||
List<String> unpublishedModulesOrPages;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.appsmith.server.constants.ArtifactJsonType;
|
|||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.domains.ImportableArtifact;
|
||||
import com.appsmith.server.domains.NewAction;
|
||||
import com.appsmith.server.domains.NewPage;
|
||||
|
|
@ -125,6 +126,11 @@ public class ApplicationJsonCE implements ArtifactExchangeJson {
|
|||
return this.getExportedApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExportableArtifact getExportableArtifact() {
|
||||
return this.getExportedApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomJSLib> getCustomJsLibFromArtifact() {
|
||||
return this.getCustomJSLibList();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.appsmith.server.dtos.ce;
|
|||
|
||||
import com.appsmith.server.constants.ArtifactJsonType;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.domains.ImportableArtifact;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -20,5 +21,7 @@ public interface ArtifactExchangeJsonCE {
|
|||
|
||||
ImportableArtifact getImportableArtifact();
|
||||
|
||||
ExportableArtifact getExportableArtifact();
|
||||
|
||||
List<CustomJSLib> getCustomJsLibFromArtifact();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public class MappedExportableResourcesCE_DTO {
|
|||
Map<String, String> pluginMap = new HashMap<>();
|
||||
Map<String, String> datasourceIdToNameMap = new HashMap<>();
|
||||
Map<String, Instant> datasourceNameToUpdatedAtMap = new HashMap<>();
|
||||
Map<String, String> pageIdToNameMap = new HashMap<>();
|
||||
Map<String, String> pageOrModuleIdToNameMap = new HashMap<>();
|
||||
Map<String, String> actionIdToNameMap = new HashMap<>();
|
||||
Map<String, String> collectionIdToNameMap = new HashMap<>();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
package com.appsmith.server.exports.exportable;
|
||||
|
||||
public interface ExportService extends ExportServiceCE {}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.appsmith.server.exports.exportable;
|
||||
|
||||
import com.appsmith.server.constants.ArtifactJsonType;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportFileDTO;
|
||||
import com.appsmith.server.exports.internal.ContextBasedExportService;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface ExportServiceCE {
|
||||
|
||||
ContextBasedExportService<?, ?> getContextBasedExportService(ArtifactJsonType artifactJsonType);
|
||||
|
||||
Mono<? extends ArtifactExchangeJson> exportByExportableArtifactIdAndBranchName(
|
||||
String artifactId,
|
||||
String branchName,
|
||||
SerialiseArtifactObjective objective,
|
||||
ArtifactJsonType artifactJsonType);
|
||||
|
||||
/**
|
||||
* This function will give the artifact the resources to rebuild the artifact in import artifact flow
|
||||
*
|
||||
* @param artifactId which needs to be exported
|
||||
* @return application reference from which entire application can be rehydrated
|
||||
*/
|
||||
Mono<? extends ArtifactExchangeJson> exportByArtifactId(
|
||||
String artifactId, SerialiseArtifactObjective objective, ArtifactJsonType artifactJsonType);
|
||||
|
||||
Mono<? extends ArtifactExchangeJson> exportByArtifactIdAndBranchName(
|
||||
String artifactId, String branchName, ArtifactJsonType artifactJsonType);
|
||||
|
||||
Mono<ExportFileDTO> getArtifactFile(String artifactId, String branchName, ArtifactJsonType artifactJsonType);
|
||||
}
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
package com.appsmith.server.exports.exportable;
|
||||
|
||||
import com.appsmith.external.constants.AnalyticsEvents;
|
||||
import com.appsmith.external.helpers.Stopwatch;
|
||||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.applications.exports.ApplicationExportService;
|
||||
import com.appsmith.server.constants.ArtifactJsonType;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.domains.Plugin;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportFileDTO;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.exports.internal.ContextBasedExportService;
|
||||
import com.appsmith.server.migrations.JsonSchemaVersions;
|
||||
import com.appsmith.server.services.AnalyticsService;
|
||||
import com.appsmith.server.services.SessionUserService;
|
||||
import com.appsmith.server.services.WorkspaceService;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.util.StringUtils;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.Boolean.TRUE;
|
||||
|
||||
@Slf4j
|
||||
public class ExportServiceCEImpl implements ExportServiceCE {
|
||||
|
||||
private final SessionUserService sessionUserService;
|
||||
private final AnalyticsService analyticsService;
|
||||
private final WorkspaceService workspaceService;
|
||||
private final ApplicationExportService applicationExportService;
|
||||
private final ExportableService<Datasource> datasourceExportableService;
|
||||
private final ExportableService<Plugin> pluginExportableService;
|
||||
private final ExportableService<CustomJSLib> customJSLibExportableService;
|
||||
protected final Gson gson;
|
||||
|
||||
public ExportServiceCEImpl(
|
||||
SessionUserService sessionUserService,
|
||||
AnalyticsService analyticsService,
|
||||
ApplicationExportService applicationExportService,
|
||||
WorkspaceService workspaceService,
|
||||
Gson gson,
|
||||
ExportableService<Datasource> datasourceExportableService,
|
||||
ExportableService<Plugin> pluginExportableService,
|
||||
ExportableService<CustomJSLib> customJSLibExportableService) {
|
||||
this.sessionUserService = sessionUserService;
|
||||
this.analyticsService = analyticsService;
|
||||
this.workspaceService = workspaceService;
|
||||
this.gson = gson;
|
||||
this.applicationExportService = applicationExportService;
|
||||
this.datasourceExportableService = datasourceExportableService;
|
||||
this.pluginExportableService = pluginExportableService;
|
||||
this.customJSLibExportableService = customJSLibExportableService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContextBasedExportService<?, ?> getContextBasedExportService(@NonNull ArtifactJsonType artifactJsonType) {
|
||||
return switch (artifactJsonType) {
|
||||
case APPLICATION -> applicationExportService;
|
||||
default -> applicationExportService;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<? extends ArtifactExchangeJson> exportByExportableArtifactIdAndBranchName(
|
||||
String artifactId,
|
||||
String branchName,
|
||||
SerialiseArtifactObjective objective,
|
||||
ArtifactJsonType artifactJsonType) {
|
||||
|
||||
// We require this to be present, without this we can't move further ahead
|
||||
if (artifactJsonType == null) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.ARTIFACT_CONTEXT));
|
||||
}
|
||||
|
||||
ContextBasedExportService<?, ?> contextBasedExportService = getContextBasedExportService(artifactJsonType);
|
||||
Map<String, String> artifactContextConstantMap = contextBasedExportService.getConstantsMap();
|
||||
String idConstant = artifactContextConstantMap.get(FieldName.ID);
|
||||
|
||||
if (!StringUtils.hasText(artifactId)) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, idConstant));
|
||||
}
|
||||
|
||||
// Start the stopwatch to log the execution time
|
||||
Stopwatch stopwatch = new Stopwatch(AnalyticsEvents.EXPORT.getEventName());
|
||||
|
||||
boolean exportWithConfiguration = false;
|
||||
|
||||
/*
|
||||
since we are merging the method exportByArtifactIdAndBranchName to one method for performance reasons
|
||||
this step is required for test cases and TemplateServices
|
||||
*/
|
||||
SerialiseArtifactObjective serialiseArtifactObjective =
|
||||
objective == null ? SerialiseArtifactObjective.SHARE : objective;
|
||||
|
||||
boolean isGitSync = SerialiseArtifactObjective.VERSION_CONTROL.equals(serialiseArtifactObjective)
|
||||
|| SerialiseArtifactObjective.KNOWLEDGE_BASE_GENERATION.equals(serialiseArtifactObjective);
|
||||
|
||||
// We need edit permission for git-related tasks, otherwise export permissions are required
|
||||
AclPermission permission =
|
||||
contextBasedExportService.getArtifactExportPermission(isGitSync, exportWithConfiguration);
|
||||
|
||||
final MappedExportableResourcesDTO mappedResourcesDTO = new MappedExportableResourcesDTO();
|
||||
final ExportingMetaDTO exportingMetaDTO = new ExportingMetaDTO();
|
||||
|
||||
ArtifactExchangeJson artifactExchangeJson = contextBasedExportService.createNewArtifactExchangeJson();
|
||||
// Set json schema version which will be used to check the compatibility while importing the JSON
|
||||
artifactExchangeJson.setServerSchemaVersion(JsonSchemaVersions.serverVersion);
|
||||
artifactExchangeJson.setClientSchemaVersion(JsonSchemaVersions.clientVersion);
|
||||
|
||||
// Find the transaction artifact with appropriate permission
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono = contextBasedExportService
|
||||
.findExistingArtifactByIdAndBranchName(artifactId, branchName, permission)
|
||||
.map(transactionArtifact -> {
|
||||
// Since we have moved the setting of artifactId from the repository, the MetaDTO needs to assigned
|
||||
// from here
|
||||
exportingMetaDTO.setArtifactId(transactionArtifact.getId());
|
||||
exportingMetaDTO.setBranchName(null);
|
||||
exportingMetaDTO.setIsGitSync(isGitSync);
|
||||
exportingMetaDTO.setExportWithConfiguration(exportWithConfiguration);
|
||||
|
||||
if (!TRUE.equals(transactionArtifact.getExportWithConfiguration())) {
|
||||
// Explicitly setting the boolean to avoid NPE for future checks
|
||||
transactionArtifact.setExportWithConfiguration(false);
|
||||
}
|
||||
exportingMetaDTO.setExportWithConfiguration(transactionArtifact.getExportWithConfiguration());
|
||||
return transactionArtifact;
|
||||
})
|
||||
.cache();
|
||||
|
||||
return exportableArtifactMono
|
||||
.flatMap(exportableArtifact -> {
|
||||
// Refactor exportableArtifact to remove the ids
|
||||
// TODO rename the method
|
||||
contextBasedExportService.getArtifactReadyForExport(
|
||||
exportableArtifact, artifactExchangeJson, exportingMetaDTO);
|
||||
return getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson)
|
||||
.then(Mono.defer(() -> sanitizeEntities(
|
||||
serialiseArtifactObjective,
|
||||
artifactExchangeJson,
|
||||
mappedResourcesDTO,
|
||||
exportingMetaDTO)))
|
||||
.then(Mono.fromCallable(() -> {
|
||||
exportableArtifact.makePristine();
|
||||
exportableArtifact.sanitiseToExportDBObject();
|
||||
// Disable exporting the exportableArtifact with datasource config once imported in
|
||||
// destination
|
||||
// instance
|
||||
exportableArtifact.setExportWithConfiguration(null);
|
||||
return artifactExchangeJson;
|
||||
}));
|
||||
})
|
||||
.then(sessionUserService.getCurrentUser())
|
||||
.flatMap(user -> {
|
||||
Map<String, String> contextConstants = contextBasedExportService.getConstantsMap();
|
||||
stopwatch.stopTimer();
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
data.put(FieldName.FLOW_NAME, stopwatch.getFlow());
|
||||
data.put("executionTime", stopwatch.getExecutionTime());
|
||||
data.put(contextConstants.get(FieldName.ID), exportingMetaDTO.getArtifactId());
|
||||
data.putAll(contextBasedExportService.getExportRelatedArtifactData(artifactExchangeJson));
|
||||
return analyticsService
|
||||
.sendEvent(AnalyticsEvents.UNIT_EXECUTION_TIME.getEventName(), user.getUsername(), data)
|
||||
.thenReturn(artifactExchangeJson);
|
||||
})
|
||||
.flatMap(unused -> sendExportArtifactAnalyticsEvent(
|
||||
contextBasedExportService, exportingMetaDTO.getArtifactId(), AnalyticsEvents.EXPORT))
|
||||
.thenReturn(artifactExchangeJson);
|
||||
}
|
||||
|
||||
protected Mono<Void> sanitizeEntities(
|
||||
SerialiseArtifactObjective serialiseFor,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
ExportingMetaDTO exportingMetaDTO) {
|
||||
|
||||
ContextBasedExportService<?, ?> contextBasedExportService =
|
||||
getContextBasedExportService(artifactExchangeJson.getArtifactJsonType());
|
||||
|
||||
datasourceExportableService.sanitizeEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, artifactExchangeJson, serialiseFor, true);
|
||||
|
||||
contextBasedExportService.sanitizeArtifactSpecificExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, artifactExchangeJson, serialiseFor);
|
||||
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
private Mono<Void> getExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson) {
|
||||
|
||||
ContextBasedExportService<?, ?> contextBasedExportService =
|
||||
getContextBasedExportService(artifactExchangeJson.getArtifactJsonType());
|
||||
|
||||
List<Mono<Void>> artifactAgnosticExportedEntities = generateArtifactAgnosticExportables(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson);
|
||||
Flux<Void> artifactSpecificExportedEntities = contextBasedExportService.generateArtifactSpecificExportables(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson);
|
||||
Flux<Void> artifactComponentDependentExportedEntities =
|
||||
contextBasedExportService.generateArtifactComponentDependentExportables(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson);
|
||||
|
||||
// The idea with both these methods is that any amount of overriding should take care of whether they want to
|
||||
// zip the additional exportables along with these or sequence them, or combine them using any other logic
|
||||
return Flux.merge(artifactAgnosticExportedEntities)
|
||||
.thenMany(Flux.merge(artifactSpecificExportedEntities))
|
||||
.thenMany(Flux.merge(artifactComponentDependentExportedEntities))
|
||||
.then();
|
||||
}
|
||||
|
||||
protected List<Mono<Void>> generateArtifactAgnosticExportables(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson) {
|
||||
|
||||
// Updates plugin map in exportable resources
|
||||
Mono<Void> pluginExportablesMono = pluginExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson, TRUE);
|
||||
|
||||
// Updates datasourceId to name map in exportable resources.
|
||||
// Also directly updates required datasources information in artifactExchangeJSON
|
||||
Mono<Void> datasourceExportablesMono = datasourceExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson, TRUE);
|
||||
|
||||
// Directly sets required custom JS lib information in artifactExchangeJSON
|
||||
Mono<Void> customJsLibsExportablesMono = customJSLibExportableService.getExportableEntities(
|
||||
exportingMetaDTO, mappedResourcesDTO, exportableArtifactMono, artifactExchangeJson, TRUE);
|
||||
|
||||
return List.of(pluginExportablesMono, datasourceExportablesMono, customJsLibsExportablesMono);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is for general export flow of any artifact with default branch with the right artifact-Id.
|
||||
* Since we are moving towards unique-id artifacts for Git (under considerations), this would be main method moving forward.
|
||||
* @param artifactId : ID of the artifact to be exported
|
||||
* @param objective : objective of serialisation, it could be for version-control, sharing, or some other purpose
|
||||
* @param artifactJsonType : Type of Artifact.
|
||||
* @return A json which extends Artifact exchange json i.e. ApplicationJson
|
||||
*/
|
||||
@Override
|
||||
public Mono<? extends ArtifactExchangeJson> exportByArtifactId(
|
||||
String artifactId, SerialiseArtifactObjective objective, ArtifactJsonType artifactJsonType) {
|
||||
return exportByExportableArtifactIdAndBranchName(artifactId, null, objective, artifactJsonType);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is explicitly for exporting applications which is present in different branches.
|
||||
* @param artifactId : ID of the artifact to be exported
|
||||
* @param branchName : branch name of the artifact in case it's git connected
|
||||
* @param artifactJsonType : Type of Artifact.
|
||||
* @return A json which extends Artifact exchange json i.e. ApplicationJson
|
||||
*/
|
||||
@Override
|
||||
public Mono<? extends ArtifactExchangeJson> exportByArtifactIdAndBranchName(
|
||||
String artifactId, String branchName, ArtifactJsonType artifactJsonType) {
|
||||
return exportByExportableArtifactIdAndBranchName(
|
||||
artifactId, branchName, SerialiseArtifactObjective.SHARE, artifactJsonType);
|
||||
}
|
||||
|
||||
public Mono<ExportFileDTO> getArtifactFile(
|
||||
String artifactId, String branchName, ArtifactJsonType artifactJsonType) {
|
||||
return exportByArtifactIdAndBranchName(artifactId, branchName, artifactJsonType)
|
||||
.map(artifactExchangeJson -> {
|
||||
String stringifiedFile = gson.toJson(artifactExchangeJson);
|
||||
String artifactName =
|
||||
artifactExchangeJson.getExportableArtifact().getName();
|
||||
Object jsonObject = gson.fromJson(stringifiedFile, Object.class);
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
ContentDisposition contentDisposition = ContentDisposition.builder("attachment")
|
||||
.filename(artifactName + ".json", StandardCharsets.UTF_8)
|
||||
.build();
|
||||
responseHeaders.setContentDisposition(contentDisposition);
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ExportFileDTO exportFileDTO = new ExportFileDTO();
|
||||
exportFileDTO.setArtifactResource(jsonObject);
|
||||
exportFileDTO.setHttpHeaders(responseHeaders);
|
||||
return exportFileDTO;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* To send analytics event for import and export of application
|
||||
*
|
||||
* @param contextBasedExportService : A exportService which is an implementation of contextBasedExportService
|
||||
* @param exportableArtifactId : String exportableArtifactId
|
||||
* @param event : Analytics Event
|
||||
* @return a subclass of which is imported or exported
|
||||
*/
|
||||
private Mono<? extends ExportableArtifact> sendExportArtifactAnalyticsEvent(
|
||||
ContextBasedExportService<?, ?> contextBasedExportService,
|
||||
String exportableArtifactId,
|
||||
AnalyticsEvents event) {
|
||||
return contextBasedExportService
|
||||
.findExistingArtifactForAnalytics(exportableArtifactId)
|
||||
.flatMap(exportableArtifact -> {
|
||||
return workspaceService
|
||||
.getById(exportableArtifact.getWorkspaceId())
|
||||
.flatMap(workspace -> {
|
||||
Map<String, String> contextConstants = contextBasedExportService.getConstantsMap();
|
||||
final Map<String, Object> data = new HashMap<>();
|
||||
final Map<String, Object> eventData = Map.of(
|
||||
contextConstants.get(FieldName.ARTIFACT_CONTEXT),
|
||||
exportableArtifact,
|
||||
FieldName.WORKSPACE,
|
||||
workspace);
|
||||
|
||||
data.put(FieldName.EVENT_DATA, eventData);
|
||||
data.put(FieldName.WORKSPACE_ID, workspace.getId());
|
||||
data.put(contextConstants.get(FieldName.ID), exportableArtifact.getId());
|
||||
return analyticsService.sendObjectEvent(event, exportableArtifact, data);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.appsmith.server.exports.exportable;
|
||||
|
||||
import com.appsmith.external.models.Datasource;
|
||||
import com.appsmith.server.applications.exports.ApplicationExportService;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.Plugin;
|
||||
import com.appsmith.server.services.AnalyticsService;
|
||||
import com.appsmith.server.services.SessionUserService;
|
||||
import com.appsmith.server.services.WorkspaceService;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ExportServiceImpl extends ExportServiceCEImpl implements ExportService {
|
||||
|
||||
public ExportServiceImpl(
|
||||
SessionUserService sessionUserService,
|
||||
AnalyticsService analyticsService,
|
||||
ApplicationExportService applicationExportService,
|
||||
WorkspaceService workspaceService,
|
||||
Gson gson,
|
||||
ExportableService<Datasource> datasourceExportableService,
|
||||
ExportableService<Plugin> pluginExportableService,
|
||||
ExportableService<CustomJSLib> customJSLibExportableService) {
|
||||
super(
|
||||
sessionUserService,
|
||||
analyticsService,
|
||||
applicationExportService,
|
||||
workspaceService,
|
||||
gson,
|
||||
datasourceExportableService,
|
||||
pluginExportableService,
|
||||
customJSLibExportableService);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
package com.appsmith.server.exports.exportable;
|
||||
|
||||
import com.appsmith.external.models.BaseDomain;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
|
@ -20,11 +22,27 @@ public interface ExportableServiceCE<T extends BaseDomain> {
|
|||
Mono<Application> applicationMono,
|
||||
ApplicationJson applicationJson);
|
||||
|
||||
default Mono<Void> getExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
Boolean isContextAgnostic) {
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
default void sanitizeEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ApplicationJson applicationJson,
|
||||
SerialiseApplicationObjective serialiseFor) {}
|
||||
SerialiseArtifactObjective serialiseFor) {}
|
||||
|
||||
default void sanitizeEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
SerialiseArtifactObjective serialiseFor,
|
||||
Boolean isContextAgnositc) {}
|
||||
|
||||
default Set<String> mapNameToIdForExportableEntities(
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO, List<T> entityList) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
package com.appsmith.server.exports.internal;
|
||||
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
|
||||
public interface ContextBasedExportService<T extends ExportableArtifact, U extends ArtifactExchangeJson>
|
||||
extends ContextBasedExportServiceCE<T, U> {}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.appsmith.server.exports.internal;
|
||||
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ContextBasedExportServiceCE<T extends ExportableArtifact, U extends ArtifactExchangeJson> {
|
||||
|
||||
U createNewArtifactExchangeJson();
|
||||
|
||||
AclPermission getArtifactExportPermission(Boolean isGitSync, Boolean exportWithConfiguration);
|
||||
|
||||
Mono<T> findExistingArtifactByIdAndBranchName(String artifactId, String branchName, AclPermission aclPermission);
|
||||
|
||||
Mono<T> findExistingArtifactForAnalytics(String artifactId);
|
||||
|
||||
void getArtifactReadyForExport(
|
||||
ExportableArtifact exportableArtifact,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
ExportingMetaDTO exportingMetaDTO);
|
||||
|
||||
Map<String, Object> getExportRelatedArtifactData(ArtifactExchangeJson artifactExchangeJson);
|
||||
|
||||
Map<String, String> getConstantsMap();
|
||||
|
||||
void sanitizeArtifactSpecificExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
SerialiseArtifactObjective serialiseArtifactObjective);
|
||||
|
||||
Flux<Void> generateArtifactSpecificExportables(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson);
|
||||
|
||||
Flux<Void> generateArtifactComponentDependentExportables(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson);
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.appsmith.server.exports.internal;
|
||||
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ExportFileDTO;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
|
@ -13,7 +13,7 @@ public interface ExportApplicationServiceCE {
|
|||
* @param applicationId which needs to be exported
|
||||
* @return application reference from which entire application can be rehydrated
|
||||
*/
|
||||
Mono<ApplicationJson> exportApplicationById(String applicationId, SerialiseApplicationObjective serialiseFor);
|
||||
Mono<ApplicationJson> exportApplicationById(String applicationId, SerialiseArtifactObjective serialiseFor);
|
||||
|
||||
Mono<ApplicationJson> exportApplicationById(String applicationId, String branchName);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import com.appsmith.external.models.Datasource;
|
|||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ApplicationPage;
|
||||
|
|
@ -71,8 +71,7 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
* @param applicationId which needs to be exported
|
||||
* @return application reference from which entire application can be rehydrated
|
||||
*/
|
||||
public Mono<ApplicationJson> exportApplicationById(
|
||||
String applicationId, SerialiseApplicationObjective serialiseFor) {
|
||||
public Mono<ApplicationJson> exportApplicationById(String applicationId, SerialiseArtifactObjective serialiseFor) {
|
||||
|
||||
// Start the stopwatch to log the execution time
|
||||
Stopwatch stopwatch = new Stopwatch(AnalyticsEvents.EXPORT.getEventName());
|
||||
|
|
@ -87,15 +86,15 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
ApplicationJson applicationJson = new ApplicationJson();
|
||||
final MappedExportableResourcesDTO mappedResourcesDTO = new MappedExportableResourcesDTO();
|
||||
final ExportingMetaDTO exportingMetaDTO = new ExportingMetaDTO();
|
||||
exportingMetaDTO.setApplicationId(applicationId);
|
||||
exportingMetaDTO.setArtifactId(applicationId);
|
||||
exportingMetaDTO.setBranchName(null);
|
||||
|
||||
if (applicationId == null || applicationId.isEmpty()) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, FieldName.APPLICATION_ID));
|
||||
}
|
||||
|
||||
boolean isGitSync = SerialiseApplicationObjective.VERSION_CONTROL.equals(serialiseFor)
|
||||
|| SerialiseApplicationObjective.KNOWLEDGE_BASE_GENERATION.equals(serialiseFor);
|
||||
boolean isGitSync = SerialiseArtifactObjective.VERSION_CONTROL.equals(serialiseFor)
|
||||
|| SerialiseArtifactObjective.KNOWLEDGE_BASE_GENERATION.equals(serialiseFor);
|
||||
exportingMetaDTO.setIsGitSync(isGitSync);
|
||||
exportingMetaDTO.setExportWithConfiguration(false);
|
||||
|
||||
|
|
@ -135,7 +134,7 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
!JsonSchemaVersions.clientVersion.equals(application.getClientSchemaVersion());
|
||||
boolean isServerSchemaMigrated =
|
||||
!JsonSchemaVersions.serverVersion.equals(application.getServerSchemaVersion());
|
||||
exportingMetaDTO.setApplicationLastCommittedAt(applicationLastCommittedAt);
|
||||
exportingMetaDTO.setArtifactLastCommittedAt(applicationLastCommittedAt);
|
||||
exportingMetaDTO.setClientSchemaMigrated(isClientSchemaMigrated);
|
||||
exportingMetaDTO.setServerSchemaMigrated(isServerSchemaMigrated);
|
||||
applicationJson.setExportedApplication(application);
|
||||
|
|
@ -145,7 +144,7 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
.map(ApplicationPage::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
exportingMetaDTO.setUnpublishedPages(unpublishedPages);
|
||||
exportingMetaDTO.setUnpublishedModulesOrPages(unpublishedPages);
|
||||
|
||||
return getExportableEntities(exportingMetaDTO, mappedResourcesDTO, applicationMono, applicationJson)
|
||||
.then(Mono.defer(() -> sanitizeEntities(
|
||||
|
|
@ -184,7 +183,7 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
}
|
||||
|
||||
protected Mono<Void> sanitizeEntities(
|
||||
SerialiseApplicationObjective serialiseFor,
|
||||
SerialiseArtifactObjective serialiseFor,
|
||||
ApplicationJson applicationJson,
|
||||
MappedExportableResourcesDTO mappedResourcesDTO,
|
||||
ExportingMetaDTO exportingMetaDTO) {
|
||||
|
|
@ -274,7 +273,7 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
public Mono<ApplicationJson> exportApplicationById(String applicationId, String branchName) {
|
||||
return applicationService
|
||||
.findBranchedApplicationId(branchName, applicationId, applicationPermission.getExportPermission())
|
||||
.flatMap(branchedAppId -> exportApplicationById(branchedAppId, SerialiseApplicationObjective.SHARE));
|
||||
.flatMap(branchedAppId -> exportApplicationById(branchedAppId, SerialiseArtifactObjective.SHARE));
|
||||
}
|
||||
|
||||
public Mono<ExportFileDTO> getApplicationFile(String applicationId, String branchName) {
|
||||
|
|
@ -290,7 +289,7 @@ public class ExportApplicationServiceCEImpl implements ExportApplicationServiceC
|
|||
responseHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ExportFileDTO exportFileDTO = new ExportFileDTO();
|
||||
exportFileDTO.setApplicationResource(jsonObject);
|
||||
exportFileDTO.setArtifactResource(jsonObject);
|
||||
exportFileDTO.setHttpHeaders(responseHeaders);
|
||||
return exportFileDTO;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.appsmith.server.acl.AclPermission;
|
|||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
|
|
@ -70,7 +70,7 @@ public class PartialExportServiceCEImpl implements PartialExportServiceCE {
|
|||
final MappedExportableResourcesDTO mappedResourcesDTO = new MappedExportableResourcesDTO();
|
||||
final ExportingMetaDTO exportingMetaDTO = new ExportingMetaDTO();
|
||||
|
||||
exportingMetaDTO.setApplicationId(applicationId);
|
||||
exportingMetaDTO.setArtifactId(applicationId);
|
||||
exportingMetaDTO.setBranchName(null);
|
||||
exportingMetaDTO.setIsGitSync(false);
|
||||
exportingMetaDTO.setExportWithConfiguration(false);
|
||||
|
|
@ -164,7 +164,7 @@ public class PartialExportServiceCEImpl implements PartialExportServiceCE {
|
|||
exportingMetaDTO,
|
||||
mappedResourcesDTO,
|
||||
applicationJson,
|
||||
SerialiseApplicationObjective.SHARE);
|
||||
SerialiseArtifactObjective.SHARE);
|
||||
}
|
||||
return Mono.just(applicationJson).zipWith(sessionUserService.getCurrentUser());
|
||||
})
|
||||
|
|
@ -266,8 +266,8 @@ public class PartialExportServiceCEImpl implements PartialExportServiceCE {
|
|||
private Mono<String> updatePageNameInResourceMapDTO(
|
||||
String pageId, MappedExportableResourcesDTO mappedResourcesDTO) {
|
||||
return newPageService.getNameByPageId(pageId, false).flatMap(pageName -> {
|
||||
mappedResourcesDTO.getPageIdToNameMap().put(pageId + EDIT, pageName);
|
||||
mappedResourcesDTO.getPageIdToNameMap().put(pageId + VIEW, pageName);
|
||||
mappedResourcesDTO.getPageOrModuleIdToNameMap().put(pageId + EDIT, pageName);
|
||||
mappedResourcesDTO.getPageOrModuleIdToNameMap().put(pageId + VIEW, pageName);
|
||||
return Mono.just(pageId);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.appsmith.server.constants.ArtifactJsonType.APPLICATION;
|
||||
|
||||
@Slf4j
|
||||
public class ImportServiceCEImpl implements ImportServiceCE {
|
||||
|
||||
|
|
@ -58,7 +56,6 @@ public class ImportServiceCEImpl implements ImportServiceCE {
|
|||
private final ImportableService<Plugin> pluginImportableService;
|
||||
private final ImportableService<Datasource> datasourceImportableService;
|
||||
private final ImportableService<Theme> themeImportableService;
|
||||
private final Map<ArtifactJsonType, ContextBasedImportService<?, ?, ?>> serviceFactory = new HashMap<>();
|
||||
|
||||
public ImportServiceCEImpl(
|
||||
ApplicationImportService applicationImportService,
|
||||
|
|
@ -81,7 +78,6 @@ public class ImportServiceCEImpl implements ImportServiceCE {
|
|||
this.pluginImportableService = pluginImportableService;
|
||||
this.datasourceImportableService = datasourceImportableService;
|
||||
this.themeImportableService = themeImportableService;
|
||||
serviceFactory.put(APPLICATION, applicationImportService);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -107,7 +103,10 @@ public class ImportServiceCEImpl implements ImportServiceCE {
|
|||
public ContextBasedImportService<
|
||||
? extends ImportableArtifact, ? extends ImportableArtifactDTO, ? extends ArtifactExchangeJson>
|
||||
getContextBasedImportService(ArtifactJsonType artifactJsonType) {
|
||||
return serviceFactory.getOrDefault(artifactJsonType, applicationImportService);
|
||||
return switch (artifactJsonType) {
|
||||
case APPLICATION -> applicationImportService;
|
||||
default -> applicationImportService;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import com.appsmith.external.models.CreatorContextType;
|
|||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.CustomJSLib;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.domains.GitApplicationMetadata;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import com.appsmith.server.exports.exportable.ExportableServiceCE;
|
||||
|
|
@ -77,9 +79,24 @@ public class CustomJSLibExportableServiceCEImpl implements ExportableServiceCE<C
|
|||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> getExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
Boolean isContextAgnostic) {
|
||||
return exportableArtifactMono.flatMap(exportableArtifact -> {
|
||||
Mono<Application> applicationMono = Mono.just((Application) exportableArtifact);
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
return getExportableEntities(
|
||||
exportingMetaDTO, mappedExportableResourcesDTO, applicationMono, applicationJson);
|
||||
});
|
||||
}
|
||||
|
||||
protected Mono<List<CustomJSLib>> getAllJSLibsInContext(ExportingMetaDTO exportingMetaDTO) {
|
||||
return customJSLibService.getAllJSLibsInContext(
|
||||
exportingMetaDTO.getApplicationId(),
|
||||
exportingMetaDTO.getArtifactId(),
|
||||
CreatorContextType.APPLICATION,
|
||||
exportingMetaDTO.getBranchName(),
|
||||
false);
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ public class NewActionExportableServiceCEImpl implements ExportableServiceCE<New
|
|||
Optional<AclPermission> optionalPermission = Optional.ofNullable(actionPermission.getExportPermission(
|
||||
exportingMetaDTO.getIsGitSync(), exportingMetaDTO.getExportWithConfiguration()));
|
||||
|
||||
Flux<NewAction> actionFlux =
|
||||
newActionService.findByPageIdsForExport(exportingMetaDTO.getUnpublishedPages(), optionalPermission);
|
||||
Flux<NewAction> actionFlux = newActionService.findByPageIdsForExport(
|
||||
exportingMetaDTO.getUnpublishedModulesOrPages(), optionalPermission);
|
||||
|
||||
return actionFlux
|
||||
.collectList()
|
||||
|
|
@ -78,19 +78,17 @@ public class NewActionExportableServiceCEImpl implements ExportableServiceCE<New
|
|||
boolean isDatasourceUpdated = ImportExportUtils.isDatasourceUpdatedSinceLastCommit(
|
||||
mappedExportableResourcesDTO.getDatasourceNameToUpdatedAtMap(),
|
||||
actionDTO,
|
||||
exportingMetaDTO.getApplicationLastCommittedAt());
|
||||
exportingMetaDTO.getArtifactLastCommittedAt());
|
||||
|
||||
boolean isPageUpdated = ImportExportUtils.isPageNameInUpdatedList(applicationJson, pageName);
|
||||
Instant newActionUpdatedAt = newAction.getUpdatedAt();
|
||||
boolean isNewActionUpdated = exportingMetaDTO.isClientSchemaMigrated()
|
||||
|| exportingMetaDTO.isServerSchemaMigrated()
|
||||
|| exportingMetaDTO.getApplicationLastCommittedAt() == null
|
||||
|| exportingMetaDTO.getArtifactLastCommittedAt() == null
|
||||
|| isPageUpdated
|
||||
|| isDatasourceUpdated
|
||||
|| newActionUpdatedAt == null
|
||||
|| exportingMetaDTO
|
||||
.getApplicationLastCommittedAt()
|
||||
.isBefore(newActionUpdatedAt);
|
||||
|| exportingMetaDTO.getArtifactLastCommittedAt().isBefore(newActionUpdatedAt);
|
||||
if (isNewActionUpdated && newActionName != null) {
|
||||
updatedActionSet.add(newActionName);
|
||||
}
|
||||
|
|
@ -141,8 +139,9 @@ public class NewActionExportableServiceCEImpl implements ExportableServiceCE<New
|
|||
// Set unique id for action
|
||||
if (newAction.getUnpublishedAction() != null) {
|
||||
ActionDTO actionDTO = newAction.getUnpublishedAction();
|
||||
actionDTO.setPageId(
|
||||
mappedExportableResourcesDTO.getPageIdToNameMap().get(actionDTO.getPageId() + EDIT));
|
||||
actionDTO.setPageId(mappedExportableResourcesDTO
|
||||
.getPageOrModuleIdToNameMap()
|
||||
.get(actionDTO.getPageId() + EDIT));
|
||||
|
||||
if (!StringUtils.isEmpty(actionDTO.getCollectionId())
|
||||
&& mappedExportableResourcesDTO
|
||||
|
|
@ -159,8 +158,9 @@ public class NewActionExportableServiceCEImpl implements ExportableServiceCE<New
|
|||
}
|
||||
if (newAction.getPublishedAction() != null) {
|
||||
ActionDTO actionDTO = newAction.getPublishedAction();
|
||||
actionDTO.setPageId(
|
||||
mappedExportableResourcesDTO.getPageIdToNameMap().get(actionDTO.getPageId() + VIEW));
|
||||
actionDTO.setPageId(mappedExportableResourcesDTO
|
||||
.getPageOrModuleIdToNameMap()
|
||||
.get(actionDTO.getPageId() + VIEW));
|
||||
|
||||
if (!StringUtils.isEmpty(actionDTO.getCollectionId())
|
||||
&& mappedExportableResourcesDTO
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.appsmith.server.newpages.exports;
|
|||
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.Layout;
|
||||
import com.appsmith.server.domains.NewPage;
|
||||
|
|
@ -47,10 +47,10 @@ public class NewPageExportableServiceCEImpl implements ExportableServiceCE<NewPa
|
|||
Optional<AclPermission> optionalPermission = Optional.ofNullable(pagePermission.getExportPermission(
|
||||
exportingMetaDTO.getIsGitSync(), exportingMetaDTO.getExportWithConfiguration()));
|
||||
|
||||
List<String> unpublishedPages = exportingMetaDTO.getUnpublishedPages();
|
||||
List<String> unpublishedPages = exportingMetaDTO.getUnpublishedModulesOrPages();
|
||||
|
||||
return newPageService
|
||||
.findNewPagesByApplicationId(exportingMetaDTO.getApplicationId(), optionalPermission)
|
||||
.findNewPagesByApplicationId(exportingMetaDTO.getArtifactId(), optionalPermission)
|
||||
.collectList()
|
||||
.map(newPageList -> {
|
||||
// Extract mongoEscapedWidgets from pages and save it to applicationJson object as this
|
||||
|
|
@ -65,7 +65,7 @@ public class NewPageExportableServiceCEImpl implements ExportableServiceCE<NewPa
|
|||
newPageList.forEach(newPage -> {
|
||||
if (newPage.getUnpublishedPage() != null) {
|
||||
mappedExportableResourcesDTO
|
||||
.getPageIdToNameMap()
|
||||
.getPageOrModuleIdToNameMap()
|
||||
.put(
|
||||
newPage.getId() + EDIT,
|
||||
newPage.getUnpublishedPage().getName());
|
||||
|
|
@ -79,7 +79,7 @@ public class NewPageExportableServiceCEImpl implements ExportableServiceCE<NewPa
|
|||
|
||||
if (newPage.getPublishedPage() != null) {
|
||||
mappedExportableResourcesDTO
|
||||
.getPageIdToNameMap()
|
||||
.getPageOrModuleIdToNameMap()
|
||||
.put(
|
||||
newPage.getId() + VIEW,
|
||||
newPage.getPublishedPage().getName());
|
||||
|
|
@ -94,11 +94,9 @@ public class NewPageExportableServiceCEImpl implements ExportableServiceCE<NewPa
|
|||
Instant newPageUpdatedAt = newPage.getUpdatedAt();
|
||||
boolean isNewPageUpdated = exportingMetaDTO.isClientSchemaMigrated()
|
||||
|| exportingMetaDTO.isServerSchemaMigrated()
|
||||
|| exportingMetaDTO.getApplicationLastCommittedAt() == null
|
||||
|| exportingMetaDTO.getArtifactLastCommittedAt() == null
|
||||
|| newPageUpdatedAt == null
|
||||
|| exportingMetaDTO
|
||||
.getApplicationLastCommittedAt()
|
||||
.isBefore(newPageUpdatedAt);
|
||||
|| exportingMetaDTO.getArtifactLastCommittedAt().isBefore(newPageUpdatedAt);
|
||||
String newPageName = newPage.getUnpublishedPage() != null
|
||||
? newPage.getUnpublishedPage().getName()
|
||||
: newPage.getPublishedPage() != null
|
||||
|
|
@ -122,7 +120,7 @@ public class NewPageExportableServiceCEImpl implements ExportableServiceCE<NewPa
|
|||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
ApplicationJson applicationJson,
|
||||
SerialiseApplicationObjective serialiseFor) {
|
||||
SerialiseArtifactObjective serialiseFor) {
|
||||
// Update ids for layoutOnLoadAction
|
||||
for (NewPage newPage : applicationJson.getPageList()) {
|
||||
updateIdsForLayoutOnLoadAction(
|
||||
|
|
@ -137,7 +135,7 @@ public class NewPageExportableServiceCEImpl implements ExportableServiceCE<NewPa
|
|||
|
||||
applicationJson
|
||||
.getExportedApplication()
|
||||
.exportApplicationPages(mappedExportableResourcesDTO.getPageIdToNameMap());
|
||||
.exportApplicationPages(mappedExportableResourcesDTO.getPageOrModuleIdToNameMap());
|
||||
}
|
||||
|
||||
private void updateIdsForLayoutOnLoadAction(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.appsmith.server.plugins.exports;
|
||||
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ExportableArtifact;
|
||||
import com.appsmith.server.domains.Plugin;
|
||||
import com.appsmith.server.domains.QPlugin;
|
||||
import com.appsmith.server.domains.WorkspacePlugin;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
import com.appsmith.server.dtos.ArtifactExchangeJson;
|
||||
import com.appsmith.server.dtos.ExportingMetaDTO;
|
||||
import com.appsmith.server.dtos.MappedExportableResourcesDTO;
|
||||
import com.appsmith.server.exports.exportable.ExportableServiceCE;
|
||||
|
|
@ -53,4 +55,19 @@ public class PluginExportableServiceCEImpl implements ExportableServiceCE<Plugin
|
|||
.collectList()
|
||||
.then();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> getExportableEntities(
|
||||
ExportingMetaDTO exportingMetaDTO,
|
||||
MappedExportableResourcesDTO mappedExportableResourcesDTO,
|
||||
Mono<? extends ExportableArtifact> exportableArtifactMono,
|
||||
ArtifactExchangeJson artifactExchangeJson,
|
||||
Boolean isContextAgnostic) {
|
||||
return exportableArtifactMono.flatMap(exportableArtifact -> {
|
||||
Mono<Application> applicationMono = Mono.just((Application) exportableArtifact);
|
||||
ApplicationJson applicationJson = (ApplicationJson) artifactExchangeJson;
|
||||
return getExportableEntities(
|
||||
exportingMetaDTO, mappedExportableResourcesDTO, applicationMono, applicationJson);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.appsmith.server.services.ce;
|
|||
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ApplicationSnapshot;
|
||||
import com.appsmith.server.dtos.ApplicationJson;
|
||||
|
|
@ -40,12 +40,12 @@ public class ApplicationSnapshotServiceCEImpl implements ApplicationSnapshotServ
|
|||
public Mono<Boolean> createApplicationSnapshot(String applicationId, String branchName) {
|
||||
return applicationService
|
||||
.findBranchedApplicationId(branchName, applicationId, applicationPermission.getEditPermission())
|
||||
/* SerialiseApplicationObjective=VERSION_CONTROL because this API can be invoked from developers.
|
||||
exportApplicationById method check for MANAGE_PERMISSION if SerialiseApplicationObjective=SHARE.
|
||||
/* SerialiseArtifactObjective=VERSION_CONTROL because this API can be invoked from developers.
|
||||
exportApplicationById method check for MANAGE_PERMISSION if SerialiseArtifactObjective=SHARE.
|
||||
*/
|
||||
.flatMap(branchedAppId -> Mono.zip(
|
||||
exportApplicationService.exportApplicationById(
|
||||
branchedAppId, SerialiseApplicationObjective.VERSION_CONTROL),
|
||||
branchedAppId, SerialiseArtifactObjective.VERSION_CONTROL),
|
||||
Mono.just(branchedAppId)))
|
||||
.flatMapMany(objects -> {
|
||||
String branchedAppId = objects.getT2();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import com.appsmith.server.constants.Assets;
|
|||
import com.appsmith.server.constants.Entity;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.GitDefaultCommitMessage;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ApplicationMode;
|
||||
|
|
@ -487,7 +487,7 @@ public class GitServiceCEImpl implements GitServiceCE {
|
|||
}
|
||||
return Mono.zip(
|
||||
exportApplicationService.exportApplicationById(
|
||||
branchedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL),
|
||||
branchedApplication.getId(), SerialiseArtifactObjective.VERSION_CONTROL),
|
||||
Mono.just(branchedApplication));
|
||||
})
|
||||
.flatMap(tuple -> {
|
||||
|
|
@ -838,7 +838,7 @@ public class GitServiceCEImpl implements GitServiceCE {
|
|||
// Set branchName for each application resource
|
||||
return exportApplicationService
|
||||
.exportApplicationById(
|
||||
applicationId, SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
applicationId, SerialiseArtifactObjective.VERSION_CONTROL)
|
||||
.flatMap(applicationJson -> {
|
||||
applicationJson
|
||||
.getExportedApplication()
|
||||
|
|
@ -1328,7 +1328,7 @@ public class GitServiceCEImpl implements GitServiceCE {
|
|||
return Mono.zip(
|
||||
applicationService.save(srcApplication),
|
||||
exportApplicationService.exportApplicationById(
|
||||
srcApplicationId, SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
srcApplicationId, SerialiseArtifactObjective.VERSION_CONTROL));
|
||||
})
|
||||
.onErrorResume(error -> Mono.error(new AppsmithException(
|
||||
AppsmithError.GIT_ACTION_FAILED, "branch", error.getMessage())));
|
||||
|
|
@ -1917,7 +1917,7 @@ public class GitServiceCEImpl implements GitServiceCE {
|
|||
}
|
||||
|
||||
Mono<ApplicationJson> exportAppMono = exportApplicationService.exportApplicationById(
|
||||
application.getId(), SerialiseApplicationObjective.VERSION_CONTROL);
|
||||
application.getId(), SerialiseArtifactObjective.VERSION_CONTROL);
|
||||
|
||||
return Mono.zip(exportAppMono, fetchRemoteMono) // zip will run them in parallel
|
||||
.map(Tuple2::getT1);
|
||||
|
|
@ -2463,7 +2463,7 @@ public class GitServiceCEImpl implements GitServiceCE {
|
|||
.findByBranchNameAndDefaultApplicationId(
|
||||
branchName, defaultApplicationId, applicationPermission.getEditPermission())
|
||||
.zipWhen(application -> exportApplicationService.exportApplicationById(
|
||||
application.getId(), SerialiseApplicationObjective.VERSION_CONTROL)))
|
||||
application.getId(), SerialiseArtifactObjective.VERSION_CONTROL)))
|
||||
.flatMap(tuple -> {
|
||||
GitApplicationMetadata defaultApplicationMetadata = tuple.getT1();
|
||||
Application application = tuple.getT2().getT1();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.appsmith.server.configurations.SecurityTestConfig;
|
|||
import com.appsmith.server.constants.Url;
|
||||
import com.appsmith.server.dtos.ApplicationImportDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithErrorCode;
|
||||
import com.appsmith.server.exports.exportable.ExportService;
|
||||
import com.appsmith.server.exports.internal.ExportApplicationService;
|
||||
import com.appsmith.server.exports.internal.PartialExportService;
|
||||
import com.appsmith.server.fork.internal.ApplicationForkingService;
|
||||
|
|
@ -62,6 +63,9 @@ public class ApplicationControllerTest {
|
|||
@MockBean
|
||||
ImportService importService;
|
||||
|
||||
@MockBean
|
||||
ExportService exportService;
|
||||
|
||||
@MockBean
|
||||
ExportApplicationService exportApplicationService;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -19,9 +19,7 @@ import com.appsmith.external.models.Property;
|
|||
import com.appsmith.external.models.SSLDetails;
|
||||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.ArtifactJsonType;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
|
|
@ -48,7 +46,7 @@ import com.appsmith.server.dtos.PageDTO;
|
|||
import com.appsmith.server.dtos.PageNameIdDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.appsmith.server.exports.internal.ExportApplicationService;
|
||||
import com.appsmith.server.exports.exportable.ExportService;
|
||||
import com.appsmith.server.helpers.MockPluginExecutor;
|
||||
import com.appsmith.server.helpers.PluginExecutorHelper;
|
||||
import com.appsmith.server.imports.importable.ImportService;
|
||||
|
|
@ -73,7 +71,6 @@ import com.appsmith.server.services.SessionUserService;
|
|||
import com.appsmith.server.services.WorkspaceService;
|
||||
import com.appsmith.server.solutions.ApplicationPermission;
|
||||
import com.appsmith.server.solutions.EnvironmentPermission;
|
||||
import com.appsmith.server.solutions.PagePermission;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
@ -133,6 +130,8 @@ import static com.appsmith.server.acl.AclPermission.READ_ACTIONS;
|
|||
import static com.appsmith.server.acl.AclPermission.READ_APPLICATIONS;
|
||||
import static com.appsmith.server.acl.AclPermission.READ_PAGES;
|
||||
import static com.appsmith.server.acl.AclPermission.READ_WORKSPACES;
|
||||
import static com.appsmith.server.constants.ArtifactJsonType.APPLICATION;
|
||||
import static com.appsmith.server.constants.SerialiseArtifactObjective.VERSION_CONTROL;
|
||||
import static com.appsmith.server.constants.ce.FieldNameCE.DEFAULT_PAGE_LAYOUT;
|
||||
import static com.appsmith.server.dtos.ce.CustomJSLibContextCE_DTO.getDTOFromCustomJSLib;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
@ -145,8 +144,6 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||
@DirtiesContext
|
||||
@TestMethodOrder(MethodOrderer.MethodName.class)
|
||||
public class ImportServiceTests {
|
||||
|
||||
private static final String INVALID_JSON_FILE = "invalid json file";
|
||||
private static final Map<String, Datasource> datasourceMap = new HashMap<>();
|
||||
private static Plugin installedPlugin;
|
||||
private static String workspaceId;
|
||||
|
|
@ -161,10 +158,10 @@ public class ImportServiceTests {
|
|||
ImportService importService;
|
||||
|
||||
@Autowired
|
||||
ExportApplicationService exportApplicationService;
|
||||
ExportService exportService;
|
||||
|
||||
// @Autowired
|
||||
// ImportApplicationService importApplicationService;
|
||||
// ExportApplicationService exportApplicationService;
|
||||
|
||||
@Autowired
|
||||
Gson gson;
|
||||
|
|
@ -223,9 +220,6 @@ public class ImportServiceTests {
|
|||
@Autowired
|
||||
EnvironmentPermission environmentPermission;
|
||||
|
||||
@Autowired
|
||||
PagePermission pagePermission;
|
||||
|
||||
@Autowired
|
||||
ApplicationPermission applicationPermission;
|
||||
|
||||
|
|
@ -372,7 +366,9 @@ public class ImportServiceTests {
|
|||
@Test
|
||||
@WithUserDetails(value = "api_user")
|
||||
public void exportApplicationById_WhenContainsInternalFields_InternalFieldsNotExported() {
|
||||
Mono<ApplicationJson> resultMono = exportApplicationService.exportApplicationById(testAppId, "");
|
||||
Mono<ApplicationJson> resultMono = exportService
|
||||
.exportByArtifactIdAndBranchName(testAppId, "", APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.assertNext(applicationJson -> {
|
||||
|
|
@ -409,7 +405,9 @@ public class ImportServiceTests {
|
|||
|
||||
return applicationPageService.createApplication(testApplication, workspaceId);
|
||||
})
|
||||
.flatMap(application -> exportApplicationService.exportApplicationById(application.getId(), ""));
|
||||
.flatMap(application ->
|
||||
exportService.exportByArtifactIdAndBranchName(application.getId(), "", APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.assertNext(applicationJson -> {
|
||||
|
|
@ -517,7 +515,8 @@ public class ImportServiceTests {
|
|||
.then(layoutActionService.createSingleAction(action2, Boolean.FALSE))
|
||||
.then(updateLayoutService.updateLayout(
|
||||
testPage.getId(), testPage.getApplicationId(), layout.getId(), layout))
|
||||
.then(exportApplicationService.exportApplicationById(testApp.getId(), ""));
|
||||
.then(exportService.exportByArtifactIdAndBranchName(testApp.getId(), "", APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
})
|
||||
.cache();
|
||||
|
||||
|
|
@ -734,8 +733,8 @@ public class ImportServiceTests {
|
|||
|
||||
return layoutActionService
|
||||
.createAction(action)
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
testApp.getId(), SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
.then(exportService.exportByArtifactId(testApp.getId(), VERSION_CONTROL, APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
});
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -838,8 +837,8 @@ public class ImportServiceTests {
|
|||
Mockito.when(filepart.content()).thenReturn(dataBufferFlux);
|
||||
Mockito.when(filepart.headers().getContentType()).thenReturn(MediaType.IMAGE_PNG);
|
||||
|
||||
Mono<? extends ImportableArtifactDTO> resultMono = importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filepart, workspaceId, null, ArtifactJsonType.APPLICATION);
|
||||
Mono<? extends ImportableArtifactDTO> resultMono =
|
||||
importService.extractArtifactExchangeJsonAndSaveArtifact(filepart, workspaceId, null, APPLICATION);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.expectErrorMatches(error -> error instanceof AppsmithException)
|
||||
|
|
@ -851,8 +850,8 @@ public class ImportServiceTests {
|
|||
public void importArtifactWithNullWorkspaceIdTest() {
|
||||
FilePart filepart = Mockito.mock(FilePart.class, Mockito.RETURNS_DEEP_STUBS);
|
||||
|
||||
Mono<? extends ImportableArtifactDTO> resultMono = importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filepart, null, null, ArtifactJsonType.APPLICATION);
|
||||
Mono<? extends ImportableArtifactDTO> resultMono =
|
||||
importService.extractArtifactExchangeJsonAndSaveArtifact(filepart, null, null, APPLICATION);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
|
|
@ -868,8 +867,8 @@ public class ImportServiceTests {
|
|||
|
||||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/invalid-json-without-pages.json");
|
||||
|
||||
Mono<? extends ImportableArtifactDTO> resultMono = importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspaceId, null, ArtifactJsonType.APPLICATION);
|
||||
Mono<? extends ImportableArtifactDTO> resultMono =
|
||||
importService.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, APPLICATION);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.expectErrorMatches(throwable -> throwable instanceof AppsmithException
|
||||
|
|
@ -885,8 +884,8 @@ public class ImportServiceTests {
|
|||
public void importArtifactFromInvalidJsonFileWithoutArtifactTest() {
|
||||
|
||||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/invalid-json-without-app.json");
|
||||
Mono<? extends ImportableArtifactDTO> resultMono = importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspaceId, null, ArtifactJsonType.APPLICATION);
|
||||
Mono<? extends ImportableArtifactDTO> resultMono =
|
||||
importService.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, APPLICATION);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.expectErrorMatches(
|
||||
|
|
@ -918,7 +917,7 @@ public class ImportServiceTests {
|
|||
|
||||
final Mono<? extends ImportableArtifactDTO> resultMono =
|
||||
workspaceMono.flatMap(workspace -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspace.getId(), null, ArtifactJsonType.APPLICATION));
|
||||
filePart, workspace.getId(), null, APPLICATION));
|
||||
|
||||
List<PermissionGroup> permissionGroups = workspaceMono
|
||||
.flatMapMany(savedWorkspace -> {
|
||||
|
|
@ -1092,8 +1091,7 @@ public class ImportServiceTests {
|
|||
newWorkspace = workspaceService.create(newWorkspace).block();
|
||||
|
||||
importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, newWorkspace.getId(), null, ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, newWorkspace.getId(), null, APPLICATION)
|
||||
.timeout(Duration.ofMillis(10))
|
||||
.subscribe();
|
||||
|
||||
|
|
@ -1130,7 +1128,7 @@ public class ImportServiceTests {
|
|||
final Mono<ApplicationImportDTO> resultMono = workspaceService
|
||||
.create(newWorkspace)
|
||||
.flatMap(workspace -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspace.getId(), null, ArtifactJsonType.APPLICATION))
|
||||
filePart, workspace.getId(), null, APPLICATION))
|
||||
.map(artifactImportDTO -> (ApplicationImportDTO) artifactImportDTO);
|
||||
|
||||
StepVerifier.create(resultMono.flatMap(applicationImportDTO -> Mono.zip(
|
||||
|
|
@ -1171,7 +1169,7 @@ public class ImportServiceTests {
|
|||
|
||||
final Mono<ApplicationImportDTO> resultMono = workspaceMono
|
||||
.flatMap(workspace -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspace.getId(), null, ArtifactJsonType.APPLICATION))
|
||||
filePart, workspace.getId(), null, APPLICATION))
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
List<PermissionGroup> permissionGroups = workspaceMono
|
||||
|
|
@ -1289,7 +1287,7 @@ public class ImportServiceTests {
|
|||
final Mono<ApplicationImportDTO> resultMono = workspaceService
|
||||
.create(newWorkspace)
|
||||
.flatMap(workspace -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspace.getId(), null, ArtifactJsonType.APPLICATION))
|
||||
filePart, workspace.getId(), null, APPLICATION))
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -1315,7 +1313,7 @@ public class ImportServiceTests {
|
|||
final Mono<ApplicationImportDTO> resultMono = workspaceService
|
||||
.create(newWorkspace)
|
||||
.flatMap(workspace -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspace.getId(), null, ArtifactJsonType.APPLICATION))
|
||||
filePart, workspace.getId(), null, APPLICATION))
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
StepVerifier.create(resultMono.flatMap(applicationImportDTO -> Mono.zip(
|
||||
|
|
@ -1396,8 +1394,9 @@ public class ImportServiceTests {
|
|||
.createAction(action)
|
||||
.flatMap(createdAction -> newActionService.findById(createdAction.getId(), READ_ACTIONS));
|
||||
})
|
||||
.then(exportApplicationService
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
.then(exportService
|
||||
.exportByArtifactId(savedApplication.getId(), VERSION_CONTROL, APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.flatMap(applicationJson -> importService.importArtifactInWorkspaceFromGit(
|
||||
workspaceId, savedApplication.getId(), applicationJson, gitData.getBranchName())))
|
||||
.map(importableArtifact -> (Application) importableArtifact)
|
||||
|
|
@ -1437,7 +1436,7 @@ public class ImportServiceTests {
|
|||
public void importApplication_incompatibleJsonFile_throwException() {
|
||||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/incompatible_version.json");
|
||||
Mono<ApplicationImportDTO> resultMono = importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, APPLICATION)
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -1459,7 +1458,7 @@ public class ImportServiceTests {
|
|||
|
||||
final Mono<ApplicationImportDTO> resultMono = workspaceMono
|
||||
.flatMap(workspace -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspace.getId(), null, ArtifactJsonType.APPLICATION))
|
||||
filePart, workspace.getId(), null, APPLICATION))
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
List<PermissionGroup> permissionGroups = workspaceMono
|
||||
|
|
@ -1785,8 +1784,9 @@ public class ImportServiceTests {
|
|||
anonymousPermissionGroup.getId()))
|
||||
.build();
|
||||
|
||||
Mono<Application> applicationMono = exportApplicationService
|
||||
.exportApplicationById(application.getId(), "master")
|
||||
Mono<Application> applicationMono = exportService
|
||||
.exportByArtifactIdAndBranchName(application.getId(), "master", APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.flatMap(applicationJson -> importService
|
||||
.importArtifactInWorkspaceFromGit(workspaceId, application.getId(), applicationJson, "master")
|
||||
.map(artifact -> (Application) artifact));
|
||||
|
|
@ -2832,7 +2832,8 @@ public class ImportServiceTests {
|
|||
.then(layoutActionService.createSingleAction(action2, Boolean.FALSE))
|
||||
.then(updateLayoutService.updateLayout(
|
||||
testPage.getId(), testPage.getApplicationId(), layout.getId(), layout))
|
||||
.then(exportApplicationService.exportApplicationById(testApp.getId(), ""));
|
||||
.then(exportService.exportByArtifactIdAndBranchName(testApp.getId(), "", APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
})
|
||||
.cache();
|
||||
|
||||
|
|
@ -3174,8 +3175,9 @@ public class ImportServiceTests {
|
|||
// Deploy the current application
|
||||
applicationPageService.publish(testApplication.getId(), true).block();
|
||||
|
||||
Mono<ApplicationJson> applicationJsonMono = exportApplicationService
|
||||
.exportApplicationById(testApplication.getId(), "")
|
||||
Mono<ApplicationJson> applicationJsonMono = exportService
|
||||
.exportByArtifactIdAndBranchName(testApplication.getId(), "", APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.cache();
|
||||
|
||||
StepVerifier.create(applicationJsonMono)
|
||||
|
|
@ -3282,8 +3284,9 @@ public class ImportServiceTests {
|
|||
})
|
||||
.block();
|
||||
|
||||
Mono<Application> result = exportApplicationService
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
Mono<Application> result = exportService
|
||||
.exportByArtifactId(savedApplication.getId(), VERSION_CONTROL, APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.flatMap(applicationJson -> {
|
||||
// setting published mode resource as null, similar to the app json exported to git repo
|
||||
applicationJson.getExportedApplication().setPublishedApplicationDetail(null);
|
||||
|
|
@ -3339,8 +3342,9 @@ public class ImportServiceTests {
|
|||
})
|
||||
.block();
|
||||
|
||||
Mono<Application> result = exportApplicationService
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
Mono<Application> result = exportService
|
||||
.exportByArtifactId(savedApplication.getId(), VERSION_CONTROL, APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.flatMap(applicationJson -> {
|
||||
// setting published mode resource as null, similar to the app json exported to git repo
|
||||
applicationJson.getExportedApplication().setPublishedAppLayout(null);
|
||||
|
|
@ -3399,8 +3403,9 @@ public class ImportServiceTests {
|
|||
.reorderPage(testApplication.getId(), testPage2.getId(), 1, null)
|
||||
.block();
|
||||
|
||||
Mono<ApplicationJson> applicationJsonMono = exportApplicationService
|
||||
.exportApplicationById(testApplication.getId(), "")
|
||||
Mono<ApplicationJson> applicationJsonMono = exportService
|
||||
.exportByArtifactIdAndBranchName(testApplication.getId(), "", APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.cache();
|
||||
|
||||
StepVerifier.create(applicationJsonMono)
|
||||
|
|
@ -3669,7 +3674,9 @@ public class ImportServiceTests {
|
|||
String branchName = null;
|
||||
return applicationService
|
||||
.save(application)
|
||||
.then(exportApplicationService.exportApplicationById(application.getId(), branchName));
|
||||
.then(exportService.exportByArtifactIdAndBranchName(
|
||||
application.getId(), branchName, APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
});
|
||||
|
||||
StepVerifier.create(exportedAppJson)
|
||||
|
|
@ -4411,7 +4418,7 @@ public class ImportServiceTests {
|
|||
.block();
|
||||
|
||||
Mono<ApplicationImportDTO> resultMono = importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, APPLICATION)
|
||||
.map(artifactImportDTO -> (ApplicationImportDTO) artifactImportDTO);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -4508,8 +4515,9 @@ public class ImportServiceTests {
|
|||
|
||||
return layoutActionService
|
||||
.createSingleAction(action, Boolean.FALSE)
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
objects.getT1().getId(), ""));
|
||||
.then(exportService.exportByArtifactIdAndBranchName(
|
||||
objects.getT1().getId(), "", APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
});
|
||||
|
||||
StepVerifier.create(exportAppMono)
|
||||
|
|
@ -4536,8 +4544,9 @@ public class ImportServiceTests {
|
|||
.createApplication(application, workspaceId)
|
||||
.block();
|
||||
|
||||
Mono<ApplicationJson> resultMono =
|
||||
exportApplicationService.exportApplicationById(createdApplication.getId(), "");
|
||||
Mono<ApplicationJson> resultMono = exportService
|
||||
.exportByArtifactIdAndBranchName(createdApplication.getId(), "", APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.assertNext(applicationJson -> {
|
||||
|
|
@ -4573,8 +4582,9 @@ public class ImportServiceTests {
|
|||
|
||||
PageDTO applicationPageDTO = applicationPageService.createPage(pageDTO).block();
|
||||
|
||||
Mono<ApplicationJson> resultMono =
|
||||
exportApplicationService.exportApplicationById(applicationPageDTO.getApplicationId(), "");
|
||||
Mono<ApplicationJson> resultMono = exportService
|
||||
.exportByArtifactIdAndBranchName(applicationPageDTO.getApplicationId(), "", APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
.assertNext(applicationJson -> {
|
||||
|
|
@ -4691,7 +4701,7 @@ public class ImportServiceTests {
|
|||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/valid-application.json");
|
||||
String workspaceId = createTemplateWorkspace().getId();
|
||||
final Mono<Application> resultMonoWithoutDiscardOperation = importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, null, APPLICATION)
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO)
|
||||
.flatMap(applicationImportDTO -> {
|
||||
PageDTO page = new PageDTO();
|
||||
|
|
@ -4747,7 +4757,7 @@ public class ImportServiceTests {
|
|||
final Mono<Application> resultMonoWithDiscardOperation = resultMonoWithoutDiscardOperation
|
||||
.flatMap(importedApplication -> applicationService.save(importedApplication))
|
||||
.flatMap(savedApplication -> importService.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspaceId, savedApplication.getId(), ArtifactJsonType.APPLICATION))
|
||||
filePart, workspaceId, savedApplication.getId(), APPLICATION))
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO)
|
||||
.map(ApplicationImportDTO::getApplication);
|
||||
|
||||
|
|
@ -4802,8 +4812,7 @@ public class ImportServiceTests {
|
|||
|
||||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/valid-application.json");
|
||||
final Mono<ApplicationImportDTO> resultMono = importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspaceId, application.getId(), ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, application.getId(), APPLICATION)
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -4830,8 +4839,9 @@ public class ImportServiceTests {
|
|||
return isJSLibAdded;
|
||||
})
|
||||
.cache();
|
||||
Mono<ApplicationJson> getExportedAppMono =
|
||||
addJSLibMonoCached.then(exportApplicationService.exportApplicationById(testAppId, ""));
|
||||
Mono<ApplicationJson> getExportedAppMono = addJSLibMonoCached
|
||||
.then(exportService.exportByArtifactIdAndBranchName(testAppId, "", APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
StepVerifier.create(Mono.zip(addJSLibMonoCached, getExportedAppMono))
|
||||
.assertNext(tuple2 -> {
|
||||
Boolean isJSLibAdded = tuple2.getT1();
|
||||
|
|
@ -4890,8 +4900,7 @@ public class ImportServiceTests {
|
|||
|
||||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/valid-application.json");
|
||||
final Mono<ApplicationImportDTO> resultMono = importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspaceId, application.getId(), ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(filePart, workspaceId, application.getId(), APPLICATION)
|
||||
.map(importableArtifactDTO -> (ApplicationImportDTO) importableArtifactDTO);
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -4926,7 +4935,7 @@ public class ImportServiceTests {
|
|||
.flatMap(application -> {
|
||||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/valid-application.json");
|
||||
return importService
|
||||
.extractArtifactExchangeJson(filePart, ArtifactJsonType.APPLICATION)
|
||||
.extractArtifactExchangeJson(filePart, APPLICATION)
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson)
|
||||
.flatMap(applicationJson -> importService.mergeArtifactExchangeJsonWithImportableArtifact(
|
||||
workspaceId, application.getId(), null, applicationJson, null))
|
||||
|
|
@ -4962,7 +4971,7 @@ public class ImportServiceTests {
|
|||
FilePart filePart = createFilePart("test_assets/ImportExportServiceTest/valid-application.json");
|
||||
return importService
|
||||
.extractArtifactExchangeJsonAndSaveArtifact(
|
||||
filePart, workspaceId, application.getId(), ArtifactJsonType.APPLICATION)
|
||||
filePart, workspaceId, application.getId(), APPLICATION)
|
||||
.map(artifactImportDTO -> (ApplicationImportDTO) artifactImportDTO);
|
||||
});
|
||||
|
||||
|
|
@ -5058,8 +5067,8 @@ public class ImportServiceTests {
|
|||
return newPageService
|
||||
.updatePage(applicationPage.getId(), pageDTO)
|
||||
// export the application
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
application.getId(), SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
.then(exportService.exportByArtifactId(application.getId(), VERSION_CONTROL, APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
});
|
||||
|
||||
// verify that the exported json has the updated page name, and the queries are in the updated resources
|
||||
|
|
@ -5158,8 +5167,8 @@ public class ImportServiceTests {
|
|||
datasource.setName("DS_FOR_RENAME_TEST_RENAMED");
|
||||
return datasourceService
|
||||
.save(datasource)
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
application.getId(), SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
.then(exportService.exportByArtifactId(application.getId(), VERSION_CONTROL, APPLICATION))
|
||||
.map(artifactExchangeJson -> (ApplicationJson) artifactExchangeJson);
|
||||
});
|
||||
|
||||
// verify that the exported json has the updated page name, and the queries are in the updated resources
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.appsmith.server.services.ce;
|
|||
|
||||
import com.appsmith.server.acl.AclPermission;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.domains.Application;
|
||||
import com.appsmith.server.domains.ApplicationPage;
|
||||
import com.appsmith.server.domains.ApplicationSnapshot;
|
||||
|
|
@ -88,7 +88,7 @@ public class ApplicationSnapshotServiceUnitTest {
|
|||
.thenReturn(Mono.just(branchedAppId));
|
||||
|
||||
Mockito.when(exportApplicationService.exportApplicationById(
|
||||
branchedAppId, SerialiseApplicationObjective.VERSION_CONTROL))
|
||||
branchedAppId, SerialiseArtifactObjective.VERSION_CONTROL))
|
||||
.thenReturn(Mono.just(applicationJson));
|
||||
|
||||
Mockito.when(applicationSnapshotRepository.deleteAllByApplicationId(branchedAppId))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import com.appsmith.external.models.SSLDetails;
|
|||
import com.appsmith.server.actioncollections.base.ActionCollectionService;
|
||||
import com.appsmith.server.applications.base.ApplicationService;
|
||||
import com.appsmith.server.constants.FieldName;
|
||||
import com.appsmith.server.constants.SerialiseApplicationObjective;
|
||||
import com.appsmith.server.constants.SerialiseArtifactObjective;
|
||||
import com.appsmith.server.datasources.base.DatasourceService;
|
||||
import com.appsmith.server.domains.ActionCollection;
|
||||
import com.appsmith.server.domains.Application;
|
||||
|
|
@ -787,7 +787,7 @@ public class ImportApplicationServiceTests {
|
|||
return layoutActionService
|
||||
.createAction(action)
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
testApp.getId(), SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
testApp.getId(), SerialiseArtifactObjective.VERSION_CONTROL));
|
||||
});
|
||||
|
||||
StepVerifier.create(resultMono)
|
||||
|
|
@ -1442,7 +1442,7 @@ public class ImportApplicationServiceTests {
|
|||
.flatMap(createdAction -> newActionService.findById(createdAction.getId(), READ_ACTIONS));
|
||||
})
|
||||
.then(exportApplicationService
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseArtifactObjective.VERSION_CONTROL)
|
||||
.flatMap(applicationJson -> importApplicationService.importApplicationInWorkspaceFromGit(
|
||||
workspaceId, applicationJson, savedApplication.getId(), gitData.getBranchName())))
|
||||
.cache();
|
||||
|
|
@ -3035,7 +3035,7 @@ public class ImportApplicationServiceTests {
|
|||
@WithUserDetails(value = "usertest@usertest.com")
|
||||
public void exportApplication_withReadOnlyAccess_exportedWithDecryptedFields() {
|
||||
Mono<ApplicationJson> exportApplicationMono = exportApplicationService.exportApplicationById(
|
||||
exportWithConfigurationAppId, SerialiseApplicationObjective.SHARE);
|
||||
exportWithConfigurationAppId, SerialiseArtifactObjective.SHARE);
|
||||
|
||||
StepVerifier.create(exportApplicationMono)
|
||||
.assertNext(applicationJson -> {
|
||||
|
|
@ -3319,7 +3319,7 @@ public class ImportApplicationServiceTests {
|
|||
.block();
|
||||
|
||||
Mono<Application> result = exportApplicationService
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseArtifactObjective.VERSION_CONTROL)
|
||||
.flatMap(applicationJson -> {
|
||||
// setting published mode resource as null, similar to the app json exported to git repo
|
||||
applicationJson.getExportedApplication().setPublishedApplicationDetail(null);
|
||||
|
|
@ -3374,7 +3374,7 @@ public class ImportApplicationServiceTests {
|
|||
.block();
|
||||
|
||||
Mono<Application> result = exportApplicationService
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseApplicationObjective.VERSION_CONTROL)
|
||||
.exportApplicationById(savedApplication.getId(), SerialiseArtifactObjective.VERSION_CONTROL)
|
||||
.flatMap(applicationJson -> {
|
||||
// setting published mode resource as null, similar to the app json exported to git repo
|
||||
applicationJson.getExportedApplication().setPublishedAppLayout(null);
|
||||
|
|
@ -5069,7 +5069,7 @@ public class ImportApplicationServiceTests {
|
|||
.updatePage(applicationPage.getId(), pageDTO)
|
||||
// export the application
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
application.getId(), SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
application.getId(), SerialiseArtifactObjective.VERSION_CONTROL));
|
||||
});
|
||||
|
||||
// verify that the exported json has the updated page name, and the queries are in the updated resources
|
||||
|
|
@ -5169,7 +5169,7 @@ public class ImportApplicationServiceTests {
|
|||
return datasourceService
|
||||
.save(datasource)
|
||||
.then(exportApplicationService.exportApplicationById(
|
||||
application.getId(), SerialiseApplicationObjective.VERSION_CONTROL));
|
||||
application.getId(), SerialiseArtifactObjective.VERSION_CONTROL));
|
||||
});
|
||||
|
||||
// verify that the exported json has the updated page name, and the queries are in the updated resources
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user