@@ -129,7 +129,7 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
129129 .zipWith (Mono .defer (() -> {
130130 String folderId = applicationView .getApplicationInfoView ().getFolderId ();
131131 if (StringUtils .isBlank (folderId )) {
132- return Mono .just (Optional .<Folder > empty ());
132+ return Mono .just (Optional .<Folder >empty ());
133133 }
134134 return folderService .findById (folderId )
135135 .map (Optional ::of )
@@ -138,7 +138,7 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
138138 .zipWith (Mono .defer (() -> {
139139 String folderId = applicationView .getApplicationInfoView ().getFolderIdFrom ();
140140 if (StringUtils .isBlank (folderId )) {
141- return Mono .just (Optional .<Folder > empty ());
141+ return Mono .just (Optional .<Folder >empty ());
142142 }
143143 return folderService .findById (folderId )
144144 .map (Optional ::of )
@@ -156,40 +156,43 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView applicationView,
156156 return Pair .of (category , description );
157157 });
158158 }), TupleUtils ::merge )
159- .delayUntil (tuple -> {
159+ .flatMap (tuple -> Mono . deferContextual ( contextView -> {
160160 OrgMember orgMember = tuple .getT1 ().getT1 ();
161161 Optional <Folder > optional = tuple .getT1 ().getT2 ();
162162 Optional <Folder > optionalFrom = tuple .getT1 ().getT3 ();
163163 String token = tuple .getT2 ();
164164 String category = tuple .getT3 ().getLeft ();
165165 String description = tuple .getT3 ().getRight ();
166166 ApplicationInfoView applicationInfoView = applicationView .getApplicationInfoView ();
167+
167168 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 );
184186 applicationEventPublisher .publishEvent (event );
185- })
186- .then ()
187+ return Mono . empty ();
188+ })) .then () // **Ensures Mono<Void> return type**
187189 .onErrorResume (throwable -> {
188190 log .error ("publishApplicationCommonEvent error. {}, {}" , applicationView , eventType , throwable );
189191 return Mono .empty ();
190192 });
191193 });
192194 }
195+
193196
194197 public Mono <Void > publishApplicationPermissionEvent (String applicationId , Set <String > userIds , Set <String > groupIds , String permissionId , String role ) {
195198 return sessionUserService .isAnonymousUser ()
@@ -199,15 +202,16 @@ public Mono<Void> publishApplicationPermissionEvent(String applicationId, Set<St
199202 }
200203 return sessionUserService .getVisitorOrgMemberCache ()
201204 .zipWith (sessionUserService .getVisitorToken ())
202- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
205+ .zipWith (applicationService .findById (applicationId )
203206 .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 -> {
206209 OrgMember orgMember = tuple .getT1 ().getT1 ();
207210 String token = tuple .getT1 ().getT2 ();
208211 String category = tuple .getT2 ().getT1 ().getT2 ();
209212 String description = tuple .getT2 ().getT2 ();
210213 Application application = tuple .getT2 ().getT1 ().getT1 ();
214+
211215 ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
212216 .orgId (orgMember .getOrgId ())
213217 .userId (orgMember .getUserId ())
@@ -224,19 +228,20 @@ public Mono<Void> publishApplicationPermissionEvent(String applicationId, Set<St
224228 .isAnonymous (anonymous )
225229 .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
226230 .build ();
231+
227232 return Mono .deferContextual (contextView -> {
228233 event .populateDetails (contextView );
229234 applicationEventPublisher .publishEvent (event );
230235 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**
237237 });
238+ })
239+ .onErrorResume (throwable -> {
240+ log .error ("publishApplicationPermissionEvent error. {}, {}, {}" , applicationId , permissionId , role , throwable );
241+ return Mono .empty ();
238242 });
239243 }
244+
240245
241246 public Mono <Void > publishApplicationSharingEvent (String applicationId , String shareType ) {
242247 return sessionUserService .isAnonymousUser ()
@@ -246,15 +251,16 @@ public Mono<Void> publishApplicationSharingEvent(String applicationId, String sh
246251 }
247252 return sessionUserService .getVisitorOrgMemberCache ()
248253 .zipWith (sessionUserService .getVisitorToken ())
249- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
254+ .zipWith (applicationService .findById (applicationId )
250255 .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 -> {
253258 OrgMember orgMember = tuple .getT1 ().getT1 ();
254259 String token = tuple .getT1 ().getT2 ();
255260 String category = tuple .getT2 ().getT1 ().getT2 ();
256261 String description = tuple .getT2 ().getT2 ();
257262 Application application = tuple .getT2 ().getT1 ().getT1 ();
263+
258264 ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
259265 .orgId (orgMember .getOrgId ())
260266 .userId (orgMember .getUserId ())
@@ -268,16 +274,20 @@ public Mono<Void> publishApplicationSharingEvent(String applicationId, String sh
268274 .isAnonymous (anonymous )
269275 .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
270276 .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**
278283 });
284+ })
285+ .onErrorResume (throwable -> {
286+ log .error ("publishApplicationSharingEvent error. {}, {}" , applicationId , shareType , throwable );
287+ return Mono .empty ();
279288 });
280289 }
290+
281291
282292 public Mono <Void > publishApplicationPublishEvent (String applicationId , ApplicationPublishRequest request ) {
283293 return sessionUserService .isAnonymousUser ()
@@ -287,15 +297,16 @@ public Mono<Void> publishApplicationPublishEvent(String applicationId, Applicati
287297 }
288298 return sessionUserService .getVisitorOrgMemberCache ()
289299 .zipWith (sessionUserService .getVisitorToken ())
290- .zipWith (Mono . defer (() -> applicationService .findById (applicationId )
300+ .zipWith (applicationService .findById (applicationId )
291301 .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 -> {
294304 OrgMember orgMember = tuple .getT1 ().getT1 ();
295305 String token = tuple .getT1 ().getT2 ();
296306 String category = tuple .getT2 ().getT1 ().getT2 ();
297307 String description = tuple .getT2 ().getT2 ();
298308 Application application = tuple .getT2 ().getT1 ().getT1 ();
309+
299310 ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
300311 .orgId (orgMember .getOrgId ())
301312 .userId (orgMember .getUserId ())
@@ -310,16 +321,20 @@ public Mono<Void> publishApplicationPublishEvent(String applicationId, Applicati
310321 .isAnonymous (anonymous )
311322 .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
312323 .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**
320330 });
331+ })
332+ .onErrorResume (throwable -> {
333+ log .error ("publishApplicationPublishEvent error. {}, {}, {}" , applicationId , request .tag (), request .commitMessage (), throwable );
334+ return Mono .empty ();
321335 });
322336 }
337+
323338
324339 public Mono <Void > publishApplicationVersionChangeEvent (String applicationId , String newtag ) {
325340 return sessionUserService .isAnonymousUser ()
@@ -329,15 +344,16 @@ public Mono<Void> publishApplicationVersionChangeEvent(String applicationId, Str
329344 }
330345 return sessionUserService .getVisitorOrgMemberCache ()
331346 .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 -> {
336351 OrgMember orgMember = tuple .getT1 ().getT1 ();
337352 String token = tuple .getT1 ().getT2 ();
338353 String category = tuple .getT2 ().getT1 ().getT2 ();
339354 String description = tuple .getT2 ().getT2 ();
340355 Application application = tuple .getT2 ().getT1 ().getT1 ();
356+
341357 ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
342358 .orgId (orgMember .getOrgId ())
343359 .userId (orgMember .getUserId ())
@@ -351,16 +367,20 @@ public Mono<Void> publishApplicationVersionChangeEvent(String applicationId, Str
351367 .isAnonymous (anonymous )
352368 .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
353369 .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**
361376 });
377+ })
378+ .onErrorResume (throwable -> {
379+ log .error ("publishApplicationVersionChangeEvent error. {}, {}" , applicationId , newtag , throwable );
380+ return Mono .empty ();
362381 });
363382 }
383+
364384
365385 public Mono <Void > publishUserLoginEvent (String source ) {
366386 return sessionUserService .getVisitorOrgMember ().zipWith (sessionUserService .getVisitorToken ())
0 commit comments