Skip to content

Commit

Permalink
Move services from Save and COSV into a common module (#2920)
Browse files Browse the repository at this point in the history
* Move services from Save and COSV into a common module
  • Loading branch information
Cheshiriks authored Feb 13, 2024
1 parent be2e216 commit a90a234
Show file tree
Hide file tree
Showing 84 changed files with 450 additions and 1,958 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import org.springframework.context.annotation.Import
/**
* An entrypoint for spring for save-backend
*/
@SpringBootApplication(scanBasePackages = ["com.saveourtool.save.backend", "com.saveourtool.save.repository"])
@SpringBootApplication(scanBasePackages = [
"com.saveourtool.save.backend",
"com.saveourtool.save.service",
"com.saveourtool.save.storage",
"com.saveourtool.save.security",
"com.saveourtool.save.utils",
"com.saveourtool.save.repository",
])
@EnableConfigurationProperties(ConfigProperties::class)
@Import(
DefaultS3Configuration::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.saveourtool.save.backend.configs

import com.saveourtool.save.service.LogService
import com.saveourtool.save.service.LokiLogService
import com.saveourtool.save.utils.BlockingBridge
import org.springframework.boot.actuate.autoconfigure.metrics.orm.jpa.HibernateMetricsAutoConfiguration
import org.springframework.boot.autoconfigure.ImportAutoConfiguration
import org.springframework.boot.autoconfigure.domain.EntityScan
Expand All @@ -24,10 +23,4 @@ class ApplicationConfiguration {
*/
@Bean
fun logService(configProperties: ConfigProperties): LogService = LokiLogService.createOrStub(configProperties.loki)

/**
* @return [BlockingBridge]
*/
@Bean
fun blockingBridge(): BlockingBridge = BlockingBridge.default
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.authservice.utils.username
import com.saveourtool.save.backend.service.OrganizationService
import com.saveourtool.save.backend.service.UserDetailsService
import com.saveourtool.save.backend.storage.AvatarStorage
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.service.UserService
import com.saveourtool.save.storage.AvatarKey
import com.saveourtool.save.storage.AvatarStorage
import com.saveourtool.save.utils.*
import com.saveourtool.save.utils.ByteBufferFluxResponse
import com.saveourtool.save.v1
Expand Down Expand Up @@ -43,7 +43,7 @@ import kotlin.time.toJavaDuration
internal class AvatarController(
private val avatarStorage: AvatarStorage,
private val organizationService: OrganizationService,
private val userDetailsService: UserDetailsService,
private val userDetailsService: UserService,
) {
@Operation(
method = "POST",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.backend.security.CommentPermissionEvaluator
import com.saveourtool.save.backend.service.CommentService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.entities.Comment
import com.saveourtool.save.entities.CommentDto
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.CommentPermissionEvaluator
import com.saveourtool.save.service.CommentService
import com.saveourtool.save.utils.StringResponse
import com.saveourtool.save.utils.blockingToMono
import com.saveourtool.save.utils.switchIfEmptyToNotFound
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.backend.security.OrganizationPermissionEvaluator
import com.saveourtool.save.backend.service.*
import com.saveourtool.save.backend.storage.TestsSourceSnapshotStorage
import com.saveourtool.save.configs.ApiSwaggerSupport
Expand All @@ -11,6 +10,8 @@ import com.saveourtool.save.entities.contest.ContestDto
import com.saveourtool.save.entities.contest.ContestStatus
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.request.TestFilesRequest
import com.saveourtool.save.security.OrganizationPermissionEvaluator
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.test.TestFilesContent
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.backend.configs.ConfigProperties
import com.saveourtool.save.backend.security.ProjectPermissionEvaluator
import com.saveourtool.save.backend.service.LnkProjectGithubService
import com.saveourtool.save.backend.service.ProjectService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.demo.DemoCreationRequest
import com.saveourtool.save.entities.FileDto
import com.saveourtool.save.entities.Project
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.ProjectPermissionEvaluator
import com.saveourtool.save.service.LogService
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.spring.utils.applyAll
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.backend.security.ProjectPermissionEvaluator
import com.saveourtool.save.backend.service.ExecutionService
import com.saveourtool.save.backend.service.OrganizationService
import com.saveourtool.save.backend.service.ProjectService
import com.saveourtool.save.backend.storage.ExecutionInfoStorage
import com.saveourtool.save.backend.utils.toMonoOrNotFound
import com.saveourtool.save.core.utils.runIf
Expand All @@ -14,6 +11,9 @@ import com.saveourtool.save.execution.ExecutionUpdateDto
import com.saveourtool.save.execution.TestingType
import com.saveourtool.save.filters.ExecutionFilter
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.ProjectPermissionEvaluator
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.utils.blockingMap
import com.saveourtool.save.utils.orNotFound
import com.saveourtool.save.utils.switchIfEmptyToNotFound
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.backend.service.ProjectService
import com.saveourtool.save.backend.storage.FileStorage
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.entities.FileDto
import com.saveourtool.save.entities.Project
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.utils.*
import com.saveourtool.save.utils.ByteBufferFluxResponse
import com.saveourtool.save.v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import com.saveourtool.save.entities.LnkContestProject
import com.saveourtool.save.entities.contest.ContestResult
import com.saveourtool.save.execution.ExecutionDto
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.service.LnkUserProjectService
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@

package com.saveourtool.save.backend.controllers

import com.saveourtool.save.backend.security.OrganizationPermissionEvaluator
import com.saveourtool.save.backend.security.TestSuitePermissionEvaluator
import com.saveourtool.save.backend.service.LnkOrganizationTestSuiteService
import com.saveourtool.save.backend.service.OrganizationService
import com.saveourtool.save.backend.service.TestSuitesService
import com.saveourtool.save.backend.service.TestsSourceVersionService
import com.saveourtool.save.configs.ApiSwaggerSupport
Expand All @@ -23,6 +21,8 @@ import com.saveourtool.save.filters.TestSuiteFilter
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.permission.Rights
import com.saveourtool.save.permission.SetRightsRequest
import com.saveourtool.save.security.OrganizationPermissionEvaluator
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.testsuite.TestSuiteVersioned
import com.saveourtool.save.utils.StringResponse
import com.saveourtool.save.utils.switchIfEmptyToNotFound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ package com.saveourtool.save.backend.controllers

import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.authservice.utils.username
import com.saveourtool.save.backend.security.OrganizationPermissionEvaluator
import com.saveourtool.save.backend.service.LnkUserOrganizationService
import com.saveourtool.save.backend.service.OrganizationService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.domain.Role
Expand All @@ -21,6 +18,9 @@ import com.saveourtool.save.filters.OrganizationFilter
import com.saveourtool.save.info.UserInfo
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.permission.SetRoleRequest
import com.saveourtool.save.security.OrganizationPermissionEvaluator
import com.saveourtool.save.service.LnkUserOrganizationService
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.utils.StringResponse
import com.saveourtool.save.utils.switchIfEmptyToNotFound
import com.saveourtool.save.utils.switchIfEmptyToResponseException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.backend.security.ProjectPermissionEvaluator
import com.saveourtool.save.backend.service.LnkUserProjectService
import com.saveourtool.save.backend.service.ProjectService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.entities.ProjectDto
import com.saveourtool.save.info.UserInfo
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.ProjectPermissionEvaluator
import com.saveourtool.save.service.LnkUserProjectService
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.utils.switchIfEmptyToNotFound
import com.saveourtool.save.v1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.saveourtool.save.backend.controllers

import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.backend.configs.ConfigProperties
import com.saveourtool.save.backend.security.OrganizationPermissionEvaluator
import com.saveourtool.save.backend.service.*
import com.saveourtool.save.backend.storage.TestsSourceSnapshotStorage
import com.saveourtool.save.configs.ApiSwaggerSupport
Expand All @@ -12,6 +11,10 @@ import com.saveourtool.save.domain.Role
import com.saveourtool.save.entities.*
import com.saveourtool.save.filters.OrganizationFilter
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.OrganizationPermissionEvaluator
import com.saveourtool.save.service.GitService
import com.saveourtool.save.service.LnkUserOrganizationService
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.authservice.utils.username
import com.saveourtool.save.backend.security.OrganizationPermissionEvaluator
import com.saveourtool.save.backend.security.ProjectPermissionEvaluator
import com.saveourtool.save.backend.service.OrganizationService
import com.saveourtool.save.backend.service.PermissionService
import com.saveourtool.save.backend.service.ProjectService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.domain.Role
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.permission.SetRoleRequest
import com.saveourtool.save.security.OrganizationPermissionEvaluator
import com.saveourtool.save.security.ProjectPermissionEvaluator
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.utils.switchIfEmptyToNotFound
import com.saveourtool.save.utils.trace
import com.saveourtool.save.v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.saveourtool.save.backend.controllers

import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.backend.security.ProjectPermissionEvaluator
import com.saveourtool.save.backend.service.LnkUserProjectService
import com.saveourtool.save.backend.service.OrganizationService
import com.saveourtool.save.backend.service.ProjectProblemService
import com.saveourtool.save.backend.service.ProjectService
import com.saveourtool.save.configs.ApiSwaggerSupport
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.domain.ProjectSaveStatus
Expand All @@ -14,6 +10,10 @@ import com.saveourtool.save.entities.*
import com.saveourtool.save.filters.ProjectFilter
import com.saveourtool.save.filters.ProjectProblemFilter
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.ProjectPermissionEvaluator
import com.saveourtool.save.service.LnkUserProjectService
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1
import com.saveourtool.save.validation.NAMING_MAX_LENGTH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.saveourtool.save.execution.ExecutionUpdateDto
import com.saveourtool.save.execution.TestingType
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.request.CreateExecutionRequest
import com.saveourtool.save.service.ProjectService
import com.saveourtool.save.spring.utils.applyAll
import com.saveourtool.save.storage.impl.InternalFileKey
import com.saveourtool.save.utils.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.saveourtool.save.agent.TestExecutionDto
import com.saveourtool.save.agent.TestExecutionExtDto
import com.saveourtool.save.agent.TestExecutionResult
import com.saveourtool.save.agent.TestSuiteExecutionStatisticDto
import com.saveourtool.save.backend.security.ProjectPermissionEvaluator
import com.saveourtool.save.backend.service.ExecutionService
import com.saveourtool.save.backend.service.TestAnalysisService
import com.saveourtool.save.backend.service.TestExecutionService
Expand All @@ -18,6 +17,7 @@ import com.saveourtool.save.domain.TestResultStatus
import com.saveourtool.save.entities.TestExecution
import com.saveourtool.save.filters.TestExecutionFilter
import com.saveourtool.save.permission.Permission
import com.saveourtool.save.security.ProjectPermissionEvaluator
import com.saveourtool.save.test.analysis.api.TestIdGenerator
import com.saveourtool.save.test.analysis.api.testId
import com.saveourtool.save.test.analysis.entities.metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.domain.EntitySaveStatus
import com.saveourtool.save.entities.*
import com.saveourtool.save.entities.TestSuitesSource.Companion.toTestSuiteSource
import com.saveourtool.save.service.GitService
import com.saveourtool.save.service.OrganizationService
import com.saveourtool.save.test.TestsSourceVersionInfoList
import com.saveourtool.save.testsuite.*
import com.saveourtool.save.utils.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package com.saveourtool.save.backend.controllers
import com.saveourtool.save.authservice.utils.SaveUserDetails
import com.saveourtool.save.authservice.utils.userId
import com.saveourtool.save.backend.configs.ConfigProperties
import com.saveourtool.save.backend.service.UserDetailsService
import com.saveourtool.save.configs.RequiresAuthorizationSourceHeader
import com.saveourtool.save.domain.UserSaveStatus
import com.saveourtool.save.entities.User
import com.saveourtool.save.info.UserInfo
import com.saveourtool.save.info.UserStatus
import com.saveourtool.save.repository.UserRepository
import com.saveourtool.save.service.UserService
import com.saveourtool.save.utils.*
import com.saveourtool.save.v1
import com.saveourtool.save.validation.isValidLengthName
Expand Down Expand Up @@ -40,7 +40,7 @@ import reactor.kotlin.core.publisher.toMono
@RequestMapping(path = ["/api/$v1/users"])
class UsersDetailsController(
private val userRepository: UserRepository,
private val userDetailsService: UserDetailsService,
private val userDetailsService: UserService,
configProperties: ConfigProperties,
jackson2WebClientCustomizer: WebClientCustomizer,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.saveourtool.save.backend.controllers.internal

import com.saveourtool.save.authservice.utils.SaveUserDetails
import com.saveourtool.save.backend.service.UserDetailsService
import com.saveourtool.save.service.UserService
import com.saveourtool.save.utils.blockingToMono

import org.springframework.http.ResponseEntity
Expand All @@ -20,7 +20,7 @@ typealias SaveUserDetailsResponse = ResponseEntity<SaveUserDetails>
@RestController
@RequestMapping("/internal/users")
class UsersController(
private val userService: UserDetailsService,
private val userService: UserService,
) {
/**
* Stores user in the DB with provided [name] with default role.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.saveourtool.save.backend.controllers.vulnerability.event

import com.saveourtool.save.backend.service.NotificationService
import com.saveourtool.save.backend.service.UserDetailsService
import com.saveourtool.save.domain.Role
import com.saveourtool.save.entities.Notification
import com.saveourtool.save.entities.vulnerability.VulnerabilityStatus
import com.saveourtool.save.entitiescosv.VulnerabilityMetadata
import com.saveourtool.save.entitiescosv.evententities.VulnerabilityMetadataEvent
import com.saveourtool.save.service.UserService

import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component
Expand All @@ -16,7 +16,7 @@ import org.springframework.stereotype.Component
*/
@Component
class VulnerabilityMetadataListener(
private val userDetailsService: UserDetailsService,
private val userDetailsService: UserService,
private val notificationService: NotificationService,
) {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.saveourtool.save.backend.event

import com.saveourtool.save.backend.service.NotificationService
import com.saveourtool.save.backend.service.UserDetailsService
import com.saveourtool.save.domain.Role
import com.saveourtool.save.entities.Notification
import com.saveourtool.save.entities.User
import com.saveourtool.save.evententities.UserEvent
import com.saveourtool.save.info.UserStatus
import com.saveourtool.save.service.UserService
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component

Expand All @@ -15,7 +15,7 @@ import org.springframework.stereotype.Component
*/
@Component
class UserListener(
private val userDetailsService: UserDetailsService,
private val userDetailsService: UserService,
private val notificationService: NotificationService,
) {
/**
Expand Down
Loading

0 comments on commit a90a234

Please sign in to comment.