@@ -105,6 +105,8 @@ public void informSubscriber(String aggregatedObject, JsonNode subscriptionJson)
105
105
String notificationType = getSubscriptionField ("notificationType" , subscriptionJson );
106
106
String notificationMeta = getSubscriptionField ("notificationMeta" , subscriptionJson );
107
107
108
+ String subject = getSubscriptionField ("emailSubject" , subscriptionJson );
109
+
108
110
MultiValueMap <String , String > mapNotificationMessage = mapNotificationMessage (aggregatedObject ,
109
111
subscriptionJson );
110
112
@@ -157,7 +159,7 @@ public void informSubscriber(String aggregatedObject, JsonNode subscriptionJson)
157
159
} else if (notificationType .trim ().equals ("MAIL" )) {
158
160
LOGGER .debug ("Notification through EMAIL" );
159
161
try {
160
- sendMail .sendMail (notificationMeta , String .valueOf ((mapNotificationMessage .get ("" )).get (0 )));
162
+ sendMail .sendMail (notificationMeta , String .valueOf ((mapNotificationMessage .get ("" )).get (0 )), subject );
161
163
} catch (MessagingException e ) {
162
164
e .printStackTrace ();
163
165
LOGGER .error (e .getMessage ());
@@ -234,8 +236,13 @@ private String prepareMissedNotification(String aggregatedObject, String subscri
234
236
* @return field value
235
237
*/
236
238
private String getSubscriptionField (String fieldName , JsonNode subscriptionJson ) {
237
- String value = subscriptionJson .get (fieldName ).toString ().replaceAll (REGEX , "" );
238
- LOGGER .debug ("Extracted field name and value from subscription json:" + fieldName + " : " + value );
239
+ String value ;
240
+ if (subscriptionJson .get (fieldName ) != null ) {
241
+ value = subscriptionJson .get (fieldName ).toString ().replaceAll (REGEX , "" );
242
+ LOGGER .debug ("Extracted field name and value from subscription json:" + fieldName + " : " + value );
243
+ } else {
244
+ value = "" ;
245
+ }
239
246
return value ;
240
247
}
241
248
@@ -250,29 +257,29 @@ private MultiValueMap<String, String> mapNotificationMessage(String aggregatedOb
250
257
MultiValueMap <String , String > mapNotificationMessage = new LinkedMultiValueMap <>();
251
258
ArrayNode arrNode = (ArrayNode ) subscriptionJson .get ("notificationMessageKeyValues" );
252
259
253
- if (subscriptionJson .has ("authenticationType" )) {
254
- String authType = subscriptionJson .get ("authenticationType" ).asText ();
255
-
256
- if (authType .equals ("BASIC_AUTH" )) {
257
- String username = subscriptionJson .get ("userName" ).asText ();
258
- String password = subscriptionJson .get ("password" ).asText ();
259
- String encoding = Base64 .getEncoder ().encodeToString ((username + ":" + password ).getBytes ());
260
-
261
- key = "Authorization" ;
262
- val = "Basic " + encoding ;
263
-
264
- }
265
- }
266
-
267
- if (arrNode .isArray ()) {
268
- for (final JsonNode objNode : arrNode ) {
269
- mapNotificationMessage .add (objNode .get ("formkey" ).toString ().replaceAll (REGEX , "" ), jmespath
270
- .runRuleOnEvent (objNode .get ("formvalue" ).toString ().replaceAll (REGEX , "" ), aggregatedObject )
271
- .toString ().replaceAll (REGEX , "" ));
272
- }
273
- }
274
- return mapNotificationMessage ;
275
- }
260
+ if (subscriptionJson .has ("authenticationType" )) {
261
+ String authType = subscriptionJson .get ("authenticationType" ).asText ();
262
+
263
+ if (authType .equals ("BASIC_AUTH" )) {
264
+ String username = subscriptionJson .get ("userName" ).asText ();
265
+ String password = subscriptionJson .get ("password" ).asText ();
266
+ String encoding = Base64 .getEncoder ().encodeToString ((username + ":" + password ).getBytes ());
267
+
268
+ key = "Authorization" ;
269
+ val = "Basic " + encoding ;
270
+
271
+ }
272
+ }
273
+
274
+ if (arrNode .isArray ()) {
275
+ for (final JsonNode objNode : arrNode ) {
276
+ mapNotificationMessage .add (objNode .get ("formkey" ).toString ().replaceAll (REGEX , "" ), jmespath
277
+ .runRuleOnEvent (objNode .get ("formvalue" ).toString ().replaceAll (REGEX , "" ), aggregatedObject )
278
+ .toString ().replaceAll (REGEX , "" ));
279
+ }
280
+ }
281
+ return mapNotificationMessage ;
282
+ }
276
283
277
284
/**
278
285
* This method is responsible to display the configurable application properties
0 commit comments