Skip to content

Commit 0198c26

Browse files
authored
Code cleanup and improvements (#906)
* File upload improvements * Optimize imports * Run automated code cleanup
1 parent 60e9375 commit 0198c26

File tree

207 files changed

+534
-751
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+534
-751
lines changed

backend/src/main/kotlin/hu/bme/sch/cmsch/addon/indulasch/IndulaschIntegrationService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ data class IndulaschTextWidgetDto(
3737

3838
@Service
3939
@ConditionalOnBean(QrFightComponent::class)
40-
open class IndulaschIntegrationService(
40+
class IndulaschIntegrationService(
4141
private val qrFightComponent: QrFightComponent,
4242
private val objectMapper: ObjectMapper
4343
) {
@@ -51,7 +51,7 @@ open class IndulaschIntegrationService(
5151
.build()
5252

5353
@Async
54-
open fun setTextOnWidget(widgetData: IndulaschTextWidgetDto){
54+
fun setTextOnWidget(widgetData: IndulaschTextWidgetDto){
5555
if(qrFightComponent.indulaschApiKey.getValue().isEmpty() || qrFightComponent.indulaschKioskId.getValue().isEmpty()) return
5656
val response: String? = indulaschApi.patch()
5757
.uri { uriBuilder ->

backend/src/main/kotlin/hu/bme/sch/cmsch/addon/nova/NovaIntegrationService.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const val CV_TAG = "cv"
3434
havingValue = "true",
3535
matchIfMissing = false
3636
)
37-
open class NovaIntegrationService(
37+
class NovaIntegrationService(
3838
private val responseRepository: ResponseRepository,
3939
private val formRepository: FormRepository,
4040
private val userRepository: UserRepository,
@@ -48,7 +48,7 @@ open class NovaIntegrationService(
4848

4949
@Retryable(value = [ SQLException::class ], maxAttempts = 5, backoff = Backoff(delay = 500L, multiplier = 1.5))
5050
@Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE)
51-
open fun updateSubmissions(emails: List<String>): Int {
51+
fun updateSubmissions(emails: List<String>): Int {
5252
val form = formRepository.findAll().firstOrNull { it.selected }
5353

5454
if (form == null) {
@@ -76,7 +76,7 @@ open class NovaIntegrationService(
7676

7777
@Retryable(value = [ SQLException::class ], maxAttempts = 5, backoff = Backoff(delay = 500L, multiplier = 1.5))
7878
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
79-
open fun fetchSubmissions(): List<FilledOutFormDto> {
79+
fun fetchSubmissions(): List<FilledOutFormDto> {
8080
val form = formRepository.findAll().firstOrNull { it.selected }
8181

8282
if (form == null) {
@@ -153,7 +153,7 @@ open class NovaIntegrationService(
153153

154154
@Retryable(value = [ SQLException::class ], maxAttempts = 5, backoff = Backoff(delay = 500L, multiplier = 1.5))
155155
@Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE)
156-
open fun setPaymentStatus(email: String, status: Boolean, rejectionMessage: String?) {
156+
fun setPaymentStatus(email: String, status: Boolean, rejectionMessage: String?) {
157157
val form = formRepository.findAll().firstOrNull { it.selected }
158158
if (form == null) {
159159
log.info("[NOVA/VALID-USERS] Form not found with non empty url")
@@ -175,7 +175,7 @@ open class NovaIntegrationService(
175175

176176
@Retryable(value = [ SQLException::class ], maxAttempts = 5, backoff = Backoff(delay = 500L, multiplier = 1.5))
177177
@Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE)
178-
open fun setDetailsStatus(email: String, status: Boolean, rejectionMessage: String?) {
178+
fun setDetailsStatus(email: String, status: Boolean, rejectionMessage: String?) {
179179
val form = formRepository.findAll().firstOrNull { it.selected }
180180
if (form == null) {
181181
log.info("[NOVA/VALID-USERS] Form not found with non empty url")
@@ -197,7 +197,7 @@ open class NovaIntegrationService(
197197

198198
@Retryable(value = [ SQLException::class ], maxAttempts = 5, backoff = Backoff(delay = 500L, multiplier = 1.5))
199199
@Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE)
200-
open fun setAvatarStatus(email: String, status: Boolean, rejectionMessage: String?) {
200+
fun setAvatarStatus(email: String, status: Boolean, rejectionMessage: String?) {
201201
val user = userRepository.findByEmail(email).orElse(null) ?: return
202202

203203
taskRepository.ifPresent { tasks ->
@@ -220,7 +220,7 @@ open class NovaIntegrationService(
220220

221221
@Retryable(value = [ SQLException::class ], maxAttempts = 5, backoff = Backoff(delay = 500L, multiplier = 1.5))
222222
@Transactional(readOnly = false, isolation = Isolation.SERIALIZABLE)
223-
open fun setCvStatus(email: String, status: Boolean, rejectionMessage: String?) {
223+
fun setCvStatus(email: String, status: Boolean, rejectionMessage: String?) {
224224
val user = userRepository.findByEmail(email).orElse(null) ?: return
225225

226226
taskRepository.ifPresent { tasks ->

backend/src/main/kotlin/hu/bme/sch/cmsch/admin/dashboard/DashboardPage.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import com.fasterxml.jackson.dataformat.csv.CsvMapper
44
import com.fasterxml.jackson.dataformat.csv.CsvSchema
55
import hu.bme.sch.cmsch.component.ComponentBase
66
import hu.bme.sch.cmsch.component.login.CmschUser
7-
import hu.bme.sch.cmsch.service.*
7+
import hu.bme.sch.cmsch.service.AdminMenuEntry
8+
import hu.bme.sch.cmsch.service.AdminMenuService
9+
import hu.bme.sch.cmsch.service.AuditLogService
10+
import hu.bme.sch.cmsch.service.PermissionValidator
811
import hu.bme.sch.cmsch.util.getUser
12+
import hu.bme.sch.cmsch.util.urlEncode
913
import jakarta.annotation.PostConstruct
1014
import jakarta.servlet.http.HttpServletResponse
1115
import org.springframework.http.MediaType
@@ -15,10 +19,7 @@ import org.springframework.web.bind.annotation.GetMapping
1519
import org.springframework.web.bind.annotation.PathVariable
1620
import org.springframework.web.bind.annotation.RequestParam
1721
import org.springframework.web.bind.annotation.ResponseBody
18-
import org.thymeleaf.util.StringUtils
1922
import java.io.ByteArrayOutputStream
20-
import java.net.URLEncoder
21-
import java.nio.charset.StandardCharsets
2223

2324
abstract class DashboardPage(
2425
var view: String,
@@ -151,19 +152,15 @@ abstract class DashboardPage(
151152
return outputStream.toByteArray()
152153
}
153154

154-
fun encodeMessage(message: String): String {
155-
return URLEncoder.encode(message, StandardCharsets.UTF_8)
156-
}
157-
158155
companion object {
159156
fun dashboardPage(view: String, card: Int = -1, message: String? = null): String {
160157
val anchor = if (card >= 0) "#${card}" else ""
161158
return if (message == null) {
162159
"redirect:/admin/control/$view$anchor"
163160
} else {
164-
"redirect:/admin/control/$view?card=$card&message=${URLEncoder.encode(message, StandardCharsets.UTF_8)}${anchor}"
161+
"redirect:/admin/control/$view?card=$card&message=${message.urlEncode()}${anchor}"
165162
}
166163
}
167164
}
168165

169-
}
166+
}

backend/src/main/kotlin/hu/bme/sch/cmsch/component/ComponentApiBase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import hu.bme.sch.cmsch.model.RoleType
55
import hu.bme.sch.cmsch.service.*
66
import hu.bme.sch.cmsch.setting.SettingType
77
import hu.bme.sch.cmsch.util.getUser
8+
import jakarta.annotation.PostConstruct
89
import org.slf4j.LoggerFactory
910
import org.springframework.security.core.Authentication
1011
import org.springframework.ui.Model
1112
import org.springframework.web.bind.annotation.GetMapping
1213
import org.springframework.web.bind.annotation.PostMapping
1314
import org.springframework.web.bind.annotation.RequestParam
1415
import org.springframework.web.multipart.MultipartRequest
15-
import jakarta.annotation.PostConstruct
1616

1717
abstract class ComponentApiBase(
1818
val adminMenuService: AdminMenuService,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package hu.bme.sch.cmsch.component
22

3-
import org.springframework.data.repository.CrudRepository as CrudRepository
3+
import org.springframework.data.repository.CrudRepository
44

55
interface RealEntityController {
66

77
val repo: CrudRepository<*, Int>
88

9-
}
9+
}

backend/src/main/kotlin/hu/bme/sch/cmsch/component/admission/AdmissionByFormController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import hu.bme.sch.cmsch.controller.admin.SimpleEntityPage
99
import hu.bme.sch.cmsch.model.IdentifiableEntity
1010
import hu.bme.sch.cmsch.service.AdminMenuService
1111
import hu.bme.sch.cmsch.service.AuditLogService
12-
import hu.bme.sch.cmsch.service.StorageService
1312
import hu.bme.sch.cmsch.service.ImportService
1413
import hu.bme.sch.cmsch.service.StaffPermissions.PERMISSION_EXPORT_ADMISSION
1514
import hu.bme.sch.cmsch.service.StaffPermissions.PERMISSION_VALIDATE_ADMISSION
15+
import hu.bme.sch.cmsch.service.StorageService
1616
import hu.bme.sch.cmsch.util.getUser
1717
import jakarta.servlet.http.HttpServletResponse
1818
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean

backend/src/main/kotlin/hu/bme/sch/cmsch/component/admission/AdmissionComponent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package hu.bme.sch.cmsch.component.admission
22

3-
import hu.bme.sch.cmsch.component.*
4-
import hu.bme.sch.cmsch.setting.ComponentSettingService
3+
import hu.bme.sch.cmsch.component.ComponentBase
54
import hu.bme.sch.cmsch.model.RoleType
65
import hu.bme.sch.cmsch.service.ControlPermissions
6+
import hu.bme.sch.cmsch.setting.ComponentSettingService
77
import hu.bme.sch.cmsch.setting.MinRoleSettingProxy
88
import hu.bme.sch.cmsch.setting.SettingProxy
99
import hu.bme.sch.cmsch.setting.SettingType

backend/src/main/kotlin/hu/bme/sch/cmsch/component/admission/AdmissionService.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import kotlin.reflect.full.memberProperties
1818

1919
@Service
2020
@ConditionalOnBean(AdmissionComponent::class)
21-
open class AdmissionService(
21+
class AdmissionService(
2222
private val admissionEntryRepository: AdmissionEntryRepository,
2323
private val clock: TimeService,
2424
private val auditLogService: AuditLogService,
@@ -29,7 +29,7 @@ open class AdmissionService(
2929
) {
3030

3131
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED)
32-
open fun logEntryAttempt(
32+
fun logEntryAttempt(
3333
response: AdmissionResponse,
3434
gate: CmschUser,
3535
token: String,
@@ -59,7 +59,7 @@ open class AdmissionService(
5959
}
6060

6161
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
62-
open fun generateAdmissionExportForForm(id: Int): ByteArrayOutputStream {
62+
fun generateAdmissionExportForForm(id: Int): ByteArrayOutputStream {
6363
val outputStream = ByteArrayOutputStream()
6464
val responses = responseRepository.orElseThrow().findAllByFormIdOrderByLineAsc(id)
6565
val admissions = admissionEntryRepository.findAllByFormIdAndAllowedTrue(id)
@@ -101,7 +101,7 @@ open class AdmissionService(
101101
}
102102

103103
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
104-
open fun getTicketByQr(cmschId: String): TicketEntity? {
104+
fun getTicketByQr(cmschId: String): TicketEntity? {
105105
val user = userRepository.findByCmschId(cmschId).getOrNull()
106106
if (user == null) {
107107
return ticketRepository.findTop1ByQrCodeAndUseCmschIdTrue(cmschId).firstOrNull()
@@ -118,12 +118,12 @@ open class AdmissionService(
118118

119119

120120
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
121-
open fun countEntries(cmschId: String): Long {
121+
fun countEntries(cmschId: String): Long {
122122
return admissionEntryRepository.countAllByToken(cmschId)
123123
}
124124

125125
@Transactional(readOnly = true, isolation = Isolation.READ_COMMITTED)
126-
open fun hasTicket(cmschId: String): Boolean {
126+
fun hasTicket(cmschId: String): Boolean {
127127
return getTicketByQr(cmschId) != null
128128
}
129129

backend/src/main/kotlin/hu/bme/sch/cmsch/component/app/ApplicationComponent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hu.bme.sch.cmsch.component.app
22

3-
import hu.bme.sch.cmsch.component.*
3+
import hu.bme.sch.cmsch.component.ComponentBase
44
import hu.bme.sch.cmsch.model.RoleType
55
import hu.bme.sch.cmsch.service.ControlPermissions
66
import hu.bme.sch.cmsch.setting.ComponentSettingService

backend/src/main/kotlin/hu/bme/sch/cmsch/component/app/ApplicationComponentController.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import hu.bme.sch.cmsch.component.ComponentApiBase
44
import hu.bme.sch.cmsch.service.AdminMenuCategory
55
import hu.bme.sch.cmsch.service.AdminMenuService
66
import hu.bme.sch.cmsch.service.AuditLogService
7-
import hu.bme.sch.cmsch.service.StorageService
87
import hu.bme.sch.cmsch.service.ControlPermissions.PERMISSION_CONTROL_APP
8+
import hu.bme.sch.cmsch.service.StorageService
99
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
1010
import org.springframework.core.env.Environment
1111
import org.springframework.stereotype.Controller

0 commit comments

Comments
 (0)