-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core-websdk/cloud_config): fix null value
Use data classes directly to avoid null
- Loading branch information
Showing
4 changed files
with
30 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 13 additions & 12 deletions
25
.../main/java/net/xzos/upgradeall/core/websdk/api/client_proxy/cloud_config/migration/Hub.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
package net.xzos.upgradeall.core.websdk.api.client_proxy.cloud_config.migration | ||
|
||
import net.xzos.upgradeall.core.utils.asSequence | ||
import net.xzos.upgradeall.core.websdk.json.HubConfigGson | ||
import org.json.JSONObject | ||
|
||
fun hub5to6(oldJson: JSONObject): JSONObject? { | ||
fun hub5to6(oldJson: JSONObject): HubConfigGson? { | ||
val versionCodeHubs = listOf( | ||
"1c010cc9-cff8-4461-8993-a86cd190d377", | ||
"6a6d590b-1809-41bf-8ce3-7e3f6c8da945", | ||
) | ||
if (oldJson.optInt("base_version") != 5) return null | ||
val uuid = oldJson.optString("uuid") | ||
val map = mapOf( | ||
"base_version" to 6, | ||
"config_version" to oldJson.getJSONObject("info").optString("config_version"), | ||
"uuid" to uuid, | ||
"info" to mapOf( | ||
"hub_name" to oldJson.getJSONObject("info").optString("hub_name"), | ||
"hub_icon_url" to "", | ||
return HubConfigGson( | ||
baseVersion = 6, | ||
configVersion = oldJson.getJSONObject("info").optInt("config_version"), | ||
uuid = uuid, | ||
info = HubConfigGson.InfoBean( | ||
hubName = oldJson.getJSONObject("info").optString("hub_name"), | ||
hubIconUrl = null, | ||
), | ||
"target_check_api" to if (uuid in versionCodeHubs) "index" else "version_number", | ||
"api_keywords" to oldJson.optJSONArray("api_keywords"), | ||
"app_url_templates" to oldJson.optJSONArray("app_url_templates"), | ||
apiKeywords = oldJson.getJSONArray("api_keywords").asSequence<String>().toList(), | ||
appUrlTemplates = oldJson.getJSONArray("app_url_templates").asSequence<String>().toList(), | ||
targetCheckApi = if (uuid in versionCodeHubs) "index" else "version_number", | ||
) | ||
return JSONObject(map) | ||
} |