22
22
import javax .annotation .PostConstruct ;
23
23
24
24
import org .slf4j .Logger ;
25
- import org .slf4j .LoggerFactory ;
26
25
27
26
import org .springframework .web .multipart .MultipartFile ;
28
27
37
36
38
37
@ RequiredArgsConstructor
39
38
public class DatabaseImagePersistenceStrategy implements ImagePersistenceStrategy {
40
- private static final Logger LOG =
41
- LoggerFactory .getLogger (DatabaseImagePersistenceStrategy .class );
42
39
40
+ private final Logger log ;
43
41
private final ImageDataDao imageDataDao ;
44
42
45
43
@ PostConstruct
46
44
public void init () {
47
- LOG .info ("Images will be saved into in-memory database" );
45
+ log .info ("Images will be saved into in-memory database" );
48
46
}
49
47
50
48
@ Override
@@ -56,7 +54,7 @@ public void save(MultipartFile file, ImageInfoDto image) {
56
54
imageData .setPreview (false );
57
55
58
56
Integer id = imageDataDao .add (imageData );
59
- LOG .info ("Image #{}: meta data has been saved to #{}" , image .getId (), id );
57
+ log .info ("Image #{}: meta data has been saved to #{}" , image .getId (), id );
60
58
61
59
} catch (IOException e ) {
62
60
// throw RuntimeException for rolling back transaction
@@ -73,14 +71,14 @@ public void savePreview(byte[] data, ImageInfoDto image) {
73
71
74
72
imageDataDao .add (imageData );
75
73
76
- LOG .info ("Image #{}: preview has been saved" , image .getId ());
74
+ log .info ("Image #{}: preview has been saved" , image .getId ());
77
75
}
78
76
79
77
@ Override
80
78
public ImageDto get (ImageInfoDto image ) {
81
79
DbImageDto imageDto = imageDataDao .findByImageId (image .getId (), false );
82
80
if (imageDto == null ) {
83
- LOG .warn ("Image #{}: content not found" , image .getId ());
81
+ log .warn ("Image #{}: content not found" , image .getId ());
84
82
return null ;
85
83
}
86
84
@@ -91,7 +89,7 @@ public ImageDto get(ImageInfoDto image) {
91
89
public ImageDto getPreview (ImageInfoDto image ) {
92
90
DbImageDto imageDto = imageDataDao .findByImageId (image .getId (), true );
93
91
if (imageDto == null ) {
94
- LOG .info ("Image #{}: preview not found" , image .getId ());
92
+ log .info ("Image #{}: preview not found" , image .getId ());
95
93
return null ;
96
94
}
97
95
0 commit comments