com.lsdconsulting.generatorui.controller.LsdController.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lsd-distributed-generator-ui-service Show documentation
Show all versions of lsd-distributed-generator-ui-service Show documentation
This is the graphical interface providing the LSD generation functionality.
The newest version!
package com.lsdconsulting.generatorui.controller
import com.lsdconsulting.generatorui.config.logger.log
import com.lsdconsulting.generatorui.service.DiffGenerator
import com.lsdconsulting.generatorui.service.LsdGenerator
import com.lsdconsulting.generatorui.service.LsdService
import io.lsdconsulting.lsd.distributed.connector.model.InterceptedInteraction
import io.lsdconsulting.stub.annotation.GenerateWireMockStub
import org.springframework.http.MediaType.*
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
@GenerateWireMockStub
@RestController
class LsdController(
private val lsdGenerator: LsdGenerator,
private val lsdService: LsdService,
private val diffGenerator: DiffGenerator,
) {
@GetMapping(value = ["/lsd/{traceId}", "/lsds/{traceId}"], produces = [TEXT_HTML_VALUE])
fun findByTraceId(@PathVariable traceId: String): String {
log().info("Received lsd request for traceId={}", traceId)
return lsdGenerator.captureInteractionsFromDatabase(traceId)
}
@GetMapping(value = ["/lsds"], produces = [APPLICATION_JSON_VALUE])
fun findByTraceIds(@RequestParam vararg traceIds:String): ResponseEntity> {
log().info("Received lsd request for traceIds={}", traceIds)
return ResponseEntity.ok(lsdService.findInteractionsByTraceIds(*traceIds))
}
@PostMapping("/lsds")
fun store(@RequestBody interceptedInteraction: InterceptedInteraction): ResponseEntity {
log().info("Received interceptedInteraction={}", interceptedInteraction)
lsdService.storeInteractionsInDatabase(interceptedInteraction)
return ResponseEntity.ok(interceptedInteraction)
}
@GetMapping(value = ["/lsdFlows"], produces = [APPLICATION_JSON_VALUE])
fun findRecentFlows(@RequestParam(required = false) resultSizeLimit: Int?): ResponseEntity> {
log().info("Received lsd request for recent flows")
return ResponseEntity.ok(lsdService.findMostRecentFlows(resultSizeLimit))
}
@GetMapping(value = ["/lsds/diff"], produces = [TEXT_HTML_VALUE])
fun diff(@RequestParam traceId1: String, @RequestParam traceId2: String): String {
log().info("Received lsd request for a diff between traceId1={} and traceId2={}", traceId1, traceId2)
return diffGenerator.sourceDiff(traceId1, traceId2)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy