-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/sql-playground-sharing' into 1481-sql-runner-su…
…pport-for-playground-sharing
- Loading branch information
Showing
86 changed files
with
2,088 additions
and
410 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
12 changes: 12 additions & 0 deletions
12
...s/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/model/v2/checker/SharePlaygroundArguments.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,12 @@ | ||
package de.thm.ii.fbs.model.v2.checker | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
data class SharePlaygroundArguments( | ||
@JsonProperty("user") | ||
val user: RunnerUser, | ||
@JsonProperty("database") | ||
val database: RunnerDatabase, | ||
@JsonProperty("runner") | ||
val runner: Runner = Runner(RunnerType.SHARE_PLAYGROUND) | ||
) : RunnerArguments() |
14 changes: 14 additions & 0 deletions
14
modules/fbs-core/api/src/main/kotlin/de/thm/ii/fbs/model/v2/security/SharePlaygroundToken.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,14 @@ | ||
package de.thm.ii.fbs.model.v2.security | ||
import java.time.LocalDateTime | ||
import javax.persistence.Entity | ||
import javax.persistence.Id | ||
|
||
@Entity | ||
class SharePlaygroundToken( | ||
@Id | ||
val token: String, | ||
val userId: Int, | ||
val dbId: Int, | ||
val expiryTime: LocalDateTime, | ||
val uri: String | ||
) |
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
...i/src/main/kotlin/de/thm/ii/fbs/services/v2/persistence/SharePlaygroundTokenRepository.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 de.thm.ii.fbs.services.v2.persistence | ||
|
||
import de.thm.ii.fbs.model.v2.security.SharePlaygroundToken | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import java.time.LocalDateTime | ||
|
||
interface SharePlaygroundTokenRepository : JpaRepository<SharePlaygroundToken, String> { | ||
fun findAllByExpiryTimeBefore(now: LocalDateTime?): List<SharePlaygroundToken> | ||
} |
25 changes: 25 additions & 0 deletions
25
.../kotlin/de/thm/ii/fbs/services/v2/sharePlaygroundCleanup/SharePlaygroundCleanupService.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,25 @@ | ||
import de.thm.ii.fbs.model.v2.security.SharePlaygroundToken | ||
import de.thm.ii.fbs.services.v2.persistence.SharePlaygroundTokenRepository | ||
import de.thm.ii.fbs.services.v2.persistence.SqlPlaygroundDatabaseRepository | ||
import de.thm.ii.fbs.utils.v2.exceptions.NotFoundException | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Service | ||
import java.time.LocalDateTime | ||
|
||
@Service | ||
class SharePlaygroundCleanupService( | ||
private val sharePlaygroundTokenRepository: SharePlaygroundTokenRepository, | ||
private val databaseRepository: SqlPlaygroundDatabaseRepository | ||
) { | ||
@Scheduled(fixedDelayString = "PT24H") // Runs every 24h | ||
fun cleanupExpiredDumps() { | ||
val now = LocalDateTime.now() | ||
val expiredTokens: List<SharePlaygroundToken> = sharePlaygroundTokenRepository.findAllByExpiryTimeBefore(now) | ||
expiredTokens.forEach { token -> | ||
val db = databaseRepository.findByOwner_IdAndIdAndDeleted(token.userId, token.dbId, false) | ||
?: throw NotFoundException() | ||
//sqlPlaygroundCheckerService.deleteDatabase(db, db.id!!, db.name) WIP | ||
sharePlaygroundTokenRepository.delete(token) | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.