-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: vityaman <[email protected]>
- Loading branch information
Showing
16 changed files
with
652 additions
and
7 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
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 @@ | ||
FROM eclipse-temurin:23-jdk-alpine | ||
|
||
WORKDIR /matchmaker-soap | ||
|
||
COPY ./build/libs/matchmaker-soap-1.0.0.jar ./matchmaker-soap.jar | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["java", "-jar", "matchmaker-soap.jar"] |
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,68 @@ | ||
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask as OpenAPIGenerateTask | ||
|
||
plugins { | ||
id("buildlogic.spring-conventions") | ||
id("com.github.bjornvester.wsdl2java") version "2.0.2" | ||
} | ||
|
||
val projectGroup = group | ||
|
||
val matchmaker = "matchmaker" | ||
val matchmakerTitle = matchmaker.replaceFirstChar { it.titlecase() } | ||
|
||
val clientGeneratedDir = layout.buildDirectory | ||
.dir("generated/client/$matchmaker").get().toString() | ||
|
||
tasks.register<OpenAPIGenerateTask>("openApiGenerate${matchmakerTitle}Client") { | ||
generatorName = "kotlin" | ||
inputSpec = rootProject.layout.projectDirectory.asFile | ||
.let { "$it/$matchmaker/src/main/resources/static/openapi/api.yml" } | ||
outputDir = clientGeneratedDir | ||
packageName = "$projectGroup.$matchmaker.client.generated" | ||
modelPackage = "$projectGroup.$matchmaker.client.model.generated" | ||
modelNameSuffix = "Message" | ||
configOptions = mapOf( | ||
"library" to "jvm-spring-restclient", | ||
"useSpringBoot3" to "true", | ||
"serializationLibrary" to "jackson", | ||
) | ||
} | ||
|
||
val versionCxf = "4.1.0" | ||
|
||
wsdl2java { | ||
wsdlDir = file("$projectDir/src/main/resources/wsdl") | ||
markGenerated = true | ||
cxfVersion = versionCxf | ||
} | ||
|
||
sourceSets { | ||
main { | ||
kotlin { | ||
srcDir("$clientGeneratedDir/src/main/kotlin") | ||
} | ||
} | ||
} | ||
|
||
tasks.compileKotlin.configure { | ||
dependsOn("openApiGenerate${matchmakerTitle}Client") | ||
dependsOn(tasks.wsdl2java) | ||
} | ||
|
||
dependencies { | ||
api(project(":starter-tls")) | ||
|
||
implementation(libs.org.springframework.boot.spring.boot.starter.web) | ||
implementation(libs.org.springframework.boot.spring.boot.starter.web.services) | ||
|
||
implementation(libs.com.fasterxml.jackson.module.jackson.module.kotlin) | ||
implementation(libs.org.jetbrains.kotlin.kotlin.reflect) | ||
|
||
implementation("org.springframework.ws:spring-ws-core:4.0.11") | ||
implementation("org.apache.cxf:cxf-spring-boot-starter-jaxws:$versionCxf") | ||
|
||
testImplementation(libs.org.springframework.boot.spring.boot.starter.test) | ||
testImplementation(libs.org.jetbrains.kotlin.kotlin.reflect) | ||
testImplementation(libs.org.jetbrains.kotlin.kotlin.test.junit5) | ||
testRuntimeOnly(libs.org.junit.platform.junit.platform.launcher) | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/matchmaker-soap/src/main/kotlin/ru/ifmo/se/dating/matchmaker/soap/Application.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,13 @@ | ||
package ru.ifmo.se.dating.matchmaker.soap | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.boot.runApplication | ||
import org.springframework.context.annotation.ComponentScan | ||
|
||
@SpringBootApplication | ||
@ComponentScan(basePackages = ["ru.ifmo.se.dating"]) | ||
class Application | ||
|
||
fun main(args: Array<String>) { | ||
runApplication<Application>(args = args) | ||
} |
47 changes: 47 additions & 0 deletions
47
...hmaker-soap/src/main/kotlin/ru/ifmo/se/dating/matchmaker/soap/MatchmakerMessageMapping.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,47 @@ | ||
package ru.ifmo.se.dating.matchmaker.soap | ||
|
||
import ru.ifmo.se.dating.matchmaker.* | ||
import ru.ifmo.se.dating.matchmaker.client.model.generated.AttitudeKindMessage | ||
import ru.ifmo.se.dating.matchmaker.client.model.generated.PersonStatusMessage | ||
import ru.ifmo.se.dating.matchmaker.client.model.generated.PersonUpdateMessage | ||
import ru.ifmo.se.dating.matchmaker.client.model.generated.StatisticsAttitudesGet200ResponseInnerMessage | ||
|
||
fun List<Long>.toSuggestionsSoap(): GetSuggestionsResponse = | ||
GetSuggestionsResponse().apply { | ||
personId.addAll(this@toSuggestionsSoap.map { it.toInt() }) | ||
} | ||
|
||
fun AttitudeKind.toRest(): AttitudeKindMessage = | ||
when (this) { | ||
AttitudeKind.LIKE -> AttitudeKindMessage.like | ||
AttitudeKind.SKIP -> AttitudeKindMessage.skip | ||
} | ||
|
||
fun List<StatisticsAttitudesGet200ResponseInnerMessage>.toSoap(): GetAttitudesStatisticsResponse = | ||
GetAttitudesStatisticsResponse().apply { | ||
statistics.addAll(this@toSoap.map { it.toSoap() }) | ||
} | ||
|
||
fun StatisticsAttitudesGet200ResponseInnerMessage.toSoap() = | ||
GetAttitudesStatisticsResponse.Statistics().apply { | ||
personId = this@toSoap.personId.toInt() | ||
likes = this@toSoap.likes | ||
skips = this@toSoap.skips | ||
} | ||
|
||
fun List<Long>.toMatchesSoap(): GetMatchesResponse = | ||
GetMatchesResponse().apply { | ||
personId.addAll(this@toMatchesSoap.map { it.toInt() }) | ||
} | ||
|
||
fun PersonUpdate.toRest(): PersonUpdateMessage = | ||
PersonUpdateMessage( | ||
status = this.status.toRest(), | ||
version = this.version, | ||
) | ||
|
||
fun PersonStatus.toRest(): PersonStatusMessage = | ||
when (this) { | ||
PersonStatus.HIDDEN -> PersonStatusMessage.hidden | ||
PersonStatus.ACTIVE -> PersonStatusMessage.active | ||
} |
26 changes: 26 additions & 0 deletions
26
...matchmaker-soap/src/main/kotlin/ru/ifmo/se/dating/matchmaker/soap/MatchmakerRestClient.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,26 @@ | ||
package ru.ifmo.se.dating.matchmaker.soap | ||
|
||
import org.springframework.web.client.RestClient | ||
import ru.ifmo.se.dating.matchmaker.client.generated.apis.PeopleApi | ||
import ru.ifmo.se.dating.matchmaker.client.generated.apis.StatisticsApi | ||
import ru.ifmo.se.dating.matchmaker.client.generated.apis.SuggestionsApi | ||
|
||
class MatchmakerRestClient(private val client: RestClient) { | ||
fun people(authorization: String? = null) = | ||
PeopleApi(clientWithHeaders(authorization)) | ||
|
||
fun statistics(authorization: String? = null) = | ||
StatisticsApi(clientWithHeaders(authorization)) | ||
|
||
fun suggestions(authorization: String? = null) = | ||
SuggestionsApi(clientWithHeaders(authorization)) | ||
|
||
private fun clientWithHeaders(authorization: String? = null) = | ||
client.mutate() | ||
.apply { client -> | ||
authorization?.let { | ||
client.defaultHeader("Authorization", "Bearer $it") | ||
} | ||
} | ||
.build() | ||
} |
57 changes: 57 additions & 0 deletions
57
...atchmaker-soap/src/main/kotlin/ru/ifmo/se/dating/matchmaker/soap/MatchmakerSoapService.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,57 @@ | ||
package ru.ifmo.se.dating.matchmaker.soap | ||
|
||
import org.springframework.stereotype.Controller | ||
import ru.ifmo.se.dating.matchmaker.* | ||
|
||
@Controller | ||
class MatchmakerSoapService( | ||
private val rest: MatchmakerRestClient, | ||
) : ITMODatingMatchmakerPortType { | ||
override fun getSuggestions( | ||
authorization: String, | ||
parameters: GetSuggestionsRequest, | ||
): GetSuggestionsResponse = | ||
rest.suggestions(authorization = authorization) | ||
.suggestionsGet(limit = parameters.limit.toLong()) | ||
.toSuggestionsSoap() | ||
|
||
override fun likeSkip( | ||
authorization: String, | ||
parameters: LikeSkipRequest, | ||
): LikeSkipResponse = | ||
rest.suggestions(authorization = authorization) | ||
.peoplePersonIdAttitudesIncomingAttitudeKindPost( | ||
personId = parameters.personId.toLong(), | ||
attitudeKind = parameters.attitudeKind.toRest(), | ||
) | ||
.let { LikeSkipResponse() } | ||
|
||
override fun getAttitudesStatistics(parameters: Any): GetAttitudesStatisticsResponse = | ||
rest.statistics() | ||
.statisticsAttitudesGet() | ||
.toSoap() | ||
|
||
override fun getMatches( | ||
authorization: String, | ||
parameters: GetMatchesRequest, | ||
): GetMatchesResponse = | ||
rest.suggestions(authorization) | ||
.peoplePersonIdMatchesGet(personId = parameters.personId.toLong()) | ||
.toMatchesSoap() | ||
|
||
override fun updatePerson(parameters: UpdatePersonRequest): UpdatePersonResponse = | ||
rest.people() | ||
.peoplePersonIdPut( | ||
personId = parameters.personId.toLong(), | ||
personUpdateMessage = parameters.personUpdate.toRest(), | ||
) | ||
.let { UpdatePersonResponse() } | ||
|
||
override fun resetAttitudes( | ||
authorization: String, | ||
parameters: ResetAttitudesRequest, | ||
): ResetAttitudesResponse = | ||
rest.suggestions(authorization) | ||
.attitudesDelete(sourceId = parameters.sourceId.toLong()) | ||
.let { ResetAttitudesResponse() } | ||
} |
24 changes: 24 additions & 0 deletions
24
...chmaker-soap/src/main/kotlin/ru/ifmo/se/dating/matchmaker/soap/RestClientConfiguration.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,24 @@ | ||
package ru.ifmo.se.dating.matchmaker.soap | ||
|
||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.boot.autoconfigure.web.client.RestClientSsl | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter | ||
import org.springframework.web.client.RestClient | ||
|
||
@Configuration | ||
class RestClientConfiguration { | ||
@Bean | ||
fun matchmakerRestClient( | ||
@Value("\${itmo-dating.matchmaker.url}") | ||
baseUrl: String, | ||
|
||
ssl: RestClientSsl, | ||
): MatchmakerRestClient = RestClient.builder() | ||
.baseUrl("$baseUrl/api") | ||
.messageConverters { it.add(MappingJackson2HttpMessageConverter()) } | ||
.apply(ssl.fromBundle("internal")) | ||
.build() | ||
.let { MatchmakerRestClient(it) } | ||
} |
26 changes: 26 additions & 0 deletions
26
...chmaker-soap/src/main/kotlin/ru/ifmo/se/dating/matchmaker/soap/WebServiceConfiguration.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,26 @@ | ||
package ru.ifmo.se.dating.matchmaker.soap | ||
|
||
import jakarta.xml.ws.Endpoint | ||
import org.apache.cxf.Bus | ||
import org.apache.cxf.bus.spring.SpringBus | ||
import org.apache.cxf.jaxws.EndpointImpl | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Configuration | ||
import ru.ifmo.se.dating.matchmaker.ITMODatingMatchmakerPortType | ||
|
||
@Configuration | ||
class WebServiceConfiguration { | ||
@Bean(Bus.DEFAULT_BUS_ID) | ||
fun springBus(): SpringBus = | ||
SpringBus() | ||
|
||
@Bean | ||
fun matchmakerEndpoint( | ||
bus: Bus, | ||
service: ITMODatingMatchmakerPortType, | ||
): Endpoint { | ||
val endpoint = EndpointImpl(bus, service) | ||
endpoint.publish("/matchmaker") | ||
return endpoint | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
backend/matchmaker-soap/src/main/resources/application.yml
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,20 @@ | ||
spring: | ||
config: | ||
import: application-tls.yml | ||
application: | ||
name: matchmaker-soap | ||
ssl: | ||
bundle: | ||
jks: | ||
internal: | ||
keystore: | ||
type: PKCS12 | ||
location: classpath:keystore/itmo-dating-backend.p12 | ||
password: ${ITMO_DATING_KEY_STORE_PASSWORD} | ||
truststore: | ||
type: PKCS12 | ||
location: classpath:keystore/itmo-dating-backend.p12 | ||
password: ${ITMO_DATING_KEY_STORE_PASSWORD} | ||
itmo-dating: | ||
matchmaker: | ||
url: https://matchmaker-0.dating.se.ifmo.ru:8080 |
Oops, something went wrong.