-
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.
- Loading branch information
1 parent
80330cc
commit ae2c325
Showing
19 changed files
with
164 additions
and
27 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
2 changes: 1 addition & 1 deletion
2
.../dto/ComponentVersionStatusWithInfoDTO.kt → .../dto/ComponentVersionStatusWithInfoDTO.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
2 changes: 1 addition & 1 deletion
2
...s/service/impl/dto/DownloadArtifactDTO.kt → ...en/octopus/dms/dto/DownloadArtifactDTO.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
9 changes: 9 additions & 0 deletions
9
...r/src/main/kotlin/org/octopusden/octopus/dms/event/DeleteComponentVersionArtifactEvent.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.octopusden.octopus.dms.event | ||
|
||
import org.octopusden.octopus.dms.client.common.dto.ArtifactFullDTO | ||
|
||
data class DeleteComponentVersionArtifactEvent( | ||
val component: String, | ||
val version: String, | ||
val artifact: ArtifactFullDTO | ||
) : Event(EventType.DELETE_COMPONENT_VERSION_ARTIFACT) |
18 changes: 18 additions & 0 deletions
18
server/src/main/kotlin/org/octopusden/octopus/dms/event/Event.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,18 @@ | ||
package org.octopusden.octopus.dms.event | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.EXISTING_PROPERTY, | ||
property = "type", | ||
visible = true | ||
) | ||
@JsonSubTypes( | ||
JsonSubTypes.Type(RegisterComponentVersionArtifactEvent::class, name = "REGISTER_COMPONENT_VERSION_ARTIFACT"), | ||
JsonSubTypes.Type(DeleteComponentVersionArtifactEvent::class, name = "DELETE_COMPONENT_VERSION_ARTIFACT") | ||
) | ||
abstract class Event( | ||
val type: EventType | ||
) |
5 changes: 5 additions & 0 deletions
5
server/src/main/kotlin/org/octopusden/octopus/dms/event/EventType.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,5 @@ | ||
package org.octopusden.octopus.dms.event | ||
|
||
enum class EventType { | ||
REGISTER_COMPONENT_VERSION_ARTIFACT, DELETE_COMPONENT_VERSION_ARTIFACT | ||
} |
9 changes: 9 additions & 0 deletions
9
...src/main/kotlin/org/octopusden/octopus/dms/event/RegisterComponentVersionArtifactEvent.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.octopusden.octopus.dms.event | ||
|
||
import org.octopusden.octopus.dms.client.common.dto.ArtifactFullDTO | ||
|
||
data class RegisterComponentVersionArtifactEvent( | ||
val component: String, | ||
val version: String, | ||
val artifact: ArtifactFullDTO | ||
) : Event(EventType.REGISTER_COMPONENT_VERSION_ARTIFACT) |
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
4 changes: 2 additions & 2 deletions
4
server/src/main/kotlin/org/octopusden/octopus/dms/service/ComponentService.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
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
29 changes: 29 additions & 0 deletions
29
server/src/main/kotlin/org/octopusden/octopus/dms/webhook/WebhookEventListener.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,29 @@ | ||
package org.octopusden.octopus.dms.webhook | ||
|
||
import org.octopusden.octopus.dms.event.Event | ||
import org.slf4j.LoggerFactory | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.scheduling.annotation.Async | ||
import org.springframework.stereotype.Component | ||
import org.springframework.transaction.event.TransactionalEventListener | ||
|
||
@ConditionalOnProperty(prefix = "dms-service.webhook", name = ["enabled"], havingValue = "true", matchIfMissing = true) | ||
@Component | ||
class WebhookEventListener( | ||
val webhookFeignClient: WebhookFeignClient | ||
) { | ||
@Async | ||
@TransactionalEventListener | ||
fun onEvent(event: Event) { | ||
log.info("Sending ${event.type} webhook") | ||
try { | ||
webhookFeignClient.post(event) | ||
} catch (e: Exception) { | ||
log.warn("Unable to send webhook", e) | ||
} | ||
} | ||
|
||
companion object { | ||
private val log = LoggerFactory.getLogger(WebhookEventListener::class.java) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
server/src/main/kotlin/org/octopusden/octopus/dms/webhook/WebhookFeignClient.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 org.octopusden.octopus.dms.webhook | ||
|
||
import org.octopusden.octopus.dms.event.Event | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty | ||
import org.springframework.cloud.openfeign.FeignClient | ||
import org.springframework.web.bind.annotation.PostMapping | ||
|
||
@ConditionalOnProperty(prefix = "dms-service.webhook", name = ["enabled"], havingValue = "true", matchIfMissing = true) | ||
@FeignClient("webhook", url = "\${dms-service.webhook.url}") | ||
interface WebhookFeignClient { | ||
@PostMapping | ||
fun post(event: Event) | ||
} |
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