Restores and extends the EPUB metadata extraction work from PR #1879
with additional fixes for field mapping gaps found in the processor,
BookDrop finalization, and JSON sidecar.
EPUB Metadata Extractor (EpubMetadataExtractor.java)
- Restore Calibre user_metadata iteration that was regressed: now
iterates <calibre:user_metadata> elements and maps custom columns
via CALIBRE_FIELD_MAPPINGS
- Add #age_rating and #content_rating to CALIBRE_FIELD_MAPPINGS
so Calibre-managed rating/rating string fields are imported
- Add CALIBRE_IDENTIFIER_PREFIXES map for calibre: identifier
fallback (hardcover_book, lubimyczytac, ranobedb, etc.)
- Support both read paths: booklore: namespace (round-trip) and
Calibre user_metadata (first import from Calibre library)
- Validate age_rating values against VALID_AGE_RATINGS whitelist
EPUB Metadata Writer (EpubMetadataWriter.java)
- Write booklore:age_rating and booklore:content_rating to the
OPF so values survive a round-trip rescan
Metadata Change Detector (MetadataChangeDetector.java)
- Mark ageRating and contentRating as includedInFileWrite=true so
saving either field triggers a write-back to the EPUB file
EPUB Processor (EpubProcessor.java)
- Map extracted ageRating and contentRating from BookMetadata DTO
into BookMetadataEntity in setBookMetadata(); these two lines were
the silent reason values never reached the DB on library scan
BookDrop Service (BookDropService.java)
- Change processMovedFile() from REPLACE_ALL to REPLACE_WHEN_PROVIDED
when applying bookdrop review metadata after file extraction.
REPLACE_ALL unconditionally calls the setter even with null, wiping
ageRating/contentRating that EpubProcessor just extracted from the
file. REPLACE_WHEN_PROVIDED skips null fields and preserves the
file-extracted values when the bookdrop review form does not submit
those fields.
JSON Sidecar (SidecarIdentifiers.java, SidecarMetadataMapper.java)
- Add missing hardcoverBookId field to SidecarIdentifiers DTO
- Write hardcoverBookId in buildIdentifiers() (toSidecarMetadata path)
- Read hardcoverBookId in toBookMetadata() (sidecar import path)
All other identifiers were already present; hardcoverBookId was the
only one absent from all three locations simultaneously.
Tests (EpubMetadataExtractorTest.java)
- Add comprehensive test coverage for both extraction paths:
booklore: namespace (round-trip) and Calibre user_metadata/
identifier extraction including age_rating and content_rating