3131import org .apache .polaris .core .admin .model .UpdatePrincipalRoleRequest ;
3232import org .apache .polaris .core .context .RealmContext ;
3333import org .apache .polaris .service .admin .api .PolarisPrincipalRolesApiService ;
34+ import org .apache .polaris .service .events .AttributeMap ;
3435import org .apache .polaris .service .events .EventAttributes ;
3536import org .apache .polaris .service .events .PolarisEvent ;
3637import org .apache .polaris .service .events .PolarisEventMetadataFactory ;
@@ -51,50 +52,52 @@ public Response createPrincipalRole(
5152 RealmContext realmContext ,
5253 SecurityContext securityContext ) {
5354 polarisEventListener .onEvent (
54- PolarisEvent . builder (
55- PolarisEventType .BEFORE_CREATE_PRINCIPAL_ROLE , eventMetadataFactory . create ())
56- . attribute ( EventAttributes . CREATE_PRINCIPAL_ROLE_REQUEST , request )
57- . build ( ));
55+ new PolarisEvent (
56+ PolarisEventType .BEFORE_CREATE_PRINCIPAL_ROLE ,
57+ eventMetadataFactory . create (),
58+ new AttributeMap (). put ( EventAttributes . CREATE_PRINCIPAL_ROLE_REQUEST , request ) ));
5859 Response resp = delegate .createPrincipalRole (request , realmContext , securityContext );
5960 polarisEventListener .onEvent (
60- PolarisEvent .builder (
61- PolarisEventType .AFTER_CREATE_PRINCIPAL_ROLE , eventMetadataFactory .create ())
62- .attribute (EventAttributes .PRINCIPAL_ROLE , (PrincipalRole ) resp .getEntity ())
63- .build ());
61+ new PolarisEvent (
62+ PolarisEventType .AFTER_CREATE_PRINCIPAL_ROLE ,
63+ eventMetadataFactory .create (),
64+ new AttributeMap ()
65+ .put (EventAttributes .PRINCIPAL_ROLE , (PrincipalRole ) resp .getEntity ())));
6466 return resp ;
6567 }
6668
6769 @ Override
6870 public Response deletePrincipalRole (
6971 String principalRoleName , RealmContext realmContext , SecurityContext securityContext ) {
7072 polarisEventListener .onEvent (
71- PolarisEvent . builder (
72- PolarisEventType .BEFORE_DELETE_PRINCIPAL_ROLE , eventMetadataFactory . create ())
73- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
74- . build ( ));
73+ new PolarisEvent (
74+ PolarisEventType .BEFORE_DELETE_PRINCIPAL_ROLE ,
75+ eventMetadataFactory . create (),
76+ new AttributeMap (). put ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName ) ));
7577 Response resp = delegate .deletePrincipalRole (principalRoleName , realmContext , securityContext );
7678 polarisEventListener .onEvent (
77- PolarisEvent . builder (
78- PolarisEventType .AFTER_DELETE_PRINCIPAL_ROLE , eventMetadataFactory . create ())
79- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
80- . build ( ));
79+ new PolarisEvent (
80+ PolarisEventType .AFTER_DELETE_PRINCIPAL_ROLE ,
81+ eventMetadataFactory . create (),
82+ new AttributeMap (). put ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName ) ));
8183 return resp ;
8284 }
8385
8486 @ Override
8587 public Response getPrincipalRole (
8688 String principalRoleName , RealmContext realmContext , SecurityContext securityContext ) {
8789 polarisEventListener .onEvent (
88- PolarisEvent . builder (
89- PolarisEventType .BEFORE_GET_PRINCIPAL_ROLE , eventMetadataFactory . create ())
90- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
91- . build ( ));
90+ new PolarisEvent (
91+ PolarisEventType .BEFORE_GET_PRINCIPAL_ROLE ,
92+ eventMetadataFactory . create (),
93+ new AttributeMap (). put ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName ) ));
9294 Response resp = delegate .getPrincipalRole (principalRoleName , realmContext , securityContext );
9395 polarisEventListener .onEvent (
94- PolarisEvent .builder (
95- PolarisEventType .AFTER_GET_PRINCIPAL_ROLE , eventMetadataFactory .create ())
96- .attribute (EventAttributes .PRINCIPAL_ROLE , (PrincipalRole ) resp .getEntity ())
97- .build ());
96+ new PolarisEvent (
97+ PolarisEventType .AFTER_GET_PRINCIPAL_ROLE ,
98+ eventMetadataFactory .create (),
99+ new AttributeMap ()
100+ .put (EventAttributes .PRINCIPAL_ROLE , (PrincipalRole ) resp .getEntity ())));
98101 return resp ;
99102 }
100103
@@ -105,33 +108,37 @@ public Response updatePrincipalRole(
105108 RealmContext realmContext ,
106109 SecurityContext securityContext ) {
107110 polarisEventListener .onEvent (
108- PolarisEvent .builder (
109- PolarisEventType .BEFORE_UPDATE_PRINCIPAL_ROLE , eventMetadataFactory .create ())
110- .attribute (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
111- .attribute (EventAttributes .UPDATE_PRINCIPAL_ROLE_REQUEST , updateRequest )
112- .build ());
111+ new PolarisEvent (
112+ PolarisEventType .BEFORE_UPDATE_PRINCIPAL_ROLE ,
113+ eventMetadataFactory .create (),
114+ new AttributeMap ()
115+ .put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
116+ .put (EventAttributes .UPDATE_PRINCIPAL_ROLE_REQUEST , updateRequest )));
113117 Response resp =
114118 delegate .updatePrincipalRole (
115119 principalRoleName , updateRequest , realmContext , securityContext );
116120 polarisEventListener .onEvent (
117- PolarisEvent .builder (
118- PolarisEventType .AFTER_UPDATE_PRINCIPAL_ROLE , eventMetadataFactory .create ())
119- .attribute (EventAttributes .PRINCIPAL_ROLE , (PrincipalRole ) resp .getEntity ())
120- .build ());
121+ new PolarisEvent (
122+ PolarisEventType .AFTER_UPDATE_PRINCIPAL_ROLE ,
123+ eventMetadataFactory .create (),
124+ new AttributeMap ()
125+ .put (EventAttributes .PRINCIPAL_ROLE , (PrincipalRole ) resp .getEntity ())));
121126 return resp ;
122127 }
123128
124129 @ Override
125130 public Response listPrincipalRoles (RealmContext realmContext , SecurityContext securityContext ) {
126131 polarisEventListener .onEvent (
127- PolarisEvent .builder (
128- PolarisEventType .BEFORE_LIST_PRINCIPAL_ROLES , eventMetadataFactory .create ())
129- .build ());
132+ new PolarisEvent (
133+ PolarisEventType .BEFORE_LIST_PRINCIPAL_ROLES ,
134+ eventMetadataFactory .create (),
135+ new AttributeMap ()));
130136 Response resp = delegate .listPrincipalRoles (realmContext , securityContext );
131137 polarisEventListener .onEvent (
132- PolarisEvent .builder (
133- PolarisEventType .AFTER_LIST_PRINCIPAL_ROLES , eventMetadataFactory .create ())
134- .build ());
138+ new PolarisEvent (
139+ PolarisEventType .AFTER_LIST_PRINCIPAL_ROLES ,
140+ eventMetadataFactory .create (),
141+ new AttributeMap ()));
135142 return resp ;
136143 }
137144
@@ -143,24 +150,24 @@ public Response assignCatalogRoleToPrincipalRole(
143150 RealmContext realmContext ,
144151 SecurityContext securityContext ) {
145152 polarisEventListener .onEvent (
146- PolarisEvent . builder (
147- PolarisEventType .BEFORE_ASSIGN_CATALOG_ROLE_TO_PRINCIPAL_ROLE ,
148- eventMetadataFactory .create ())
149- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
150- . attribute (EventAttributes .CATALOG_NAME , catalogName )
151- . attribute (EventAttributes .CATALOG_ROLE_NAME , request . getCatalogRole (). getName () )
152- . build ( ));
153+ new PolarisEvent (
154+ PolarisEventType .BEFORE_ASSIGN_CATALOG_ROLE_TO_PRINCIPAL_ROLE ,
155+ eventMetadataFactory .create (),
156+ new AttributeMap ( )
157+ . put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
158+ . put (EventAttributes .CATALOG_NAME , catalogName )
159+ . put ( EventAttributes . CATALOG_ROLE_NAME , request . getCatalogRole (). getName ()) ));
153160 Response resp =
154161 delegate .assignCatalogRoleToPrincipalRole (
155162 principalRoleName , catalogName , request , realmContext , securityContext );
156163 polarisEventListener .onEvent (
157- PolarisEvent . builder (
158- PolarisEventType .AFTER_ASSIGN_CATALOG_ROLE_TO_PRINCIPAL_ROLE ,
159- eventMetadataFactory .create ())
160- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
161- . attribute (EventAttributes .CATALOG_NAME , catalogName )
162- . attribute (EventAttributes .CATALOG_ROLE_NAME , request . getCatalogRole (). getName () )
163- . build ( ));
164+ new PolarisEvent (
165+ PolarisEventType .AFTER_ASSIGN_CATALOG_ROLE_TO_PRINCIPAL_ROLE ,
166+ eventMetadataFactory .create (),
167+ new AttributeMap ( )
168+ . put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
169+ . put (EventAttributes .CATALOG_NAME , catalogName )
170+ . put ( EventAttributes . CATALOG_ROLE_NAME , request . getCatalogRole (). getName ()) ));
164171 return resp ;
165172 }
166173
@@ -172,45 +179,43 @@ public Response revokeCatalogRoleFromPrincipalRole(
172179 RealmContext realmContext ,
173180 SecurityContext securityContext ) {
174181 polarisEventListener .onEvent (
175- PolarisEvent . builder (
176- PolarisEventType .BEFORE_REVOKE_CATALOG_ROLE_FROM_PRINCIPAL_ROLE ,
177- eventMetadataFactory .create ())
178- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
179- . attribute (EventAttributes .CATALOG_NAME , catalogName )
180- . attribute (EventAttributes .CATALOG_ROLE_NAME , catalogRoleName )
181- . build ( ));
182+ new PolarisEvent (
183+ PolarisEventType .BEFORE_REVOKE_CATALOG_ROLE_FROM_PRINCIPAL_ROLE ,
184+ eventMetadataFactory .create (),
185+ new AttributeMap ( )
186+ . put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
187+ . put (EventAttributes .CATALOG_NAME , catalogName )
188+ . put ( EventAttributes . CATALOG_ROLE_NAME , catalogRoleName ) ));
182189 Response resp =
183190 delegate .revokeCatalogRoleFromPrincipalRole (
184191 principalRoleName , catalogName , catalogRoleName , realmContext , securityContext );
185192 polarisEventListener .onEvent (
186- PolarisEvent . builder (
187- PolarisEventType .AFTER_REVOKE_CATALOG_ROLE_FROM_PRINCIPAL_ROLE ,
188- eventMetadataFactory .create ())
189- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
190- . attribute (EventAttributes .CATALOG_NAME , catalogName )
191- . attribute (EventAttributes .CATALOG_ROLE_NAME , catalogRoleName )
192- . build ( ));
193+ new PolarisEvent (
194+ PolarisEventType .AFTER_REVOKE_CATALOG_ROLE_FROM_PRINCIPAL_ROLE ,
195+ eventMetadataFactory .create (),
196+ new AttributeMap ( )
197+ . put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
198+ . put (EventAttributes .CATALOG_NAME , catalogName )
199+ . put ( EventAttributes . CATALOG_ROLE_NAME , catalogRoleName ) ));
193200 return resp ;
194201 }
195202
196203 @ Override
197204 public Response listAssigneePrincipalsForPrincipalRole (
198205 String principalRoleName , RealmContext realmContext , SecurityContext securityContext ) {
199206 polarisEventListener .onEvent (
200- PolarisEvent .builder (
201- PolarisEventType .BEFORE_LIST_ASSIGNEE_PRINCIPALS_FOR_PRINCIPAL_ROLE ,
202- eventMetadataFactory .create ())
203- .attribute (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
204- .build ());
207+ new PolarisEvent (
208+ PolarisEventType .BEFORE_LIST_ASSIGNEE_PRINCIPALS_FOR_PRINCIPAL_ROLE ,
209+ eventMetadataFactory .create (),
210+ new AttributeMap ().put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )));
205211 Response resp =
206212 delegate .listAssigneePrincipalsForPrincipalRole (
207213 principalRoleName , realmContext , securityContext );
208214 polarisEventListener .onEvent (
209- PolarisEvent .builder (
210- PolarisEventType .AFTER_LIST_ASSIGNEE_PRINCIPALS_FOR_PRINCIPAL_ROLE ,
211- eventMetadataFactory .create ())
212- .attribute (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
213- .build ());
215+ new PolarisEvent (
216+ PolarisEventType .AFTER_LIST_ASSIGNEE_PRINCIPALS_FOR_PRINCIPAL_ROLE ,
217+ eventMetadataFactory .create (),
218+ new AttributeMap ().put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )));
214219 return resp ;
215220 }
216221
@@ -221,22 +226,22 @@ public Response listCatalogRolesForPrincipalRole(
221226 RealmContext realmContext ,
222227 SecurityContext securityContext ) {
223228 polarisEventListener .onEvent (
224- PolarisEvent . builder (
225- PolarisEventType .BEFORE_LIST_CATALOG_ROLES_FOR_PRINCIPAL_ROLE ,
226- eventMetadataFactory .create ())
227- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
228- . attribute (EventAttributes .CATALOG_NAME , catalogName )
229- . build ( ));
229+ new PolarisEvent (
230+ PolarisEventType .BEFORE_LIST_CATALOG_ROLES_FOR_PRINCIPAL_ROLE ,
231+ eventMetadataFactory .create (),
232+ new AttributeMap ( )
233+ . put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
234+ . put ( EventAttributes . CATALOG_NAME , catalogName ) ));
230235 Response resp =
231236 delegate .listCatalogRolesForPrincipalRole (
232237 principalRoleName , catalogName , realmContext , securityContext );
233238 polarisEventListener .onEvent (
234- PolarisEvent . builder (
235- PolarisEventType .AFTER_LIST_CATALOG_ROLES_FOR_PRINCIPAL_ROLE ,
236- eventMetadataFactory .create ())
237- . attribute ( EventAttributes . PRINCIPAL_ROLE_NAME , principalRoleName )
238- . attribute (EventAttributes .CATALOG_NAME , catalogName )
239- . build ( ));
239+ new PolarisEvent (
240+ PolarisEventType .AFTER_LIST_CATALOG_ROLES_FOR_PRINCIPAL_ROLE ,
241+ eventMetadataFactory .create (),
242+ new AttributeMap ( )
243+ . put (EventAttributes .PRINCIPAL_ROLE_NAME , principalRoleName )
244+ . put ( EventAttributes . CATALOG_NAME , catalogName ) ));
240245 return resp ;
241246 }
242247}
0 commit comments