diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..8e0a657b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +[{*.kts,*.kt}] +ktlint_standard_no-wildcard-imports = disabled diff --git a/build.gradle.kts b/build.gradle.kts index 2c2b81c1..cca92c5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,10 +12,11 @@ plugins { kotlin("plugin.allopen") version kotlinVersion kotlin("kapt") version kotlinVersion id("com.github.node-gradle.node") version "3.5.1" - id("org.jlleitschuh.gradle.ktlint") version "11.3.2" + id("org.jlleitschuh.gradle.ktlint") version "11.5.0" } configure { + version.set("0.50.0") outputToConsole.set(true) coloredOutput.set(true) disabledRules.set(setOf("no-wildcard-imports", "parameter-list-wrapping")) @@ -101,7 +102,7 @@ tasks.withType { kotlinOptions { freeCompilerArgs = listOf( "-Xjsr305=strict", - "-opt-in=kotlin.time.ExperimentalTime" + "-opt-in=kotlin.time.ExperimentalTime", ) jvmTarget = "11" } diff --git a/src/main/kotlin/io/github/bayang/jelu/config/AuthHeaderFilter.kt b/src/main/kotlin/io/github/bayang/jelu/config/AuthHeaderFilter.kt index 1408b642..71bd866b 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/AuthHeaderFilter.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/AuthHeaderFilter.kt @@ -21,13 +21,13 @@ private val LOGGER = KotlinLogging.logger {} @ConditionalOnProperty(name = ["jelu.auth.proxy.enabled"], havingValue = "true", matchIfMissing = false) class AuthHeaderFilter( private val userService: UserService, - private val properties: JeluProperties + private val properties: JeluProperties, ) : OncePerRequestFilter() { override fun doFilterInternal( request: HttpServletRequest, response: HttpServletResponse, - filterChain: FilterChain + filterChain: FilterChain, ) { val headerName = properties.auth.proxy.header val headerAuth: String? = request.getHeader(headerName) @@ -44,7 +44,7 @@ class AuthHeaderFilter( val authentication = UsernamePasswordAuthenticationToken( user, null, - user.authorities + user.authorities, ) authentication.details = WebAuthenticationDetailsSource().buildDetails(request) SecurityContextHolder.getContext().authentication = authentication diff --git a/src/main/kotlin/io/github/bayang/jelu/config/GlobalConfig.kt b/src/main/kotlin/io/github/bayang/jelu/config/GlobalConfig.kt index 4193d992..a0de8585 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/GlobalConfig.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/GlobalConfig.kt @@ -26,8 +26,8 @@ class GlobalConfig { }.build() return WebClient.builder().exchangeStrategies(exchange).clientConnector( ReactorClientHttpConnector( - HttpClient.create().compress(true).followRedirect(true) - ) + HttpClient.create().compress(true).followRedirect(true), + ), ).build() } @@ -45,7 +45,7 @@ class GlobalConfig { allowCredentials = true addExposedHeader(HttpHeaders.CONTENT_DISPOSITION) addExposedHeader(sessionHeaderName) - } + }, ) } } diff --git a/src/main/kotlin/io/github/bayang/jelu/config/JeluLdapUserDetailsContextMapper.kt b/src/main/kotlin/io/github/bayang/jelu/config/JeluLdapUserDetailsContextMapper.kt index 4dc1b9b4..82129065 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/JeluLdapUserDetailsContextMapper.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/JeluLdapUserDetailsContextMapper.kt @@ -21,14 +21,14 @@ private val logger = KotlinLogging.logger {} @Component @ConditionalOnProperty(name = ["jelu.auth.ldap.enabled"], havingValue = "true", matchIfMissing = false) class JeluLdapUserDetailsContextMapper( - private val userRepository: UserRepository + private val userRepository: UserRepository, ) : UserDetailsContextMapper { @Transactional override fun mapUserFromContext( ctx: DirContextOperations?, username: String?, - authorities: MutableCollection? + authorities: MutableCollection?, ): UserDetails { dumpAttributesForDebug(ctx?.attributes) val isAdmin = findAdminMembership(ctx?.attributes) diff --git a/src/main/kotlin/io/github/bayang/jelu/config/JeluProperties.kt b/src/main/kotlin/io/github/bayang/jelu/config/JeluProperties.kt index 09ac451e..80061a9f 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/JeluProperties.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/JeluProperties.kt @@ -17,49 +17,49 @@ data class JeluProperties( val metadata: Metadata = Metadata(Calibre(null)), val auth: Auth = Auth( Ldap(), - Proxy() + Proxy(), ), val metadataProviders: List?, - val lucene: Lucene = Lucene(indexAnalyzer = IndexAnalyzer()) + val lucene: Lucene = Lucene(indexAnalyzer = IndexAnalyzer()), ) { data class MetaDataProvider( var name: String, var isEnabled: Boolean = false, var apiKey: String?, - var order: Int = -1000 + var order: Int = -1000, ) data class Database( - @get:NotBlank var path: String + @get:NotBlank var path: String, ) data class Files( @get:NotBlank var images: String, @get:NotBlank var imports: String, - var resizeImages: Boolean = true + var resizeImages: Boolean = true, ) data class Session( - @get:Positive var duration: Int + @get:Positive var duration: Int, ) data class Cors( - var allowedOrigins: List = emptyList() + var allowedOrigins: List = emptyList(), ) data class Calibre( var path: String?, - var order: Int = 1000 + var order: Int = 1000, ) data class Metadata( - var calibre: Calibre + var calibre: Calibre, ) data class Auth( var ldap: Ldap, - var proxy: Proxy + var proxy: Proxy, ) data class Ldap( @@ -69,13 +69,13 @@ data class JeluProperties( val userSearchFilter: String = "", val userSearchBase: String = "", val userDn: String = "", - val password: String = "" + val password: String = "", ) data class Proxy( var enabled: Boolean = false, val adminName: String = "", - val header: String = "X-Authenticated-User" + val header: String = "X-Authenticated-User", ) data class IndexAnalyzer( @@ -83,14 +83,14 @@ data class JeluProperties( var minGram: Int = 3, @get:Positive var maxGram: Int = 10, - var preserveOriginal: Boolean = true + var preserveOriginal: Boolean = true, ) data class Lucene( @get:NotBlank var dataDirectory: String = "", - var indexAnalyzer: IndexAnalyzer + var indexAnalyzer: IndexAnalyzer, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/config/LdapConfig.kt b/src/main/kotlin/io/github/bayang/jelu/config/LdapConfig.kt index 16f80a46..9cd567da 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/LdapConfig.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/LdapConfig.kt @@ -16,7 +16,7 @@ import org.springframework.security.ldap.userdetails.UserDetailsContextMapper @ConditionalOnProperty(name = ["jelu.auth.ldap.enabled"], havingValue = "true", matchIfMissing = false) class LdapConfig( private val userDetailsContextMapper: UserDetailsContextMapper, - private val properties: JeluProperties + private val properties: JeluProperties, ) { @Bean @@ -41,7 +41,7 @@ class LdapConfig( if (!properties.auth.ldap.userSearchFilter.isNullOrBlank()) { val userSearchBase = if (properties.auth.ldap.userSearchBase.isNullOrBlank()) "" else properties.auth.ldap.userSearchBase authenticator.setUserSearch( - FilterBasedLdapUserSearch(userSearchBase, properties.auth.ldap.userSearchFilter, contextSource) + FilterBasedLdapUserSearch(userSearchBase, properties.auth.ldap.userSearchFilter, contextSource), ) } authenticator.afterPropertiesSet() diff --git a/src/main/kotlin/io/github/bayang/jelu/config/LuceneConfiguration.kt b/src/main/kotlin/io/github/bayang/jelu/config/LuceneConfiguration.kt index d5cbd51f..500e06c7 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/LuceneConfiguration.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/LuceneConfiguration.kt @@ -12,7 +12,7 @@ import java.nio.file.Paths @Configuration class LuceneConfiguration( - private val jeluProperties: JeluProperties + private val jeluProperties: JeluProperties, ) { @Bean diff --git a/src/main/kotlin/io/github/bayang/jelu/config/OpenApiConfig.kt b/src/main/kotlin/io/github/bayang/jelu/config/OpenApiConfig.kt index 94f8675d..2a90404e 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/OpenApiConfig.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/OpenApiConfig.kt @@ -22,19 +22,19 @@ class OpenApiConfig { Info() .title("Jelu API") .version("v1.0") - .license(License().name("MIT").url("https://github.com/bayang/jelu/blob/main/LICENSE")) + .license(License().name("MIT").url("https://github.com/bayang/jelu/blob/main/LICENSE")), ) .externalDocs( ExternalDocumentation() .description("jelu documentation") - .url("https://github.com/bayang/jelu") + .url("https://github.com/bayang/jelu"), ) .components( Components() .addSecuritySchemes( "basicAuth", - SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic") - ) + SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"), + ), ) .servers(mutableListOf(server)) } diff --git a/src/main/kotlin/io/github/bayang/jelu/config/SecurityConfig.kt b/src/main/kotlin/io/github/bayang/jelu/config/SecurityConfig.kt index 110c789e..54637a0c 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/SecurityConfig.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/SecurityConfig.kt @@ -19,7 +19,7 @@ class SecurityConfig( private val properties: JeluProperties, private val userDetailsService: UserDetailsService, private val passwordEncoder: PasswordEncoder, - private val authHeaderFilter: AuthHeaderFilter? + private val authHeaderFilter: AuthHeaderFilter?, ) { @Bean @@ -37,7 +37,7 @@ class SecurityConfig( "/api/v1/token", "/api/v1/setup/status", "/api/v1/server-settings", - "/api/v1/reviews/**" + "/api/v1/reviews/**", ).permitAll() it.mvcMatchers(HttpMethod.GET, "/api/v1/reviews/**").permitAll() it.mvcMatchers(HttpMethod.GET, "/api/v1/books/**").permitAll() @@ -46,20 +46,20 @@ class SecurityConfig( it.mvcMatchers(HttpMethod.PUT, "/api/v1/users/**").hasAnyRole("USER") it.mvcMatchers( HttpMethod.GET, - "/api/v1/users/me" + "/api/v1/users/me", ).hasRole("USER") it.antMatchers( - "/api/v1/users/**" + "/api/v1/users/**", ).hasRole("USER") it.antMatchers( - "/api/v1/users" + "/api/v1/users", ).hasRole("USER") it.mvcMatchers( HttpMethod.POST, - "/api/v1/user-messages" + "/api/v1/user-messages", ).hasRole("ADMIN") it.antMatchers( - "/api/**" + "/api/**", ).hasRole("USER") } .httpBasic() diff --git a/src/main/kotlin/io/github/bayang/jelu/config/WebMvcConfig.kt b/src/main/kotlin/io/github/bayang/jelu/config/WebMvcConfig.kt index e174f95f..b0ee8cf0 100644 --- a/src/main/kotlin/io/github/bayang/jelu/config/WebMvcConfig.kt +++ b/src/main/kotlin/io/github/bayang/jelu/config/WebMvcConfig.kt @@ -41,7 +41,7 @@ class WebMvcConfig(private val properties: JeluProperties) : WebMvcConfigurer { "/android-chrome-192x192.png", "/android-chrome-512x512.png", "/manifest.json", - "/site.webmanifest" + "/site.webmanifest", ) .addResourceLocations( "classpath:public/index.html", @@ -54,7 +54,7 @@ class WebMvcConfig(private val properties: JeluProperties) : WebMvcConfigurer { "classpath:public/android-chrome-192x192.png", "classpath:public/android-chrome-512x512.png", "classpath:public/manifest.json", - "classpath:public/site.webmanifest" + "classpath:public/site.webmanifest", ) .setCacheControl(CacheControl.noStore()) } diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/BooksController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/BooksController.kt index 6459b0ab..970fb99d 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/BooksController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/BooksController.kt @@ -48,7 +48,7 @@ private val logger = KotlinLogging.logger {} @RequestMapping("/api/v1") class BooksController( private val repository: BookService, - private val properties: JeluProperties + private val properties: JeluProperties, ) { @GetMapping(path = ["/books"]) @@ -56,13 +56,13 @@ class BooksController( @RequestParam(name = "q", required = false) query: String?, @RequestParam(name = "libraryFilter", required = false) libraryFilter: LibraryFilter?, @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["title"]) @ParameterObject pageable: Pageable, - principal: Authentication + principal: Authentication, ): Page { return repository.findAll( query, pageable, (principal.principal as JeluUser).user, - libraryFilter ?: LibraryFilter.ANY + libraryFilter ?: LibraryFilter.ANY, ) } @@ -90,7 +90,7 @@ class BooksController( @DeleteMapping(path = ["/books/{bookId}/tags/{tagId}"]) fun deleteTagFromBook( @PathVariable("bookId") bookId: UUID, - @PathVariable("tagId") tagId: UUID + @PathVariable("tagId") tagId: UUID, ): ResponseEntity { repository.deleteTagFromBook(bookId, tagId) return ResponseEntity.noContent().build() @@ -107,7 +107,7 @@ class BooksController( @DeleteMapping(path = ["/books/{bookId}/authors/{authorId}"]) fun deleteAuthorFromBook( @PathVariable("bookId") bookId: UUID, - @PathVariable("authorId") authorId: UUID + @PathVariable("authorId") authorId: UUID, ): ResponseEntity { repository.deleteAuthorFromBook(bookId, authorId) return ResponseEntity.noContent().build() @@ -117,7 +117,7 @@ class BooksController( @DeleteMapping(path = ["/books/{bookId}/translators/{translatorId}"]) fun deleteTranslatorFromBook( @PathVariable("bookId") bookId: UUID, - @PathVariable("translatorId") translatorId: UUID + @PathVariable("translatorId") translatorId: UUID, ): ResponseEntity { repository.deleteTranslatorFromBook(bookId, translatorId) return ResponseEntity.noContent().build() @@ -139,7 +139,7 @@ class BooksController( @RequestParam(name = "owned", required = false) owned: Boolean?, @RequestParam(name = "borrowed", required = false) borrowed: Boolean?, @RequestParam(name = "userId", required = false) userId: UUID?, - @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["modificationDate"]) @ParameterObject pageable: Pageable + @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["modificationDate"]) @ParameterObject pageable: Pageable, ): Page { assertIsJeluUser(principal.principal) val finalUserId = userId ?: (principal.principal as JeluUser).user.id.value @@ -149,7 +149,7 @@ class BooksController( @GetMapping(path = ["/authors"]) fun authors( @RequestParam(name = "name", required = false) name: String?, - @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["name"]) @ParameterObject pageable: Pageable + @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["name"]) @ParameterObject pageable: Pageable, ): Page { return repository.findAllAuthors(name, pageable) } @@ -157,13 +157,13 @@ class BooksController( @GetMapping(path = ["/tags"]) fun tags( @RequestParam(name = "name", required = false) name: String?, - @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["name"]) @ParameterObject pageable: Pageable + @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["name"]) @ParameterObject pageable: Pageable, ): Page = repository.findAllTags(name, pageable) @GetMapping(path = ["/tags/{id}"]) fun tagById( @PathVariable("id") tagId: UUID, - principal: Authentication + principal: Authentication, ): TagDto { assertIsJeluUser(principal.principal) return repository.findTagById(tagId, (principal.principal as JeluUser).user) @@ -174,7 +174,7 @@ class BooksController( @PathVariable("id") tagId: UUID, @RequestParam(name = "libraryFilter", required = false) libraryFilter: LibraryFilter?, @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["title"]) @ParameterObject pageable: Pageable, - principal: Authentication + principal: Authentication, ): Page { assertIsJeluUser(principal.principal) return repository.findTagBooksById(tagId, (principal.principal as JeluUser).user, pageable, libraryFilter ?: LibraryFilter.ANY) @@ -189,14 +189,14 @@ class BooksController( @RequestParam(name = "libraryFilter", required = false) libraryFilter: LibraryFilter?, @RequestParam(name = "roleFilter", required = false) roleFilter: Role?, @PageableDefault(page = 0, size = 20, direction = Sort.Direction.ASC, sort = ["title"]) @ParameterObject pageable: Pageable, - principal: Authentication + principal: Authentication, ): Page = repository.findAuthorBooksById(authorId, (principal.principal as JeluUser).user, pageable, libraryFilter ?: LibraryFilter.ANY, roleFilter ?: Role.ANY) @PostMapping(path = ["/books"], consumes = [MediaType.APPLICATION_JSON_VALUE]) fun saveBook( @RequestBody @Valid - book: BookCreateDto + book: BookCreateDto, ): BookDto { return repository.save(book, null) } @@ -204,7 +204,7 @@ class BooksController( @PostMapping(path = ["/books"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE]) fun saveBook( @RequestPart("book") @Valid book: BookCreateDto, - @RequestPart("file", required = false) file: MultipartFile? + @RequestPart("file", required = false) file: MultipartFile?, ): BookDto { return repository.save(book, file) } @@ -213,7 +213,7 @@ class BooksController( fun saveUserBook( @RequestBody @Valid book: CreateUserBookDto, - principal: Authentication + principal: Authentication, ): UserBookLightDto { return repository.save(book, (principal.principal as JeluUser).user, null) } @@ -222,7 +222,7 @@ class BooksController( fun saveUserBook( @RequestPart("book") @Valid book: CreateUserBookDto, principal: Authentication, - @RequestPart("file", required = false) file: MultipartFile? + @RequestPart("file", required = false) file: MultipartFile?, ): UserBookLightDto { return repository.save(book, (principal.principal as JeluUser).user, file) } @@ -230,7 +230,7 @@ class BooksController( @PostMapping(path = ["/authors"]) fun saveAuthor( @RequestBody @Valid - author: AuthorDto + author: AuthorDto, ): AuthorDto { return repository.save(author) } @@ -241,7 +241,7 @@ class BooksController( bookId: UUID, @RequestBody @Valid - book: BookUpdateDto + book: BookUpdateDto, ): BookDto { return repository.update(bookId, book) } @@ -252,7 +252,7 @@ class BooksController( authorId: UUID, @RequestBody @Valid - author: AuthorUpdateDto + author: AuthorUpdateDto, ): AuthorDto { return repository.updateAuthor(authorId, author) } @@ -261,7 +261,7 @@ class BooksController( fun updateAuthor( @PathVariable("id") authorId: UUID, @RequestPart("author") @Valid author: AuthorUpdateDto, - @RequestPart("file", required = false) file: MultipartFile? + @RequestPart("file", required = false) file: MultipartFile?, ): AuthorDto { return repository.updateAuthor(authorId, author, file) } @@ -272,7 +272,7 @@ class BooksController( @PathVariable("otherId") otherId: UUID, @RequestBody @Valid author: AuthorUpdateDto, - principal: Authentication + principal: Authentication, ): AuthorDto { return repository.mergeAuthors(authorId, otherId, author, (principal.principal as JeluUser).user) } @@ -283,7 +283,7 @@ class BooksController( userBookId: UUID, @RequestBody @Valid - book: UserBookUpdateDto + book: UserBookUpdateDto, ): UserBookLightDto { return repository.update(userBookId, book) } @@ -292,7 +292,7 @@ class BooksController( fun updateUserBook( @PathVariable("id") userBookId: UUID, @RequestPart("book") @Valid book: UserBookUpdateDto, - @RequestPart("file", required = false) file: MultipartFile? + @RequestPart("file", required = false) file: MultipartFile?, ): UserBookLightDto { return repository.update(userBookId, book, file) } @@ -300,7 +300,7 @@ class BooksController( @PutMapping(path = ["/userbooks"], consumes = [MediaType.APPLICATION_JSON_VALUE]) fun bulkUpdateUserBooks( @RequestBody @Valid - bulkUpdateDto: UserBookBulkUpdateDto + bulkUpdateDto: UserBookBulkUpdateDto, ): Int { return repository.bulkEditUserbooks(bulkUpdateDto) } diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/GlobalControllerExceptionHandler.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/GlobalControllerExceptionHandler.kt index 2c99b145..a601e819 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/GlobalControllerExceptionHandler.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/GlobalControllerExceptionHandler.kt @@ -20,29 +20,29 @@ class GlobalControllerExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody fun handleConstraintValidationException( - e: ConstraintViolationException + e: ConstraintViolationException, ): ApiError = ApiError( "Constraint violation", - e.constraintViolations.map { ApiValidationErrorItem(it.propertyPath.toString(), it.message) } + e.constraintViolations.map { ApiValidationErrorItem(it.propertyPath.toString(), it.message) }, ) @ExceptionHandler(MethodArgumentNotValidException::class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody fun handleMethodArgumentNotValidException( - e: MethodArgumentNotValidException + e: MethodArgumentNotValidException, ): ApiError = ApiError( "Validation error(s)", - e.bindingResult.fieldErrors.map { ApiValidationErrorItem(it.field, it.defaultMessage) } + e.bindingResult.fieldErrors.map { ApiValidationErrorItem(it.field, it.defaultMessage) }, ) @ExceptionHandler(EntityNotFoundException::class) @ResponseStatus(HttpStatus.NOT_FOUND) @ResponseBody fun handleNonExistingEntityException( - e: EntityNotFoundException + e: EntityNotFoundException, ): ApiError = ApiError(e.message) @@ -50,7 +50,7 @@ class GlobalControllerExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody fun handleHttpMessageNotReadableException( - e: HttpMessageNotReadableException + e: HttpMessageNotReadableException, ): ApiError = ApiError(e.message) @@ -58,7 +58,7 @@ class GlobalControllerExceptionHandler { @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ResponseBody fun handleJeluException( - e: JeluException + e: JeluException, ): ApiError = ApiError(e.message) @@ -66,7 +66,7 @@ class GlobalControllerExceptionHandler { @ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseBody fun handleJeluAuthenticationException( - e: JeluAuthenticationException + e: JeluAuthenticationException, ): ApiError = ApiError(e.message) @@ -74,17 +74,17 @@ class GlobalControllerExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody fun handleJeluValidationException( - e: JeluValidationException + e: JeluValidationException, ): ApiError = ApiError(e.message) } data class ApiError( val message: String? = null, - val violations: List = emptyList() + val violations: List = emptyList(), ) data class ApiValidationErrorItem( val field: String? = null, - val error: String? = null + val error: String? = null, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/ImportController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/ImportController.kt index ef211247..6a5d4a08 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/ImportController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/ImportController.kt @@ -29,7 +29,7 @@ private val logger = KotlinLogging.logger {} class ImportController( val csvImportService: CsvImportService, val csvExportService: CsvExportService, - private val properties: JeluProperties + private val properties: JeluProperties, ) { @ApiResponse(responseCode = "201", description = "Imported the csv file") @@ -38,7 +38,7 @@ class ImportController( fun importCsv( principal: Authentication, @RequestPart("importConfig") @Valid importConfig: ImportConfigurationDto, - @RequestPart("file") file: MultipartFile + @RequestPart("file") file: MultipartFile, ): ResponseEntity { val destFileName = FilenameUtils.getName(file.originalFilename) val destFile = File(properties.files.imports, destFileName) @@ -56,7 +56,7 @@ class ImportController( @PostMapping(path = ["/exports"]) fun exportCsv( principal: Authentication, - locale: Locale + locale: Locale, ): ResponseEntity { csvExportService.export((principal.principal as JeluUser).user, locale) return ResponseEntity.status(HttpStatus.CREATED).build() diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/MetadataController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/MetadataController.kt index e23492cf..242daaef 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/MetadataController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/MetadataController.kt @@ -28,7 +28,7 @@ class MetadataController( private val properties: JeluProperties, private val metadataService: FetchMetadataService, private val wikipediaService: WikipediaService, - private val pluginInfoHolder: PluginInfoHolder + private val pluginInfoHolder: PluginInfoHolder, ) { @Operation(description = "fetch metadata from the configured providers") @@ -36,7 +36,7 @@ class MetadataController( fun fetchMetadata( @RequestParam(name = "isbn", required = false) isbn: String?, @RequestParam(name = "title", required = false) title: String?, - @RequestParam(name = "authors", required = false) authors: String? + @RequestParam(name = "authors", required = false) authors: String?, ): Mono = if (pluginInfoHolder.plugins().isEmpty()) { throw JeluException("Automatic fetching of metadata is disabled, install calibre or configure a metadata plugin") @@ -48,7 +48,7 @@ class MetadataController( @PostMapping(path = ["/metadata"]) fun fetchMetadata( @RequestBody @Valid - metadataRequestDto: MetadataRequestDto + metadataRequestDto: MetadataRequestDto, ): Mono { if (pluginInfoHolder.plugins().isEmpty()) { throw JeluException("Automatic fetching of metadata is disabled, install calibre or configure a metadata plugin") @@ -60,7 +60,7 @@ class MetadataController( @GetMapping(path = ["/wikipedia/search"]) fun searchWikipedia( @RequestParam(name = "query", required = true) query: String, - @RequestParam(name = "language", defaultValue = "en") language: String + @RequestParam(name = "language", defaultValue = "en") language: String, ): Mono { return wikipediaService.search(query, language) } @@ -69,7 +69,7 @@ class MetadataController( @GetMapping(path = ["/wikipedia/page"]) fun wikipediaPage( @RequestParam(name = "pageTitle", required = true) pageTitle: String, - @RequestParam(name = "language", defaultValue = "en") language: String + @RequestParam(name = "language", defaultValue = "en") language: String, ): Mono { return wikipediaService.fetchPage(pageTitle, language) } diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/QuotesController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/QuotesController.kt index af8356df..a386286d 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/QuotesController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/QuotesController.kt @@ -16,7 +16,7 @@ import reactor.core.publisher.Mono @RestController @RequestMapping("/api/v1") class QuotesController( - private val quotesProvider: IQuoteProvider + private val quotesProvider: IQuoteProvider, ) { @ApiResponses( @@ -31,15 +31,15 @@ class QuotesController( array = ( ArraySchema( schema = Schema( - implementation = QuoteDto::class - ) + implementation = QuoteDto::class, + ), ) - ) - ) + ), ) - ] - ) - ] + ), + ], + ), + ], ) @GetMapping(path = ["/quotes"]) fun quotes(@RequestParam(name = "query", required = false) query: String?): Mono> = @@ -57,15 +57,15 @@ class QuotesController( array = ( ArraySchema( schema = Schema( - implementation = QuoteDto::class - ) + implementation = QuoteDto::class, + ), ) - ) - ) + ), ) - ] - ) - ] + ), + ], + ), + ], ) @GetMapping(path = ["/quotes/random"]) fun quotes(): Mono> = quotesProvider.random() diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/ReadingEventsController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/ReadingEventsController.kt index 87306a37..29aaadc0 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/ReadingEventsController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/ReadingEventsController.kt @@ -42,7 +42,7 @@ private val logger = KotlinLogging.logger {} @RequestMapping("/api/v1") class ReadingEventsController( private val repository: ReadingEventService, - private val properties: JeluProperties + private val properties: JeluProperties, ) { @GetMapping(path = ["/reading-events"]) @@ -62,7 +62,7 @@ class ReadingEventsController( @RequestParam(name = "endedBefore", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) endedBefore: LocalDate?, - @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["modificationDate"]) @ParameterObject pageable: Pageable + @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["modificationDate"]) @ParameterObject pageable: Pageable, ): Page = repository.findAll(eventTypes, userId, bookId, startedAfter, startedBefore, endedAfter, endedBefore, pageable) @GetMapping(path = ["/reading-events/me"]) @@ -82,7 +82,7 @@ class ReadingEventsController( @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) endedBefore: LocalDate?, @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["modificationDate"]) @ParameterObject pageable: Pageable, - principal: Authentication + principal: Authentication, ): Page { assertIsJeluUser(principal.principal) return repository.findAll(eventTypes, (principal.principal as JeluUser).user.id.value, bookId, startedAfter, startedBefore, endedAfter, endedBefore, pageable) @@ -92,7 +92,7 @@ class ReadingEventsController( fun saveReadingEvent( @RequestBody @Valid event: CreateReadingEventDto, - principal: Authentication + principal: Authentication, ): ReadingEventDto { logger.debug { "event creation request for ${principal.name}" } assertIsJeluUser(principal.principal) @@ -105,7 +105,7 @@ class ReadingEventsController( readingEventId: UUID, @RequestBody @Valid - readingEvent: UpdateReadingEventDto + readingEvent: UpdateReadingEventDto, ): ReadingEventDto { return repository.updateReadingEvent(readingEventId, readingEvent) } @@ -114,7 +114,7 @@ class ReadingEventsController( @DeleteMapping(path = ["/reading-events/{id}"]) fun deleteEventById( @PathVariable("id") - eventId: UUID + eventId: UUID, ): ResponseEntity { repository.deleteReadingEventById(eventId) return ResponseEntity.noContent().build() @@ -122,7 +122,7 @@ class ReadingEventsController( @GetMapping(path = ["/stats"]) fun stats( - principal: Authentication + principal: Authentication, ): ResponseEntity> { var events: Page var currentPage = 0 @@ -154,7 +154,7 @@ class ReadingEventsController( @GetMapping(path = ["/stats/{year}"]) fun statsForYear( @PathVariable("year") year: Int, - principal: Authentication + principal: Authentication, ): ResponseEntity> { var events: Page var currentPage = 0 @@ -188,7 +188,7 @@ class ReadingEventsController( @ApiResponse(description = "Return a list of years for which there are reading events") @GetMapping(path = ["/stats/years"]) fun years( - principal: Authentication + principal: Authentication, ): ResponseEntity> { val years = repository.findYears(listOf(ReadingEventType.FINISHED, ReadingEventType.DROPPED), (principal.principal as JeluUser).user.id.value, null) return if (years != null && years.isNotEmpty()) { diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/ReviewsController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/ReviewsController.kt index 5c12df8e..1c265be3 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/ReviewsController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/ReviewsController.kt @@ -32,14 +32,14 @@ import javax.validation.Valid @RestController @RequestMapping("/api/v1") class ReviewsController( - private val reviewService: ReviewService + private val reviewService: ReviewService, ) { @PostMapping(path = ["/reviews"]) fun createReview( @RequestBody @Valid createReviewDto: CreateReviewDto, - principal: Authentication + principal: Authentication, ): ReviewDto { return reviewService.save(createReviewDto, (principal.principal as JeluUser).user) } @@ -55,7 +55,7 @@ class ReviewsController( @RequestParam(name = "before", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) before: LocalDate?, - @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["reviewDate"]) @ParameterObject pageable: Pageable + @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["reviewDate"]) @ParameterObject pageable: Pageable, ): Page { return reviewService.find(userId, bookId, visibility, after, before, pageable) } @@ -64,7 +64,7 @@ class ReviewsController( fun updateReview( @PathVariable("id") reviewId: UUID, @RequestBody @Valid - updateReviewDto: UpdateReviewDto + updateReviewDto: UpdateReviewDto, ): ReviewDto { return reviewService.update(reviewId, updateReviewDto) } @@ -72,7 +72,7 @@ class ReviewsController( @GetMapping(path = ["/reviews/{id}"]) fun getReview( @PathVariable("id") reviewId: UUID, - principal: Authentication? + principal: Authentication?, ): ReviewDto { val review = reviewService.findById(reviewId) if (review.visibility == Visibility.PRIVATE && principal == null) { diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/ServerSettingsController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/ServerSettingsController.kt index 9166b633..5b734931 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/ServerSettingsController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/ServerSettingsController.kt @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController class ServerSettingsController( private val pluginInfoHolder: PluginInfoHolder, private val properties: JeluProperties, - private val buildProperties: BuildProperties + private val buildProperties: BuildProperties, ) { @Operation(description = "Get the capabilities configured for this server, eg : is the metadata binary installed etc...") @@ -26,7 +26,7 @@ class ServerSettingsController( metadataFetchCalibreEnabled = pluginInfoHolder.calibreEnabled(), buildProperties.version, ldapEnabled = properties.auth.ldap.enabled, - metadataPlugins = plugins + metadataPlugins = plugins, ) } } diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/ShelvesController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/ShelvesController.kt index 90801a31..177dd028 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/ShelvesController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/ShelvesController.kt @@ -21,14 +21,14 @@ import javax.validation.Valid @RestController @RequestMapping("/api/v1") class ShelvesController( - private val shelvesService: ShelfService + private val shelvesService: ShelfService, ) { @GetMapping(path = ["/shelves"]) fun shelves( @RequestParam(name = "name", required = false) name: String?, @RequestParam(name = "targetId", required = false) targetId: UUID?, - principal: Authentication + principal: Authentication, ): List { return shelvesService.find((principal.principal as JeluUser).user, name, targetId) } @@ -36,7 +36,7 @@ class ShelvesController( @GetMapping(path = ["/shelves/{id}"]) fun shelfById( @PathVariable("id") shelfId: UUID, - principal: Authentication + principal: Authentication, ): ShelfDto { return shelvesService.findById(shelfId) } @@ -45,7 +45,7 @@ class ShelvesController( fun saveShelf( @RequestBody @Valid createShelfDto: CreateShelfDto, - principal: Authentication + principal: Authentication, ): ShelfDto { return shelvesService.save(createShelfDto, (principal.principal as JeluUser).user) } diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/UserMessagesController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/UserMessagesController.kt index 57ed063d..1f87b055 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/UserMessagesController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/UserMessagesController.kt @@ -32,7 +32,7 @@ private val logger = KotlinLogging.logger {} @RequestMapping("/api/v1") class UserMessagesController( private val userMessageService: UserMessageService, - private val properties: JeluProperties + private val properties: JeluProperties, ) { @GetMapping(path = ["/user-messages"]) @@ -40,7 +40,7 @@ class UserMessagesController( @RequestParam(name = "messageCategories", required = false) messageCategories: List?, @RequestParam(name = "read", required = false) read: Boolean?, @PageableDefault(page = 0, size = 20, direction = Sort.Direction.DESC, sort = ["modificationDate"]) @ParameterObject pageable: Pageable, - principal: Authentication + principal: Authentication, ): Page = userMessageService.find((principal.principal as JeluUser).user, read, messageCategories, pageable) @PutMapping(path = ["/user-messages/{id}"]) @@ -49,7 +49,7 @@ class UserMessagesController( messageId: UUID, @RequestBody @Valid - updateDto: UpdateUserMessageDto + updateDto: UpdateUserMessageDto, ): UserMessageDto { return userMessageService.update(messageId, updateDto) } @@ -59,7 +59,7 @@ class UserMessagesController( fun createMessage( @RequestBody @Valid createUserMessageDto: CreateUserMessageDto, - principal: Authentication + principal: Authentication, ): UserMessageDto { return userMessageService.save(createUserMessageDto, (principal.principal as JeluUser).user) } diff --git a/src/main/kotlin/io/github/bayang/jelu/controllers/UsersController.kt b/src/main/kotlin/io/github/bayang/jelu/controllers/UsersController.kt index ed6d7b89..53d6f605 100644 --- a/src/main/kotlin/io/github/bayang/jelu/controllers/UsersController.kt +++ b/src/main/kotlin/io/github/bayang/jelu/controllers/UsersController.kt @@ -31,7 +31,7 @@ private val logger = KotlinLogging.logger {} @RestController @RequestMapping("/api/v1") class UsersController( - private val repository: UserService + private val repository: UserService, ) { @Operation(description = "get the current session token that the caller should provide in the X-Auth-Token header") @@ -55,9 +55,9 @@ class UsersController( password = "****", modificationDate = null, creationDate = null, - provider = Provider.JELU_DB + provider = Provider.JELU_DB, ), - token = session.id + token = session.id, ) } is JeluUser -> { @@ -71,9 +71,9 @@ class UsersController( password = "****", modificationDate = null, creationDate = null, - provider = (principal.principal as JeluUser).user.provider + provider = (principal.principal as JeluUser).user.provider, ), - token = session.id + token = session.id, ) } else -> { @@ -85,9 +85,9 @@ class UsersController( id = null, password = "****", modificationDate = null, - creationDate = null + creationDate = null, ), - token = session.id + token = session.id, ) } } @@ -110,7 +110,7 @@ class UsersController( @Valid user: UpdateUserDto, principal: Authentication, - session: HttpSession + session: HttpSession, ): UserDto { if (principal.principal is JeluUser) { if ((principal.principal as JeluUser).user.isAdmin || (principal.principal as JeluUser).user.id.value == userId) { @@ -129,7 +129,7 @@ class UsersController( @PostMapping(path = ["/users"]) fun saveUser( @RequestBody @Valid - user: CreateUserDto + user: CreateUserDto, ): UserDto { return repository.save(user) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/AuthorTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/AuthorTable.kt index 74744224..f46ff22c 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/AuthorTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/AuthorTable.kt @@ -60,7 +60,7 @@ class Author(id: EntityID) : UUIDEntity(id) { goodreadsPage = this.goodreadsPage, twitterPage = this.twitterPage, facebookPage = this.facebookPage, - instagramPage = this.instagramPage + instagramPage = this.instagramPage, ) } object BookAuthors : Table(name = "book_authors") { diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/BookRepository.kt b/src/main/kotlin/io/github/bayang/jelu/dao/BookRepository.kt index dcf5509b..dc9bfba3 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/BookRepository.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/BookRepository.kt @@ -76,7 +76,7 @@ fun formatLike(input: String): String { @Repository class BookRepository( val readingEventRepository: ReadingEventRepository, - val fileManager: FileManager + val fileManager: FileManager, ) { fun findAll(bookIds: List?, pageable: Pageable, user: User, filter: LibraryFilter = LibraryFilter.ANY): Page { @@ -115,7 +115,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow, user.id.value) }, pageable, - total + total, ) } @@ -185,7 +185,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow) }, pageable, - total + total, ) } @@ -267,7 +267,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow, user.id.value) }, pageable, - total + total, ) } @@ -283,7 +283,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> Author.wrapRow(resultRow) }, pageable, - total + total, ) } @@ -299,7 +299,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> Tag.wrapRow(resultRow) }, pageable, - total + total, ) } @@ -341,7 +341,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow, user.id.value) }, pageable, - total + total, ) } @@ -359,7 +359,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow) }, pageable, - total + total, ) } @@ -395,7 +395,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow, user.id.value) }, pageable, - total + total, ) } @@ -420,7 +420,7 @@ class BookRepository( return PageImpl( query.map { resultRow -> wrapRow(resultRow) }, pageable, - total + total, ) } @@ -581,8 +581,8 @@ class BookRepository( eventType = book.lastReadingEvent, bookId = null, eventDate = null, - startDate = null - ) + startDate = null, + ), ) } if (book.borrowed != null) { @@ -765,7 +765,7 @@ class BookRepository( toRead: Boolean?, owned: Boolean?, borrowed: Boolean?, - pageable: Pageable + pageable: Pageable, ): PageImpl { val cols = mutableListOf>() cols.addAll(UserBookTable.columns) @@ -815,7 +815,7 @@ class BookRepository( return PageImpl( res, pageable, - total + total, ) } @@ -859,7 +859,7 @@ class BookRepository( if (modified) { it[UserBookTable.modificationDate] = now } - } + }, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/BookTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/BookTable.kt index 87263495..fe54842f 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/BookTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/BookTable.kt @@ -77,7 +77,7 @@ class Book(id: EntityID) : UUIDEntity(id) { authors = this.authors.map { it.toAuthorDto() }, translators = this.translators.map { it.toAuthorDto() }, tags = this.tags.map { it.toTagDto() }, - userBookId = this.userBookId + userBookId = this.userBookId, ) fun toBookUpdateDto(): BookUpdateDto = @@ -99,6 +99,6 @@ class Book(id: EntityID) : UUIDEntity(id) { language = this.language, authors = this.authors.map { it.toAuthorDto() }, translators = this.translators.map { it.toAuthorDto() }, - tags = this.tags.map { it.toTagDto() } + tags = this.tags.map { it.toTagDto() }, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ImportRepository.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ImportRepository.kt index c58b0202..b5d7823f 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ImportRepository.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ImportRepository.kt @@ -19,7 +19,7 @@ class ImportRepository { fun deleteByprocessingStatusAndUser( processingStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): Int { // FIXME SQLite doesn't support LIMIT in DELETE clause., dialect: sqlite. return ImportEntityTable.deleteWhere { @@ -29,7 +29,7 @@ class ImportRepository { fun getByprocessingStatusAndUser( processingStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): List { return ImportEntity.find { ImportEntityTable.processingStatus eq processingStatus and (ImportEntityTable.userId eq userId) } .limit(DEFAULT_BLOCK_SIZE) @@ -38,14 +38,14 @@ class ImportRepository { fun countByprocessingStatusAndUser( processingStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): Long = ImportEntity.count(ImportEntityTable.processingStatus eq processingStatus and(ImportEntityTable.userId eq userId)) fun save( entity: ImportDto, processingStatus: ProcessingStatus, userId: UUID, - shouldFetchMetadata: Boolean + shouldFetchMetadata: Boolean, ): ImportEntity { return ImportEntity.new { this.processingStatus = processingStatus @@ -75,7 +75,7 @@ class ImportRepository { fun updateStatus( oldStatus: ProcessingStatus, newStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): Int { return ImportEntityTable.update({ ImportEntityTable.processingStatus eq oldStatus and (ImportEntityTable.userId eq userId) }) { it[processingStatus] = newStatus diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ImportTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ImportTable.kt index 61972869..4347fce2 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ImportTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ImportTable.kt @@ -59,11 +59,11 @@ enum class ProcessingStatus { SAVED, PROCESSING, IMPORTED, - ERROR + ERROR, } enum class ImportSource { GOODREADS, STORYGRAPH, LIBRARYTHING, - ISBN_LIST + ISBN_LIST, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventRepository.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventRepository.kt index 52f232c4..e9b4b81f 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventRepository.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventRepository.kt @@ -37,7 +37,7 @@ class ReadingEventRepository { startedBefore: LocalDate?, endedAfter: LocalDate?, endedBefore: LocalDate?, - pageable: Pageable + pageable: Pageable, ): Page { val query = ReadingEventTable.join(UserBookTable, JoinType.LEFT) .selectAll() @@ -73,14 +73,14 @@ class ReadingEventRepository { return PageImpl( ReadingEvent.wrapRows(query).toList(), pageable, - total + total, ) } fun findYears( eventTypes: List?, userId: UUID?, - bookId: UUID? + bookId: UUID?, ): List { val query = ReadingEventTable.join(UserBookTable, JoinType.LEFT) .slice(ReadingEventTable.endDate.year()) diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventTable.kt index 7928fde1..8c597898 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ReadingEventTable.kt @@ -42,7 +42,7 @@ class ReadingEvent(id: EntityID) : UUIDEntity(id) { userBook = this.userBook.toUserBookWithoutEventsDto(), eventType = this.eventType, startDate = this.startDate, - endDate = this.endDate + endDate = this.endDate, ) fun toReadingEventWithoutUserBookDto(): ReadingEventWithoutUserBookDto = ReadingEventWithoutUserBookDto( id = this.id.value, @@ -50,11 +50,11 @@ class ReadingEvent(id: EntityID) : UUIDEntity(id) { modificationDate = this.modificationDate, eventType = this.eventType, startDate = this.startDate, - endDate = this.endDate + endDate = this.endDate, ) } enum class ReadingEventType { FINISHED, DROPPED, - CURRENTLY_READING + CURRENTLY_READING, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ReviewRepository.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ReviewRepository.kt index 89d71d77..1a31c906 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ReviewRepository.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ReviewRepository.kt @@ -50,7 +50,7 @@ class ReviewRepository { visibility: Visibility?, after: LocalDate?, before: LocalDate?, - pageable: Pageable + pageable: Pageable, ): Page { val query = ReviewTable.selectAll() if (userId != null) { @@ -77,7 +77,7 @@ class ReviewRepository { return PageImpl( Review.wrapRows(query).toList(), pageable, - total + total, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ReviewTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ReviewTable.kt index a1499ddf..9d809da1 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ReviewTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ReviewTable.kt @@ -40,10 +40,10 @@ class Review(id: EntityID) : UUIDEntity(id) { visibility = this.visibility, rating = this.rating, user = this.user.id.value, - book = this.book.id.value + book = this.book.id.value, ) } enum class Visibility { PUBLIC, - PRIVATE + PRIVATE, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ShelfRepository.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ShelfRepository.kt index 5b95c7e4..1b611575 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ShelfRepository.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ShelfRepository.kt @@ -28,7 +28,7 @@ class ShelfRepository { fun find( user: User?, name: String?, - targetId: UUID? + targetId: UUID?, ): List { val query = ShelfTable.selectAll() user?.let { @@ -44,7 +44,7 @@ class ShelfRepository { } fun findById( - id: UUID + id: UUID, ): Shelf = Shelf[id] fun delete(shelfId: UUID) { diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/ShelfTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/ShelfTable.kt index 7edea362..820eb703 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/ShelfTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/ShelfTable.kt @@ -30,6 +30,6 @@ class Shelf(id: EntityID) : UUIDEntity(id) { name = this.name, creationDate = this.creationDate, modificationDate = this.modificationDate, - targetId = this.targetId + targetId = this.targetId, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/TagTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/TagTable.kt index a226a12a..7f87b722 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/TagTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/TagTable.kt @@ -26,7 +26,7 @@ class Tag(id: EntityID) : UUIDEntity(id) { id = this.id.value, creationDate = this.creationDate, modificationDate = this.modificationDate, - name = this.name + name = this.name, ) } object BookTags : Table(name = "book_tags") { diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/UserBookTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/UserBookTable.kt index ead9eb7f..02993aba 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/UserBookTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/UserBookTable.kt @@ -57,7 +57,7 @@ class UserBook(id: EntityID) : UUIDEntity(id) { personalNotes = this.personalNotes, percentRead = this.percentRead, borrowed = this.borrowed, - readingEvents = this.readingEvents.map { it.toReadingEventWithoutUserBookDto() } + readingEvents = this.readingEvents.map { it.toReadingEventWithoutUserBookDto() }, ) fun toUserBookLightDto(): UserBookLightDto = UserBookLightDto( @@ -72,7 +72,7 @@ class UserBook(id: EntityID) : UUIDEntity(id) { lastReadingEventDate = this.lastReadingEventDate, percentRead = this.percentRead, borrowed = this.borrowed, - readingEvents = this.readingEvents.map { it.toReadingEventWithoutUserBookDto() } + readingEvents = this.readingEvents.map { it.toReadingEventWithoutUserBookDto() }, ) fun toUserBookWthoutEventsAndUserDto(): UserBookWithoutEventsAndUserDto = UserBookWithoutEventsAndUserDto( @@ -86,7 +86,7 @@ class UserBook(id: EntityID) : UUIDEntity(id) { lastReadingEvent = this.lastReadingEvent, lastReadingEventDate = this.lastReadingEventDate, percentRead = this.percentRead, - borrowed = this.borrowed + borrowed = this.borrowed, ) fun toUserBookWithoutEventsDto(): UserBookWithoutEventsDto = UserBookWithoutEventsDto( @@ -99,6 +99,6 @@ class UserBook(id: EntityID) : UUIDEntity(id) { personalNotes = this.personalNotes, user = this.user.toUserDto(), percentRead = this.percentRead, - borrowed = this.borrowed + borrowed = this.borrowed, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageRepository.kt b/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageRepository.kt index 8cbf29ce..d25c59e5 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageRepository.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageRepository.kt @@ -38,7 +38,7 @@ class UserMessageRepository { user: User, read: Boolean?, messageCategories: List?, - pageable: Pageable + pageable: Pageable, ): Page { val query = UserMessageTable.join(UserTable, JoinType.LEFT) .select { UserMessageTable.user eq user.id } @@ -56,7 +56,7 @@ class UserMessageRepository { return PageImpl( res, pageable, - total + total, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageTable.kt index e773866d..11a5db21 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/UserMessageTable.kt @@ -36,12 +36,12 @@ class UserMessage(id: EntityID) : UUIDEntity(id) { modificationDate = this.modificationDate, link = this.link, read = this.read, - category = this.messageCategory + category = this.messageCategory, ) } enum class MessageCategory { SUCCESS, INFO, WARNING, - ERROR + ERROR, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dao/UserTable.kt b/src/main/kotlin/io/github/bayang/jelu/dao/UserTable.kt index 28c1e816..167eb25e 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dao/UserTable.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dao/UserTable.kt @@ -26,7 +26,7 @@ class User(id: EntityID) : UUIDEntity(id) { login = this.login, password = "****", isAdmin = this.isAdmin, - provider = this.provider + provider = this.provider, ) companion object : UUIDEntityClass(UserTable) @@ -42,5 +42,5 @@ class User(id: EntityID) : UUIDEntity(id) { enum class Provider { LDAP, JELU_DB, - PROXY + PROXY, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/BookDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/BookDto.kt index f88399a4..2e7f1e8e 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/BookDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/BookDto.kt @@ -25,7 +25,7 @@ data class BookDto( val goodreadsId: String?, val librarythingId: String?, val language: String?, - val userBookId: UUID? + val userBookId: UUID?, ) data class BookCreateDto( @@ -47,7 +47,7 @@ data class BookCreateDto( var amazonId: String? = null, var goodreadsId: String? = null, var librarythingId: String? = null, - var language: String? = null + var language: String? = null, ) data class BookUpdateDto( @@ -68,7 +68,7 @@ data class BookUpdateDto( val amazonId: String?, val goodreadsId: String?, val librarythingId: String?, - val language: String? + val language: String?, ) data class AuthorDto( @@ -86,7 +86,7 @@ data class AuthorDto( val goodreadsPage: String?, val twitterPage: String?, val facebookPage: String?, - val instagramPage: String? + val instagramPage: String?, ) data class AuthorUpdateDto( @@ -104,14 +104,14 @@ data class AuthorUpdateDto( val goodreadsPage: String?, val twitterPage: String?, val facebookPage: String?, - val instagramPage: String? + val instagramPage: String?, ) data class TagDto( val id: UUID?, val creationDate: Instant?, val modificationDate: Instant?, - val name: String + val name: String, ) fun fromBookCreateDto(dto: BookCreateDto): BookUpdateDto { @@ -133,6 +133,6 @@ fun fromBookCreateDto(dto: BookCreateDto): BookUpdateDto { amazonId = dto.amazonId, goodreadsId = dto.goodreadsId, librarythingId = dto.librarythingId, - language = dto.language + language = dto.language, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/DummyUser.kt b/src/main/kotlin/io/github/bayang/jelu/dto/DummyUser.kt index f3f9d3e1..388b70a0 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/DummyUser.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/DummyUser.kt @@ -6,7 +6,7 @@ import org.springframework.security.core.userdetails.UserDetails class DummyUser(private val startupPassword: String) : UserDetails { override fun getAuthorities(): MutableCollection = mutableSetOf( - SimpleGrantedAuthority(ROLE_INITIAL_SETUP) + SimpleGrantedAuthority(ROLE_INITIAL_SETUP), ) override fun getPassword(): String = startupPassword diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/ImportDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/ImportDto.kt index 024f1dee..0890be81 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/ImportDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/ImportDto.kt @@ -23,5 +23,5 @@ class ImportDto { data class ImportConfigurationDto( var shouldFetchMetadata: Boolean, var shouldFetchCovers: Boolean, - var importSource: ImportSource + var importSource: ImportSource, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/LibraryFilter.kt b/src/main/kotlin/io/github/bayang/jelu/dto/LibraryFilter.kt index 381766b5..5cbac363 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/LibraryFilter.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/LibraryFilter.kt @@ -3,5 +3,5 @@ package io.github.bayang.jelu.dto enum class LibraryFilter { ONLY_USER_BOOKS, ONLY_NON_USER_BOOKS, - ANY + ANY, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/MetadataDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/MetadataDto.kt index 330b619d..cb965b6c 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/MetadataDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/MetadataDto.kt @@ -16,11 +16,11 @@ data class MetadataDto( var language: String? = null, var googleId: String? = null, var amazonId: String? = null, - var goodreadsId: String? = null + var goodreadsId: String? = null, ) data class MetadataRequestDto( val isbn: String? = null, val title: String? = null, val authors: String? = null, - val plugins: List? = null + val plugins: List? = null, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/PluginInfo.kt b/src/main/kotlin/io/github/bayang/jelu/dto/PluginInfo.kt index 9b954408..7a7b2117 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/PluginInfo.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/PluginInfo.kt @@ -2,5 +2,5 @@ package io.github.bayang.jelu.dto data class PluginInfo( val name: String, - val order: Int + val order: Int, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/QuoteDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/QuoteDto.kt index b0d96b8e..a203b8d3 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/QuoteDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/QuoteDto.kt @@ -4,5 +4,5 @@ data class QuoteDto( var content: String, var author: String?, var origin: String?, - var link: String? + var link: String?, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/ReadStatsDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/ReadStatsDto.kt index 581fed97..6ff7a351 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/ReadStatsDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/ReadStatsDto.kt @@ -4,7 +4,7 @@ data class YearStatsDto( val dropped: Int = 0, val finished: Int = 0, val year: Int, - val pageCount: Int = 0 + val pageCount: Int = 0, ) data class MonthStatsDto( @@ -12,5 +12,5 @@ data class MonthStatsDto( val finished: Int = 0, val year: Int, val month: Int, - val pageCount: Int = 0 + val pageCount: Int = 0, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/ReadingEventDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/ReadingEventDto.kt index 7ac76d75..f7f9a992 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/ReadingEventDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/ReadingEventDto.kt @@ -11,7 +11,7 @@ data class ReadingEventDto( val eventType: ReadingEventType, val userBook: UserBookWithoutEventsDto, val startDate: Instant?, - val endDate: Instant? + val endDate: Instant?, ) data class ReadingEventWithoutUserBookDto( val id: UUID?, @@ -19,21 +19,21 @@ data class ReadingEventWithoutUserBookDto( val modificationDate: Instant?, val eventType: ReadingEventType, val startDate: Instant?, - val endDate: Instant? + val endDate: Instant?, ) data class CreateReadingEventWithUserInfoDto( val eventType: ReadingEventType, val bookId: UUID, - val userId: UUID? + val userId: UUID?, ) data class CreateReadingEventDto( val eventType: ReadingEventType, val bookId: UUID?, val eventDate: Instant?, - val startDate: Instant? + val startDate: Instant?, ) data class UpdateReadingEventDto( val eventType: ReadingEventType, val eventDate: Instant?, - val startDate: Instant? + val startDate: Instant?, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/ReviewDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/ReviewDto.kt index 4862e6d4..351bab2d 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/ReviewDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/ReviewDto.kt @@ -13,18 +13,18 @@ data class ReviewDto( val rating: Double, val visibility: Visibility, val user: UUID?, - val book: UUID? + val book: UUID?, ) data class UpdateReviewDto( val reviewDate: Instant?, val text: String?, val rating: Double?, - val visibility: Visibility? + val visibility: Visibility?, ) data class CreateReviewDto( val reviewDate: Instant?, val text: String, val rating: Double, val visibility: Visibility, - val bookId: UUID + val bookId: UUID, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/Role.kt b/src/main/kotlin/io/github/bayang/jelu/dto/Role.kt index f4cbae2f..7df3c893 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/Role.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/Role.kt @@ -3,5 +3,5 @@ package io.github.bayang.jelu.dto enum class Role { AUTHOR, TRANSLATOR, - ANY + ANY, } diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/ServerSettingsDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/ServerSettingsDto.kt index 03dde9ee..7b71691a 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/ServerSettingsDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/ServerSettingsDto.kt @@ -11,5 +11,5 @@ data class ServerSettingsDto( val metadataFetchCalibreEnabled: Boolean, val appVersion: String, val ldapEnabled: Boolean, - val metadataPlugins: List = listOf() + val metadataPlugins: List = listOf(), ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/ShelfDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/ShelfDto.kt index b9d58db7..a51d4005 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/ShelfDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/ShelfDto.kt @@ -8,9 +8,9 @@ data class ShelfDto( val creationDate: Instant?, val modificationDate: Instant?, val name: String, - val targetId: UUID + val targetId: UUID, ) data class CreateShelfDto( val name: String, - val targetId: UUID + val targetId: UUID, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/UserBookDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/UserBookDto.kt index 5143881c..a6b3b476 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/UserBookDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/UserBookDto.kt @@ -17,7 +17,7 @@ data class UserBookDto( val owned: Boolean?, val toRead: Boolean?, val percentRead: Int?, - val borrowed: Boolean? + val borrowed: Boolean?, ) data class UserBookLightDto( val id: UUID?, @@ -31,7 +31,7 @@ data class UserBookLightDto( val owned: Boolean?, val toRead: Boolean?, val percentRead: Int?, - val borrowed: Boolean? + val borrowed: Boolean?, ) data class UserBookWithoutEventsAndUserDto( val id: UUID?, @@ -44,7 +44,7 @@ data class UserBookWithoutEventsAndUserDto( val owned: Boolean?, val toRead: Boolean?, val percentRead: Int?, - val borrowed: Boolean? + val borrowed: Boolean?, ) data class UserBookWithoutEventsDto( val id: UUID?, @@ -56,7 +56,7 @@ data class UserBookWithoutEventsDto( val owned: Boolean?, val toRead: Boolean?, val percentRead: Int?, - val borrowed: Boolean? + val borrowed: Boolean?, ) data class CreateUserBookDto( val lastReadingEvent: ReadingEventType?, @@ -66,7 +66,7 @@ data class CreateUserBookDto( val book: BookCreateDto, val toRead: Boolean?, val percentRead: Int?, - val borrowed: Boolean? + val borrowed: Boolean?, ) data class UserBookUpdateDto( val lastReadingEvent: ReadingEventType?, @@ -75,12 +75,12 @@ data class UserBookUpdateDto( val book: BookCreateDto?, val toRead: Boolean?, val percentRead: Int?, - val borrowed: Boolean? + val borrowed: Boolean?, ) data class UserBookBulkUpdateDto( val ids: List, val toRead: Boolean?, val owned: Boolean?, val removeTags: List?, - val addTags: List? + val addTags: List?, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/UserDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/UserDto.kt index 32edc69b..ce8cfe6a 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/UserDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/UserDto.kt @@ -11,20 +11,20 @@ data class UserDto( val password: String?, val modificationDate: Instant?, val isAdmin: Boolean, - val provider: Provider = Provider.JELU_DB + val provider: Provider = Provider.JELU_DB, ) data class CreateUserDto( val login: String, val password: String, val isAdmin: Boolean, - val provider: Provider = Provider.JELU_DB + val provider: Provider = Provider.JELU_DB, ) data class UpdateUserDto( val password: String, val isAdmin: Boolean?, - val provider: Provider? + val provider: Provider?, ) data class AuthenticationDto( val user: UserDto, - val token: String? + val token: String?, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/UserMessageDto.kt b/src/main/kotlin/io/github/bayang/jelu/dto/UserMessageDto.kt index d4506105..0ac92ae6 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/UserMessageDto.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/UserMessageDto.kt @@ -7,14 +7,14 @@ import java.util.UUID data class CreateUserMessageDto( val message: String?, val link: String?, - val category: MessageCategory + val category: MessageCategory, ) data class UpdateUserMessageDto( val message: String?, val link: String?, val category: MessageCategory?, - val read: Boolean? + val read: Boolean?, ) data class UserMessageDto( @@ -24,5 +24,5 @@ data class UserMessageDto( val category: MessageCategory, val read: Boolean, val creationDate: Instant?, - val modificationDate: Instant? + val modificationDate: Instant?, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaPageResult.kt b/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaPageResult.kt index 2dbee2c7..c5ba7c63 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaPageResult.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaPageResult.kt @@ -20,23 +20,23 @@ data class WikipediaPageResult( val contentUrls: ContentUrlList, val thumbnail: PageThumbnail?, @JsonAlias("originalimage") - val originalImage: PageThumbnail? + val originalImage: PageThumbnail?, ) data class PageThumbnail( val source: String, val width: Int, - val height: Int + val height: Int, ) data class ContentUrlList( val desktop: ContentUrl, - val mobile: ContentUrl + val mobile: ContentUrl, ) data class ContentUrl( val page: String, val revisions: String, val edit: String, - val talk: String + val talk: String, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaSearchResultElement.kt b/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaSearchResultElement.kt index 1f2ecbe6..17548cb1 100644 --- a/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaSearchResultElement.kt +++ b/src/main/kotlin/io/github/bayang/jelu/dto/WikipediaSearchResultElement.kt @@ -11,7 +11,7 @@ data class WikipediaSearchResultElement( val description: String?, @JsonAlias("matched_title") val matchedTitle: String?, - val thumbnail: Thumbnail? + val thumbnail: Thumbnail?, ) data class Thumbnail( @@ -20,9 +20,9 @@ data class Thumbnail( val width: Int, val height: Int, val duration: Int, - val url: String + val url: String, ) data class WikipediaSearchResult( - val pages: List + val pages: List, ) diff --git a/src/main/kotlin/io/github/bayang/jelu/search/LuceneEntity.kt b/src/main/kotlin/io/github/bayang/jelu/search/LuceneEntity.kt index d680855f..65511d42 100644 --- a/src/main/kotlin/io/github/bayang/jelu/search/LuceneEntity.kt +++ b/src/main/kotlin/io/github/bayang/jelu/search/LuceneEntity.kt @@ -12,34 +12,34 @@ enum class LuceneEntity(val type: String, val id: String, val defaultFields: Arr ; companion object { - const val TYPE = "type" + const val TYPE = "type" } } fun Book.toDocument() = - Document().apply { - add(TextField("title", title, Field.Store.NO)) - if (!isbn10.isNullOrBlank()) add(TextField("isbn", isbn10, Field.Store.NO)) - if (!isbn13.isNullOrBlank()) add(TextField("isbn", isbn13, Field.Store.NO)) - tags.forEach { - add(TextField("tag", it.name, Field.Store.NO)) - } - authors.forEach { - add(TextField("author", it.name, Field.Store.NO)) - } - translators.forEach { - add(TextField("translator", it.name, Field.Store.NO)) - } - if (!series.isNullOrBlank()) add(TextField("series", series, Field.Store.NO)) - if (!language.isNullOrBlank()) add(TextField("language", language, Field.Store.NO)) - if (!publishedDate.isNullOrBlank()) add(TextField("published_date", publishedDate, Field.Store.NO)) - if (!publisher.isNullOrBlank()) add(TextField("publisher", publisher, Field.Store.NO)) - if (!summary.isNullOrBlank()) add(TextField("summary", summary, Field.Store.NO)) - if (!googleId.isNullOrBlank()) add(TextField("googleId", googleId, Field.Store.NO)) - if (!goodreadsId.isNullOrBlank()) add(TextField("goodreadsId", goodreadsId, Field.Store.NO)) - if (!amazonId.isNullOrBlank()) add(TextField("amazonId", amazonId, Field.Store.NO)) - if (!librarythingId.isNullOrBlank()) add(TextField("librarythingId", librarythingId, Field.Store.NO)) + Document().apply { + add(TextField("title", title, Field.Store.NO)) + if (!isbn10.isNullOrBlank()) add(TextField("isbn", isbn10, Field.Store.NO)) + if (!isbn13.isNullOrBlank()) add(TextField("isbn", isbn13, Field.Store.NO)) + tags.forEach { + add(TextField("tag", it.name, Field.Store.NO)) + } + authors.forEach { + add(TextField("author", it.name, Field.Store.NO)) + } + translators.forEach { + add(TextField("translator", it.name, Field.Store.NO)) + } + if (!series.isNullOrBlank()) add(TextField("series", series, Field.Store.NO)) + if (!language.isNullOrBlank()) add(TextField("language", language, Field.Store.NO)) + if (!publishedDate.isNullOrBlank()) add(TextField("published_date", publishedDate, Field.Store.NO)) + if (!publisher.isNullOrBlank()) add(TextField("publisher", publisher, Field.Store.NO)) + if (!summary.isNullOrBlank()) add(TextField("summary", summary, Field.Store.NO)) + if (!googleId.isNullOrBlank()) add(TextField("googleId", googleId, Field.Store.NO)) + if (!goodreadsId.isNullOrBlank()) add(TextField("goodreadsId", goodreadsId, Field.Store.NO)) + if (!amazonId.isNullOrBlank()) add(TextField("amazonId", amazonId, Field.Store.NO)) + if (!librarythingId.isNullOrBlank()) add(TextField("librarythingId", librarythingId, Field.Store.NO)) - add(StringField(LuceneEntity.TYPE, LuceneEntity.Book.type, Field.Store.NO)) - add(StringField(LuceneEntity.Book.id, id.value.toString(), Field.Store.YES)) - } + add(StringField(LuceneEntity.TYPE, LuceneEntity.Book.type, Field.Store.NO)) + add(StringField(LuceneEntity.Book.id, id.value.toString(), Field.Store.YES)) + } diff --git a/src/main/kotlin/io/github/bayang/jelu/search/LuceneHelper.kt b/src/main/kotlin/io/github/bayang/jelu/search/LuceneHelper.kt index a4c42212..fb08980d 100644 --- a/src/main/kotlin/io/github/bayang/jelu/search/LuceneHelper.kt +++ b/src/main/kotlin/io/github/bayang/jelu/search/LuceneHelper.kt @@ -24,67 +24,69 @@ private val logger = KotlinLogging.logger {} @Component class LuceneHelper( - private val directory: Directory, - private val indexAnalyzer: Analyzer, - private val searchAnalyzer: Analyzer, + private val directory: Directory, + private val indexAnalyzer: Analyzer, + private val searchAnalyzer: Analyzer, ) { - private fun getIndexWriterConfig() = IndexWriterConfig(indexAnalyzer) + private fun getIndexWriterConfig() = IndexWriterConfig(indexAnalyzer) - fun getIndexWriter() = IndexWriter(directory, getIndexWriterConfig()) + fun getIndexWriter() = IndexWriter(directory, getIndexWriterConfig()) - fun getIndexReader(): DirectoryReader = DirectoryReader.open(directory) + fun getIndexReader(): DirectoryReader = DirectoryReader.open(directory) - fun indexExists(): Boolean = DirectoryReader.indexExists(directory) + fun indexExists(): Boolean = DirectoryReader.indexExists(directory) - fun setIndexVersion(version: Int) { - getIndexWriter().use { indexWriter -> - val doc = Document().apply { - add(StringField("index_version", version.toString(), Field.Store.YES)) - add(StringField("type", "index_version", Field.Store.NO)) - } - indexWriter.updateDocument(Term("type", "index_version"), doc) + fun setIndexVersion(version: Int) { + getIndexWriter().use { indexWriter -> + val doc = Document().apply { + add(StringField("index_version", version.toString(), Field.Store.YES)) + add(StringField("type", "index_version", Field.Store.NO)) + } + indexWriter.updateDocument(Term("type", "index_version"), doc) + } + logger.info { "Lucene index version: ${getIndexVersion()}" } } - logger.info { "Lucene index version: ${getIndexVersion()}" } - } - fun getIndexVersion(): Int = - getIndexReader().use { index -> - val searcher = IndexSearcher(index) - val topDocs = searcher.search(TermQuery(Term("type", "index_version")), 1) - topDocs.scoreDocs.map { searcher.storedFields().document(it.doc)["index_version"] }.firstOrNull()?.toIntOrNull() ?: 1 - } + fun getIndexVersion(): Int = + getIndexReader().use { index -> + val searcher = IndexSearcher(index) + val topDocs = searcher.search(TermQuery(Term("type", "index_version")), 1) + topDocs.scoreDocs.map { searcher.storedFields().document(it.doc)["index_version"] }.firstOrNull()?.toIntOrNull() ?: 1 + } - fun searchEntitiesIds(searchTerm: String?, entity: LuceneEntity): List? { - return if (!searchTerm.isNullOrBlank()) { - try { - val fieldsQuery = MultiFieldQueryParser(entity.defaultFields, searchAnalyzer).apply { - defaultOperator = QueryParser.Operator.AND - }.parse("$searchTerm *:*") + fun searchEntitiesIds(searchTerm: String?, entity: LuceneEntity): List? { + return if (!searchTerm.isNullOrBlank()) { + try { + val fieldsQuery = MultiFieldQueryParser(entity.defaultFields, searchAnalyzer).apply { + defaultOperator = QueryParser.Operator.AND + }.parse("$searchTerm *:*") - val typeQuery = TermQuery(Term(LuceneEntity.TYPE, entity.type)) + val typeQuery = TermQuery(Term(LuceneEntity.TYPE, entity.type)) - val booleanQuery = BooleanQuery.Builder() - .add(fieldsQuery, BooleanClause.Occur.MUST) - .add(typeQuery, BooleanClause.Occur.MUST) - .build() + val booleanQuery = BooleanQuery.Builder() + .add(fieldsQuery, BooleanClause.Occur.MUST) + .add(typeQuery, BooleanClause.Occur.MUST) + .build() - getIndexReader().use { index -> - val searcher = IndexSearcher(index) - val topDocs = searcher.search(booleanQuery, index.numDocs()) - topDocs.scoreDocs.map { searcher.storedFields().document(it.doc)[entity.id] } + getIndexReader().use { index -> + val searcher = IndexSearcher(index) + val topDocs = searcher.search(booleanQuery, index.numDocs()) + topDocs.scoreDocs.map { searcher.storedFields().document(it.doc)[entity.id] } + } + } catch (e: ParseException) { + emptyList() + } catch (e: Exception) { + logger.error(e) { "Error fetching entities from index" } + emptyList() + } + } else { + null } - } catch (e: ParseException) { - emptyList() - } catch (e: Exception) { - logger.error(e) { "Error fetching entities from index" } - emptyList() - } - } else null - } + } - fun upgradeIndex() { - IndexUpgrader(directory, getIndexWriterConfig(), true).upgrade() - logger.info { "Lucene index upgraded" } - } -} \ No newline at end of file + fun upgradeIndex() { + IndexUpgrader(directory, getIndexWriterConfig(), true).upgrade() + logger.info { "Lucene index upgraded" } + } +} diff --git a/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualAnalyzer.kt b/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualAnalyzer.kt index 4fe470bb..9c452eee 100644 --- a/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualAnalyzer.kt +++ b/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualAnalyzer.kt @@ -14,20 +14,20 @@ import org.apache.lucene.analysis.standard.StandardTokenizer * for all the lucene related stuff */ open class MultiLingualAnalyzer : Analyzer() { - override fun createComponents(fieldName: String): TokenStreamComponents { - val source: Tokenizer = StandardTokenizer() - // run the widthfilter first before bigramming, it sometimes combines characters. - var filter: TokenStream = CJKWidthFilter(source) - filter = LowerCaseFilter(filter) - filter = CJKBigramFilter(filter) - filter = ASCIIFoldingFilter(filter) - return TokenStreamComponents(source, filter) - } + override fun createComponents(fieldName: String): TokenStreamComponents { + val source: Tokenizer = StandardTokenizer() + // run the widthfilter first before bigramming, it sometimes combines characters. + var filter: TokenStream = CJKWidthFilter(source) + filter = LowerCaseFilter(filter) + filter = CJKBigramFilter(filter) + filter = ASCIIFoldingFilter(filter) + return TokenStreamComponents(source, filter) + } - override fun normalize(fieldName: String?, `in`: TokenStream): TokenStream { - var filter: TokenStream = CJKWidthFilter(`in`) - filter = LowerCaseFilter(filter) - filter = ASCIIFoldingFilter(filter) - return filter - } + override fun normalize(fieldName: String?, `in`: TokenStream): TokenStream { + var filter: TokenStream = CJKWidthFilter(`in`) + filter = LowerCaseFilter(filter) + filter = ASCIIFoldingFilter(filter) + return filter + } } diff --git a/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualNGramAnalyzer.kt b/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualNGramAnalyzer.kt index 39e9fe3d..8b4ea1df 100644 --- a/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualNGramAnalyzer.kt +++ b/src/main/kotlin/io/github/bayang/jelu/search/MultiLingualNGramAnalyzer.kt @@ -14,14 +14,14 @@ import org.apache.lucene.analysis.standard.StandardTokenizer * for all the lucene related stuff */ class MultiLingualNGramAnalyzer(private val minGram: Int, private val maxGram: Int, private val preserveOriginal: Boolean) : MultiLingualAnalyzer() { - override fun createComponents(fieldName: String): TokenStreamComponents { - val source: Tokenizer = StandardTokenizer() - // run the widthfilter first before bigramming, it sometimes combines characters. - var filter: TokenStream = CJKWidthFilter(source) - filter = LowerCaseFilter(filter) - filter = CJKBigramFilter(filter) - filter = NGramTokenFilter(filter, minGram, maxGram, preserveOriginal) - filter = ASCIIFoldingFilter(filter) - return TokenStreamComponents(source, filter) - } + override fun createComponents(fieldName: String): TokenStreamComponents { + val source: Tokenizer = StandardTokenizer() + // run the widthfilter first before bigramming, it sometimes combines characters. + var filter: TokenStream = CJKWidthFilter(source) + filter = LowerCaseFilter(filter) + filter = CJKBigramFilter(filter) + filter = NGramTokenFilter(filter, minGram, maxGram, preserveOriginal) + filter = ASCIIFoldingFilter(filter) + return TokenStreamComponents(source, filter) + } } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/AppLifecycleAware.kt b/src/main/kotlin/io/github/bayang/jelu/service/AppLifecycleAware.kt index 37fad4ee..372192c1 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/AppLifecycleAware.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/AppLifecycleAware.kt @@ -14,7 +14,7 @@ private val logger = KotlinLogging.logger {} class AppLifecycleAware( private val properties: JeluProperties, private val luceneHelper: LuceneHelper, - private val searchIndexService: SearchIndexService + private val searchIndexService: SearchIndexService, ) { @EventListener diff --git a/src/main/kotlin/io/github/bayang/jelu/service/BookService.kt b/src/main/kotlin/io/github/bayang/jelu/service/BookService.kt index 8c75fc4a..757ea13e 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/BookService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/BookService.kt @@ -54,7 +54,7 @@ class BookService( private val fileManager: FileManager, private val shelfService: ShelfService, private val searchIndexService: SearchIndexService, - private val luceneHelper: LuceneHelper + private val luceneHelper: LuceneHelper, ) { @Transactional @@ -62,7 +62,7 @@ class BookService( query: String?, pageable: Pageable, user: User, - libraryFilter: LibraryFilter + libraryFilter: LibraryFilter, ): Page { val entitiesIds = luceneHelper.searchEntitiesIds(query, LuceneEntity.Book) // we had a query but nothing matched, so don't return anything @@ -72,7 +72,7 @@ class BookService( return PageImpl( listOf(), pageable, - 0 + 0, ) } else { return bookRepository.findAll(entitiesIds, pageable, user, libraryFilter).map { it.toBookDto() } @@ -90,7 +90,7 @@ class BookService( tags: List?, pageable: Pageable, user: User, - libraryFilter: LibraryFilter + libraryFilter: LibraryFilter, ): Page = bookRepository.findAll(title, isbn10, isbn13, series, authors, translators, tags, pageable, user, libraryFilter).map { it.toBookDto() } @@ -186,8 +186,8 @@ class BookService( eventType = userBook.lastReadingEvent, bookId = null, eventDate = userBook.lastReadingEventDate, - startDate = null - ) + startDate = null, + ), ) } var backup: File? = null @@ -255,7 +255,7 @@ class BookService( val targetFilename: String = imageName( slugify(title), id, - FilenameUtils.getExtension(dtoImage) + FilenameUtils.getExtension(dtoImage), ) val currentFile = File(targetDir, "$dtoImage.bak") val targetFile = File(currentFile.parent, targetFilename) @@ -267,7 +267,7 @@ class BookService( dtoImage, slugify(title), id, - targetDir + targetDir, ) savedImage = destFileName } @@ -337,7 +337,7 @@ class BookService( toRead: Boolean?, owned: Boolean? = null, borrowed: Boolean? = null, - pageable: Pageable + pageable: Pageable, ): Page { return bookRepository.findUserBookByCriteria(userId, bookId, eventTypes, toRead, owned, borrowed, pageable).map { it.toUserBookWthoutEventsAndUserDto() } } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/FileManager.kt b/src/main/kotlin/io/github/bayang/jelu/service/FileManager.kt index 42c0dfa0..47d34d6b 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/FileManager.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/FileManager.kt @@ -19,7 +19,7 @@ private val logger = KotlinLogging.logger {} @Component class FileManager( - private val jeluProperties: JeluProperties + private val jeluProperties: JeluProperties, ) { @Scheduled(cron = "\${files.metadataImportCleanCron:0 0 */6 * * *}") diff --git a/src/main/kotlin/io/github/bayang/jelu/service/ImportService.kt b/src/main/kotlin/io/github/bayang/jelu/service/ImportService.kt index 43bcbb88..f4ef6ab2 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/ImportService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/ImportService.kt @@ -16,7 +16,7 @@ class ImportService(private val importRepository: ImportRepository) { entity: ImportDto, processingStatus: ProcessingStatus, userId: UUID, - shouldFetchMetadata: Boolean + shouldFetchMetadata: Boolean, ) { importRepository.save(entity, processingStatus, userId, shouldFetchMetadata) } @@ -25,13 +25,13 @@ class ImportService(private val importRepository: ImportRepository) { fun updateStatus( oldStatus: ProcessingStatus, newStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): Int = importRepository.updateStatus(oldStatus, newStatus, userId) @Transactional fun getByprocessingStatusAndUser( processingStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): List = importRepository.getByprocessingStatusAndUser(processingStatus, userId) @Transactional @@ -40,12 +40,12 @@ class ImportService(private val importRepository: ImportRepository) { @Transactional fun countByprocessingStatusAndUser( processingStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): Long = importRepository.countByprocessingStatusAndUser(processingStatus, userId) @Transactional fun deleteByprocessingStatusAndUser( processingStatus: ProcessingStatus, - userId: UUID + userId: UUID, ): Int = importRepository.deleteByprocessingStatusAndUser(processingStatus, userId) } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/ReadingEventService.kt b/src/main/kotlin/io/github/bayang/jelu/service/ReadingEventService.kt index a7a6edaf..6558a63f 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/ReadingEventService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/ReadingEventService.kt @@ -24,7 +24,7 @@ class ReadingEventService(private val readingEventRepository: ReadingEventReposi startedBefore: LocalDate?, endedAfter: LocalDate?, endedBefore: LocalDate?, - pageable: Pageable + pageable: Pageable, ) = readingEventRepository.findAll(eventTypes, userId, bookId, startedAfter, startedBefore, endedAfter, endedBefore, pageable).map { it.toReadingEventDto() } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/ReviewService.kt b/src/main/kotlin/io/github/bayang/jelu/service/ReviewService.kt index 73a060f0..a1f1a73a 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/ReviewService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/ReviewService.kt @@ -16,7 +16,7 @@ import java.util.UUID @Component class ReviewService( private val reviewRepository: ReviewRepository, - private val bookService: BookService + private val bookService: BookService, ) { @Transactional @@ -34,7 +34,7 @@ class ReviewService( visibility: Visibility?, after: LocalDate?, before: LocalDate?, - pageable: Pageable + pageable: Pageable, ): Page { return reviewRepository.find(userId, bookId, visibility, after, before, pageable).map { it.toReviewDto() } } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/SearchIndexService.kt b/src/main/kotlin/io/github/bayang/jelu/service/SearchIndexService.kt index 05234c0d..deccbf8f 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/SearchIndexService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/SearchIndexService.kt @@ -22,100 +22,104 @@ private val logger = KotlinLogging.logger {} @Component class SearchIndexService( - private val luceneHelper: LuceneHelper, - private val bookRepository: BookRepository, + private val luceneHelper: LuceneHelper, + private val bookRepository: BookRepository, ) { - fun upgradeIndex() { - luceneHelper.upgradeIndex() - luceneHelper.setIndexVersion(INDEX_VERSION) - } - - @Transactional - fun rebuildIndex(entities: Set? = null) { - val targetEntities = entities ?: LuceneEntity.values().toSet() - logger.info { "Rebuild index for: ${targetEntities.map { it.type }}" } - targetEntities.forEach { - when (it) { - LuceneEntity.Book -> rebuildIndex(it, { - p: Pageable -> bookRepository.findAllNoFilters(null, null, null, null, null, null, null, p) }, - { e: Book -> e.toDocument() }) - LuceneEntity.Author -> logger.debug { "no authors index yet" } - } + fun upgradeIndex() { + luceneHelper.upgradeIndex() + luceneHelper.setIndexVersion(INDEX_VERSION) } - luceneHelper.setIndexVersion(INDEX_VERSION) - } - - private fun rebuildIndex(entity: LuceneEntity, provider: (Pageable) -> Page, toDoc: (T) -> Document) { - logger.info { "Rebuilding index for ${entity.name}" } - - val count = provider(Pageable.ofSize(1)).totalElements - val batchSize = 5_000 - val pages = ceil(count.toDouble() / batchSize).toInt() - logger.info { "Number of entities: $count and pages : $pages" } - - luceneHelper.getIndexWriter().use { indexWriter -> - measureTime { - indexWriter.deleteDocuments(Term(LuceneEntity.TYPE, entity.type)) - - (0 until pages).forEach { page -> - logger.info { "Processing page ${page + 1} of $pages ($batchSize elements)" } - val entityDocs = provider(PageRequest.of(page, batchSize)).content - .map { toDoc(it) } - indexWriter.addDocuments(entityDocs) + + @Transactional + fun rebuildIndex(entities: Set? = null) { + val targetEntities = entities ?: LuceneEntity.values().toSet() + logger.info { "Rebuild index for: ${targetEntities.map { it.type }}" } + targetEntities.forEach { + when (it) { + LuceneEntity.Book -> rebuildIndex( + it, + { + p: Pageable -> + bookRepository.findAllNoFilters(null, null, null, null, null, null, null, p) + }, + { e: Book -> e.toDocument() }, + ) + LuceneEntity.Author -> logger.debug { "no authors index yet" } + } } - }.also { duration -> - logger.info { "Wrote ${entity.name} index in $duration" } - } + luceneHelper.setIndexVersion(INDEX_VERSION) + } + + private fun rebuildIndex(entity: LuceneEntity, provider: (Pageable) -> Page, toDoc: (T) -> Document) { + logger.info { "Rebuilding index for ${entity.name}" } + + val count = provider(Pageable.ofSize(1)).totalElements + val batchSize = 5_000 + val pages = ceil(count.toDouble() / batchSize).toInt() + logger.info { "Number of entities: $count and pages : $pages" } + + luceneHelper.getIndexWriter().use { indexWriter -> + measureTime { + indexWriter.deleteDocuments(Term(LuceneEntity.TYPE, entity.type)) + + (0 until pages).forEach { page -> + logger.info { "Processing page ${page + 1} of $pages ($batchSize elements)" } + val entityDocs = provider(PageRequest.of(page, batchSize)).content + .map { toDoc(it) } + indexWriter.addDocuments(entityDocs) + } + }.also { duration -> + logger.info { "Wrote ${entity.name} index in $duration" } + } + } + } + + fun bookAdded(book: Book) { + addEntity(book.toDocument()) + } + + fun bookUpdated(book: Book) { + updateEntity(LuceneEntity.Book, book.id.value.toString(), book.toDocument()) + } + + fun bookUpdated(bookId: UUID) { + bookUpdated(bookRepository.findBookById(bookId)) } - } - - fun bookAdded(book: Book) { - addEntity(book.toDocument()) - } - - fun bookUpdated(book: Book) { - updateEntity(LuceneEntity.Book, book.id.value.toString(), book.toDocument()) - } - - fun bookUpdated(bookId: UUID) { - bookUpdated(bookRepository.findBookById(bookId)) - } - - fun booksUpdated(bookIds: List) { - bookIds.forEach { bookUpdated(bookRepository.findBookById(it)) } - } - - fun bookDeleted(bookId: UUID) { - deleteEntity(LuceneEntity.Book, bookId.toString()) - } - - fun authorUpdated(authorId: UUID) { - var books: Page - do { - books = bookRepository.findAuthorBooksByIdNoFilters(authorId, Pageable.ofSize(30)) - books.forEach { deleteEntity(LuceneEntity.Book, it.id.value.toString()) } - books.forEach { addEntity(it.toDocument()) } + + fun booksUpdated(bookIds: List) { + bookIds.forEach { bookUpdated(bookRepository.findBookById(it)) } } - while (books.hasNext()) - } - private fun addEntity(doc: Document) { - luceneHelper.getIndexWriter().use { indexWriter -> - indexWriter.addDocument(doc) + fun bookDeleted(bookId: UUID) { + deleteEntity(LuceneEntity.Book, bookId.toString()) } - } - private fun updateEntity(entity: LuceneEntity, entityId: String, newDoc: Document) { - luceneHelper.getIndexWriter().use { indexWriter -> - indexWriter.updateDocument(Term(entity.id, entityId), newDoc) + fun authorUpdated(authorId: UUID) { + var books: Page + do { + books = bookRepository.findAuthorBooksByIdNoFilters(authorId, Pageable.ofSize(30)) + books.forEach { deleteEntity(LuceneEntity.Book, it.id.value.toString()) } + books.forEach { addEntity(it.toDocument()) } + } + while (books.hasNext()) } - } - private fun deleteEntity(entity: LuceneEntity, entityId: String) { - luceneHelper.getIndexWriter().use { indexWriter -> - indexWriter.deleteDocuments(Term(entity.id, entityId)) + private fun addEntity(doc: Document) { + luceneHelper.getIndexWriter().use { indexWriter -> + indexWriter.addDocument(doc) + } } - } -} \ No newline at end of file + private fun updateEntity(entity: LuceneEntity, entityId: String, newDoc: Document) { + luceneHelper.getIndexWriter().use { indexWriter -> + indexWriter.updateDocument(Term(entity.id, entityId), newDoc) + } + } + + private fun deleteEntity(entity: LuceneEntity, entityId: String) { + luceneHelper.getIndexWriter().use { indexWriter -> + indexWriter.deleteDocuments(Term(entity.id, entityId)) + } + } +} diff --git a/src/main/kotlin/io/github/bayang/jelu/service/ShelfService.kt b/src/main/kotlin/io/github/bayang/jelu/service/ShelfService.kt index acb8f242..924bd02c 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/ShelfService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/ShelfService.kt @@ -11,7 +11,7 @@ import java.util.UUID @Component class ShelfService( - private val shelfRepository: ShelfRepository + private val shelfRepository: ShelfRepository, ) { @Transactional @@ -27,14 +27,14 @@ class ShelfService( fun find( user: User?, name: String?, - targetId: UUID? + targetId: UUID?, ): List { return shelfRepository.find(user, name, targetId).map { it.toShelfDto() } } @Transactional fun findById( - id: UUID + id: UUID, ): ShelfDto = shelfRepository.findById(id).toShelfDto() @Transactional diff --git a/src/main/kotlin/io/github/bayang/jelu/service/UserMessageService.kt b/src/main/kotlin/io/github/bayang/jelu/service/UserMessageService.kt index d4774749..96e57967 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/UserMessageService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/UserMessageService.kt @@ -25,7 +25,7 @@ class UserMessageService(private val userMessageRepository: UserMessageRepositor user: User, read: Boolean?, messageCategories: List?, - pageable: Pageable + pageable: Pageable, ): Page { return userMessageRepository.find(user, read, messageCategories, pageable).map { it.toUserMessageDto() } } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/UserService.kt b/src/main/kotlin/io/github/bayang/jelu/service/UserService.kt index 365500e7..eda08c88 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/UserService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/UserService.kt @@ -25,7 +25,7 @@ private val logger = KotlinLogging.logger {} class UserService( private val userRepository: UserRepository, private val sessionRegistry: SessionRegistry, - private val passwordEncoder: PasswordEncoder + private val passwordEncoder: PasswordEncoder, ) : UserDetailsService { @Transactional diff --git a/src/main/kotlin/io/github/bayang/jelu/service/exports/CsvExportService.kt b/src/main/kotlin/io/github/bayang/jelu/service/exports/CsvExportService.kt index a8e44c4e..e8bdad52 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/exports/CsvExportService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/exports/CsvExportService.kt @@ -43,7 +43,7 @@ class CsvExportService( private val bookService: BookService, private val properties: JeluProperties, private val readingEventService: ReadingEventService, - private val userMessageService: UserMessageService + private val userMessageService: UserMessageService, ) { /** @@ -68,9 +68,9 @@ class CsvExportService( CreateUserMessageDto( "Export started at $nowPretty", null, - MessageCategory.INFO + MessageCategory.INFO, ), - user + user, ) } catch (e: Exception) { logger.error(e) { "failed to save message for $destFileName export" } @@ -103,9 +103,9 @@ class CsvExportService( CreateUserMessageDto( "Export completed : $msg", "$EXPORTS_PREFIX/$destFileName", - MessageCategory.SUCCESS + MessageCategory.SUCCESS, ), - user + user, ) } catch (e: Exception) { logger.error(e) { "failed to save message for $destFileName export" } @@ -130,7 +130,7 @@ class CsvExportService( if (it.book.isbn13.isNullOrBlank()) "" else it.book.isbn13, if (it.owned == true) "true" else "", listOfDatesForEvent(it, userId, ReadingEventType.DROPPED), - listOfDatesForEvent(it, userId, ReadingEventType.CURRENTLY_READING) + listOfDatesForEvent(it, userId, ReadingEventType.CURRENTLY_READING), ) } } @@ -156,7 +156,7 @@ class CsvExportService( fun toDateString(instant: Instant?): String { return if (instant != null) { LocalDate.ofInstant(instant, ZoneId.systemDefault()).format( - goodreadsDateFormatter + goodreadsDateFormatter, ) } else { "" diff --git a/src/main/kotlin/io/github/bayang/jelu/service/imports/CsvImportService.kt b/src/main/kotlin/io/github/bayang/jelu/service/imports/CsvImportService.kt index 0bb15349..cba33ca5 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/imports/CsvImportService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/imports/CsvImportService.kt @@ -76,7 +76,7 @@ class CsvImportService( private val bookService: BookService, private val userService: UserService, private val readingEventService: ReadingEventService, - private val userMessageService: UserMessageService + private val userMessageService: UserMessageService, ) { // maybe later : use coroutines ? @@ -90,9 +90,9 @@ class CsvImportService( CreateUserMessageDto( "Import started at $nowString", null, - MessageCategory.INFO + MessageCategory.INFO, ), - userEntity + userEntity, ) } catch (e: Exception) { logger.error(e) { "failed to save message for ${file.absolutePath} import" } @@ -116,9 +116,9 @@ class CsvImportService( CreateUserMessageDto( "Import for ${file.absolutePath} ended after : $deltaInSec seconds, with $success imports and $failures failures", null, - MessageCategory.SUCCESS + MessageCategory.SUCCESS, ), - userEntity + userEntity, ) } catch (e: Exception) { logger.error(e) { "failed to save message for ${file.absolutePath} import" } @@ -178,9 +178,9 @@ class CsvImportService( CreateUserMessageDto( "no title nor authors for input $isbn10 $isbn13, not saving", null, - MessageCategory.WARNING + MessageCategory.WARNING, ), - userEntity + userEntity, ) } catch (e: Exception) { logger.error(e) { "failed to save message for failed isbn fetch" } @@ -233,9 +233,9 @@ class CsvImportService( merge(book, bookFromDb), if (readStatusFromShelves.equals(TO_READ, true) && userbook.toRead == null) true else null, null, - null + null, ), - null + null, ) } else { // update book only and create userbook @@ -247,7 +247,7 @@ class CsvImportService( merge(book, bookFromDb), if (readStatusFromShelves.equals(TO_READ, true)) true else null, null, - null + null, ) bookService.save(userbook, userEntity, null) } @@ -260,7 +260,7 @@ class CsvImportService( book, if (readStatusFromShelves.equals(TO_READ, true)) true else null, null, - null + null, ) bookService.save(userbook, userEntity, null) } @@ -309,12 +309,12 @@ class CsvImportService( savedUserBook.book.id, toInstant( pastDate.plusDays( - idx.toLong() - ) + idx.toLong(), + ), ), - null + null, ), - userEntity + userEntity, ) } importService.updateStatus(importEntity.id.value, ProcessingStatus.IMPORTED) @@ -396,7 +396,7 @@ class CsvImportService( // we must send the currently existing image image = if (dbBook.image.isNullOrBlank()) incoming.image else dbBook.image, authors = authors, - tags = tags + tags = tags, ) } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataService.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataService.kt index 7f5f4d63..6ec0c3da 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataService.kt @@ -13,12 +13,12 @@ private val logger = KotlinLogging.logger {} @Service class FetchMetadataService( private val providers: List, - private val pluginInfoHolder: PluginInfoHolder + private val pluginInfoHolder: PluginInfoHolder, ) { fun fetchMetadata( metadataRequestDto: MetadataRequestDto, - config: Map = mapOf() + config: Map = mapOf(), ): Mono { var pluginsToUse = if (metadataRequestDto.plugins.isNullOrEmpty()) pluginInfoHolder.plugins() else metadataRequestDto.plugins pluginsToUse = pluginsToUse.toMutableList() diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolder.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolder.kt index 1bb011bf..4f0013ed 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolder.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolder.kt @@ -7,7 +7,7 @@ import org.springframework.stereotype.Service @Service class PluginInfoHolder( - private val properties: JeluProperties + private val properties: JeluProperties, ) { companion object { diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/WikipediaService.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/WikipediaService.kt index 7f9754b1..162b793c 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/WikipediaService.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/WikipediaService.kt @@ -11,7 +11,7 @@ import javax.annotation.Resource @Service class WikipediaService( - @Resource(name = "restClient") val restClient: WebClient + @Resource(name = "restClient") val restClient: WebClient, ) { // curl https://fr.wikipedia.org/w/rest.php/v1/search/title\?q\=stefan%20platteau\&limit\=5 diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/CalibreMetadataProvider.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/CalibreMetadataProvider.kt index 034b4c26..8ae4c31d 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/CalibreMetadataProvider.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/CalibreMetadataProvider.kt @@ -33,7 +33,7 @@ private val logger = KotlinLogging.logger {} @Service class CalibreMetadataProvider( - private val properties: JeluProperties + private val properties: JeluProperties, ) : IMetaDataProvider { companion object { @@ -47,7 +47,7 @@ class CalibreMetadataProvider( override fun fetchMetadata( metadataRequestDto: MetadataRequestDto, - config: Map + config: Map, ): Mono? { if (metadataRequestDto.isbn.isNullOrBlank() && metadataRequestDto.title.isNullOrBlank() && metadataRequestDto.authors.isNullOrBlank() diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/DebugMetadataProvider.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/DebugMetadataProvider.kt index 0221bf9f..3e4b98dd 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/DebugMetadataProvider.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/DebugMetadataProvider.kt @@ -14,7 +14,7 @@ class DebugMetadataProvider : IMetaDataProvider { override fun fetchMetadata( metadataRequestDto: MetadataRequestDto, - config: Map + config: Map, ): Mono? { logger.debug { "debug plugin called with isbn ${metadataRequestDto.isbn}, title ${metadataRequestDto.title}, " + diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProvider.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProvider.kt index 322c80d6..037bc9a5 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProvider.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProvider.kt @@ -18,14 +18,14 @@ private val logger = KotlinLogging.logger {} @Service class GoogleBooksIMetaDataProvider( @Resource(name = "restClient") private val restClient: WebClient, - private val properties: JeluProperties + private val properties: JeluProperties, ) : IMetaDataProvider { private val _name = "google" override fun fetchMetadata( metadataRequestDto: MetadataRequestDto, - config: Map + config: Map, ): Mono? { val googleProviderApiKey = getGoogleProviderApiKey() if (googleProviderApiKey.isNullOrBlank() || metadataRequestDto.isbn.isNullOrBlank()) { @@ -47,7 +47,7 @@ class GoogleBooksIMetaDataProvider( ObjectMapper() .readTree(bodyString) .get("items") - .get(0) + .get(0), ) } } else { @@ -78,7 +78,7 @@ class GoogleBooksIMetaDataProvider( image = volumeInfo.get("imageLinks").get("thumbnail").asText(), language = volumeInfo.get("language").asText(), publishedDate = volumeInfo.get("publishedDate").asText(), - summary = node.get("searchInfo").get("textSnippet").asText() + summary = node.get("searchInfo").get("textSnippet").asText(), ) } } diff --git a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/IMetaDataProvider.kt b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/IMetaDataProvider.kt index 93a4efb2..10854b7e 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/IMetaDataProvider.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/metadata/providers/IMetaDataProvider.kt @@ -7,7 +7,7 @@ import reactor.core.publisher.Mono interface IMetaDataProvider { fun fetchMetadata( metadataRequestDto: MetadataRequestDto, - config: Map = mapOf() + config: Map = mapOf(), ): Mono? fun name(): String diff --git a/src/main/kotlin/io/github/bayang/jelu/service/quotes/GoodreadsQuoteProviderImpl.kt b/src/main/kotlin/io/github/bayang/jelu/service/quotes/GoodreadsQuoteProviderImpl.kt index cbc79567..fa47da99 100644 --- a/src/main/kotlin/io/github/bayang/jelu/service/quotes/GoodreadsQuoteProviderImpl.kt +++ b/src/main/kotlin/io/github/bayang/jelu/service/quotes/GoodreadsQuoteProviderImpl.kt @@ -29,7 +29,7 @@ const val KEY: String = "quotes" @Service class GoodreadsQuoteProviderImpl( val bookService: BookService, - @Resource(name = "restClient") val restClient: WebClient + @Resource(name = "restClient") val restClient: WebClient, ) : IQuoteProvider { var cache: Cache> = Caffeine.newBuilder() @@ -125,7 +125,7 @@ class GoodreadsQuoteProviderImpl( content = element.ownText(), author = element.select("span.authorOrTitle").text(), origin = element.select("a.authorOrTitle").text(), - link = if (url.isBlank()) "" else BASE_URL + url + link = if (url.isBlank()) "" else BASE_URL + url, ) } } diff --git a/src/test/kotlin/io/github/bayang/jelu/TestHelpers.kt b/src/test/kotlin/io/github/bayang/jelu/TestHelpers.kt index c84c3d48..8aacc7ba 100644 --- a/src/test/kotlin/io/github/bayang/jelu/TestHelpers.kt +++ b/src/test/kotlin/io/github/bayang/jelu/TestHelpers.kt @@ -18,7 +18,7 @@ fun createUserBookDto(bookDto: BookCreateDto, lastReadingEvent: ReadingEventType toRead = toRead, percentRead = null, book = bookDto, - borrowed = borrowed + borrowed = borrowed, ) } @@ -41,7 +41,7 @@ fun bookDto(title: String = "title1", withTags: Boolean = false): BookCreateDto googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) } diff --git a/src/test/kotlin/io/github/bayang/jelu/service/BookServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/BookServiceTest.kt index 18a0f952..1bce914f 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/BookServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/BookServiceTest.kt @@ -43,7 +43,7 @@ class BookServiceTest( @Autowired private val userService: UserService, @Autowired private val jeluProperties: JeluProperties, @Autowired private val readingEventService: ReadingEventService, - @Autowired private val luceneHelper: LuceneHelper + @Autowired private val luceneHelper: LuceneHelper, ) { companion object { @@ -167,9 +167,9 @@ class BookServiceTest( googleId = "", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ), - null + null, ) Assertions.assertNotNull(res.id) val found = bookService.findBookById(res.id!!) @@ -232,7 +232,7 @@ class BookServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val res: BookDto = bookService.save(bookDto(), null) Assertions.assertNotNull(res.id) @@ -322,7 +322,7 @@ class BookServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val res: BookDto = bookService.save(dto, null) Assertions.assertNotNull(res.id) @@ -493,7 +493,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified) val saved: UserBookLightDto = bookService.save(createUserBookDto, user(), null) @@ -539,7 +539,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified) val saved: UserBookLightDto = bookService.save(createUserBookDto, user(), null) @@ -583,7 +583,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified) val replacementFile = MockMultipartFile("test-replace-cover.jpg", "test-replace-cover.jpg", "image/jpeg", this::class.java.getResourceAsStream("test-cover.jpg")) @@ -651,7 +651,7 @@ class BookServiceTest( book = null, toRead = null, percentRead = 50, - borrowed = null + borrowed = null, ) val updated = bookService.update(saved.id!!, updater, null) Assertions.assertEquals(createBook.title, updated.book.title) @@ -719,7 +719,7 @@ class BookServiceTest( book = null, toRead = null, percentRead = 50, - borrowed = true + borrowed = true, ) val updated = bookService.update(saved.id!!, updater, null) Assertions.assertEquals(createBook.title, updated.book.title) @@ -788,7 +788,7 @@ class BookServiceTest( book = createBook.copy(image = null), toRead = null, percentRead = 50, - borrowed = false + borrowed = false, ) // val replacementFile = MockMultipartFile("test-replace-cover.jpg", "test-replace-cover.jpg", "image/jpeg", this::class.java.getResourceAsStream("test-cover.jpg")) val updated = bookService.update(saved.id!!, updater, null) @@ -858,7 +858,7 @@ class BookServiceTest( book = null, toRead = null, percentRead = 50, - borrowed = null + borrowed = null, ) val replacementFile = MockMultipartFile("test-replace-cover.jpg", "test-replace-cover.jpg", "image/jpeg", this::class.java.getResourceAsStream("test-cover.jpg")) val updated = bookService.update(saved.id!!, updater, replacementFile) @@ -905,7 +905,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified, ReadingEventType.FINISHED) val saved1: UserBookLightDto = bookService.save(createUserBookDto, user(), null) @@ -946,7 +946,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified, ReadingEventType.FINISHED) val saved1: UserBookLightDto = bookService.save(createUserBookDto, user(), null) @@ -1001,7 +1001,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified, ReadingEventType.FINISHED) val saved1: UserBookLightDto = bookService.save(createUserBookDto, user(), null) @@ -1053,7 +1053,7 @@ class BookServiceTest( savedBook.id, title = "modified title", isbn10 = savedBook.isbn10, - isbn13 = savedBook.isbn13 + isbn13 = savedBook.isbn13, ) val createUserBookDto = createUserBookDto(modified, ReadingEventType.FINISHED) val saved1: UserBookLightDto = bookService.save(createUserBookDto, user(), null) @@ -1187,7 +1187,7 @@ class BookServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val book2 = BookCreateDto( id = null, @@ -1207,7 +1207,7 @@ class BookServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val book3 = BookCreateDto( id = null, @@ -1227,7 +1227,7 @@ class BookServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val savedBook1 = bookService.save(book1, null) Assertions.assertNotNull(savedBook1) diff --git a/src/test/kotlin/io/github/bayang/jelu/service/ReadingEventServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/ReadingEventServiceTest.kt index e954df40..2cf7ab3b 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/ReadingEventServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/ReadingEventServiceTest.kt @@ -37,7 +37,7 @@ class ReadingEventServiceTest( @Autowired private val bookService: BookService, @Autowired private val userService: UserService, @Autowired private val jeluProperties: JeluProperties, - @Autowired private val readingEventService: ReadingEventService + @Autowired private val readingEventService: ReadingEventService, ) { companion object { @@ -107,7 +107,7 @@ class ReadingEventServiceTest( book = null, toRead = null, percentRead = 50, - borrowed = null + borrowed = null, ) val updated = bookService.update(saved.id!!, updater, null) Assertions.assertEquals(createBook.title, updated.book.title) @@ -166,7 +166,7 @@ class ReadingEventServiceTest( book = null, toRead = null, percentRead = 50, - borrowed = null + borrowed = null, ) val updated = bookService.update(saved.id!!, updater, null) Assertions.assertEquals(createBook.title, updated.book.title) @@ -225,9 +225,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysBefore, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) @@ -278,9 +278,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysBefore, - thirtyDaysBefore.plus(1, ChronoUnit.DAYS) + thirtyDaysBefore.plus(1, ChronoUnit.DAYS), ), - user() + user(), ) } } @@ -317,9 +317,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) @@ -369,9 +369,9 @@ class ReadingEventServiceTest( ReadingEventType.FINISHED, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.FINISHED, newEvent.eventType) @@ -409,9 +409,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, savedBook.id, dateAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) nbUserBooks = bookService.findUserBookByCriteria(user.id.value, null, null, null, null, null, Pageable.ofSize(30)).totalElements @@ -436,9 +436,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, null, dateAfter, - null + null, ), - user() + user(), ) } Assertions.assertEquals(0, readingEventService.findAll(null, null, null, null, null, null, null, Pageable.ofSize(30)).totalElements) @@ -476,9 +476,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) @@ -494,8 +494,8 @@ class ReadingEventServiceTest( UpdateReadingEventDto( ReadingEventType.FINISHED, nowInstant().plus(40, ChronoUnit.DAYS), - null - ) + null, + ), ) Assertions.assertEquals(ReadingEventType.FINISHED, updated.eventType) Assertions.assertFalse(updated.creationDate?.isAfter(nowInstant().plus(2, ChronoUnit.HOURS))!!) @@ -538,9 +538,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) @@ -557,8 +557,8 @@ class ReadingEventServiceTest( UpdateReadingEventDto( ReadingEventType.FINISHED, nowInstant().plus(40, ChronoUnit.DAYS), - nowInstant().plus(41, ChronoUnit.DAYS) - ) + nowInstant().plus(41, ChronoUnit.DAYS), + ), ) } userbook = bookService.findUserBookById(saved.id!!) @@ -600,9 +600,9 @@ class ReadingEventServiceTest( ReadingEventType.FINISHED, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.FINISHED, newEvent.eventType) @@ -619,8 +619,8 @@ class ReadingEventServiceTest( UpdateReadingEventDto( ReadingEventType.FINISHED, null, - nowInstant().plus(41, ChronoUnit.DAYS) - ) + nowInstant().plus(41, ChronoUnit.DAYS), + ), ) } userbook = bookService.findUserBookById(saved.id!!) @@ -662,9 +662,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) @@ -681,8 +681,8 @@ class ReadingEventServiceTest( UpdateReadingEventDto( ReadingEventType.FINISHED, nowInstant().plus(20, ChronoUnit.DAYS), - null - ) + null, + ), ) } userbook = bookService.findUserBookById(saved.id!!) @@ -724,9 +724,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, thirtyDaysAfter, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEvent.eventType) @@ -743,9 +743,9 @@ class ReadingEventServiceTest( ReadingEventType.CURRENTLY_READING, saved.book.id, threeYearsBefore, - null + null, ), - user() + user(), ) Assertions.assertEquals(ReadingEventType.CURRENTLY_READING, newEventBefore.eventType) diff --git a/src/test/kotlin/io/github/bayang/jelu/service/ReviewServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/ReviewServiceTest.kt index fbc40a52..29b784ab 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/ReviewServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/ReviewServiceTest.kt @@ -25,7 +25,7 @@ import java.time.ZoneId class ReviewServiceTest( @Autowired private val userService: UserService, @Autowired private val bookService: BookService, - @Autowired private val reviewService: ReviewService + @Autowired private val reviewService: ReviewService, ) { val reviewText = """ @@ -54,11 +54,11 @@ class ReviewServiceTest( reviewText, 8.5, Visibility.PUBLIC, - bookDto.id!! + bookDto.id!!, ) val saved = reviewService.save( createReviewDto, - user() + user(), ) Assertions.assertNotNull(saved.id) Assertions.assertEquals(createReviewDto.visibility, saved.visibility) @@ -69,7 +69,7 @@ class ReviewServiceTest( text = "new text", rating = 5.0, reviewDate = null, - visibility = null + visibility = null, ) val updated = reviewService.update(saved.id!!, update) Assertions.assertEquals(update.rating, updated.rating) @@ -84,11 +84,11 @@ class ReviewServiceTest( reviewText, 8.5, Visibility.PUBLIC, - bookDto.id!! + bookDto.id!!, ) val saved1 = reviewService.save( createReviewDto1, - user() + user(), ) Assertions.assertEquals(oneYearBefore, saved1.reviewDate) found = reviewService.find(null, null, null, null, null, Pageable.ofSize(200)) diff --git a/src/test/kotlin/io/github/bayang/jelu/service/ShelfServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/ShelfServiceTest.kt index ff81df89..bbba73bd 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/ShelfServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/ShelfServiceTest.kt @@ -22,7 +22,7 @@ import java.util.UUID class ShelfServiceTest( @Autowired private val shelfService: ShelfService, @Autowired private val userService: UserService, - @Autowired private val bookService: BookService + @Autowired private val bookService: BookService, ) { @BeforeAll diff --git a/src/test/kotlin/io/github/bayang/jelu/service/UserMessageServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/UserMessageServiceTest.kt index ff7a79fe..37cc6005 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/UserMessageServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/UserMessageServiceTest.kt @@ -19,7 +19,7 @@ import org.springframework.data.domain.Pageable @TestInstance(TestInstance.Lifecycle.PER_CLASS) class UserMessageServiceTest( @Autowired private val userMessageService: UserMessageService, - @Autowired private val userService: UserService + @Autowired private val userService: UserService, ) { @BeforeAll @@ -40,9 +40,9 @@ class UserMessageServiceTest( CreateUserMessageDto( "this is a message", "/test/myfile.csv", - MessageCategory.INFO + MessageCategory.INFO, ), - user() + user(), ) Assertions.assertEquals("this is a message", saved.message) Assertions.assertEquals(MessageCategory.INFO, saved.category) diff --git a/src/test/kotlin/io/github/bayang/jelu/service/exports/CsvExportServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/exports/CsvExportServiceTest.kt index 8c6cc4ab..d010ed5a 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/exports/CsvExportServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/exports/CsvExportServiceTest.kt @@ -40,7 +40,7 @@ class CsvExportServiceTest( @Autowired private val userService: UserService, @Autowired private val jeluProperties: JeluProperties, @Autowired private val readingEventService: ReadingEventService, - @Autowired private val userMessageService: UserMessageService + @Autowired private val userMessageService: UserMessageService, ) { companion object { @@ -97,7 +97,7 @@ class CsvExportServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val createUserBookDto1 = CreateUserBookDto( personalNotes = "test personal notes\nwith a newline", @@ -107,7 +107,7 @@ class CsvExportServiceTest( toRead = true, percentRead = null, book = book1, - borrowed = null + borrowed = null, ) val saved1: UserBookLightDto = bookService.save(createUserBookDto1, user(), null) @@ -129,7 +129,7 @@ class CsvExportServiceTest( googleId = "1234", librarythingId = "", language = "", - amazonId = "" + amazonId = "", ) val offset = OffsetDateTime.now(ZoneId.systemDefault()).offset val date1 = OffsetDateTime.of(2022, 2, 10, 6, 30, 0, 0, offset) @@ -142,18 +142,18 @@ class CsvExportServiceTest( ReadingEventType.FINISHED, saved2.book.id, date3.toInstant(), - null + null, ), - user() + user(), ) readingEventService.save( CreateReadingEventDto( ReadingEventType.FINISHED, saved2.book.id, date2.toInstant(), - null + null, ), - user() + user(), ) readingEventService.save( @@ -161,27 +161,27 @@ class CsvExportServiceTest( ReadingEventType.DROPPED, saved1.book.id, date3.toInstant(), - null + null, ), - user() + user(), ) readingEventService.save( CreateReadingEventDto( ReadingEventType.DROPPED, saved1.book.id, date2.toInstant(), - null + null, ), - user() + user(), ) readingEventService.save( CreateReadingEventDto( ReadingEventType.CURRENTLY_READING, saved1.book.id, date1.toInstant(), - null + null, ), - user() + user(), ) csvExportService.export(user(), Locale.ENGLISH) val csv = File(jeluProperties.files.imports).listFiles()[0] diff --git a/src/test/kotlin/io/github/bayang/jelu/service/imports/CsvImportServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/imports/CsvImportServiceTest.kt index b6bac86e..88497c79 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/imports/CsvImportServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/imports/CsvImportServiceTest.kt @@ -35,7 +35,7 @@ class CsvImportServiceTest( @Autowired private val jeluProperties: JeluProperties, @Autowired private val readingEventService: ReadingEventService, @Autowired private val csvImportService: CsvImportService, - @Autowired private val importService: ImportService + @Autowired private val importService: ImportService, ) { companion object { @@ -131,7 +131,7 @@ class CsvImportServiceTest( csvImportService.parse( csv, userId, - ImportConfigurationDto(shouldFetchMetadata = true, shouldFetchCovers = false, ImportSource.GOODREADS) + ImportConfigurationDto(shouldFetchMetadata = true, shouldFetchCovers = false, ImportSource.GOODREADS), ) val nb = importService.countByprocessingStatusAndUser(ProcessingStatus.SAVED, userId) Assertions.assertEquals(10, nb) @@ -198,11 +198,11 @@ class CsvImportServiceTest( null, null, BookCreateDto( - image = CalibreMetadataProvider.FILE_PREFIX + "test.jpg" + image = CalibreMetadataProvider.FILE_PREFIX + "test.jpg", ), null, null, - null + null, ) bookService.update(imported.id!!, u, null) userbooksPage = bookService.findUserBookByCriteria(userId, null, null, null, null, null, Pageable.ofSize(30)) diff --git a/src/test/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataServiceTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataServiceTest.kt index a802a989..8f786bc5 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataServiceTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/metadata/FetchMetadataServiceTest.kt @@ -22,7 +22,7 @@ class FetchMetadataServiceTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)) + listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)), ) val providers = mutableListOf() val jeluDebug = mockk() @@ -49,7 +49,7 @@ class FetchMetadataServiceTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)) + listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)), ) val providers = mutableListOf() val jeluDebug = mockk() @@ -68,10 +68,10 @@ class FetchMetadataServiceTest { plugins = listOf( PluginInfo( name = PluginInfoHolder.jelu_debug, - order = 1 - ) - ) - ) + order = 1, + ), + ), + ), ) verify { jeluDebug.fetchMetadata(any(), any()) } verify(exactly = 0) { calibre.fetchMetadata(any(), any()) } @@ -86,7 +86,7 @@ class FetchMetadataServiceTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)) + listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)), ) val providers = mutableListOf() val jeluDebug = mockk() @@ -113,7 +113,7 @@ class FetchMetadataServiceTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)) + listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)), ) val providers = mutableListOf() val jeluDebug = mockk() @@ -132,14 +132,14 @@ class FetchMetadataServiceTest { plugins = listOf( PluginInfo( name = "not-existing", - order = 1 + order = 1, ), PluginInfo( name = "not-existing2", - order = 2 - ) - ) - ) + order = 2, + ), + ), + ), ) verify(exactly = 0) { jeluDebug.fetchMetadata(any(), any()) } verify(exactly = 0) { calibre.fetchMetadata(any(), any()) } @@ -154,7 +154,7 @@ class FetchMetadataServiceTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)) + listOf(JeluProperties.MetaDataProvider(PluginInfoHolder.jelu_debug, true, "", order = 10)), ) val providers = mutableListOf() val jeluDebug = mockk() @@ -173,14 +173,14 @@ class FetchMetadataServiceTest { plugins = listOf( PluginInfo( name = "not-existing", - order = 1 + order = 1, ), PluginInfo( name = PluginInfoHolder.jelu_debug, - order = 2 - ) - ) - ) + order = 2, + ), + ), + ), ) verify { jeluDebug.fetchMetadata(any(), any()) } verify(exactly = 0) { calibre.fetchMetadata(any(), any()) } diff --git a/src/test/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolderTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolderTest.kt index dd1fd98f..a1d0ac1d 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolderTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/metadata/PluginInfoHolderTest.kt @@ -15,7 +15,7 @@ class PluginInfoHolderTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("")), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key")) + listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key")), ) var info = PluginInfoHolder(jeluProperties) var plugins = info.plugins() @@ -31,7 +31,7 @@ class PluginInfoHolderTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path")), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key")) + listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key")), ) info = PluginInfoHolder(jeluProperties) plugins = info.plugins() @@ -47,7 +47,7 @@ class PluginInfoHolderTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key", order = 2)) + listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key", order = 2)), ) info = PluginInfoHolder(jeluProperties) plugins = info.plugins() @@ -63,7 +63,7 @@ class PluginInfoHolderTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("/path", order = 1)), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key", order = 1)) + listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key", order = 1)), ) info = PluginInfoHolder(jeluProperties) plugins = info.plugins() diff --git a/src/test/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProviderTest.kt b/src/test/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProviderTest.kt index 1e273bc0..75c0b012 100644 --- a/src/test/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProviderTest.kt +++ b/src/test/kotlin/io/github/bayang/jelu/service/metadata/providers/GoogleBooksIMetaDataProviderTest.kt @@ -95,9 +95,9 @@ class GoogleBooksIMetaDataProviderTest { " }\n" + " }\n" + " ]\n" + - "}\n" + "}\n", ) - .build() + .build(), ) }.build() @@ -108,14 +108,14 @@ class GoogleBooksIMetaDataProviderTest { JeluProperties.Cors(), JeluProperties.Metadata(JeluProperties.Calibre("")), JeluProperties.Auth(JeluProperties.Ldap(), JeluProperties.Proxy()), - listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key")) + listOf(JeluProperties.MetaDataProvider("google", true, "fake-google-api-key")), ) val service = GoogleBooksIMetaDataProvider(webClient, jeluProperties) // When val result: MetadataDto = service.fetchMetadata( MetadataRequestDto("9781785650406"), - mapOf() + mapOf(), )?.block()!! // Then @@ -127,7 +127,7 @@ class GoogleBooksIMetaDataProviderTest { Assertions.assertEquals(mutableSetOf("Jack Campbell"), result.authors) Assertions.assertEquals( "http://books.google.com/books/content?id=0GJOMQAACAAJ&printsec=frontcover&img=1&zoom=1&source=gbs_api", - result.image + result.image, ) Assertions.assertEquals("en", result.language) Assertions.assertEquals("2017-05", result.publishedDate)