Some logging
This commit is contained in:
@@ -56,3 +56,9 @@ dependencies {
|
|||||||
implementation 'org.mapstruct:mapstruct:1.6.3'
|
implementation 'org.mapstruct:mapstruct:1.6.3'
|
||||||
annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.3'
|
annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hibernate {
|
||||||
|
enhancement {
|
||||||
|
enableAssociationManagement = true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ public enum ApiError {
|
|||||||
IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, "Image not found or not readable"),
|
IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, "Image not found or not readable"),
|
||||||
INVALID_FILE_FORMAT(HttpStatus.BAD_REQUEST, "Invalid file format, only pdf and epub are supported"),
|
INVALID_FILE_FORMAT(HttpStatus.BAD_REQUEST, "Invalid file format, only pdf and epub are supported"),
|
||||||
LIBRARY_NOT_FOUND(HttpStatus.NOT_FOUND, "Library not found with ID: %d"),
|
LIBRARY_NOT_FOUND(HttpStatus.NOT_FOUND, "Library not found with ID: %d"),
|
||||||
BAD_REQUEST(HttpStatus.BAD_REQUEST, "Bad request"),
|
|
||||||
FILE_TOO_LARGE(HttpStatus.BAD_REQUEST, "File size exceeds the limit: 100 MB"),
|
FILE_TOO_LARGE(HttpStatus.BAD_REQUEST, "File size exceeds the limit: 100 MB"),
|
||||||
DIRECTORY_CREATION_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "Failed to create the directory: %s"),
|
DIRECTORY_CREATION_FAILED(HttpStatus.INTERNAL_SERVER_ERROR, "Failed to create the directory: %s"),
|
||||||
INVALID_LIBRARY_PATH(HttpStatus.BAD_REQUEST, "Invalid library path"),
|
INVALID_LIBRARY_PATH(HttpStatus.BAD_REQUEST, "Invalid library path"),
|
||||||
@@ -21,6 +20,7 @@ public enum ApiError {
|
|||||||
SHELF_ALREADY_EXISTS(HttpStatus.CONFLICT, "Shelf already exists: %s"),
|
SHELF_ALREADY_EXISTS(HttpStatus.CONFLICT, "Shelf already exists: %s"),
|
||||||
SHELF_NOT_FOUND(HttpStatus.NOT_FOUND, "Shelf not found with ID: %d"),
|
SHELF_NOT_FOUND(HttpStatus.NOT_FOUND, "Shelf not found with ID: %d"),
|
||||||
SCHEDULE_REFRESH_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "Failed to schedule metadata refresh job. Error: %s"),
|
SCHEDULE_REFRESH_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "Failed to schedule metadata refresh job. Error: %s"),
|
||||||
|
ANOTHER_METADATA_JOB_RUNNING(HttpStatus.CONFLICT, "A metadata refresh job is currently running. Please wait for it to complete before initiating a new one."),
|
||||||
METADATA_SOURCE_NOT_IMPLEMENT_OR_DOES_NOT_EXIST(HttpStatus.BAD_REQUEST, "Metadata source not implement or does not exist");
|
METADATA_SOURCE_NOT_IMPLEMENT_OR_DOES_NOT_EXIST(HttpStatus.BAD_REQUEST, "Metadata source not implement or does not exist");
|
||||||
|
|
||||||
private final HttpStatus status;
|
private final HttpStatus status;
|
||||||
|
|||||||
+4
-1
@@ -3,12 +3,14 @@ package com.adityachandel.booklore.quartz;
|
|||||||
import com.adityachandel.booklore.model.dto.request.MetadataRefreshRequest;
|
import com.adityachandel.booklore.model.dto.request.MetadataRefreshRequest;
|
||||||
import com.adityachandel.booklore.service.metadata.BookMetadataService;
|
import com.adityachandel.booklore.service.metadata.BookMetadataService;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.DisallowConcurrentExecution;
|
import org.quartz.DisallowConcurrentExecution;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@DisallowConcurrentExecution
|
@DisallowConcurrentExecution
|
||||||
@@ -19,7 +21,8 @@ public class RefreshMetadataJob implements Job {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
try {
|
try {
|
||||||
MetadataRefreshRequest request = (MetadataRefreshRequest) context.getJobDetail().getJobDataMap().get("request");
|
MetadataRefreshRequest request = (MetadataRefreshRequest) context.getMergedJobDataMap().get("request");
|
||||||
|
log.info("Refreshing metadata for library ID: {}", request.getLibraryId());
|
||||||
bookMetadataService.refreshMetadata(request);
|
bookMetadataService.refreshMetadata(request);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new JobExecutionException("Error occurred while executing metadata refresh job", e);
|
throw new JobExecutionException("Error occurred while executing metadata refresh job", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user