This commit is contained in:
rdavidek 2026-02-19 12:55:40 +01:00
commit 66b46259b2

View File

@ -22,6 +22,8 @@ import cz.trask.migration.util.CredentialsDecoder;
public class ApiDefinitionMapper32to45 { public class ApiDefinitionMapper32to45 {
private static final String CONTEXT_VERSION_TEMPLATE = "/{version}";
public static ApiDefinition45 map(ApiDefinition32 oldApi, String swagger) throws Exception { public static ApiDefinition45 map(ApiDefinition32 oldApi, String swagger) throws Exception {
if (oldApi == null) if (oldApi == null)
return null; return null;
@ -46,7 +48,7 @@ public class ApiDefinitionMapper32to45 {
data.setProvider(oldApi.getId() != null ? oldApi.getId().getProviderName() : null); data.setProvider(oldApi.getId() != null ? oldApi.getId().getProviderName() : null);
// data.setContext(swaggerData.get("basePath") != null ? // data.setContext(swaggerData.get("basePath") != null ?
// swaggerData.get("basePath").toString() : ""); // swaggerData.get("basePath").toString() : "");
data.setContext(oldApi.getContext()); data.setContext(getContext(oldApi.getContext(), oldApi.getContextTemplate(), oldApi.getId().getVersion()));
data.setLifeCycleStatus(oldApi.getStatus()); data.setLifeCycleStatus(oldApi.getStatus());
data.setDefaultVersion(oldApi.isDefaultVersion()); data.setDefaultVersion(oldApi.isDefaultVersion());
data.setRevision(false); data.setRevision(false);
@ -159,6 +161,16 @@ public class ApiDefinitionMapper32to45 {
return newApi; return newApi;
} }
private static String getContext(String context, String contextTemplate, String version) {
if (contextTemplate != null && !contextTemplate.isEmpty()) {
return contextTemplate.replace(CONTEXT_VERSION_TEMPLATE, "");
}
if (context != null && !context.isEmpty()) {
return context.replace(version, "");
}
return context;
}
private static Map mapEndpointConfig(Map endpointConfig) { private static Map mapEndpointConfig(Map endpointConfig) {
if (endpointConfig == null || endpointConfig.isEmpty()) if (endpointConfig == null || endpointConfig.isEmpty())
return new HashMap(); return new HashMap();