@@ -266,51 +266,11 @@ protected static String toNotificationContent (JsonNode node) {
266
266
}
267
267
268
268
public static int getNotificationCount (String serverId , String mirthVersion , Map <String , String > extensionVersions , Set <Integer > archivedNotifications , String [] protocols , String [] cipherSuites ) {
269
- CloseableHttpClient client = null ;
270
- HttpPost post = new HttpPost ();
271
- CloseableHttpResponse response = null ;
272
-
273
269
int notificationCount = 0 ;
274
-
275
270
try {
276
- ObjectMapper mapper = new ObjectMapper ();
277
- String extensionVersionsJson = mapper .writeValueAsString (extensionVersions );
278
- NameValuePair [] params = { new BasicNameValuePair ("op" , NOTIFICATION_COUNT_GET ),
279
- new BasicNameValuePair ("serverId" , serverId ),
280
- new BasicNameValuePair ("version" , mirthVersion ),
281
- new BasicNameValuePair ("extensionVersions" , extensionVersionsJson ) };
282
- RequestConfig requestConfig = RequestConfig .custom ().setConnectTimeout (TIMEOUT ).setConnectionRequestTimeout (TIMEOUT ).setSocketTimeout (TIMEOUT ).build ();
283
-
284
- post .setURI (URI .create (URL_CONNECT_SERVER + URL_NOTIFICATION_SERVLET ));
285
- post .setEntity (new UrlEncodedFormEntity (Arrays .asList (params ), Charset .forName ("UTF-8" )));
286
-
287
- HttpClientContext postContext = HttpClientContext .create ();
288
- postContext .setRequestConfig (requestConfig );
289
- client = getClient (protocols , cipherSuites );
290
- response = client .execute (post , postContext );
291
- StatusLine statusLine = response .getStatusLine ();
292
- int statusCode = statusLine .getStatusCode ();
293
- if ((statusCode == HttpStatus .SC_OK )) {
294
- HttpEntity responseEntity = response .getEntity ();
295
- Charset responseCharset = null ;
296
- try {
297
- responseCharset = ContentType .getOrDefault (responseEntity ).getCharset ();
298
- } catch (Exception e ) {
299
- responseCharset = ContentType .TEXT_PLAIN .getCharset ();
300
- }
301
-
302
- List <Integer > notificationIds = mapper .readValue (IOUtils .toString (responseEntity .getContent (), responseCharset ).trim (), new TypeReference <List <Integer >>() {
303
- });
304
- for (int id : notificationIds ) {
305
- if (!archivedNotifications .contains (id )) {
306
- notificationCount ++;
307
- }
308
- }
309
- }
310
- } catch (Exception e ) {
311
- } finally {
312
- HttpClientUtils .closeQuietly (response );
313
- HttpClientUtils .closeQuietly (client );
271
+ notificationCount = getNotifications (serverId , mirthVersion , extensionVersions , protocols , cipherSuites ).size ();
272
+ } catch (Exception ignore ) {
273
+ System .err .println ("Failed to get notification count, defaulting to zero: " + ignore );
314
274
}
315
275
return notificationCount ;
316
276
}
0 commit comments