WPI: Add table for display books

This commit is contained in:
aditya.chandel
2025-01-06 15:18:14 -07:00
parent 7e748bb79a
commit 65b7e6df8d
9 changed files with 98 additions and 9 deletions
@@ -30,6 +30,9 @@ public class JobSchedulerService {
scheduler.scheduleJob(jobDetail, trigger);
} catch (Exception e) {
if(e.getMessage().contains("already exists")) {
throw ApiError.ANOTHER_METADATA_JOB_RUNNING.createException();
}
throw ApiError.SCHEDULE_REFRESH_ERROR.createException(e.getMessage());
}
}
@@ -26,16 +26,21 @@ public class FileService {
private final AppProperties appProperties;
public Resource getBookCover(String thumbnailPath) {
Path filePath = Paths.get(thumbnailPath);
Path thumbPath;
if (thumbnailPath == null || thumbnailPath.isEmpty()) {
thumbPath = Paths.get(getMissingThumbnailPath());
} else {
thumbPath = Paths.get(thumbnailPath);
}
try {
Resource resource = new UrlResource(filePath.toUri());
Resource resource = new UrlResource(thumbPath.toUri());
if (resource.exists() && resource.isReadable()) {
return resource;
} else {
throw ApiError.IMAGE_NOT_FOUND.createException(filePath);
throw ApiError.IMAGE_NOT_FOUND.createException(thumbPath);
}
} catch (IOException e) {
throw ApiError.IMAGE_NOT_FOUND.createException(filePath);
throw ApiError.IMAGE_NOT_FOUND.createException(thumbPath);
}
}
@@ -75,4 +80,8 @@ public class FileService {
return appProperties.getPathConfig() + "/thumbs/" + bookId + "/";
}
public String getMissingThumbnailPath() {
return appProperties.getPathConfig() + "/thumbs/missing/m.jpg";
}
}