1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package fr.cnes.doi.exception;
20
21 import fr.cnes.doi.application.AbstractApplication;
22 import fr.cnes.doi.application.DoiMdsApplication.API_MDS;
23 import fr.cnes.doi.client.ClientMDS.DATACITE_API_RESPONSE;
24 import org.restlet.Application;
25 import org.restlet.data.Status;
26 import org.restlet.resource.ResourceException;
27
28
29
30
31
32
33 public class DoiServerException extends ResourceException {
34
35
36
37
38
39
40
41
42 public DoiServerException(final Application app, final API_MDS error) {
43 super(error.getStatus().getCode(), error.getShortMessage());
44 }
45
46
47
48
49
50
51
52
53
54 public DoiServerException(final Application app, final API_MDS error, final Exception ex) {
55 super(error.getStatus(), error.getShortMessage(), ex);
56 }
57
58
59
60
61
62
63
64
65
66 public DoiServerException(final Application app, final API_MDS error, final String description) {
67 super(error.getStatus().getCode(), error.getShortMessage(), description);
68 }
69
70
71
72
73
74
75
76
77
78
79 public DoiServerException(final Application app,
80 final API_MDS error,
81 final String description,
82 final Throwable cause) {
83 super(error.getStatus().getCode(), cause, error.getShortMessage(), description);
84 }
85
86
87
88
89
90
91
92
93 public DoiServerException(final Application app, final DATACITE_API_RESPONSE error) {
94 super(error.getStatus().getCode(), error.getShortMessage());
95 if (DATACITE_API_RESPONSE.INTERNAL_SERVER_ERROR.getStatus().getCode() == error.getStatus().
96 getCode()) {
97 sendAlert(app);
98 }
99 }
100
101
102
103
104
105
106
107
108
109 public DoiServerException(final Application app,
110 final DATACITE_API_RESPONSE error,
111 final Exception ex) {
112 super(error.getStatus(), error.getShortMessage(), ex);
113 if (DATACITE_API_RESPONSE.INTERNAL_SERVER_ERROR.getStatus().getCode() == error.getStatus().
114 getCode()) {
115 sendAlert(app);
116 }
117 }
118
119
120
121
122
123
124
125
126
127 public DoiServerException(final Application app,
128 final DATACITE_API_RESPONSE error,
129 final String description) {
130 super(error.getStatus().getCode(), error.getShortMessage(), description);
131 if (DATACITE_API_RESPONSE.INTERNAL_SERVER_ERROR.getStatus().getCode() == error.getStatus().
132 getCode()) {
133 sendAlert(app);
134 }
135 }
136
137
138
139
140
141
142
143
144
145
146 public DoiServerException(final Application app,
147 final DATACITE_API_RESPONSE error,
148 final String description,
149 final Throwable cause) {
150 super(error.getStatus().getCode(), cause, error.getShortMessage(), description);
151 if (DATACITE_API_RESPONSE.INTERNAL_SERVER_ERROR.getStatus().getCode() == error.getStatus().
152 getCode()) {
153 sendAlert(app);
154 }
155 }
156
157
158
159
160
161
162
163
164
165
166 public DoiServerException(final Application app,
167 final Status status,
168 final String description,
169 final Throwable cause) {
170 super(status, description, cause);
171 sendAlert(app);
172 }
173
174
175
176
177
178
179
180
181
182 public DoiServerException(final Application app,
183 final Status status,
184 final String description) {
185 super(status, description);
186 }
187
188
189
190
191
192
193 private void sendAlert(final Application app) {
194 ((AbstractApplication) app).sendAlertWhenDataCiteFailed(this);
195 }
196
197 }