diff --git a/backend/Dockerfile b/backend/Dockerfile
index 983908a..f13a96f 100644
--- a/backend/Dockerfile
+++ b/backend/Dockerfile
@@ -1,11 +1,11 @@
-FROM openjdk:17-jdk-slim
+FROM eclipse-temurin:17-jdk-jammy
WORKDIR /app
# Install Maven and PostgreSQL 15 client tools
RUN apt-get update && apt-get install -y wget ca-certificates gnupg maven && \
- wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
- echo "deb http://apt.postgresql.org/pub/repos/apt/ bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \
+ echo "deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
apt-get update && \
apt-get install -y postgresql-client-15 && \
rm -rf /var/lib/apt/lists/*
diff --git a/backend/src/main/java/com/storycove/service/EPUBImportService.java b/backend/src/main/java/com/storycove/service/EPUBImportService.java
index 6f5de6b..e9c34d0 100644
--- a/backend/src/main/java/com/storycove/service/EPUBImportService.java
+++ b/backend/src/main/java/com/storycove/service/EPUBImportService.java
@@ -62,64 +62,74 @@ public class EPUBImportService {
public EPUBImportResponse importEPUB(EPUBImportRequest request) {
try {
MultipartFile epubFile = request.getEpubFile();
-
+
if (epubFile == null || epubFile.isEmpty()) {
return EPUBImportResponse.error("EPUB file is required");
}
-
+
if (!isValidEPUBFile(epubFile)) {
return EPUBImportResponse.error("Invalid EPUB file format");
}
-
+
+ log.info("Parsing EPUB file: {}", epubFile.getOriginalFilename());
Book book = parseEPUBFile(epubFile);
-
+
+ log.info("Creating story entity from EPUB metadata");
Story story = createStoryFromEPUB(book, request);
-
+
+ log.info("Saving story to database: {}", story.getTitle());
Story savedStory = storyService.create(story);
+ log.info("Story saved successfully with ID: {}", savedStory.getId());
// Process embedded images if content contains any
String originalContent = story.getContentHtml();
if (originalContent != null && originalContent.contains("
allTags = new ArrayList<>();
- if (request.getTags() != null && !request.getTags().isEmpty()) {
- allTags.addAll(request.getTags());
+ try {
+ List allTags = new ArrayList<>();
+ if (request.getTags() != null && !request.getTags().isEmpty()) {
+ allTags.addAll(request.getTags());
+ }
+
+ // Extract subjects/keywords from EPUB metadata
+ List epubTags = extractTags(metadata);
+ if (epubTags != null && !epubTags.isEmpty()) {
+ allTags.addAll(epubTags);
+ }
+
+ log.info("Processing {} tags for story", allTags.size());
+ // Remove duplicates and create tags
+ allTags.stream()
+ .distinct()
+ .forEach(tagName -> {
+ try {
+ log.debug("Finding or creating tag: {}", tagName);
+ Tag tag = tagService.findOrCreate(tagName.trim());
+ story.addTag(tag);
+ } catch (Exception e) {
+ log.error("Error creating tag '{}': {}", tagName, e.getMessage(), e);
+ throw e;
+ }
+ });
+ } catch (Exception e) {
+ log.error("Error handling tags: {}", e.getMessage(), e);
+ throw e;
}
-
- // Extract subjects/keywords from EPUB metadata
- List epubTags = extractTags(metadata);
- if (epubTags != null && !epubTags.isEmpty()) {
- allTags.addAll(epubTags);
- }
-
- // Remove duplicates and create tags
- allTags.stream()
- .distinct()
- .forEach(tagName -> {
- Tag tag = tagService.findOrCreate(tagName.trim());
- story.addTag(tag);
- });
-
+
// Extract additional metadata for potential future use
extractAdditionalMetadata(metadata, story);
-
+
+ log.info("Story entity created successfully: {}", title);
return story;
}
@@ -244,7 +296,13 @@ public class EPUBImportService {
private String extractDescription(Metadata metadata) {
List descriptions = metadata.getDescriptions();
if (descriptions != null && !descriptions.isEmpty()) {
- return descriptions.get(0);
+ String description = descriptions.get(0);
+ // Truncate to 1000 characters if necessary
+ if (description != null && description.length() > 1000) {
+ log.info("Description exceeds 1000 characters ({}), truncating...", description.length());
+ return description.substring(0, 997) + "...";
+ }
+ return description;
}
return null;
}
diff --git a/backend/src/main/java/com/storycove/service/HtmlSanitizationService.java b/backend/src/main/java/com/storycove/service/HtmlSanitizationService.java
index 28758a2..919a731 100644
--- a/backend/src/main/java/com/storycove/service/HtmlSanitizationService.java
+++ b/backend/src/main/java/com/storycove/service/HtmlSanitizationService.java
@@ -188,13 +188,13 @@ public class HtmlSanitizationService {
return "";
}
- logger.info("Content before sanitization: "+html);
+ logger.debug("Sanitizing HTML content (length: {} characters)", html.length());
// Preprocess to extract images from figure tags
String preprocessed = preprocessFigureTags(html);
String saniztedHtml = Jsoup.clean(preprocessed, allowlist.preserveRelativeLinks(true));
- logger.info("Content after sanitization: "+saniztedHtml);
+ logger.debug("Sanitization complete (output length: {} characters)", saniztedHtml.length());
return saniztedHtml;
}