Skip to content

Commit

Permalink
feat: Update to Spring Boot 3, stabilize, project & organization dele…
Browse files Browse the repository at this point in the history
…te performance (soft deleting) (#1938)
  • Loading branch information
JanCizmar authored Dec 15, 2023
1 parent b46b23c commit 3147302
Show file tree
Hide file tree
Showing 422 changed files with 3,346 additions and 1,995 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/reportIntermittentTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ jobs:
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}

- name: Compile kotlin
run: ./gradlew compileTestKotlin --parallel

- name: Build backend
run: ./gradlew bootJar
run: ./gradlew bootJar --parallel

- name: Tar App build
run: tar -czf ~/backend-app.tgz ./backend/app/build
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}

- name: Compile kotlin
run: ./gradlew compileTestKotlin --parallel

- name: Build backend
run: ./gradlew bootJar --parallel

Expand Down
25 changes: 11 additions & 14 deletions backend/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ plugins {
id 'java'
id 'io.spring.dependency-management'
id 'org.jetbrains.kotlin.jvm'
id 'org.springframework.boot'
id 'org.springframework.boot' apply false
id "kotlin-allopen"

}

group = 'io.tolgee'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: "org.jetbrains.kotlin.plugin.spring"
apply plugin: 'org.springframework.boot'
apply plugin: "kotlin-allopen"
apply plugin: 'io.spring.dependency-management'

Expand All @@ -31,7 +29,7 @@ repositories {
}

kotlin {
jvmToolchain(11)
jvmToolchain(17)
}

allOpen {
Expand All @@ -54,15 +52,9 @@ dependencies {
/**
* SPRING DOC
*/
implementation libs.springDocOpenApiWebMvcCore
implementation libs.springDocWebmvcApi
implementation libs.springDocOpenApiUi
implementation libs.springDocOpenApiKotlin
implementation libs.springDocOpenApiDataRest
implementation libs.springDocOpenApiHateoas
implementation dependencies.create(libs.redissonSpringBootStarter.get()) {
exclude group: 'org.redisson', module: 'redisson-spring-data-31'
}
implementation libs.redissonSpringData
implementation libs.redissonSpringBootStarter

/**
* Misc
Expand All @@ -74,15 +66,20 @@ dependencies {
implementation libs.jjwtJackson
implementation("com.github.ben-manes.caffeine:caffeine:3.0.5")
api libs.postHog
implementation libs.kotlinReflect
implementation libs.jacksonModuleKotlin
}

sourceSets {
main.kotlin.srcDirs = ['src/main/kotlin', 'src/main/java']
test.kotlin.srcDirs = ['src/test/kotlin', 'src/test/java']
}

tasks.findByName("jar").enabled(true)
tasks.findByName("bootJar").enabled(false)
dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}

jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.tolgee.security.authentication.JwtService
import io.tolgee.security.authentication.RequiresSuperAuthentication
import io.tolgee.service.organization.OrganizationService
import io.tolgee.service.security.UserAccountService
import org.springdoc.api.annotations.ParameterObject
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.data.web.SortDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import io.tolgee.service.project.ProjectService
import io.tolgee.service.security.ApiKeyService
import io.tolgee.service.security.PermissionService
import io.tolgee.service.security.SecurityService
import jakarta.validation.Valid
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.hateoas.PagedModel
Expand All @@ -46,7 +47,6 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@Suppress("MVCPathVariableInspection")
@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import io.tolgee.security.ProjectHolder
import io.tolgee.security.authentication.AllowApiAccess
import io.tolgee.security.authorization.RequiresProjectPermissions
import io.tolgee.service.bigMeta.BigMetaService
import jakarta.validation.Valid
import org.springframework.hateoas.CollectionModel
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@Suppress("MVCPathVariableInspection")
@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ import io.tolgee.hateoas.key.KeyWithScreenshotsModelAssembler
import io.tolgee.hateoas.language.LanguageModel
import io.tolgee.hateoas.language.LanguageModelAssembler
import io.tolgee.hateoas.screenshot.ScreenshotModelAssembler
import io.tolgee.model.Language
import io.tolgee.model.Project
import io.tolgee.model.enums.AssignableTranslationState
import io.tolgee.model.enums.Scope
import io.tolgee.model.key.Key
import io.tolgee.model.views.LanguageViewImpl
import io.tolgee.security.ProjectHolder
import io.tolgee.security.authentication.AllowApiAccess
import io.tolgee.security.authorization.RequiresProjectPermissions
import io.tolgee.security.authorization.UseDefaultPermissions
import io.tolgee.service.key.KeySearchResultView
import io.tolgee.service.key.KeyService
import io.tolgee.service.security.SecurityService
import org.springdoc.api.annotations.ParameterObject
import jakarta.validation.Valid
import org.springdoc.core.annotations.ParameterObject
import org.springframework.context.ApplicationContext
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
Expand All @@ -58,7 +61,6 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@Suppress("MVCPathVariableInspection")
@RestController
Expand Down Expand Up @@ -251,7 +253,7 @@ class KeyController(
@Operation(summary = "Returns languages, in which key is disabled")
fun getDisabledLanguages(@PathVariable id: Long): CollectionModel<LanguageModel> {
val languages = keyService.getDisabledLanguages(projectHolder.project.id, id)
return languageModelAssembler.toCollectionModel(languages)
return languageModelAssembler.toCollectionModel(languages.toViews())
}

@PutMapping("/{id}/disabled-languages")
Expand All @@ -263,7 +265,12 @@ class KeyController(
@RequestBody @Valid dto: SetDisabledLanguagesRequest
): CollectionModel<LanguageModel> {
val languages = keyService.setDisabledLanguages(projectHolder.project.id, id, dto.languageIds)
return languageModelAssembler.toCollectionModel(languages)
return languageModelAssembler.toCollectionModel(languages.toViews())
}

private fun List<Language>.toViews(): List<LanguageViewImpl> {
val baseLanguage = projectHolder.projectEntity.baseLanguage
return this.map { LanguageViewImpl(it, it.id == baseLanguage?.id) }
}

private fun Key.checkInProject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import io.tolgee.security.authentication.AllowApiAccess
import io.tolgee.security.authorization.RequiresProjectPermissions
import io.tolgee.security.authorization.UseDefaultPermissions
import io.tolgee.service.key.NamespaceService
import org.springdoc.api.annotations.ParameterObject
import jakarta.validation.Valid
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.data.web.SortDefault
Expand All @@ -29,7 +30,6 @@ import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@Suppress("MVCPathVariableInspection")
@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import io.tolgee.security.authentication.AuthTokenType
import io.tolgee.security.authentication.AuthenticationFacade
import io.tolgee.security.authentication.RequiresSuperAuthentication
import io.tolgee.service.security.PatService
import org.springdoc.api.annotations.ParameterObject
import jakarta.validation.Valid
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.hateoas.PagedModel
Expand All @@ -34,7 +35,6 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@RestController
@RequestMapping("/v2/pats")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import io.tolgee.model.views.activity.ProjectActivityView
import io.tolgee.security.ProjectHolder
import io.tolgee.security.authentication.AllowApiAccess
import io.tolgee.security.authorization.RequiresProjectPermissions
import org.springdoc.api.annotations.ParameterObject
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.hateoas.MediaTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.tags.Tag
import io.tolgee.dtos.request.GenerateSlugDto
import io.tolgee.service.organization.OrganizationService
import io.tolgee.service.project.ProjectService
import jakarta.validation.Valid
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.CrossOrigin
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@RestController
@CrossOrigin(origins = ["*"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import io.tolgee.security.authorization.RequiresProjectPermissions
import io.tolgee.security.authorization.UseDefaultPermissions
import io.tolgee.service.key.KeyService
import io.tolgee.service.key.TagService
import org.springdoc.api.annotations.ParameterObject
import jakarta.validation.Valid
import org.springdoc.core.annotations.ParameterObject
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PagedResourcesAssembler
import org.springframework.data.web.SortDefault
Expand All @@ -31,7 +32,6 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid
import io.swagger.v3.oas.annotations.tags.Tag as OpenApiTag

@Suppress("MVCPathVariableInspection", "SpringJavaInjectionPointsAutowiringInspection")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import io.tolgee.security.authentication.AuthenticationFacade
import io.tolgee.security.authentication.JwtService
import io.tolgee.security.payload.JwtAuthenticationResponse
import io.tolgee.service.security.MfaService
import jakarta.validation.Valid
import org.springframework.web.bind.annotation.DeleteMapping
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.validation.Valid

@RestController
@RequestMapping("/v2/user/mfa")
Expand Down
Loading

0 comments on commit 3147302

Please sign in to comment.