refactor(api): replace FQNs with proper imports (#1206)

This commit is contained in:
brios
2026-05-08 17:13:29 +02:00
committed by GitHub
parent 633f011319
commit 2deb25a911
83 changed files with 405 additions and 298 deletions
@@ -46,6 +46,8 @@ import java.util.stream.Collectors;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import jakarta.persistence.Query;
import java.time.Duration;
@Service
@Transactional(readOnly = true)
@@ -66,7 +68,7 @@ public class AppBookService {
private final EntityManager entityManager;
private final Cache<String, AppFilterOptions> filterOptionsCache = Caffeine.newBuilder()
.expireAfterWrite(java.time.Duration.ofSeconds(30))
.expireAfterWrite(Duration.ofSeconds(30))
.maximumSize(50)
.build();
@@ -1175,7 +1177,7 @@ public class AppBookService {
return sb.toString();
}
private void setFilterQueryParams(jakarta.persistence.Query query, Set<Long> accessibleLibraryIds, Long libraryId, Long shelfId, Set<Long> magicBookIds) {
private void setFilterQueryParams(Query query, Set<Long> accessibleLibraryIds, Long libraryId, Long shelfId, Set<Long> magicBookIds) {
if (libraryId != null) {
query.setParameter("libraryId", libraryId);
} else if (accessibleLibraryIds != null) {
@@ -26,6 +26,7 @@ import java.time.Instant;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import jakarta.persistence.Query;
@Service
@AllArgsConstructor
@@ -317,7 +318,7 @@ public class AppSeriesService {
return "";
}
private void setLibraryParams(jakarta.persistence.Query query, Set<Long> accessibleLibraryIds, Long libraryId) {
private void setLibraryParams(Query query, Set<Long> accessibleLibraryIds, Long libraryId) {
if (libraryId != null) {
query.setParameter("libraryId", libraryId);
} else if (accessibleLibraryIds != null) {
@@ -14,6 +14,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
import org.springframework.web.client.RestClientException;
@Slf4j
@Service
@@ -75,7 +76,7 @@ public class OidcTokenClient {
(String) response.get("token_type"),
response.get("expires_in") instanceof Number n ? n.intValue() : null
);
} catch (org.springframework.web.client.RestClientException e) {
} catch (RestClientException e) {
log.error("OIDC token exchange failed: {}", e.getMessage());
throw ApiError.OIDC_PROVIDER_UNREACHABLE.createException(e.getMessage());
}
@@ -99,7 +100,7 @@ public class OidcTokenClient {
.exchange(userinfoEndpoint, HttpMethod.GET, new HttpEntity<>(headers), Map.class);
return response.getBody() != null ? response.getBody() : Map.of();
} catch (org.springframework.web.client.RestClientException e) {
} catch (RestClientException e) {
log.warn("Failed to fetch userinfo: {}", e.getMessage());
return Map.of();
}
@@ -32,6 +32,9 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;
import java.text.ParseException;
import java.net.MalformedURLException;
import java.net.URL;
@Slf4j
@Service
@@ -125,7 +128,7 @@ public class OidcTokenValidator {
if (azp != null && !azp.equals(clientId)) {
throw ApiError.OIDC_INVALID_TOKEN.createException("ID token authorized party mismatch");
}
} catch (java.text.ParseException e) {
} catch (ParseException e) {
throw ApiError.OIDC_INVALID_TOKEN.createException("Failed to parse azp claim");
}
}
@@ -157,7 +160,7 @@ public class OidcTokenValidator {
if (!expectedNonce.equals(tokenNonce)) {
throw ApiError.OIDC_INVALID_TOKEN.createException("ID token nonce mismatch");
}
} catch (java.text.ParseException e) {
} catch (ParseException e) {
throw ApiError.OIDC_INVALID_TOKEN.createException("Failed to parse nonce claim");
}
}
@@ -184,7 +187,7 @@ public class OidcTokenValidator {
}
} catch (APIException e) {
throw e;
} catch (java.text.ParseException | NoSuchAlgorithmException e) {
} catch (ParseException | NoSuchAlgorithmException e) {
log.warn("Failed to validate at_hash: {}", e.getMessage());
}
}
@@ -228,10 +231,10 @@ public class OidcTokenValidator {
}
}
private static java.net.URL uriToUrl(URI uri) {
private static URL uriToUrl(URI uri) {
try {
return uri.toURL();
} catch (java.net.MalformedURLException e) {
} catch (MalformedURLException e) {
throw new IllegalStateException("Invalid JWKS URI: " + uri, e);
}
}
@@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
import java.io.IOException;
@Tag(name = "Books", description = "Endpoints for managing books, their metadata, progress, and recommendations")
@RequestMapping("/api/v1/books")
@@ -175,7 +176,7 @@ public class BookController {
public ResponseEntity<Void> replaceBookContent(
@Parameter(description = "ID of the book") @PathVariable long bookId,
@Parameter(description = "Optional book type for alternative format") @RequestParam(required = false) String bookType,
HttpServletRequest request) throws java.io.IOException {
HttpServletRequest request) throws IOException {
bookService.replaceBookContent(bookId, bookType, request.getInputStream());
return ResponseEntity.noContent().build();
}
@@ -24,6 +24,8 @@ import reactor.core.scheduler.Schedulers;
import java.util.List;
import java.util.Map;
import jakarta.validation.constraints.NotEmpty;
import java.util.Set;
@RestController
@RequestMapping("/api/v1/books")
@@ -144,7 +146,7 @@ public class BookCoverController {
@PreAuthorize("@securityUtil.canBulkEditMetadata() or @securityUtil.isAdmin()")
public void bulkUploadCover(
@Parameter(description = "Cover image file") @RequestParam("file") MultipartFile file,
@Parameter(description = "Comma-separated book IDs") @RequestParam("bookIds") @jakarta.validation.constraints.NotEmpty java.util.Set<Long> bookIds) {
@Parameter(description = "Comma-separated book IDs") @RequestParam("bookIds") @NotEmpty Set<Long> bookIds) {
bookCoverService.updateCoverFromFileForBooks(bookIds, file);
}
@@ -163,4 +165,4 @@ public class BookCoverController {
.build())
.onErrorMap(e -> ApiError.INTERNAL_SERVER_ERROR.createException("DuckDuckGo cover fetch failed"));
}
}
}
@@ -52,7 +52,7 @@ public class AnnotationEntity {
@Column(name = "chapter_title", length = 500)
private String chapterTitle;
@jakarta.persistence.Version
@Version
@Column(name = "version", nullable = false)
private Long version;
@@ -132,7 +132,7 @@ public class BookFileEntity {
Path folderPath = getFullFilePath();
try (var files = Files.list(folderPath)) {
return files
.filter(java.nio.file.Files::isRegularFile)
.filter(Files::isRegularFile)
.filter(p -> {
String name = p.getFileName().toString().toLowerCase();
return name.endsWith(".mp3") || name.endsWith(".m4a") || name.endsWith(".m4b") || name.endsWith(".opus");
@@ -61,7 +61,7 @@ public class BookMarkEntity {
@Column(name = "priority")
private Integer priority;
@jakarta.persistence.Version
@Version
@Column(name = "version", nullable = false)
private Long version;
@@ -49,7 +49,7 @@ public class BookNoteV2Entity {
@Column(name = "chapter_title", length = 500)
private String chapterTitle;
@jakarta.persistence.Version
@Version
@Column(name = "version", nullable = false)
private Long version;
@@ -41,7 +41,7 @@ public class PdfAnnotationEntity {
@Column(name = "data", nullable = false, columnDefinition = "LONGTEXT")
private String data;
@jakarta.persistence.Version
@Version
@Column(name = "version", nullable = false)
private Long version;
@@ -7,6 +7,8 @@ import java.lang.reflect.Method;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import com.github.gotson.nightcompress.Archive;
import org.grimmory.pdfium4j.PdfiumLibrary;
/**
* JVM-wide single source of truth for native-library availability.
@@ -33,11 +35,11 @@ public final class NativeLibraries {
if (clean != null) {
return clean;
}
org.grimmory.pdfium4j.PdfiumLibrary.initialize();
PdfiumLibrary.initialize();
return true;
}));
probes.put(Library.LIBARCHIVE, new Probe("libarchive", com.github.gotson.nightcompress.Archive::isAvailable));
probes.put(Library.LIBARCHIVE, new Probe("libarchive", Archive::isAvailable));
probes.put(Library.EPUB4J_NATIVE, new Probe("epub4j-native", () -> {
Boolean clean = tryInvokeStaticBoolean(
@@ -16,6 +16,7 @@ import java.time.Instant;
import java.time.LocalDate;
import java.util.List;
import java.util.stream.Stream;
import java.time.LocalDateTime;
@Repository
public interface ReadingSessionRepository extends JpaRepository<ReadingSessionEntity, Long> {
@@ -85,8 +86,8 @@ public interface ReadingSessionRepository extends JpaRepository<ReadingSessionEn
""")
List<ReadingSpeedDto> findReadingSpeedByUserAndYear(
@Param("userId") Long userId,
@Param("periodStart") java.time.LocalDateTime periodStart,
@Param("periodEnd") java.time.LocalDateTime periodEnd);
@Param("periodStart") LocalDateTime periodStart,
@Param("periodEnd") LocalDateTime periodEnd);
@Query("""
SELECT rs.startTime as startTime,
@@ -23,8 +23,8 @@ public interface ShelfRepository extends JpaRepository<ShelfEntity, Long> {
@Query("SELECT s FROM ShelfEntity s WHERE s.id = :id")
Optional<ShelfEntity> findByIdWithUser(@Param("id") Long id);
@org.springframework.data.jpa.repository.Query("SELECT s FROM ShelfEntity s WHERE s.user.id = :userId OR s.isPublic = true")
List<ShelfEntity> findByUserIdOrPublicShelfTrue(@org.springframework.data.repository.query.Param("userId") Long userId);
@Query("SELECT s FROM ShelfEntity s WHERE s.user.id = :userId OR s.isPublic = true")
List<ShelfEntity> findByUserIdOrPublicShelfTrue(@Param("userId") Long userId);
List<ShelfEntity> findByUserIdInAndName(List<Long> userIds, String name);
}
@@ -130,7 +130,7 @@ public interface UserBookProgressRepository extends JpaRepository<UserBookProgre
WHERE ubp.user.id = :userId
AND ubp.book.id IN :bookIds
""")
int bulkResetBookloreProgress(@Param("userId") Long userId, @Param("bookIds") List<Long> bookIds, @Param("modifiedTime") java.time.Instant modifiedTime);
int bulkResetBookloreProgress(@Param("userId") Long userId, @Param("bookIds") List<Long> bookIds, @Param("modifiedTime") Instant modifiedTime);
@Modifying
@Transactional
@@ -41,6 +41,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.time.Duration;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Stream;
@Slf4j
@Service
@@ -86,7 +92,7 @@ public class AuthorMetadataService {
return authorParserMap.values().stream()
.flatMap(provider -> {
List<AuthorSearchResult> results = provider.searchAuthors(name, region);
return results != null ? results.stream() : java.util.stream.Stream.empty();
return results != null ? results.stream() : Stream.empty();
})
.toList();
}
@@ -94,7 +100,7 @@ public class AuthorMetadataService {
public List<AuthorSearchResult> lookupAuthorByAsin(String asin, String region) {
return authorParserMap.values().stream()
.map(provider -> provider.getAuthorByAsin(asin, region))
.filter(java.util.Objects::nonNull)
.filter(Objects::nonNull)
.toList();
}
@@ -166,14 +172,14 @@ public class AuthorMetadataService {
.build();
})
.subscribeOn(Schedulers.boundedElastic())
.delayElement(java.time.Duration.ofMillis(
java.util.concurrent.ThreadLocalRandom.current().nextLong(250, 750)))
.delayElement(Duration.ofMillis(
ThreadLocalRandom.current().nextLong(250, 750)))
.onErrorResume(e -> {
log.warn("Failed to auto-match author ID {}: {}", authorId, e.getMessage());
return Mono.empty();
})
)
.filter(java.util.Objects::nonNull);
.filter(Objects::nonNull);
}
@Transactional
@@ -246,13 +252,13 @@ public class AuthorMetadataService {
validatePhoto(file);
try {
java.awt.image.BufferedImage image = FileService.readImage(file.getInputStream());
BufferedImage image = FileService.readImage(file.getInputStream());
if (image == null) {
throw ApiError.FILE_READ_ERROR.createException("Failed to decode image");
}
fileService.saveAuthorImages(image, authorId);
image.flush();
} catch (java.io.IOException e) {
} catch (IOException e) {
throw ApiError.FILE_READ_ERROR.createException(e.getMessage());
}
}
@@ -20,6 +20,7 @@ import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
@Slf4j
@Service
@@ -577,7 +578,7 @@ public class BookRuleEvaluatorService {
private Predicate buildStringPredicate(RuleField field, CriteriaQuery<?> query, Root<BookEntity> root,
Join<BookEntity, UserBookProgressEntity> progressJoin,
CriteriaBuilder cb,
java.util.function.Function<Expression<String>, Predicate> predicateBuilder) {
Function<Expression<String>, Predicate> predicateBuilder) {
if (isArrayField(field)) {
Subquery<Long> subquery = query.subquery(Long.class);
Root<BookEntity> subRoot = subquery.from(BookEntity.class);
@@ -728,7 +729,7 @@ public class BookRuleEvaluatorService {
}
private Predicate buildFieldInPredicate(RuleField ruleField,
java.util.function.Function<Expression<?>, Expression<?>> fieldTransformer,
Function<Expression<?>, Expression<?>> fieldTransformer,
List<String> ruleList,
CriteriaBuilder cb,
Root<BookEntity> root,
@@ -26,6 +26,7 @@ import java.util.stream.Stream;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import java.time.Duration;
@Slf4j
@RequiredArgsConstructor
@@ -37,7 +38,7 @@ public class IconService {
private final Cache<String, String> svgCache = Caffeine.newBuilder()
.maximumSize(200)
.expireAfterAccess(java.time.Duration.ofHours(1))
.expireAfterAccess(Duration.ofHours(1))
.build();
private static final String ICONS_DIR = "icons";
@@ -46,7 +46,7 @@ public class ShelfService {
throw ApiError.SHELF_ALREADY_EXISTS.createException(request.getName());
}
if (request.isPublicShelf() && !authenticationService.getAuthenticatedUser().getPermissions().isAdmin()) {
throw new org.springframework.security.access.AccessDeniedException("Only admins can create public shelves");
throw new AccessDeniedException("Only admins can create public shelves");
}
ShelfEntity shelfEntity = ShelfEntity.builder()
.icon(request.getIcon())
@@ -37,6 +37,8 @@ import java.util.List;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.ByteArrayOutputStream;
import org.springframework.core.io.ByteArrayResource;
@Slf4j
@AllArgsConstructor
@@ -332,7 +334,7 @@ public class BookDownloadService {
}
private ResponseEntity<Resource> downloadFolderAsZip(Path folderPath, String folderName) throws IOException {
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (ZipOutputStream zos = new ZipOutputStream(baos)) {
// Get all files in the folder, sorted by name
@@ -350,7 +352,7 @@ public class BookDownloadService {
}
byte[] zipBytes = baos.toByteArray();
Resource resource = new org.springframework.core.io.ByteArrayResource(zipBytes);
Resource resource = new ByteArrayResource(zipBytes);
String zipFileName = folderName + ".zip";
@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.time.Instant;
@RequiredArgsConstructor
@Service
@@ -98,7 +99,7 @@ public class BookQueryService {
if (embeddingJson != null && book.getMetadata() != null) {
if (!Objects.equals(book.getMetadata().getEmbeddingVector(), embeddingJson)) {
book.getMetadata().setEmbeddingVector(embeddingJson);
book.getMetadata().setEmbeddingUpdatedAt(java.time.Instant.now());
book.getMetadata().setEmbeddingUpdatedAt(Instant.now());
}
}
}
@@ -42,6 +42,7 @@ import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.stream.Collectors;
import java.io.InputStream;
@Slf4j
@AllArgsConstructor
@@ -385,7 +386,7 @@ public class BookService {
.body(new FileSystemResource(file));
}
public void replaceBookContent(long bookId, String bookType, java.io.InputStream content) throws IOException {
public void replaceBookContent(long bookId, String bookType, InputStream content) throws IOException {
BookEntity bookEntity = bookRepository.findByIdWithBookFiles(bookId)
.orElseThrow(() -> ApiError.BOOK_NOT_FOUND.createException(bookId));
@@ -471,9 +472,9 @@ public class BookService {
if (!Files.exists(path)) return;
try (var walk = Files.walk(path)) {
walk.sorted(java.util.Comparator.reverseOrder())
walk.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(java.io.File::delete);
.forEach(File::delete);
}
}
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Consumer;
@Slf4j
@Service
@@ -122,7 +123,7 @@ public class BookdropBulkEditService {
private void updateArrayField(String fieldName, Set<String> enabledFields,
List<String> currentValue, List<String> newValue,
java.util.function.Consumer<List<String>> setter, boolean mergeArrays) {
Consumer<List<String>> setter, boolean mergeArrays) {
if (enabledFields.contains(fieldName) && newValue != null) {
if (mergeArrays && currentValue != null) {
List<String> merged = new ArrayList<>(currentValue);
@@ -138,7 +139,7 @@ public class BookdropBulkEditService {
private void updateArrayField(String fieldName, Set<String> enabledFields,
Set<String> currentValue, Set<String> newValue,
java.util.function.Consumer<Set<String>> setter, boolean mergeArrays) {
Consumer<Set<String>> setter, boolean mergeArrays) {
if (enabledFields.contains(fieldName) && newValue != null) {
if (mergeArrays && currentValue != null) {
Set<String> merged = new LinkedHashSet<>(currentValue);
@@ -151,4 +152,4 @@ public class BookdropBulkEditService {
}
private record BatchEditResult(int successCount, int failureCount) {}
}
}
@@ -21,6 +21,7 @@ import java.util.concurrent.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.time.MonthDay;
@Slf4j
@Service
@@ -445,7 +446,7 @@ public class FilenamePatternExtractor {
try {
if ("yyyy".equals(detectedFormat)) {
Year year = Year.parse(value, DateTimeFormatter.ofPattern("yyyy"));
metadata.setPublishedDate(year.atMonthDay(java.time.MonthDay.of(1, 1)));
metadata.setPublishedDate(year.atMonthDay(MonthDay.of(1, 1)));
return;
}
@@ -29,6 +29,7 @@ import java.util.Optional;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.io.File;
@Slf4j
@AllArgsConstructor
@@ -89,9 +90,9 @@ public class AdditionalFileService {
if (!Files.exists(path)) return;
try (var walk = Files.walk(path)) {
walk.sorted(java.util.Comparator.reverseOrder())
walk.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(java.io.File::delete);
.forEach(File::delete);
}
}
@@ -31,6 +31,8 @@ import java.util.Set;
import java.util.stream.Collectors;
import static org.booklore.util.FileService.truncate;
import java.nio.file.Path;
import java.nio.file.Paths;
@Slf4j
@Service
@@ -155,9 +157,9 @@ public class AudiobookProcessor extends AbstractFileProcessor implements BookFil
private File getAudioFileForMetadata(BookEntity bookEntity, boolean isFolderBased) {
if (isFolderBased) {
java.nio.file.Path folderPath = bookEntity.getFullFilePath();
Path folderPath = bookEntity.getFullFilePath();
return FileUtils.getFirstAudioFileInFolder(folderPath)
.map(java.nio.file.Path::toFile)
.map(Path::toFile)
.orElse(null);
} else {
return FileUtils.getBookFullPath(bookEntity).toFile();
@@ -179,11 +181,11 @@ public class AudiobookProcessor extends AbstractFileProcessor implements BookFil
return null;
}
java.nio.file.Path filePath;
Path filePath;
if (subPath == null || subPath.isEmpty()) {
filePath = java.nio.file.Paths.get(libraryPath, fileName).normalize();
filePath = Paths.get(libraryPath, fileName).normalize();
} else {
filePath = java.nio.file.Paths.get(libraryPath, subPath, fileName).normalize();
filePath = Paths.get(libraryPath, subPath, fileName).normalize();
}
log.debug("Constructed audiobook path: {}, isFolderBased: {}", filePath, bookFile.isFolderBased());
@@ -193,7 +195,7 @@ public class AudiobookProcessor extends AbstractFileProcessor implements BookFil
if (audioFile.isEmpty()) {
log.debug("No audio file found in folder: {}", filePath);
}
return audioFile.map(java.nio.file.Path::toFile).orElse(null);
return audioFile.map(Path::toFile).orElse(null);
} else {
return filePath.toFile();
}
@@ -19,6 +19,8 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Service to sync reading progress to Hardcover.
@@ -286,7 +288,7 @@ public class HardcoverSyncService {
GraphQLRequest request = new GraphQLRequest();
request.setQuery(query);
Map<String, Object> variables = new java.util.HashMap<>();
Map<String, Object> variables = new HashMap<>();
variables.put("bookId", bookId);
variables.put("isbn13", (isbn13 != null && !isbn13.isBlank()) ? isbn13 : "");
variables.put("isbn10", (isbn10 != null && !isbn10.isBlank()) ? isbn10 : "");
@@ -394,7 +396,7 @@ public class HardcoverSyncService {
GraphQLRequest request = new GraphQLRequest();
request.setQuery(query);
Map<String, Object> variables = new java.util.HashMap<>();
Map<String, Object> variables = new HashMap<>();
variables.put("isbn13", (isbn13 != null && !isbn13.isBlank()) ? isbn13 : "");
variables.put("isbn10", (isbn10 != null && !isbn10.isBlank()) ? isbn10 : "");
request.setVariables(variables);
@@ -476,7 +478,7 @@ public class HardcoverSyncService {
GraphQLRequest request = new GraphQLRequest();
request.setQuery(query);
Map<String, Object> variables = new java.util.HashMap<>();
Map<String, Object> variables = new HashMap<>();
variables.put("bookId", bookId);
request.setVariables(variables);
@@ -543,7 +545,7 @@ public class HardcoverSyncService {
}
""";
Map<String, Object> bookInput = new java.util.HashMap<>();
Map<String, Object> bookInput = new HashMap<>();
bookInput.put("book_id", bookId);
bookInput.put("edition_id", editionId);
bookInput.put("status_id", STATUS_CURRENTLY_READING);
@@ -621,7 +623,7 @@ public class HardcoverSyncService {
}
""";
Map<String, Object> bookInput = new java.util.HashMap<>();
Map<String, Object> bookInput = new HashMap<>();
bookInput.put("edition_id", editionId);
bookInput.put("status_id", STATUS_CURRENTLY_READING);
@@ -687,11 +689,11 @@ public class HardcoverSyncService {
}
""";
Map<String, Object> bookInput = new java.util.HashMap<>();
Map<String, Object> bookInput = new HashMap<>();
bookInput.put("edition_id", editionId);
bookInput.put("status_id", isFinished ? STATUS_READ : STATUS_CURRENTLY_READING);
Map<String, Object> readInput = new java.util.HashMap<>();
Map<String, Object> readInput = new HashMap<>();
readInput.put("started_at", LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
readInput.put("progress_pages", progressPages);
if (isFinished) {
@@ -752,7 +754,7 @@ public class HardcoverSyncService {
}
""";
Map<String, Object> readInput = new java.util.HashMap<>();
Map<String, Object> readInput = new HashMap<>();
readInput.put("edition_id", readInfo.editionId);
readInput.put("started_at", readInfo.startedAt);
readInput.put("progress_pages", readInfo.progressPages);
@@ -863,7 +865,7 @@ public class HardcoverSyncService {
static UserBookWithReads fromMap(Map<String, Object> userBook) {
UserBookWithReads result = new UserBookWithReads();
result.reads = new java.util.ArrayList<>();
result.reads = new ArrayList<>();
result.id = extractInteger(userBook.get("id"));
result.statusId = extractInteger(userBook.get("status_id"));
result.editionId = extractInteger(userBook.get("edition_id"));
@@ -32,6 +32,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.util.*;
import java.util.zip.CRC32;
/**
* Service for converting comic book archive files (CBX) to EPUB format.
@@ -568,7 +569,7 @@ public class CbxConversionService {
}
private long calculateCrc32(byte[] data) {
java.util.zip.CRC32 crc32 = new java.util.zip.CRC32();
CRC32 crc32 = new CRC32();
crc32.update(data);
return crc32.getValue();
}
@@ -24,6 +24,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import static org.booklore.service.kobo.KoboEpubUtils.normalizeHref;
import org.jsoup.nodes.Document;
@Service
@Slf4j
@@ -173,7 +174,7 @@ public class KoboSpanMapExtractionService {
return new ExtractedChapter(zipEntry.getName(), spineIndex, 1, List.of());
}
org.jsoup.nodes.Document document = Jsoup.parse(html, "", Parser.htmlParser().setTrackPosition(true));
Document document = Jsoup.parse(html, "", Parser.htmlParser().setTrackPosition(true));
List<KoboSpanPositionMap.Span> spans = document.select("span.koboSpan[id]").stream()
.map(span -> {
if (span.id().isBlank() || span.sourceRange() == null) {
@@ -16,6 +16,7 @@ import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.io.IOException;
@Service
@RequiredArgsConstructor
@@ -26,7 +27,7 @@ public class KoboSpanMapService {
private final KoboSpanMapExtractionService koboSpanMapExtractionService;
@Transactional
public void computeAndStoreIfNeeded(BookFileEntity bookFile, File kepubFile) throws java.io.IOException {
public void computeAndStoreIfNeeded(BookFileEntity bookFile, File kepubFile) throws IOException {
if (bookFile == null || bookFile.getId() == null) {
return;
}
@@ -109,8 +109,8 @@ public class MetadataManagementService {
List<AuthorEntity> authorsToMerge = valuesToMerge.stream()
.map(authorRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (AuthorEntity oldAuthor : authorsToMerge) {
@@ -147,8 +147,8 @@ public class MetadataManagementService {
List<CategoryEntity> categoriesToMerge = valuesToMerge.stream()
.map(categoryRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (CategoryEntity oldCategory : categoriesToMerge) {
@@ -184,8 +184,8 @@ public class MetadataManagementService {
List<MoodEntity> moodsToMerge = valuesToMerge.stream()
.map(moodRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (MoodEntity oldMood : moodsToMerge) {
@@ -222,8 +222,8 @@ public class MetadataManagementService {
List<TagEntity> tagsToMerge = valuesToMerge.stream()
.map(tagRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (TagEntity oldTag : tagsToMerge) {
@@ -323,8 +323,8 @@ public class MetadataManagementService {
private void deleteAuthors(List<String> valuesToDelete, boolean moveFile) {
List<AuthorEntity> authorsToDelete = valuesToDelete.stream()
.map(authorRepository::findByName)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (AuthorEntity author : authorsToDelete) {
@@ -346,8 +346,8 @@ public class MetadataManagementService {
private void deleteCategories(List<String> valuesToDelete, boolean moveFile) {
List<CategoryEntity> categoriesToDelete = valuesToDelete.stream()
.map(categoryRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (CategoryEntity category : categoriesToDelete) {
@@ -369,8 +369,8 @@ public class MetadataManagementService {
private void deleteMoods(List<String> valuesToDelete, boolean moveFile) {
List<MoodEntity> moodsToDelete = valuesToDelete.stream()
.map(moodRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (MoodEntity mood : moodsToDelete) {
@@ -392,8 +392,8 @@ public class MetadataManagementService {
private void deleteTags(List<String> valuesToDelete, boolean moveFile) {
List<TagEntity> tagsToDelete = valuesToDelete.stream()
.map(tagRepository::findByNameIgnoreCase)
.filter(java.util.Optional::isPresent)
.map(java.util.Optional::get)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
for (TagEntity tag : tagsToDelete) {
@@ -22,6 +22,11 @@ import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer;
import java.util.regex.Matcher;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@Slf4j
@Component
@@ -303,31 +308,31 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
if (url.isBlank()) continue;
url = url.trim();
java.util.regex.Matcher grMatcher = GOODREADS_URL_PATTERN.matcher(url);
Matcher grMatcher = GOODREADS_URL_PATTERN.matcher(url);
if (grMatcher.find()) {
builder.goodreadsId(grMatcher.group(1));
continue;
}
java.util.regex.Matcher azMatcher = AMAZON_URL_PATTERN.matcher(url);
Matcher azMatcher = AMAZON_URL_PATTERN.matcher(url);
if (azMatcher.find()) {
builder.asin(azMatcher.group(1));
continue;
}
java.util.regex.Matcher cvMatcher = COMICVINE_URL_PATTERN.matcher(url);
Matcher cvMatcher = COMICVINE_URL_PATTERN.matcher(url);
if (cvMatcher.find()) {
builder.comicvineId(cvMatcher.group(1));
continue;
}
java.util.regex.Matcher cvSiteMatcher = COMICVINE_SITE_URL_PATTERN.matcher(url);
Matcher cvSiteMatcher = COMICVINE_SITE_URL_PATTERN.matcher(url);
if (cvSiteMatcher.find()) {
builder.comicvineId(cvSiteMatcher.group(1));
continue;
}
java.util.regex.Matcher hcMatcher = HARDCOVER_URL_PATTERN.matcher(url);
Matcher hcMatcher = HARDCOVER_URL_PATTERN.matcher(url);
if (hcMatcher.find()) {
builder.hardcoverId(hcMatcher.group(1));
continue;
@@ -336,7 +341,7 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
}
private void parseNotes(String notes, BookMetadata.BookMetadataBuilder builder) {
java.util.regex.Matcher matcher = BOOKLORE_NOTE_PATTERN.matcher(notes);
Matcher matcher = BOOKLORE_NOTE_PATTERN.matcher(notes);
while (matcher.find()) {
String key = matcher.group(1).trim();
String value = matcher.group(2).trim();
@@ -373,7 +378,7 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
}
}
private void safeParseDouble(String value, java.util.function.DoubleConsumer consumer) {
private void safeParseDouble(String value, DoubleConsumer consumer) {
try {
consumer.accept(Double.parseDouble(value));
} catch (NumberFormatException e) {
@@ -381,7 +386,7 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
}
}
private void safeParseInt(String value, java.util.function.IntConsumer consumer) {
private void safeParseInt(String value, IntConsumer consumer) {
try {
consumer.accept(Integer.parseInt(value));
} catch (NumberFormatException e) {
@@ -519,8 +524,8 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
NodeList pages = document.getElementsByTagName("Page");
for (int i = 0; i < pages.getLength(); i++) {
try {
org.w3c.dom.Node node = pages.item(i);
if (!(node instanceof org.w3c.dom.Element page)) {
Node node = pages.item(i);
if (!(node instanceof Element page)) {
continue;
}
@@ -34,6 +34,8 @@ import java.util.*;
import java.util.regex.Pattern;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer;
@Slf4j
@Component
@@ -432,14 +434,14 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
}
}
private static void safeParseInt(String value, java.util.function.IntConsumer setter) {
private static void safeParseInt(String value, IntConsumer setter) {
try {
setter.accept(Integer.parseInt(value));
} catch (NumberFormatException _) {
}
}
private static void safeParseDouble(String value, java.util.function.DoubleConsumer setter) {
private static void safeParseDouble(String value, DoubleConsumer setter) {
try {
setter.accept(Double.parseDouble(value));
} catch (NumberFormatException _) {
@@ -592,7 +594,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
String combined = basePath + href;
// Normalize path components to handle ".." and "."
java.util.LinkedList<String> parts = new java.util.LinkedList<>();
LinkedList<String> parts = new LinkedList<>();
for (String part : combined.split("/")) {
if ("..".equals(part)) {
if (!parts.isEmpty()) parts.removeLast();
@@ -24,6 +24,8 @@ import java.time.LocalDate;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.w3c.dom.Node;
import java.util.function.Consumer;
@Component
@Slf4j
@@ -104,7 +106,7 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
Set<String> categories = Arrays.stream(parts)
.map(String::trim)
.filter(StringUtils::isNotBlank)
.collect(java.util.stream.Collectors.toSet());
.collect(Collectors.toSet());
if (!categories.isEmpty()) {
metadataBuilder.categories(categories);
}
@@ -481,7 +483,7 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
* Extracts a rating field, trying both new camelCase and old PascalCase format.
*/
private void extractBookloreRating(XPath xpath, Document doc, String newName, String legacyName,
java.util.function.Consumer<Double> setter) {
Consumer<Double> setter) {
try {
String value = xpath.evaluate("//booklore:" + newName + "/text()", doc);
if (StringUtils.isBlank(value)) {
@@ -566,7 +568,7 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
return result == null ? "" : result.trim();
}
private String xpathEvaluate(XPath xpath, org.w3c.dom.Node node, String expression) throws XPathExpressionException {
private String xpathEvaluate(XPath xpath, Node node, String expression) throws XPathExpressionException {
String result = xpath.evaluate(expression, node);
return result == null ? "" : result.trim();
}
@@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.text.DecimalFormat;
@Slf4j
@Service
@@ -982,7 +983,7 @@ public class ComicvineBookParser implements BookParser, DetailedMetadataProvider
if (d == Math.floor(d)) {
return String.valueOf((int) d);
} else {
return new java.text.DecimalFormat("0.#####").format(d);
return new DecimalFormat("0.#####").format(d);
}
} else {
return String.valueOf(Integer.parseInt(issueNumber));
@@ -1022,4 +1023,4 @@ public class ComicvineBookParser implements BookParser, DetailedMetadataProvider
}
private record SeriesAndIssue(String series, String issue, Integer year, String issueType, String remainder) {}
}
}
@@ -23,6 +23,9 @@ import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.nio.channels.UnresolvedAddressException;
@Service
@Slf4j
@@ -450,9 +453,9 @@ public class LubimyCzytacParser implements BookParser {
private boolean isConnectivityError(Exception e) {
Throwable cause = e;
while (cause != null) {
if (e instanceof java.net.ConnectException ||
e instanceof java.nio.channels.UnresolvedAddressException ||
e instanceof java.net.SocketTimeoutException) {
if (e instanceof ConnectException ||
e instanceof UnresolvedAddressException ||
e instanceof SocketTimeoutException) {
return true;
}
cause = cause.getCause();
@@ -11,6 +11,7 @@ import org.springframework.web.client.RestClientResponseException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.Map;
@Slf4j
@Service
@@ -91,7 +92,7 @@ public class HardcoverBookSearchService {
}
}
}""");
body.setVariables(java.util.Map.of("isbn", isbn));
body.setVariables(Map.of("isbn", isbn));
GraphQLResponse response = executeRequest(body, GraphQLResponse.class, apiToken);
if (response == null || response.getData() == null ||
@@ -117,7 +118,7 @@ public class HardcoverBookSearchService {
GraphQLRequest body = new GraphQLRequest();
body.setQuery("query BookSearch($q: String!, $limit: Int!) { search(query: $q, query_type: \"Book\", per_page: $limit, page: 1) { results } }");
body.setVariables(java.util.Map.of("q", query, "limit", sanitizedPerPage));
body.setVariables(Map.of("q", query, "limit", sanitizedPerPage));
GraphQLResponse response = executeRequest(body, GraphQLResponse.class, apiToken);
if (response == null || response.getData() == null ||
@@ -138,7 +139,7 @@ public class HardcoverBookSearchService {
GraphQLRequest body = new GraphQLRequest();
body.setQuery("query BookDetails($id: Int!) { books_by_pk(id: $id) { id title cached_tags } }");
body.setVariables(java.util.Map.of("id", bookId));
body.setVariables(Map.of("id", bookId));
HardcoverBookDetailsResponse response = executeRequest(body, HardcoverBookDetailsResponse.class, apiToken);
if (response == null || response.getData() == null) {
@@ -46,7 +46,7 @@ public class CbxMetadataWriter implements MetadataWriter {
static {
try {
JAXB_CONTEXT = JAXBContext.newInstance(ComicInfo.class);
} catch (jakarta.xml.bind.JAXBException e) {
} catch (JAXBException e) {
throw new RuntimeException("Failed to initialize JAXB Context", e);
}
}
@@ -48,6 +48,8 @@ import java.util.zip.ZipOutputStream;
import org.grimmory.epub4j.archive.EpubContainer;
import org.grimmory.epub4j.archive.EpubContainers;
import java.util.function.Predicate;
import java.io.UncheckedIOException;
@Slf4j
@Component
@@ -576,7 +578,7 @@ public class EpubMetadataWriter implements MetadataWriter {
zos.closeEntry();
}
} catch (IOException e) {
throw new java.io.UncheckedIOException(e);
throw new UncheckedIOException(e);
}
});
}
@@ -716,7 +718,7 @@ public class EpubMetadataWriter implements MetadataWriter {
return subj;
}
private Element getMetaElementByFilter(Element metadataElement, java.util.function.Predicate<Element> filter) {
private Element getMetaElementByFilter(Element metadataElement, Predicate<Element> filter) {
NodeList metas = metadataElement.getElementsByTagNameNS("*", "meta");
for (int i = 0; i < metas.getLength(); i++) {
Element meta = (Element) metas.item(i);
@@ -1164,19 +1166,19 @@ public class EpubMetadataWriter implements MetadataWriter {
private void organizeMetadataElements(Element metadataElement) {
final String DC_NS = "http://purl.org/dc/elements/1.1/";
java.util.List<Element> identifiers = new java.util.ArrayList<>();
java.util.List<Element> titles = new java.util.ArrayList<>();
java.util.List<Element> creators = new java.util.ArrayList<>();
java.util.List<Element> contributors = new java.util.ArrayList<>();
java.util.List<Element> languages = new java.util.ArrayList<>();
java.util.List<Element> dates = new java.util.ArrayList<>();
java.util.List<Element> publishers = new java.util.ArrayList<>();
java.util.List<Element> descriptions = new java.util.ArrayList<>();
java.util.List<Element> subjects = new java.util.ArrayList<>();
java.util.List<Element> seriesMetas = new java.util.ArrayList<>();
java.util.List<Element> bookloreMetas = new java.util.ArrayList<>();
java.util.List<Element> modifiedMetas = new java.util.ArrayList<>();
java.util.List<Element> otherMetas = new java.util.ArrayList<>();
List<Element> identifiers = new ArrayList<>();
List<Element> titles = new ArrayList<>();
List<Element> creators = new ArrayList<>();
List<Element> contributors = new ArrayList<>();
List<Element> languages = new ArrayList<>();
List<Element> dates = new ArrayList<>();
List<Element> publishers = new ArrayList<>();
List<Element> descriptions = new ArrayList<>();
List<Element> subjects = new ArrayList<>();
List<Element> seriesMetas = new ArrayList<>();
List<Element> bookloreMetas = new ArrayList<>();
List<Element> modifiedMetas = new ArrayList<>();
List<Element> otherMetas = new ArrayList<>();
NodeList allChildren = metadataElement.getChildNodes();
for (int i = 0; i < allChildren.getLength(); i++) {
@@ -363,7 +363,7 @@ public class PdfMetadataWriter implements MetadataWriter {
return s.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;").replace("\"", "&quot;");
}
private static final java.util.regex.Pattern TIMESTAMP_PATTERN = java.util.regex.Pattern.compile(
private static final Pattern TIMESTAMP_PATTERN = Pattern.compile(
"<xmp:(MetadataDate|ModifyDate)>[^<]*</xmp:(MetadataDate|ModifyDate)>");
private boolean isXmpMetadataDifferent(String existingXmp, String newXmp) {
@@ -23,6 +23,7 @@ import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.time.Instant;
@Slf4j
@Service
@@ -274,7 +275,7 @@ public class OpdsFeedService {
escapeXml(author),
escapeXml(author),
now(),
escapeXml("/api/v1/opds/catalog?author=" + java.net.URLEncoder.encode(author, java.nio.charset.StandardCharsets.UTF_8)),
escapeXml("/api/v1/opds/catalog?author=" + URLEncoder.encode(author, StandardCharsets.UTF_8)),
escapeXml(author)
));
}
@@ -311,7 +312,7 @@ public class OpdsFeedService {
escapeXml(series),
escapeXml(series),
now(),
escapeXml("/api/v1/opds/catalog?series=" + java.net.URLEncoder.encode(series, java.nio.charset.StandardCharsets.UTF_8)),
escapeXml("/api/v1/opds/catalog?series=" + URLEncoder.encode(series, StandardCharsets.UTF_8)),
escapeXml(series)
));
}
@@ -641,7 +642,7 @@ public class OpdsFeedService {
}
private String now() {
return DateTimeFormatter.ISO_INSTANT.format(java.time.Instant.now());
return DateTimeFormatter.ISO_INSTANT.format(Instant.now());
}
private boolean hasValidFilePath(BookFile bookFile) {
@@ -354,10 +354,10 @@ public class CbxReaderService {
// Tier 1: Check L1 Memory Map (OS File Cache) via open ZipFile
// This is the fastest path for ZIP/CBZ
try {
java.util.zip.ZipFile zip = getZipFile(cbxPath, metadata.lastModified());
ZipFile zip = getZipFile(cbxPath, metadata.lastModified());
if (zip != null) {
String entryName = metadata.imageEntries().get(page - 1);
java.util.zip.ZipEntry entry = zip.getEntry(entryName);
ZipEntry entry = zip.getEntry(entryName);
if (entry != null) {
try (InputStream is = zip.getInputStream(entry)) {
is.transferTo(outputStream);
@@ -387,7 +387,7 @@ public class CbxReaderService {
return zipHandleCache.get(cacheKey, _ -> {
try {
if (isZipPath(cbxPath)) {
return new java.util.zip.ZipFile(cbxPath.toFile());
return new ZipFile(cbxPath.toFile());
}
} catch (IOException e) {
log.warn("Failed to open ZipFile for {}: {}", cbxPath, e.getMessage());
@@ -23,6 +23,8 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.*;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@Slf4j
@Service
@@ -67,7 +69,7 @@ public class EpubReaderService {
);
private final BookRepository bookRepository;
private final com.github.benmanes.caffeine.cache.Cache<String, CachedEpubMetadata> metadataCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
private final Cache<String, CachedEpubMetadata> metadataCache = Caffeine.newBuilder()
.maximumSize(MAX_CACHE_ENTRIES)
.expireAfterAccess(Duration.ofMinutes(30))
.build();
@@ -39,6 +39,7 @@ import java.time.Instant;
import java.util.Optional;
import org.booklore.model.enums.AuditAction;
import org.booklore.service.audit.AuditService;
import java.nio.file.Paths;
@RequiredArgsConstructor
@Service
@@ -400,7 +401,7 @@ public class FileUploadService {
// If the metadata title is the same as the temporary file's base name (which happens
// when CBX files have no embedded metadata), use the original filename as the title instead
String tempFileBaseName = java.nio.file.Paths.get(file.getName()).getFileName().toString();
String tempFileBaseName = Paths.get(file.getName()).getFileName().toString();
int lastDotIndex = tempFileBaseName.lastIndexOf('.');
if (lastDotIndex > 0) {
tempFileBaseName = tempFileBaseName.substring(0, lastDotIndex);
@@ -9,6 +9,7 @@ import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.regex.Pattern;
import java.text.Normalizer;
@UtilityClass
public class BookUtils {
@@ -52,7 +53,7 @@ public class BookUtils {
if (term == null) {
return null;
}
String s = java.text.Normalizer.normalize(term, java.text.Normalizer.Form.NFD);
String s = Normalizer.normalize(term, Normalizer.Form.NFD);
s = DIACRITICAL_MARKS_PATTERN.matcher(s).replaceAll("");
s = s.replace("ø", "o").replace("Ø", "O")
.replace("ł", "l").replace("Ł", "L")
@@ -39,6 +39,7 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;
import java.util.stream.Stream;
import java.net.UnknownHostException;
@Slf4j
@RequiredArgsConstructor
@@ -427,7 +428,7 @@ public class FileService {
System.arraycopy(addr, 12, ipv4Bytes, 0, 4);
InetAddress ipv4Addr = InetAddress.getByAddress(ipv4Bytes);
return isInternalAddress(ipv4Addr);
} catch (java.net.UnknownHostException e) {
} catch (UnknownHostException e) {
return false;
}
}