-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow connecting the MP client to MP 1.0 with backwards compatible MP…
…Project
- Loading branch information
1 parent
0e84017
commit eb10e93
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...ementportal-client/src/main/kotlin/org/radarbase/management/client/HttpStatusException.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.radarbase.management.client | ||
|
||
import io.ktor.http.* | ||
import java.io.IOException | ||
|
||
class HttpStatusException( | ||
val code: HttpStatusCode, | ||
message: String, | ||
) : IOException(message) |
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
23 changes: 23 additions & 0 deletions
23
...ementportal-client/src/main/kotlin/org/radarbase/management/client/MPProjectSerializer.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.radarbase.management.client | ||
|
||
import kotlinx.serialization.json.JsonElement | ||
import kotlinx.serialization.json.JsonNull | ||
import kotlinx.serialization.json.JsonObject | ||
import kotlinx.serialization.json.JsonTransformingSerializer | ||
|
||
class MPProjectSerializer : JsonTransformingSerializer<MPProject>(MPProject.serializer()) { | ||
override fun transformDeserialize(element: JsonElement): JsonElement { | ||
if (element !is JsonObject) return element | ||
val organization = element["organization"] | ||
return if (organization == null || organization is JsonNull || organization is JsonObject) { | ||
// MP 2.0 structure | ||
element | ||
} else { | ||
// MP 0.x structure | ||
val elementMap = element.toMutableMap() | ||
elementMap["organization"] = JsonNull | ||
elementMap["organizationName"] = organization | ||
return JsonObject(elementMap) | ||
} | ||
} | ||
} |