@@ -129,7 +129,7 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
129
129
.zipWith (Mono .defer (() -> {
130
130
String folderId = applicationView .getApplicationInfoView ().getFolderId ();
131
131
if (StringUtils .isBlank (folderId )) {
132
- return Mono .just (Optional .<Folder > empty ());
132
+ return Mono .just (Optional .<Folder >empty ());
133
133
}
134
134
return folderService .findById (folderId )
135
135
.map (Optional ::of )
@@ -138,7 +138,7 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
138
138
.zipWith (Mono .defer (() -> {
139
139
String folderId = applicationView .getApplicationInfoView ().getFolderIdFrom ();
140
140
if (StringUtils .isBlank (folderId )) {
141
- return Mono .just (Optional .<Folder > empty ());
141
+ return Mono .just (Optional .<Folder >empty ());
142
142
}
143
143
return folderService .findById (folderId )
144
144
.map (Optional ::of )
@@ -156,40 +156,43 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
156
156
return Pair .of (category , description );
157
157
});
158
158
}), TupleUtils ::merge )
159
- .delayUntil (tuple -> {
159
+ .flatMap (tuple -> Mono . deferContextual ( contextView -> {
160
160
OrgMember orgMember = tuple .getT1 ().getT1 ();
161
161
Optional <Folder > optional = tuple .getT1 ().getT2 ();
162
162
Optional <Folder > optionalFrom = tuple .getT1 ().getT3 ();
163
163
String token = tuple .getT2 ();
164
164
String category = tuple .getT3 ().getLeft ();
165
165
String description = tuple .getT3 ().getRight ();
166
166
ApplicationInfoView applicationInfoView = applicationView .getApplicationInfoView ();
167
+
167
168
ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
168
- .orgId (orgMember .getOrgId ())
169
- .userId (orgMember .getUserId ())
170
- .applicationId (applicationInfoView .getApplicationId ())
171
- .applicationGid (applicationInfoView .getApplicationGid ())
172
- .applicationName (applicationInfoView .getName ())
173
- .applicationCategory (category )
174
- .applicationDescription (description )
175
- .type (eventType )
176
- .folderId (optional .map (Folder ::getId ).orElse (null ))
177
- .folderName (optional .map (Folder ::getName ).orElse (null ))
178
- .oldFolderId (optionalFrom .map (Folder ::getId ).orElse (null ))
179
- .oldFolderName (optionalFrom .map (Folder ::getName ).orElse (null ))
180
- .isAnonymous (anonymous )
181
- .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
182
- .build ();
183
- event .populateDetails ();
169
+ .orgId (orgMember .getOrgId ())
170
+ .userId (orgMember .getUserId ())
171
+ .applicationId (applicationInfoView .getApplicationId ())
172
+ .applicationGid (applicationInfoView .getApplicationGid ())
173
+ .applicationName (applicationInfoView .getName ())
174
+ .applicationCategory (category )
175
+ .applicationDescription (description )
176
+ .type (eventType )
177
+ .folderId (optional .map (Folder ::getId ).orElse (null ))
178
+ .folderName (optional .map (Folder ::getName ).orElse (null ))
179
+ .oldFolderId (optionalFrom .map (Folder ::getId ).orElse (null ))
180
+ .oldFolderName (optionalFrom .map (Folder ::getName ).orElse (null ))
181
+ .isAnonymous (anonymous )
182
+ .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
183
+ .build ();
184
+
185
+ event .populateDetails (contextView );
184
186
applicationEventPublisher .publishEvent (event );
185
- })
186
- .then ()
187
+ return Mono . empty ();
188
+ })) .then () // **Ensures Mono<Void> return type**
187
189
.onErrorResume (throwable -> {
188
190
log .error ("publishApplicationCommonEvent error. {}, {}" , applicationView , eventType , throwable );
189
191
return Mono .empty ();
190
192
});
191
193
});
192
194
}
195
+
193
196
194
197
public Mono <Void > publishApplicationPermissionEvent (String applicationId , Set <String > userIds , Set <String > groupIds , String permissionId , String role ) {
195
198
return sessionUserService .isAnonymousUser ()
@@ -199,15 +202,16 @@ public Mono<Void> publishApplicationPermissionEvent(String applicationId, Set<St
199
202
}
200
203
return sessionUserService .getVisitorOrgMemberCache ()
201
204
.zipWith (sessionUserService .getVisitorToken ())
202
- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
205
+ .zipWith (applicationService .findById (applicationId )
203
206
.zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
204
- .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl ))))
205
- .doOnNext (tuple -> {
207
+ .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl )))
208
+ .flatMap (tuple -> {
206
209
OrgMember orgMember = tuple .getT1 ().getT1 ();
207
210
String token = tuple .getT1 ().getT2 ();
208
211
String category = tuple .getT2 ().getT1 ().getT2 ();
209
212
String description = tuple .getT2 ().getT2 ();
210
213
Application application = tuple .getT2 ().getT1 ().getT1 ();
214
+
211
215
ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
212
216
.orgId (orgMember .getOrgId ())
213
217
.userId (orgMember .getUserId ())
@@ -224,19 +228,20 @@ public Mono<Void> publishApplicationPermissionEvent(String applicationId, Set<St
224
228
.isAnonymous (anonymous )
225
229
.sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
226
230
.build ();
231
+
227
232
return Mono .deferContextual (contextView -> {
228
233
event .populateDetails (contextView );
229
234
applicationEventPublisher .publishEvent (event );
230
235
return Mono .empty ();
231
- });
232
- })
233
- .then ()
234
- .onErrorResume (throwable -> {
235
- log .error ("publishApplicationPermissionEvent error. {}, {}, {}" , applicationId , permissionId , role , throwable );
236
- return Mono .empty ();
236
+ }).then (); // **Fix: Ensures Mono<Void> is returned**
237
237
});
238
+ })
239
+ .onErrorResume (throwable -> {
240
+ log .error ("publishApplicationPermissionEvent error. {}, {}, {}" , applicationId , permissionId , role , throwable );
241
+ return Mono .empty ();
238
242
});
239
243
}
244
+
240
245
241
246
public Mono <Void > publishApplicationSharingEvent (String applicationId , String shareType ) {
242
247
return sessionUserService .isAnonymousUser ()
@@ -246,15 +251,16 @@ public Mono<Void> publishApplicationSharingEvent(String applicationId, String sh
246
251
}
247
252
return sessionUserService .getVisitorOrgMemberCache ()
248
253
.zipWith (sessionUserService .getVisitorToken ())
249
- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
254
+ .zipWith (applicationService .findById (applicationId )
250
255
.zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
251
- .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl ))))
252
- .doOnNext (tuple -> {
256
+ .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl )))
257
+ .flatMap (tuple -> {
253
258
OrgMember orgMember = tuple .getT1 ().getT1 ();
254
259
String token = tuple .getT1 ().getT2 ();
255
260
String category = tuple .getT2 ().getT1 ().getT2 ();
256
261
String description = tuple .getT2 ().getT2 ();
257
262
Application application = tuple .getT2 ().getT1 ().getT1 ();
263
+
258
264
ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
259
265
.orgId (orgMember .getOrgId ())
260
266
.userId (orgMember .getUserId ())
@@ -268,16 +274,20 @@ public Mono<Void> publishApplicationSharingEvent(String applicationId, String sh
268
274
.isAnonymous (anonymous )
269
275
.sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
270
276
.build ();
271
- event .populateDetails ();
272
- applicationEventPublisher .publishEvent (event );
273
- })
274
- .then ()
275
- .onErrorResume (throwable -> {
276
- log .error ("publishApplicationSharingEvent error. {}, {}" , applicationId , shareType , throwable );
277
- return Mono .empty ();
277
+
278
+ return Mono .deferContextual (contextView -> {
279
+ event .populateDetails (contextView );
280
+ applicationEventPublisher .publishEvent (event );
281
+ return Mono .empty ();
282
+ }).then (); // **Fix: Ensures Mono<Void> is returned**
278
283
});
284
+ })
285
+ .onErrorResume (throwable -> {
286
+ log .error ("publishApplicationSharingEvent error. {}, {}" , applicationId , shareType , throwable );
287
+ return Mono .empty ();
279
288
});
280
289
}
290
+
281
291
282
292
public Mono <Void > publishApplicationPublishEvent (String applicationId , ApplicationPublishRequest request ) {
283
293
return sessionUserService .isAnonymousUser ()
@@ -287,15 +297,16 @@ public Mono<Void> publishApplicationPublishEvent(String applicationId, Applicati
287
297
}
288
298
return sessionUserService .getVisitorOrgMemberCache ()
289
299
.zipWith (sessionUserService .getVisitorToken ())
290
- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
300
+ .zipWith (applicationService .findById (applicationId )
291
301
.zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
292
- .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl ))))
293
- .doOnNext (tuple -> {
302
+ .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl )))
303
+ .flatMap (tuple -> {
294
304
OrgMember orgMember = tuple .getT1 ().getT1 ();
295
305
String token = tuple .getT1 ().getT2 ();
296
306
String category = tuple .getT2 ().getT1 ().getT2 ();
297
307
String description = tuple .getT2 ().getT2 ();
298
308
Application application = tuple .getT2 ().getT1 ().getT1 ();
309
+
299
310
ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
300
311
.orgId (orgMember .getOrgId ())
301
312
.userId (orgMember .getUserId ())
@@ -310,16 +321,20 @@ public Mono<Void> publishApplicationPublishEvent(String applicationId, Applicati
310
321
.isAnonymous (anonymous )
311
322
.sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
312
323
.build ();
313
- event .populateDetails ();
314
- applicationEventPublisher .publishEvent (event );
315
- })
316
- .then ()
317
- .onErrorResume (throwable -> {
318
- log .error ("publishApplicationPublishEvent error. {}, {}, {}" , applicationId , request .tag (), request .commitMessage (), throwable );
319
- return Mono .empty ();
324
+
325
+ return Mono .deferContextual (contextView -> {
326
+ event .populateDetails (contextView );
327
+ applicationEventPublisher .publishEvent (event );
328
+ return Mono .empty ();
329
+ }).then (); // **Fix: Ensures Mono<Void> is returned**
320
330
});
331
+ })
332
+ .onErrorResume (throwable -> {
333
+ log .error ("publishApplicationPublishEvent error. {}, {}, {}" , applicationId , request .tag (), request .commitMessage (), throwable );
334
+ return Mono .empty ();
321
335
});
322
336
}
337
+
323
338
324
339
public Mono <Void > publishApplicationVersionChangeEvent (String applicationId , String newtag ) {
325
340
return sessionUserService .isAnonymousUser ()
@@ -329,15 +344,16 @@ public Mono<Void> publishApplicationVersionChangeEvent(String applicationId, Str
329
344
}
330
345
return sessionUserService .getVisitorOrgMemberCache ()
331
346
.zipWith (sessionUserService .getVisitorToken ())
332
- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
333
- .zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
334
- .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl ) )))
335
- .doOnNext (tuple -> {
347
+ .zipWith (applicationService .findById (applicationId )
348
+ .zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
349
+ .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl )))
350
+ .flatMap (tuple -> {
336
351
OrgMember orgMember = tuple .getT1 ().getT1 ();
337
352
String token = tuple .getT1 ().getT2 ();
338
353
String category = tuple .getT2 ().getT1 ().getT2 ();
339
354
String description = tuple .getT2 ().getT2 ();
340
355
Application application = tuple .getT2 ().getT1 ().getT1 ();
356
+
341
357
ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
342
358
.orgId (orgMember .getOrgId ())
343
359
.userId (orgMember .getUserId ())
@@ -351,16 +367,20 @@ public Mono<Void> publishApplicationVersionChangeEvent(String applicationId, Str
351
367
.isAnonymous (anonymous )
352
368
.sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
353
369
.build ();
354
- event .populateDetails ();
355
- applicationEventPublisher .publishEvent (event );
356
- })
357
- .then ()
358
- .onErrorResume (throwable -> {
359
- log .error ("publishApplicationPublishEvent error. {}, {}" , applicationId , newtag , throwable );
360
- return Mono .empty ();
370
+
371
+ return Mono .deferContextual (contextView -> {
372
+ event .populateDetails (contextView );
373
+ applicationEventPublisher .publishEvent (event );
374
+ return Mono .empty ();
375
+ }).then (); // **Fix: Ensures Mono<Void> is returned**
361
376
});
377
+ })
378
+ .onErrorResume (throwable -> {
379
+ log .error ("publishApplicationVersionChangeEvent error. {}, {}" , applicationId , newtag , throwable );
380
+ return Mono .empty ();
362
381
});
363
382
}
383
+
364
384
365
385
public Mono <Void > publishUserLoginEvent (String source ) {
366
386
return sessionUserService .getVisitorOrgMember ().zipWith (sessionUserService .getVisitorToken ())
0 commit comments