chore: modified server schema version (#28358)

## Description
> fixes xml parser

Fixes: https://github.com/appsmithorg/appsmith/issues/28364
This commit is contained in:
Manish Kumar 2023-10-26 10:02:13 +05:30 committed by GitHub
parent 492eece3c9
commit a3f184b986
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 30 deletions

View File

@ -1,6 +1,5 @@
package com.appsmith.server.jslibs.imports;
import com.appsmith.server.constants.ApplicationConstants;
import com.appsmith.server.domains.Application;
import com.appsmith.server.domains.CustomJSLib;
import com.appsmith.server.domains.Workspace;
@ -37,8 +36,6 @@ public class CustomJSLibImportableServiceCEImpl implements ImportableServiceCE<C
customJSLibs = new ArrayList<>();
}
ensureXmlParserPresenceInCustomJsLibList(customJSLibs);
return Flux.fromIterable(customJSLibs)
.flatMap(customJSLib -> {
customJSLib.setId(null);
@ -56,30 +53,4 @@ public class CustomJSLibImportableServiceCEImpl implements ImportableServiceCE<C
return Mono.error(e);
});
}
/**
* This method takes customJSLibList from application JSON, checks if an entry for XML parser exists,
* otherwise adds the entry.
* This has been done to add the xmlParser entry in imported application as appsmith is stopping native support
* for xml parser.
* Read More: https://github.com/appsmithorg/appsmith/pull/28012
*
* @param customJSLibList
*/
private void ensureXmlParserPresenceInCustomJsLibList(List<CustomJSLib> customJSLibList) {
boolean isXmlParserLibFound = false;
for (CustomJSLib customJSLib : customJSLibList) {
if (!customJSLib.getUidString().equals(ApplicationConstants.XML_PARSER_LIBRARY_UID)) {
continue;
}
isXmlParserLibFound = true;
break;
}
if (!isXmlParserLibFound) {
CustomJSLib xmlParserJsLib = ApplicationConstants.getDefaultParserCustomJsLibCompatibilityDTO();
customJSLibList.add(xmlParserJsLib);
}
}
}

View File

@ -66,6 +66,9 @@ public class JsonSchemaMigration {
case 5:
MigrationHelperMethods.migrateGoogleSheetsActionsToUqi(applicationJson);
applicationJson.setServerSchemaVersion(6);
case 6:
MigrationHelperMethods.ensureXmlParserPresenceInCustomJsLibList(applicationJson);
applicationJson.setServerSchemaVersion(7);
default:
// Unable to detect the serverSchema
}

View File

@ -12,6 +12,6 @@ import lombok.Getter;
*/
@Getter
public class JsonSchemaVersions {
public static final Integer serverVersion = 6;
public static final Integer serverVersion = 7;
public static final Integer clientVersion = 1;
}

View File

@ -3,9 +3,11 @@ package com.appsmith.server.migrations;
import com.appsmith.external.models.ActionDTO;
import com.appsmith.external.models.BaseDomain;
import com.appsmith.external.models.InvisibleActionFields;
import com.appsmith.server.constants.ApplicationConstants;
import com.appsmith.server.constants.FieldName;
import com.appsmith.server.constants.ResourceModes;
import com.appsmith.server.domains.ApplicationPage;
import com.appsmith.server.domains.CustomJSLib;
import com.appsmith.server.domains.NewAction;
import com.appsmith.server.domains.Plugin;
import com.appsmith.server.domains.QUser;
@ -256,4 +258,37 @@ public class MigrationHelperMethods {
where(FieldName.DELETED_AT).exists(false),
where(FieldName.DELETED_AT).is(null)));
}
/**
* This method takes customJSLibList from application JSON, checks if an entry for XML parser exists,
* otherwise adds the entry.
* This has been done to add the xmlParser entry in imported application as appsmith is stopping native support
* for xml parser.
* Read More: https://github.com/appsmithorg/appsmith/pull/28012
*
* @param applicationJson
*/
public static void ensureXmlParserPresenceInCustomJsLibList(ApplicationJson applicationJson) {
if (CollectionUtils.isNullOrEmpty(applicationJson.getCustomJSLibList())) {
applicationJson.setCustomJSLibList(new ArrayList<>());
}
List<CustomJSLib> customJSLibList = applicationJson.getCustomJSLibList();
boolean isXmlParserLibFound = false;
for (CustomJSLib customJSLib : customJSLibList) {
if (!customJSLib.getUidString().equals(ApplicationConstants.XML_PARSER_LIBRARY_UID)) {
continue;
}
isXmlParserLibFound = true;
break;
}
if (!isXmlParserLibFound) {
CustomJSLib xmlParserJsLib = ApplicationConstants.getDefaultParserCustomJsLibCompatibilityDTO();
customJSLibList.add(xmlParserJsLib);
}
}
}