@@ -125,83 +125,82 @@ public Mono<Void> publishApplicationCommonEvent(ApplicationView originalApplicat
125
125
126
126
public Mono <Void > publishApplicationCommonEvent (ApplicationView originalApplicationView , ApplicationView applicationView , EventType eventType ) {
127
127
return sessionUserService .isAnonymousUser ()
128
- .flatMap (anonymous -> {
129
- return sessionUserService .getVisitorOrgMemberCache ()
130
- .onErrorReturn (new OrgMember (originalApplicationView .getApplicationInfoView ().getOrgId (), null , null , null , 0 ))
131
- .zipWith (Mono .defer (() -> {
132
- String folderId = applicationView .getApplicationInfoView ().getFolderId ();
133
- if (StringUtils .isBlank (folderId )) {
134
- return Mono .just (Optional .<Folder >empty ());
135
- }
136
- return folderService .findById (folderId )
137
- .map (Optional ::of )
138
- .onErrorReturn (Optional .empty ());
139
- }))
140
- .zipWith (Mono .defer (() -> {
141
- String folderId = applicationView .getApplicationInfoView ().getFolderIdFrom ();
142
- if (StringUtils .isBlank (folderId )) {
143
- return Mono .just (Optional .<Folder >empty ());
144
- }
145
- return folderService .findById (folderId )
146
- .map (Optional ::of )
147
- .onErrorReturn (Optional .empty ());
148
- }), TupleUtils ::merge )
149
- .zipWith (sessionUserService .getVisitorToken ())
150
- .zipWith (Mono .defer (() -> {
151
- String appId = applicationView .getApplicationInfoView ().getApplicationId ();
152
- return applicationService .findById (appId )
153
- .zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
154
- .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl ))
155
- .zipWhen (application -> application .getT1 ().getT1 ().getTitle (applicationRecordServiceImpl ))
156
- .map (tuple -> {
157
- String category = tuple .getT1 ().getT1 ().getT2 ();
158
- String description = tuple .getT1 ().getT2 ();
159
- String title = tuple .getT2 ();
160
- return new String []{category , description , title };
161
- });
162
- }), TupleUtils ::merge )
163
- .flatMap (tuple -> Mono .deferContextual (contextView -> {
164
- OrgMember orgMember = tuple .getT1 ().getT1 ();
165
- Optional <Folder > optional = tuple .getT1 ().getT2 ();
166
- Optional <Folder > optionalFrom = tuple .getT1 ().getT3 ();
167
- String token = tuple .getT2 ();
168
- String category = tuple .getT3 ()[0 ];
169
- String description = tuple .getT3 ()[1 ];
170
- String title = tuple .getT3 ()[2 ];
171
- ApplicationInfoView applicationInfoView = applicationView .getApplicationInfoView ();
172
-
173
- ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
174
- .orgId (orgMember .getOrgId ())
175
- .userId (orgMember .getUserId ())
176
- .applicationId (applicationInfoView .getApplicationId ())
177
- .applicationGid (applicationInfoView .getApplicationGid ())
178
- .applicationName (applicationInfoView .getName ())
179
- .applicationAuthor (applicationInfoView .getCreateBy ())
180
- .applicationCategory (category )
181
- .applicationDescription (description )
182
- .applicationTitle (title )
183
- .oldApplicationName (originalApplicationView !=null ? originalApplicationView .getApplicationInfoView ().getName () : null )
184
- .oldApplicationCategory (originalApplicationView !=null ?originalApplicationView .getApplicationInfoView ().getCategory () : null )
185
- .oldApplicationDescription (originalApplicationView !=null ?originalApplicationView .getApplicationInfoView ().getDescription () : null )
186
- .oldApplicationTitle (originalApplicationView !=null ?originalApplicationView .getApplicationInfoView ().getTitle () : null )
187
- .type (eventType )
188
- .folderId (optional .map (Folder ::getId ).orElse (null ))
189
- .folderName (optional .map (Folder ::getName ).orElse (null ))
190
- .oldFolderId (optionalFrom .map (Folder ::getId ).orElse (null ))
191
- .oldFolderName (optionalFrom .map (Folder ::getName ).orElse (null ))
192
- .isAnonymous (anonymous )
193
- .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
194
- .build ();
195
-
196
- event .populateDetails (contextView );
197
- applicationEventPublisher .publishEvent (event );
198
- return Mono .empty ();
199
- })).then () // **Ensures Mono<Void> return type**
200
- .onErrorResume (throwable -> {
201
- log .error ("publishApplicationCommonEvent error. {}, {}" , applicationView , eventType , throwable );
202
- return Mono .empty ();
203
- });
204
- });
128
+ .flatMap (anonymous -> sessionUserService .getVisitorOrgMemberCache ()
129
+ .onErrorReturn (new OrgMember (null , null , null , null , 0 ))
130
+ .zipWith (Mono .defer (() -> {
131
+ String folderId = applicationView .getApplicationInfoView ().getFolderId ();
132
+ if (StringUtils .isBlank (folderId )) {
133
+ return Mono .just (Optional .<Folder >empty ());
134
+ }
135
+ return folderService .findById (folderId )
136
+ .map (Optional ::of )
137
+ .onErrorReturn (Optional .empty ());
138
+ }))
139
+ .zipWith (Mono .defer (() -> {
140
+ String folderId = applicationView .getApplicationInfoView ().getFolderIdFrom ();
141
+ if (StringUtils .isBlank (folderId )) {
142
+ return Mono .just (Optional .<Folder >empty ());
143
+ }
144
+ return folderService .findById (folderId )
145
+ .map (Optional ::of )
146
+ .onErrorReturn (Optional .empty ());
147
+ }), TupleUtils ::merge )
148
+ .zipWith (sessionUserService .getVisitorToken ())
149
+ .zipWith (Mono .defer (() -> {
150
+ String appId = applicationView .getApplicationInfoView ().getApplicationId ();
151
+ return applicationService .findById (appId )
152
+ .zipWhen (application -> application .getCategory (applicationRecordServiceImpl ))
153
+ .zipWhen (application -> application .getT1 ().getDescription (applicationRecordServiceImpl ))
154
+ .zipWhen (application -> application .getT1 ().getT1 ().getTitle (applicationRecordServiceImpl ))
155
+ .map (tuple -> {
156
+ String category = tuple .getT1 ().getT1 ().getT2 ();
157
+ String description = tuple .getT1 ().getT2 ();
158
+ String title = tuple .getT2 ();
159
+ return new String []{category , description , title };
160
+ });
161
+ }), TupleUtils ::merge )
162
+ .flatMap (tuple -> Mono .deferContextual (contextView -> {
163
+ OrgMember orgMember = tuple .getT1 ().getT1 ();
164
+ Optional <Folder > optional = tuple .getT1 ().getT2 ();
165
+ Optional <Folder > optionalFrom = tuple .getT1 ().getT3 ();
166
+ String token = tuple .getT2 ();
167
+ String category = tuple .getT3 ()[0 ];
168
+ String description = tuple .getT3 ()[1 ];
169
+ String title = tuple .getT3 ()[2 ];
170
+ ApplicationInfoView applicationInfoView = applicationView .getApplicationInfoView ();
171
+
172
+ ApplicationCommonEvent event = ApplicationCommonEvent .builder ()
173
+ .orgId (orgMember .getOrgId ())
174
+ .userId (orgMember .getUserId ())
175
+ .applicationId (applicationInfoView .getApplicationId ())
176
+ .applicationGid (applicationInfoView .getApplicationGid ())
177
+ .applicationName (applicationInfoView .getName ())
178
+ .applicationAuthor (applicationInfoView .getCreateBy ())
179
+ .applicationAuthorOrgId (applicationInfoView .getOrgId ())
180
+ .applicationCategory (category )
181
+ .applicationDescription (description )
182
+ .applicationTitle (title )
183
+ .oldApplicationName (originalApplicationView !=null ? originalApplicationView .getApplicationInfoView ().getName () : null )
184
+ .oldApplicationCategory (originalApplicationView !=null ?originalApplicationView .getApplicationInfoView ().getCategory () : null )
185
+ .oldApplicationDescription (originalApplicationView !=null ?originalApplicationView .getApplicationInfoView ().getDescription () : null )
186
+ .oldApplicationTitle (originalApplicationView !=null ?originalApplicationView .getApplicationInfoView ().getTitle () : null )
187
+ .type (eventType )
188
+ .folderId (optional .map (Folder ::getId ).orElse (null ))
189
+ .folderName (optional .map (Folder ::getName ).orElse (null ))
190
+ .oldFolderId (optionalFrom .map (Folder ::getId ).orElse (null ))
191
+ .oldFolderName (optionalFrom .map (Folder ::getName ).orElse (null ))
192
+ .isAnonymous (anonymous )
193
+ .sessionHash (Hashing .sha512 ().hashString (token , StandardCharsets .UTF_8 ).toString ())
194
+ .build ();
195
+
196
+ event .populateDetails (contextView );
197
+ applicationEventPublisher .publishEvent (event );
198
+ return Mono .empty ();
199
+ })).then () // **Ensures Mono<Void> return type**
200
+ .onErrorResume (throwable -> {
201
+ log .error ("publishApplicationCommonEvent error. {}, {}" , applicationView , eventType , throwable );
202
+ return Mono .empty ();
203
+ }));
205
204
}
206
205
207
206
0 commit comments