Skip to content
Snippets Groups Projects
Verified Commit 837901cd authored by Jan-Niclas Strüwer's avatar Jan-Niclas Strüwer
Browse files

added test endpoint.

added external process task
parent 634fb811
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ class SecurityConfiguration {
authorizeExchange {
authorize("/gitlab/repoChanged", permitAll)
authorize("/gitlab/repoChangedPath", permitAll)
authorize("/gitlab/test", permitAll)
}
csrf {
disable()
......
package de.fraunhofer.iem.dataprovider.gitlab
import de.fraunhofer.iem.dataprovider.logger.getLogger
import de.fraunhofer.iem.dataprovider.taskManager.TaskManager
import de.fraunhofer.iem.dataprovider.taskManager.tasks.ProcessTask
import de.fraunhofer.iem.dataprovider.taskManager.tasks.TaskType
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
......@@ -14,7 +18,7 @@ data class RepositoryChangedDto(val repoId: Long, val platform: Platform)
data class RepositoryChangedPathDto(val path: String, val platform: Platform)
@RestController
@RequestMapping("/gitlab")
class GitlabController(private val gitlabService: GitlabService) {
class GitlabController(private val gitlabService: GitlabService, private val taskManager: TaskManager) {
private val logger = getLogger(javaClass)
......@@ -44,4 +48,9 @@ class GitlabController(private val gitlabService: GitlabService) {
}
}
}
@GetMapping("/test")
suspend fun test() {
taskManager.addTask(ProcessTask(TaskType.REPO_CHANGED))
}
}
\ No newline at end of file
package de.fraunhofer.iem.dataprovider.taskManager.tasks
sealed class ProcessTask(protected open vararg val flags: String): Task() {
protected abstract val execPath: String
override suspend fun execute() {
val p = ProcessBuilder(execPath, *flags)
.start()
p.onExit().thenApply { p1 ->
handleProcessReturn(p1)
}
}
abstract fun handleProcessReturn(p: Process)
}
class JavaTask(
override val type: TaskType,
override val execPath: String,
override vararg val flags: String,
val addTask: (task: Task) -> Unit
): ProcessTask() {
override fun handleProcessReturn(p: Process) {
addTask(DoneTask("Done with external process. Exit value ${p.exitValue()}"))
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

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.