Skip to content
Snippets Groups Projects
GitlabController.kt 1.12 KiB
Newer Older
package de.fraunhofer.iem.dataprovider.gitlab

import de.fraunhofer.iem.dataprovider.logger.getLogger
import org.springframework.web.bind.annotation.*
Jan-Niclas Strüwer's avatar
Jan-Niclas Strüwer committed
enum class Platform {
    OPEN_CODE,
    GITHUB,
}
data class RepositoryChangedDto(val repoId: Long, val platform: Platform)
@RestController
@RequestMapping("/gitlab")
class GitlabController(private val gitlabService: GitlabService) {

    private val logger = getLogger(javaClass)

Jan-Niclas Strüwer's avatar
Jan-Niclas Strüwer committed
    // TODO: if the parsing of the request body fails we send a stack
    //  trace back this should be changed to a custom error.
    @PostMapping("/repoChanged")
    suspend fun repoChanged(@RequestBody repositoryChangedDto: RepositoryChangedDto) {
Jan-Niclas Strüwer's avatar
Jan-Niclas Strüwer committed
        logger.info("Repo changed POST request for ID ${repositoryChangedDto.repoId} on platform ${repositoryChangedDto.platform} received.")
        when (repositoryChangedDto.platform) {
            Platform.OPEN_CODE -> gitlabService.queryOpenCodeProject(repositoryChangedDto.repoId)
            else -> {
                logger.info("Platform currently not supported.")
                // TODO: send fitting http response
            }
        }

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.