1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.bremersee.data.minio;
18
19 import io.minio.MinioClient;
20 import org.springframework.util.ErrorHandler;
21
22
23
24
25
26
27 public class MinioTemplate implements MinioOperations, Cloneable {
28
29 private final MinioClient client;
30
31 private ErrorHandler errorHandler = new DefaultMinioErrorHandler();
32
33
34
35
36
37
38 public MinioTemplate(MinioClient client) {
39 this.client = client;
40 }
41
42
43
44
45
46
47 public void setErrorHandler(ErrorHandler errorHandler) {
48 if (errorHandler != null) {
49 this.errorHandler = errorHandler;
50 }
51 }
52
53 @SuppressWarnings("MethodDoesntCallSuperMethod")
54 @Override
55 public MinioTemplate clone() {
56 return clone(null);
57 }
58
59
60
61
62
63
64
65 public MinioTemplate clone(ErrorHandler errorHandler) {
66 MinioTemplatelate.html#MinioTemplate">MinioTemplate clone = new MinioTemplate(client);
67 clone.setErrorHandler(errorHandler);
68 return clone;
69 }
70
71 @Override
72 public <T> T execute(MinioClientCallback<T> callback) {
73 try {
74 return callback.doWithMinioClient(client);
75
76 } catch (Exception e) {
77 errorHandler.handleError(e);
78 return null;
79 }
80 }
81
82 }