001package ca.uhn.fhir.interceptor.api;
002
003/*-
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2020 University Health Network
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
024import ca.uhn.fhir.rest.annotation.Read;
025import ca.uhn.fhir.rest.annotation.Search;
026import ca.uhn.fhir.rest.server.exceptions.AuthenticationException;
027import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
028
029import javax.annotation.Nonnull;
030import java.util.*;
031
032/**
033 * Value for {@link Hook#value()}
034 * <p>
035 * Hook pointcuts are divided into several broad categories:
036 * <ul>
037 * <li>INTERCEPTOR_xxx: Hooks on the interceptor infrastructure itself</li>
038 * <li>CLIENT_xxx: Hooks on the HAPI FHIR Client framework</li>
039 * <li>SERVER_xxx: Hooks on the HAPI FHIR Server framework</li>
040 * <li>SUBSCRIPTION_xxx: Hooks on the HAPI FHIR Subscription framework</li>
041 * <li>STORAGE_xxx: Hooks on the storage engine</li>
042 * <li>JPA_PERFTRACE_xxx: Performance tracing hooks on the JPA server</li>
043 * </ul>
044 * </p>
045 */
046public enum Pointcut {
047
048        /**
049         * <b>Interceptor Framework Hook:</b>
050         * This pointcut will be called once when a given interceptor is registered
051         */
052        INTERCEPTOR_REGISTERED(void.class),
053
054        /**
055         * <b>Client Hook:</b>
056         * This hook is called before an HTTP client request is sent
057         * <p>
058         * Hooks may accept the following parameters:
059         * <ul>
060         * <li>
061         * ca.uhn.fhir.rest.client.api.IHttpRequest - The details of the request
062         * </li>
063         * </ul>
064         * </p>
065         * Hook methods must return <code>void</code>.
066         */
067        CLIENT_REQUEST(void.class,
068                "ca.uhn.fhir.rest.client.api.IHttpRequest"
069        ),
070
071        /**
072         * <b>Client Hook:</b>
073         * This hook is called after an HTTP client request has completed, prior to returning
074         * the results to the calling code. Hook methods may modify the response.
075         * <p>
076         * Hooks may accept the following parameters:
077         * <ul>
078         * <li>
079         * ca.uhn.fhir.rest.client.api.IHttpRequest - The details of the request
080         * ca.uhn.fhir.rest.client.api.IHttpRequest - The details of the response
081         * </li>
082         * </ul>
083         * </p>
084         * Hook methods must return <code>void</code>.
085         */
086        CLIENT_RESPONSE(void.class,
087                "ca.uhn.fhir.rest.client.api.IHttpRequest",
088                "ca.uhn.fhir.rest.client.api.IHttpResponse"
089        ),
090
091        /**
092         * <b>Server Hook:</b>
093         * This hook is called before any other processing takes place for each incoming request. It may be used to provide
094         * alternate handling for some requests, or to screen requests before they are handled, etc.
095         * <p>
096         * Note that any exceptions thrown by this method will not be trapped by HAPI (they will be passed up to the server)
097         * </p>
098         * <p>
099         * Hooks may accept the following parameters:
100         * <ul>
101         * <li>
102         * javax.servlet.http.HttpServletRequest - The servlet request, when running in a servlet environment
103         * </li>
104         * <li>
105         * javax.servlet.http.HttpServletResponse - The servlet response, when running in a servlet environment
106         * </li>
107         * </ul>
108         * </p>
109         * Hook methods may return <code>true</code> or <code>void</code> if processing should continue normally.
110         * This is generally the right thing to do. If your interceptor is providing a response rather than
111         * letting HAPI handle the response normally, you must return <code>false</code>. In this case,
112         * no further processing will occur and no further interceptors will be called.
113         */
114        SERVER_INCOMING_REQUEST_PRE_PROCESSED(boolean.class,
115                "javax.servlet.http.HttpServletRequest",
116                "javax.servlet.http.HttpServletResponse"
117        ),
118
119        /**
120         * <b>Server Hook:</b>
121         * This hook is invoked upon any exception being thrown within the server's request processing code. This includes
122         * any exceptions thrown within resource provider methods (e.g. {@link Search} and {@link Read} methods) as well as
123         * any runtime exceptions thrown by the server itself. This also includes any {@link AuthenticationException}
124         * thrown.
125         * <p>
126         * Hooks may accept the following parameters:
127         * <ul>
128         * <li>
129         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
130         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
131         * pulled out of the servlet request. Note that the bean
132         * properties are not all guaranteed to be populated, depending on how early during processing the
133         * exception occurred.
134         * </li>
135         * <li>
136         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
137         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
138         * pulled out of the servlet request. Note that the bean
139         * properties are not all guaranteed to be populated, depending on how early during processing the
140         * exception occurred. This parameter is identical to the RequestDetails parameter above but will
141         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
142         * </li>
143         * <li>
144         * javax.servlet.http.HttpServletRequest - The servlet request, when running in a servlet environment
145         * </li>
146         * <li>
147         * javax.servlet.http.HttpServletResponse - The servlet response, when running in a servlet environment
148         * </li>
149         * <li>
150         * ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException - The exception that was thrown
151         * </li>
152         * </ul>
153         * </p>
154         * <p>
155         * Implementations of this method may choose to ignore/log/count/etc exceptions, and return <code>true</code> or
156         * <code>void</code>. In
157         * this case, processing will continue, and the server will automatically generate an {@link BaseOperationOutcome
158         * OperationOutcome}. Implementations may also choose to provide their own response to the client. In this case, they
159         * should return <code>false</code>, to indicate that they have handled the request and processing should stop.
160         * </p>
161         */
162        SERVER_HANDLE_EXCEPTION(boolean.class,
163                "ca.uhn.fhir.rest.api.server.RequestDetails",
164                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
165                "javax.servlet.http.HttpServletRequest",
166                "javax.servlet.http.HttpServletResponse",
167                "ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException"
168        ),
169
170        /**
171         * <b>Server Hook:</b>
172         * This method is called just before the actual implementing server method is invoked.
173         * <p>
174         * Hooks may accept the following parameters:
175         * <ul>
176         * <li>
177         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
178         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
179         * pulled out of the servlet request. Note that the bean
180         * properties are not all guaranteed to be populated, depending on how early during processing the
181         * exception occurred.
182         * </li>
183         * <li>
184         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
185         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
186         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
187         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
188         * </li>
189         * <li>
190         * javax.servlet.http.HttpServletRequest - The servlet request, when running in a servlet environment
191         * </li>
192         * <li>
193         * javax.servlet.http.HttpServletResponse - The servlet response, when running in a servlet environment
194         * </li>
195         * </ul>
196         * <p>
197         * Hook methods may return <code>true</code> or <code>void</code> if processing should continue normally.
198         * This is generally the right thing to do.
199         * If your interceptor is providing an HTTP response rather than letting HAPI handle the response normally, you
200         * must return <code>false</code>. In this case, no further processing will occur and no further interceptors
201         * will be called.
202         * </p>
203         * <p>
204         * Hook methods may also throw {@link AuthenticationException} if they would like. This exception may be thrown
205         * to indicate that the interceptor has detected an unauthorized access
206         * attempt. If thrown, processing will stop and an HTTP 401 will be returned to the client.
207         */
208        SERVER_INCOMING_REQUEST_POST_PROCESSED(boolean.class,
209                "ca.uhn.fhir.rest.api.server.RequestDetails",
210                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
211                "javax.servlet.http.HttpServletRequest",
212                "javax.servlet.http.HttpServletResponse"
213        ),
214
215
216        /**
217         * <b>Server Hook:</b>
218         * This hook is invoked before an incoming request is processed. Note that this method is called
219         * after the server has begin preparing the response to the incoming client request.
220         * As such, it is not able to supply a response to the incoming request in the way that
221         * SERVER_INCOMING_REQUEST_PRE_HANDLED and
222         * {@link #SERVER_INCOMING_REQUEST_POST_PROCESSED}
223         * are.
224         * <p>
225         * Hooks may accept the following parameters:
226         * <ul>
227         * <li>
228         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
229         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
230         * pulled out of the servlet request. Note that the bean
231         * properties are not all guaranteed to be populated, depending on how early during processing the
232         * exception occurred.
233         * </li>
234         * <li>
235         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
236         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
237         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
238         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
239         * </li>
240         * <li>
241         * ca.uhn.fhir.rest.api.RestOperationTypeEnum - The type of operation that the FHIR server has determined that the client is trying to invoke
242         * </li>
243         * <li>
244         * ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails - This parameter is provided for legacy reasons only and will be removed in the future. Do not use.
245         * </li>
246         * </ul>
247         * </p>
248         * <p>
249         * Hook methods must return <code>void</code>
250         * </p>
251         * <p>
252         * Hook methods method may throw a subclass of {@link BaseServerResponseException}, and processing
253         * will be aborted with an appropriate error returned to the client.
254         * </p>
255         */
256        SERVER_INCOMING_REQUEST_PRE_HANDLED(void.class,
257                "ca.uhn.fhir.rest.api.server.RequestDetails",
258                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
259                "ca.uhn.fhir.rest.api.RestOperationTypeEnum",
260                "ca.uhn.fhir.rest.server.interceptor.IServerInterceptor$ActionRequestDetails"
261        ),
262
263        /**
264         * <b>Server Hook:</b>
265         * This method is called upon any exception being thrown within the server's request processing code. This includes
266         * any exceptions thrown within resource provider methods (e.g. {@link Search} and {@link Read} methods) as well as
267         * any runtime exceptions thrown by the server itself. This hook method is invoked for each interceptor (until one of them
268         * returns a non-<code>null</code> response or the end of the list is reached), after which
269         * {@link #SERVER_HANDLE_EXCEPTION} is
270         * called for each interceptor.
271         * <p>
272         * This may be used to add an OperationOutcome to a response, or to convert between exception types for any reason.
273         * </p>
274         * <p>
275         * Implementations of this method may choose to ignore/log/count/etc exceptions, and return <code>null</code>. In
276         * this case, processing will continue, and the server will automatically generate an {@link BaseOperationOutcome
277         * OperationOutcome}. Implementations may also choose to provide their own response to the client. In this case, they
278         * should return a non-<code>null</code>, to indicate that they have handled the request and processing should stop.
279         * </p>
280         * <p>
281         * Hooks may accept the following parameters:
282         * <ul>
283         * <li>
284         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
285         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
286         * pulled out of the servlet request. Note that the bean
287         * properties are not all guaranteed to be populated, depending on how early during processing the
288         * exception occurred.
289         * </li>
290         * <li>
291         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
292         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
293         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
294         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
295         * </li>
296         * <li>
297         * java.lang.Throwable - The exception that was thrown. This will often be an instance of
298         * {@link BaseServerResponseException} but will not necessarily be one (e.g. it could be a
299         * {@link NullPointerException} in the case of a bug being triggered.
300         * </li>
301         * <li>
302         * javax.servlet.http.HttpServletRequest - The servlet request, when running in a servlet environment
303         * </li>
304         * <li>
305         * javax.servlet.http.HttpServletResponse - The servlet response, when running in a servlet environment
306         * </li>
307         * </ul>
308         * <p>
309         * Hook methods may return a new exception to use for processing, or <code>null</code> if this interceptor is not trying to
310         * modify the exception. For example, if this interceptor has nothing to do with exception processing, it
311         * should always return <code>null</code>. If this interceptor adds an OperationOutcome to the exception, it
312         * should return an exception.
313         * </p>
314         */
315        SERVER_PRE_PROCESS_OUTGOING_EXCEPTION(BaseServerResponseException.class,
316                "ca.uhn.fhir.rest.api.server.RequestDetails",
317                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
318                "java.lang.Throwable",
319                "javax.servlet.http.HttpServletRequest",
320                "javax.servlet.http.HttpServletResponse"
321        ),
322
323        /**
324         * <b>Server Hook:</b>
325         * This method is called after the server implementation method has been called, but before any attempt
326         * to stream the response back to the client. Interceptors may examine or modify the response before it
327         * is returned, or even prevent the response.
328         * <p>
329         * Hooks may accept the following parameters:
330         * <ul>
331         * <li>
332         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
333         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
334         * pulled out of the servlet request.
335         * </li>
336         * <li>
337         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
338         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
339         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
340         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
341         * </li>
342         * <li>
343         * org.hl7.fhir.instance.model.api.IBaseResource - The resource that will be returned. This parameter may be <code>null</code> for some responses.
344         * </li>
345         * <li>
346         * ca.uhn.fhir.rest.api.server.ResponseDetails - This object contains details about the response, including the contents. Hook methods may modify this object to change or replace the response.
347         * </li>
348         * <li>
349         * javax.servlet.http.HttpServletRequest - The servlet request, when running in a servlet environment
350         * </li>
351         * <li>
352         * javax.servlet.http.HttpServletResponse - The servlet response, when running in a servlet environment
353         * </li>
354         * </ul>
355         * </p>
356         * <p>
357         * Hook methods may return <code>true</code> or <code>void</code> if processing should continue normally.
358         * This is generally the right thing to do. If your interceptor is providing a response rather than
359         * letting HAPI handle the response normally, you must return <code>false</code>. In this case,
360         * no further processing will occur and no further interceptors will be called.
361         * </p>
362         * <p>
363         * Hook methods may also throw {@link AuthenticationException} to indicate that the interceptor
364         * has detected an unauthorized access attempt. If thrown, processing will stop and an HTTP 401
365         * will be returned to the client.
366         */
367        SERVER_OUTGOING_RESPONSE(boolean.class,
368                "ca.uhn.fhir.rest.api.server.RequestDetails",
369                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
370                "org.hl7.fhir.instance.model.api.IBaseResource",
371                "ca.uhn.fhir.rest.api.server.ResponseDetails",
372                "javax.servlet.http.HttpServletRequest",
373                "javax.servlet.http.HttpServletResponse"
374        ),
375
376
377
378        /**
379         * <b>Server Hook:</b>
380         * This method is called after the server implementation method has been called, but before any attempt
381         * to stream the response back to the client, specifically for GraphQL requests (as these do not fit
382         * cleanly into the model provided by {@link #SERVER_OUTGOING_RESPONSE}).
383         * <p>
384         * Hooks may accept the following parameters:
385         * <ul>
386         * <li>
387         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
388         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
389         * pulled out of the servlet request.
390         * </li>
391         * <li>
392         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
393         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
394         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
395         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
396         * </li>
397         * <li>
398         * java.lang.String - The GraphQL query
399         * </li>
400         * <li>
401         * java.lang.String - The GraphQL response
402         * </li>
403         * <li>
404         * javax.servlet.http.HttpServletRequest - The servlet request, when running in a servlet environment
405         * </li>
406         * <li>
407         * javax.servlet.http.HttpServletResponse - The servlet response, when running in a servlet environment
408         * </li>
409         * </ul>
410         * </p>
411         * <p>
412         * Hook methods may return <code>true</code> or <code>void</code> if processing should continue normally.
413         * This is generally the right thing to do. If your interceptor is providing a response rather than
414         * letting HAPI handle the response normally, you must return <code>false</code>. In this case,
415         * no further processing will occur and no further interceptors will be called.
416         * </p>
417         * <p>
418         * Hook methods may also throw {@link AuthenticationException} to indicate that the interceptor
419         * has detected an unauthorized access attempt. If thrown, processing will stop and an HTTP 401
420         * will be returned to the client.
421         */
422        SERVER_OUTGOING_GRAPHQL_RESPONSE(boolean.class,
423                "ca.uhn.fhir.rest.api.server.RequestDetails",
424                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
425                "java.lang.String",
426                "java.lang.String",
427                "javax.servlet.http.HttpServletRequest",
428                "javax.servlet.http.HttpServletResponse"
429        ),
430
431
432        /**
433         * <b>Server Hook:</b>
434         * This method is called when an OperationOutcome is being returned in response to a failure.
435         * Hook methods may use this hook to modify the OperationOutcome being returned.
436         * <p>
437         * Hooks may accept the following parameters:
438         * <ul>
439         * <li>
440         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
441         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
442         * pulled out of the servlet request. Note that the bean
443         * properties are not all guaranteed to be populated, depending on how early during processing the
444         * exception occurred.
445         * </li>
446         * <li>
447         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
448         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
449         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
450         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
451         * </li>
452         * <li>
453         * org.hl7.fhir.instance.model.api.IBaseOperationOutcome - The OperationOutcome resource that will be
454         * returned.
455         * </ul>
456         * <p>
457         * Hook methods must return <code>void</code>
458         * </p>
459         */
460        SERVER_OUTGOING_FAILURE_OPERATIONOUTCOME(
461                void.class,
462                "ca.uhn.fhir.rest.api.server.RequestDetails",
463                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
464                "org.hl7.fhir.instance.model.api.IBaseOperationOutcome"
465        ),
466
467
468        /**
469         * <b>Server Hook:</b>
470         * This method is called after all processing is completed for a request, but only if the
471         * request completes normally (i.e. no exception is thrown).
472         * <p>
473         * Hooks may accept the following parameters:
474         * <ul>
475         * <li>
476         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
477         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
478         * pulled out of the servlet request.
479         * </li>
480         * <li>
481         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
482         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
483         * pulled out of the request. This will be null if the server is not deployed to a RestfulServer environment.
484         * </li>
485         * </ul>
486         * </p>
487         * <p>
488         * This method must return <code>void</code>
489         * </p>
490         * <p>
491         * This method should not throw any exceptions. Any exception that is thrown by this
492         * method will be logged, but otherwise not acted upon (i.e. even if a hook method
493         * throws an exception, processing will continue and other interceptors will be
494         * called). Therefore it is considered a bug to throw an exception from hook methods using this
495         * pointcut.
496         * </p>
497         */
498        SERVER_PROCESSING_COMPLETED_NORMALLY(
499                void.class,
500                new ExceptionHandlingSpec()
501                        .addLogAndSwallow(Throwable.class),
502                "ca.uhn.fhir.rest.api.server.RequestDetails",
503                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
504        ),
505
506        /**
507         * <b>Server Hook:</b>
508         * This method is called after all processing is completed for a request, regardless of whether
509         * the request completed successfully or not. It is called after {@link #SERVER_PROCESSING_COMPLETED_NORMALLY}
510         * in the case of successful operations.
511         * <p>
512         * Hooks may accept the following parameters:
513         * <ul>
514         * <li>
515         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
516         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
517         * pulled out of the servlet request.
518         * </li>
519         * <li>
520         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
521         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
522         * pulled out of the request. This will be null if the server is not deployed to a RestfulServer environment.
523         * </li>
524         * </ul>
525         * </p>
526         * <p>
527         * This method must return <code>void</code>
528         * </p>
529         * <p>
530         * This method should not throw any exceptions. Any exception that is thrown by this
531         * method will be logged, but otherwise not acted upon (i.e. even if a hook method
532         * throws an exception, processing will continue and other interceptors will be
533         * called). Therefore it is considered a bug to throw an exception from hook methods using this
534         * pointcut.
535         * </p>
536         */
537        SERVER_PROCESSING_COMPLETED(
538                void.class,
539                new ExceptionHandlingSpec()
540                        .addLogAndSwallow(Throwable.class),
541                "ca.uhn.fhir.rest.api.server.RequestDetails",
542                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
543        ),
544
545        /**
546         * <b>Subscription Hook:</b>
547         * Invoked whenever a persisted resource has been modified and is being submitted to the
548         * subscription processing pipeline. This method is called before the resource is placed
549         * on any queues for processing and executes synchronously during the resource modification
550         * operation itself, so it should return quickly.
551         * <p>
552         * Hooks may accept the following parameters:
553         * <ul>
554         * <li>ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage - Hooks may modify this parameter. This will affect the checking process.</li>
555         * </ul>
556         * </p>
557         * <p>
558         * Hooks may return <code>void</code> or may return a <code>boolean</code>. If the method returns
559         * <code>void</code> or <code>true</code>, processing will continue normally. If the method
560         * returns <code>false</code>, subscription processing will not proceed for the given resource;
561         * </p>
562         */
563        SUBSCRIPTION_RESOURCE_MODIFIED(boolean.class, "ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage"),
564
565
566        /**
567         * <b>Subscription Hook:</b>
568         * Invoked any time that a resource is matched by an individual subscription, and
569         * is about to be queued for delivery.
570         * <p>
571         * Hooks may make changes to the delivery payload, or make changes to the
572         * canonical subscription such as adding headers, modifying the channel
573         * endpoint, etc.
574         * </p>
575         * Hooks may accept the following parameters:
576         * <ul>
577         * <li>ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription</li>
578         * <li>ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage</li>
579         * <li>ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult</li>
580         * </ul>
581         * <p>
582         * Hooks may return <code>void</code> or may return a <code>boolean</code>. If the method returns
583         * <code>void</code> or <code>true</code>, processing will continue normally. If the method
584         * returns <code>false</code>, delivery will be aborted.
585         * </p>
586         */
587        SUBSCRIPTION_RESOURCE_MATCHED(boolean.class, "ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription", "ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage", "ca.uhn.fhir.jpa.searchparam.matcher.InMemoryMatchResult"),
588
589        /**
590         * <b>Subscription Hook:</b>
591         * Invoked whenever a persisted resource was checked against all active subscriptions, and did not
592         * match any.
593         * <p>
594         * Hooks may accept the following parameters:
595         * <ul>
596         * <li>ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage - Hooks should not modify this parameter as changes will not have any effect.</li>
597         * </ul>
598         * </p>
599         * <p>
600         * Hooks should return <code>void</code>.
601         * </p>
602         */
603        SUBSCRIPTION_RESOURCE_DID_NOT_MATCH_ANY_SUBSCRIPTIONS(void.class, "ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage"),
604
605        /**
606         * <b>Subscription Hook:</b>
607         * Invoked immediately before the delivery of a subscription, and right before any channel-specific
608         * hooks are invoked (e.g. {@link #SUBSCRIPTION_BEFORE_REST_HOOK_DELIVERY}.
609         * <p>
610         * Hooks may make changes to the delivery payload, or make changes to the
611         * canonical subscription such as adding headers, modifying the channel
612         * endpoint, etc.
613         * </p>
614         * Hooks may accept the following parameters:
615         * <ul>
616         * <li>ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription</li>
617         * <li>ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage</li>
618         * </ul>
619         * <p>
620         * Hooks may return <code>void</code> or may return a <code>boolean</code>. If the method returns
621         * <code>void</code> or <code>true</code>, processing will continue normally. If the method
622         * returns <code>false</code>, processing will be aborted.
623         * </p>
624         */
625        SUBSCRIPTION_BEFORE_DELIVERY(boolean.class, "ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription", "ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage"),
626
627        /**
628         * <b>Subscription Hook:</b>
629         * Invoked immediately after the delivery of a subscription, and right before any channel-specific
630         * hooks are invoked (e.g. {@link #SUBSCRIPTION_AFTER_REST_HOOK_DELIVERY}.
631         * <p>
632         * Hooks may accept the following parameters:
633         * </p>
634         * <ul>
635         * <li>ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription</li>
636         * <li>ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage</li>
637         * </ul>
638         * <p>
639         * Hooks should return <code>void</code>.
640         * </p>
641         */
642        SUBSCRIPTION_AFTER_DELIVERY(void.class, "ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription", "ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage"),
643
644
645        /**
646         * <b>Subscription Hook:</b>
647         * Invoked immediately after the attempted delivery of a subscription, if the delivery
648         * failed.
649         * <p>
650         * Hooks may accept the following parameters:
651         * </p>
652         * <ul>
653         * <li>java.lang.Exception - The exception that caused the failure.  Note this could be an exception thrown by a SUBSCRIPTION_BEFORE_DELIVERY or SUBSCRIPTION_AFTER_DELIVERY interceptor</li>
654         * <li>ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage - the message that triggered the exception</li>
655         * <li>java.lang.Exception</li>
656         * </ul>
657         * <p>
658         * Hooks may return <code>void</code> or may return a <code>boolean</code>. If the method returns
659         * <code>void</code> or <code>true</code>, processing will continue normally, meaning that
660         * an exception will be thrown by the delivery mechanism. This typically means that the
661         * message will be returned to the processing queue. If the method
662         * returns <code>false</code>, processing will be aborted and no further action will be
663         * taken for the delivery.
664         * </p>
665         */
666        SUBSCRIPTION_AFTER_DELIVERY_FAILED(boolean.class, "ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage", "java.lang.Exception"),
667
668        /**
669         * <b>Subscription Hook:</b>
670         * Invoked immediately after the delivery of a REST HOOK subscription.
671         * <p>
672         * When this hook is called, all processing is complete so this hook should not
673         * make any changes to the parameters.
674         * </p>
675         * Hooks may accept the following parameters:
676         * <ul>
677         * <li>ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription</li>
678         * <li>ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage</li>
679         * </ul>
680         * <p>
681         * Hooks should return <code>void</code>.
682         * </p>
683         */
684        SUBSCRIPTION_AFTER_REST_HOOK_DELIVERY(void.class, "ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription", "ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage"),
685
686        /**
687         * <b>Subscription Hook:</b>
688         * Invoked immediately before the delivery of a REST HOOK subscription.
689         * <p>
690         * Hooks may make changes to the delivery payload, or make changes to the
691         * canonical subscription such as adding headers, modifying the channel
692         * endpoint, etc.
693         * </p>
694         * Hooks may accept the following parameters:
695         * <ul>
696         * <li>ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription</li>
697         * <li>ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage</li>
698         * </ul>
699         * <p>
700         * Hooks may return <code>void</code> or may return a <code>boolean</code>. If the method returns
701         * <code>void</code> or <code>true</code>, processing will continue normally. If the method
702         * returns <code>false</code>, processing will be aborted.
703         * </p>
704         */
705        SUBSCRIPTION_BEFORE_REST_HOOK_DELIVERY(boolean.class, "ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription", "ca.uhn.fhir.jpa.subscription.module.subscriber.ResourceDeliveryMessage"),
706
707        /**
708         * <b>Subscription Hook:</b>
709         * Invoked whenever a persisted resource (a resource that has just been stored in the
710         * database via a create/update/patch/etc.) is about to be checked for whether any subscriptions
711         * were triggered as a result of the operation.
712         * <p>
713         * Hooks may accept the following parameters:
714         * <ul>
715         * <li>ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage - Hooks may modify this parameter. This will affect the checking process.</li>
716         * </ul>
717         * </p>
718         * <p>
719         * Hooks may return <code>void</code> or may return a <code>boolean</code>. If the method returns
720         * <code>void</code> or <code>true</code>, processing will continue normally. If the method
721         * returns <code>false</code>, processing will be aborted.
722         * </p>
723         */
724        SUBSCRIPTION_BEFORE_PERSISTED_RESOURCE_CHECKED(boolean.class, "ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage"),
725
726
727        /**
728         * <b>Subscription Hook:</b>
729         * Invoked whenever a persisted resource (a resource that has just been stored in the
730         * database via a create/update/patch/etc.) has been checked for whether any subscriptions
731         * were triggered as a result of the operation.
732         * <p>
733         * Hooks may accept the following parameters:
734         * <ul>
735         * <li>ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage - This parameter should not be modified as processing is complete when this hook is invoked.</li>
736         * </ul>
737         * </p>
738         * <p>
739         * Hooks should return <code>void</code>.
740         * </p>
741         */
742        SUBSCRIPTION_AFTER_PERSISTED_RESOURCE_CHECKED(void.class, "ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage"),
743
744
745        /**
746         * <b>Subscription Hook:</b>
747         * Invoked immediately after an active subscription is "registered". In HAPI FHIR, when
748         * a subscription
749         * <p>
750         * Hooks may make changes to the canonicalized subscription and this will have an effect
751         * on processing across this server. Note however that timing issues may occur, since the
752         * subscription is already technically live by the time this hook is called.
753         * </p>
754         * Hooks may accept the following parameters:
755         * <ul>
756         * <li>ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription</li>
757         * </ul>
758         * <p>
759         * Hooks should return <code>void</code>.
760         * </p>
761         */
762        SUBSCRIPTION_AFTER_ACTIVE_SUBSCRIPTION_REGISTERED(void.class, "ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription"),
763
764
765        /**
766         * <b>Storage Hook:</b>
767         * Invoked when a resource is being deleted in a cascaded delete. This means that
768         * some other resource is being deleted, but per use request or other
769         * policy, the given resource (the one supplied as a parameter to this hook)
770         * is also being deleted.
771         * <p>
772         * Hooks may accept the following parameters:
773         * </p>
774         * <ul>
775         * <li>
776         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
777         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
778         * pulled out of the servlet request. Note that the bean
779         * properties are not all guaranteed to be populated, depending on how early during processing the
780         * exception occurred. <b>Note that this parameter may be null in contexts where the request is not
781         * known, such as while processing searches</b>
782         * </li>
783         * <li>
784         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
785         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
786         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
787         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
788         * </li>
789         * <li>
790         * ca.uhn.fhir.jpa.util.DeleteConflictList - Contains the details about the delete conflicts that are
791         * being resolved via deletion. The source resource is the resource that will be deleted, and
792         * is a cascade because the target resource is already being deleted.
793         * </li>
794         * <li>
795         * org.hl7.fhir.instance.model.api.IBaseResource - The actual resource that is about to be deleted via a cascading delete
796         * </li>
797         * </ul>
798         * <p>
799         * Hooks should return <code>void</code>. They may choose to throw an exception however, in
800         * which case the delete should be rolled back.
801         * </p>
802         */
803        STORAGE_CASCADE_DELETE(
804                void.class,
805                "ca.uhn.fhir.rest.api.server.RequestDetails",
806                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
807                "ca.uhn.fhir.jpa.delete.DeleteConflictList",
808                "org.hl7.fhir.instance.model.api.IBaseResource"
809        ),
810
811        /**
812         * <b>Storage Hook:</b>
813         * Invoked when one or more resources may be returned to the user, whether as a part of a READ,
814         * a SEARCH, or even as the response to a CREATE/UPDATE, etc.
815         * <p>
816         * This hook is invoked when a resource has been loaded by the storage engine and
817         * is being returned to the HTTP stack for response. This is not a guarantee that the
818         * client will ultimately see it, since filters/headers/etc may affect what
819         * is returned but if a resource is loaded it is likely to be used.
820         * Note also that caching may affect whether this pointcut is invoked.
821         * </p>
822         * <p>
823         * Hooks will have access to the contents of the resource being returned
824         * and may choose to make modifications. These changes will be reflected in
825         * returned resource but have no effect on storage.
826         * </p>
827         * Hooks may accept the following parameters:
828         * <ul>
829         * <li>
830         * ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails - Contains details about the
831         * specific resources being returned.
832         * </li>
833         * <li>
834         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
835         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
836         * pulled out of the servlet request. Note that the bean
837         * properties are not all guaranteed to be populated, depending on how early during processing the
838         * exception occurred. <b>Note that this parameter may be null in contexts where the request is not
839         * known, such as while processing searches</b>
840         * </li>
841         * <li>
842         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
843         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
844         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
845         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
846         * </li>
847         * </ul>
848         * <p>
849         * Hooks should return <code>void</code>.
850         * </p>
851         */
852        STORAGE_PREACCESS_RESOURCES(void.class,
853                "ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails",
854                "ca.uhn.fhir.rest.api.server.RequestDetails",
855                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
856        ),
857
858        /**
859         * <b>Storage Hook:</b>
860         * Invoked when the storage engine is about to check for the existence of a pre-cached search
861         * whose results match the given search parameters.
862         * <p>
863         * Hooks may accept the following parameters:
864         * </p>
865         * <ul>
866         * <li>
867         * ca.uhn.fhir.jpa.searchparam.SearchParameterMap - Contains the details of the search being checked
868         * </li>
869         * <li>
870         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
871         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
872         * pulled out of the servlet request. Note that the bean
873         * properties are not all guaranteed to be populated, depending on how early during processing the
874         * exception occurred. <b>Note that this parameter may be null in contexts where the request is not
875         * known, such as while processing searches</b>
876         * </li>
877         * <li>
878         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
879         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
880         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
881         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
882         * </li>
883         * </ul>
884         * <p>
885         * Hooks may return <code>boolean</code>. If the hook method returns
886         * <code>false</code>, the server will not attempt to check for a cached
887         * search no matter what.
888         * </p>
889         */
890        STORAGE_PRECHECK_FOR_CACHED_SEARCH(boolean.class,
891                "ca.uhn.fhir.jpa.searchparam.SearchParameterMap",
892                "ca.uhn.fhir.rest.api.server.RequestDetails",
893                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
894        ),
895
896        /**
897         * <b>Storage Hook:</b>
898         * Invoked when a search is starting, prior to creating a record for the search.
899         * <p>
900         * Hooks may accept the following parameters:
901         * </p>
902         * <ul>
903         * <li>
904         * ca.uhn.fhir.rest.server.util.ICachedSearchDetails - Contains the details of the search that
905         * is being created and initialized
906         * </li>
907         * <li>
908         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
909         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
910         * pulled out of the servlet request. Note that the bean
911         * properties are not all guaranteed to be populated, depending on how early during processing the
912         * exception occurred. <b>Note that this parameter may be null in contexts where the request is not
913         * known, such as while processing searches</b>
914         * </li>
915         * <li>
916         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
917         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
918         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
919         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
920         * </li>
921         * </ul>
922         * <p>
923         * Hooks should return <code>void</code>.
924         * </p>
925         */
926        STORAGE_PRESEARCH_REGISTERED(void.class,
927                "ca.uhn.fhir.rest.server.util.ICachedSearchDetails",
928                "ca.uhn.fhir.rest.api.server.RequestDetails",
929                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
930        ),
931
932        /**
933         * <b>Storage Hook:</b>
934         * Invoked when one or more resources may be returned to the user, whether as a part of a READ,
935         * a SEARCH, or even as the response to a CREATE/UPDATE, etc.
936         * <p>
937         * This hook is invoked when a resource has been loaded by the storage engine and
938         * is being returned to the HTTP stack for response.
939         * This is not a guarantee that the
940         * client will ultimately see it, since filters/headers/etc may affect what
941         * is returned but if a resource is loaded it is likely to be used.
942         * Note also that caching may affect whether this pointcut is invoked.
943         * </p>
944         * <p>
945         * Hooks will have access to the contents of the resource being returned
946         * and may choose to make modifications. These changes will be reflected in
947         * returned resource but have no effect on storage.
948         * </p>
949         * Hooks may accept the following parameters:
950         * <ul>
951         * <li>
952         * ca.uhn.fhir.rest.api.server.IPreResourceShowDetails - Contains the resources that
953         * will be shown to the user. This object may be manipulated in order to modify
954         * the actual resources being shown to the user (e.g. for masking)
955         * </li>
956         * <li>
957         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
958         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
959         * pulled out of the servlet request. Note that the bean
960         * properties are not all guaranteed to be populated, depending on how early during processing the
961         * exception occurred. <b>Note that this parameter may be null in contexts where the request is not
962         * known, such as while processing searches</b>
963         * </li>
964         * <li>
965         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
966         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
967         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
968         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
969         * </li>
970         * </ul>
971         * <p>
972         * Hooks should return <code>void</code>.
973         * </p>
974         */
975        STORAGE_PRESHOW_RESOURCES(void.class,
976                "ca.uhn.fhir.rest.api.server.IPreResourceShowDetails",
977                "ca.uhn.fhir.rest.api.server.RequestDetails",
978                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
979        ),
980
981        /**
982         * <b>Storage Hook:</b>
983         * Invoked before a resource will be created, immediately before the resource
984         * is persisted to the database.
985         * <p>
986         * Hooks will have access to the contents of the resource being created
987         * and may choose to make modifications to it. These changes will be
988         * reflected in permanent storage.
989         * </p>
990         * Hooks may accept the following parameters:
991         * <ul>
992         * <li>org.hl7.fhir.instance.model.api.IBaseResource</li>
993         * <li>
994         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
995         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
996         * pulled out of the servlet request. Note that the bean
997         * properties are not all guaranteed to be populated, depending on how early during processing the
998         * exception occurred.
999         * </li>
1000         * <li>
1001         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1002         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1003         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1004         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1005         * </li>
1006         * </ul>
1007         * <p>
1008         * Hooks should return <code>void</code>.
1009         * </p>
1010         */
1011        STORAGE_PRESTORAGE_RESOURCE_CREATED(void.class,
1012                "org.hl7.fhir.instance.model.api.IBaseResource",
1013                "ca.uhn.fhir.rest.api.server.RequestDetails",
1014                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1015        ),
1016
1017        /**
1018         * <b>Storage Hook:</b>
1019         * Invoked before a resource will be updated, immediately before the resource
1020         * is persisted to the database.
1021         * <p>
1022         * Hooks will have access to the contents of the resource being updated
1023         * (both the previous and new contents) and may choose to make modifications
1024         * to the new contents of the resource. These changes will be reflected in
1025         * permanent storage.
1026         * </p>
1027         * Hooks may accept the following parameters:
1028         * <ul>
1029         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The previous contents of the resource being updated</li>
1030         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The new contents of the resource being updated</li>
1031         * <li>
1032         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1033         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1034         * pulled out of the servlet request. Note that the bean
1035         * properties are not all guaranteed to be populated, depending on how early during processing the
1036         * exception occurred.
1037         * </li>
1038         * <li>
1039         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1040         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1041         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1042         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1043         * </li>
1044         * </ul>
1045         * <p>
1046         * Hooks should return <code>void</code>.
1047         * </p>
1048         */
1049        STORAGE_PRESTORAGE_RESOURCE_UPDATED(void.class,
1050                "org.hl7.fhir.instance.model.api.IBaseResource",
1051                "org.hl7.fhir.instance.model.api.IBaseResource",
1052                "ca.uhn.fhir.rest.api.server.RequestDetails",
1053                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1054        ),
1055
1056        /**
1057         * <b>Storage Hook:</b>
1058         * Invoked before a resource will be created, immediately before the resource
1059         * is persisted to the database.
1060         * <p>
1061         * Hooks will have access to the contents of the resource being created
1062         * and may choose to make modifications to it. These changes will be
1063         * reflected in permanent storage.
1064         * </p>
1065         * Hooks may accept the following parameters:
1066         * <ul>
1067         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The resource being deleted</li>
1068         * <li>
1069         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1070         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1071         * pulled out of the servlet request. Note that the bean
1072         * properties are not all guaranteed to be populated, depending on how early during processing the
1073         * exception occurred.
1074         * </li>
1075         * <li>
1076         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1077         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1078         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1079         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1080         * </li>
1081         * </ul>
1082         * <p>
1083         * Hooks should return <code>void</code>.
1084         * </p>
1085         */
1086        STORAGE_PRESTORAGE_RESOURCE_DELETED(void.class,
1087                "org.hl7.fhir.instance.model.api.IBaseResource",
1088                "ca.uhn.fhir.rest.api.server.RequestDetails",
1089                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1090        ),
1091
1092
1093        /**
1094         * <b>Storage Hook:</b>
1095         * Invoked before a resource will be created, immediately before the transaction
1096         * is committed (after all validation and other business rules have successfully
1097         * completed, and any other database activity is complete.
1098         * <p>
1099         * Hooks will have access to the contents of the resource being created
1100         * but should generally not make any
1101         * changes as storage has already occurred. Changes will not be reflected
1102         * in storage, but may be reflected in the HTTP response.
1103         * </p>
1104         * Hooks may accept the following parameters:
1105         * <ul>
1106         * <li>org.hl7.fhir.instance.model.api.IBaseResource</li>
1107         * <li>
1108         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1109         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1110         * pulled out of the servlet request. Note that the bean
1111         * properties are not all guaranteed to be populated, depending on how early during processing the
1112         * exception occurred.
1113         * </li>
1114         * <li>
1115         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1116         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1117         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1118         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1119         * </li>
1120         * </ul>
1121         * <p>
1122         * Hooks should return <code>void</code>.
1123         * </p>
1124         */
1125        STORAGE_PRECOMMIT_RESOURCE_CREATED(void.class,
1126                "org.hl7.fhir.instance.model.api.IBaseResource",
1127                "ca.uhn.fhir.rest.api.server.RequestDetails",
1128                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1129        ),
1130
1131        /**
1132         * <b>Storage Hook:</b>
1133         * Invoked before a resource will be updated, immediately before the transaction
1134         * is committed (after all validation and other business rules have successfully
1135         * completed, and any other database activity is complete.
1136         * <p>
1137         * Hooks will have access to the contents of the resource being updated
1138         * (both the previous and new contents) but should generally not make any
1139         * changes as storage has already occurred. Changes will not be reflected
1140         * in storage, but may be reflected in the HTTP response.
1141         * </p>
1142         * Hooks may accept the following parameters:
1143         * <ul>
1144         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The previous contents of the resource</li>
1145         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The proposed new new contents of the resource</li>
1146         * <li>
1147         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1148         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1149         * pulled out of the servlet request. Note that the bean
1150         * properties are not all guaranteed to be populated, depending on how early during processing the
1151         * exception occurred.
1152         * </li>
1153         * <li>
1154         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1155         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1156         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1157         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1158         * </li>
1159         * </ul>
1160         * <p>
1161         * Hooks should return <code>void</code>.
1162         * </p>
1163         */
1164        STORAGE_PRECOMMIT_RESOURCE_UPDATED(void.class,
1165                "org.hl7.fhir.instance.model.api.IBaseResource",
1166                "org.hl7.fhir.instance.model.api.IBaseResource",
1167                "ca.uhn.fhir.rest.api.server.RequestDetails",
1168                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1169        ),
1170
1171
1172        /**
1173         * <b>Storage Hook:</b>
1174         * Invoked before a resource will be created
1175         * <p>
1176         * Hooks will have access to the contents of the resource being deleted
1177         * but should not make any changes as storage has already occurred
1178         * </p>
1179         * Hooks may accept the following parameters:
1180         * <ul>
1181         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The resource being deleted</li>
1182         * <li>
1183         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1184         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1185         * pulled out of the servlet request. Note that the bean
1186         * properties are not all guaranteed to be populated, depending on how early during processing the
1187         * exception occurred.
1188         * </li>
1189         * <li>
1190         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1191         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1192         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1193         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1194         * </li>
1195         * </ul>
1196         * <p>
1197         * Hooks should return <code>void</code>.
1198         * </p>
1199         */
1200        STORAGE_PRECOMMIT_RESOURCE_DELETED(void.class,
1201                "org.hl7.fhir.instance.model.api.IBaseResource",
1202                "ca.uhn.fhir.rest.api.server.RequestDetails",
1203                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1204        ),
1205
1206        /**
1207         * <b>Storage Hook:</b>
1208         * Invoked when a resource delete operation is about to fail due to referential integrity conflicts.
1209         * <p>
1210         * Hooks will have access to the list of resources that have references to the resource being deleted.
1211         * </p>
1212         * Hooks may accept the following parameters:
1213         * <ul>
1214         * <li>ca.uhn.fhir.jpa.delete.DeleteConflictList - The list of delete conflicts</li>
1215         * <li>
1216         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1217         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1218         * pulled out of the servlet request. Note that the bean
1219         * properties are not all guaranteed to be populated, depending on how early during processing the
1220         * exception occurred.
1221         * </li>
1222         * <li>
1223         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1224         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1225         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1226         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1227         * </li>
1228         * </ul>
1229         * <p>
1230         * Hooks should return <code>ca.uhn.fhir.jpa.delete.DeleteConflictOutcome</code>.
1231         * If the interceptor returns a non-null result, the DeleteConflictOutcome can be
1232         * used to indicate a number of times to retry.
1233         * </p>
1234         */
1235        STORAGE_PRESTORAGE_DELETE_CONFLICTS(
1236                // Return type
1237                "ca.uhn.fhir.jpa.delete.DeleteConflictOutcome",
1238                // Params
1239                "ca.uhn.fhir.jpa.delete.DeleteConflictList",
1240                "ca.uhn.fhir.rest.api.server.RequestDetails",
1241                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1242        ),
1243
1244        /**
1245         * <b>Storage Hook:</b>
1246         * Invoked before a resource is about to be expunged via the <code>$expunge</code> operation.
1247         * <p>
1248         * Hooks will be passed a reference to a counter containing the current number of records that have been deleted.
1249         * If the hook deletes any records, the hook is expected to increment this counter by the number of records deleted.
1250         * </p>
1251         * <p>
1252         * Hooks may accept the following parameters:
1253         * </p>
1254         * <ul>
1255         * <li>java.util.concurrent.atomic.AtomicInteger - The counter holding the number of records deleted.</li>
1256         * <li>org.hl7.fhir.instance.model.api.IIdType - The ID of the resource that is about to be deleted</li>
1257         * <li>org.hl7.fhir.instance.model.api.IBaseResource - The resource that is about to be deleted</li>
1258         * <li>
1259         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1260         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1261         * pulled out of the servlet request. Note that the bean
1262         * properties are not all guaranteed to be populated, depending on how early during processing the
1263         * exception occurred.
1264         * </li>
1265         * <li>
1266         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1267         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1268         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1269         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1270         * </li>
1271         * </ul>
1272         * <p>
1273         * Hooks should return void.
1274         * </p>
1275         */
1276        STORAGE_PRESTORAGE_EXPUNGE_RESOURCE(
1277                // Return type
1278                void.class,
1279                // Params
1280                "java.util.concurrent.atomic.AtomicInteger",
1281                "org.hl7.fhir.instance.model.api.IIdType",
1282                "org.hl7.fhir.instance.model.api.IBaseResource",
1283                "ca.uhn.fhir.rest.api.server.RequestDetails",
1284                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1285        ),
1286
1287        /**
1288         * <b>Storage Hook:</b>
1289         * Invoked before an <code>$expunge</code> operation on all data (expungeEverything) is called.
1290         * <p>
1291         * Hooks will be passed a reference to a counter containing the current number of records that have been deleted.
1292         * If the hook deletes any records, the hook is expected to increment this counter by the number of records deleted.
1293         * </p>
1294         * Hooks may accept the following parameters:
1295         * <ul>
1296         * <li>java.util.concurrent.atomic.AtomicInteger - The counter holding the number of records deleted.</li>
1297         * <li>
1298         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1299         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1300         * pulled out of the servlet request. Note that the bean
1301         * properties are not all guaranteed to be populated, depending on how early during processing the
1302         * exception occurred.
1303         * </li>
1304         * <li>
1305         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1306         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1307         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1308         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1309         * </li>
1310         * </ul>
1311         * <p>
1312         * Hooks should return void.
1313         * </p>
1314         */
1315        STORAGE_PRESTORAGE_EXPUNGE_EVERYTHING(
1316                // Return type
1317                void.class,
1318                // Params
1319                "java.util.concurrent.atomic.AtomicInteger",
1320                "ca.uhn.fhir.rest.api.server.RequestDetails",
1321                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1322        ),
1323
1324        /**
1325         * <b>Performance Tracing Hook:</b>
1326         * This hook is invoked when any informational messages generated by the
1327         * SearchCoordinator are created. It is typically used to provide logging
1328         * or capture details related to a specific request.
1329         * <p>
1330         * Note that this is a performance tracing hook. Use with caution in production
1331         * systems, since calling it may (or may not) carry a cost.
1332         * </p>
1333         * Hooks may accept the following parameters:
1334         * <ul>
1335         * <li>
1336         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1337         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1338         * pulled out of the servlet request. Note that the bean
1339         * properties are not all guaranteed to be populated, depending on how early during processing the
1340         * exception occurred.
1341         * </li>
1342         * <li>
1343         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1344         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1345         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1346         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1347         * </li>
1348         * <li>
1349         * ca.uhn.fhir.jpa.model.search.StorageProcessingMessage - Contains the message
1350         * </li>
1351         * </ul>
1352         * <p>
1353         * Hooks should return <code>void</code>.
1354         * </p>
1355         */
1356        JPA_PERFTRACE_INFO(void.class,
1357                "ca.uhn.fhir.rest.api.server.RequestDetails",
1358                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1359                "ca.uhn.fhir.jpa.model.search.StorageProcessingMessage"
1360        ),
1361
1362        /**
1363         * <b>Performance Tracing Hook:</b>
1364         * This hook is invoked when any warning messages generated by the
1365         * SearchCoordinator are created. It is typically used to provide logging
1366         * or capture details related to a specific request.
1367         * <p>
1368         * Note that this is a performance tracing hook. Use with caution in production
1369         * systems, since calling it may (or may not) carry a cost.
1370         * </p>
1371         * Hooks may accept the following parameters:
1372         * <ul>
1373         * <li>
1374         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1375         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1376         * pulled out of the servlet request. Note that the bean
1377         * properties are not all guaranteed to be populated, depending on how early during processing the
1378         * exception occurred.
1379         * </li>
1380         * <li>
1381         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1382         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1383         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1384         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1385         * </li>
1386         * <li>
1387         * ca.uhn.fhir.jpa.model.search.StorageProcessingMessage - Contains the message
1388         * </li>
1389         * </ul>
1390         * <p>
1391         * Hooks should return <code>void</code>.
1392         * </p>
1393         */
1394        JPA_PERFTRACE_WARNING(void.class,
1395                "ca.uhn.fhir.rest.api.server.RequestDetails",
1396                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1397                "ca.uhn.fhir.jpa.model.search.StorageProcessingMessage"
1398        ),
1399
1400        /**
1401         * <b>Performance Tracing Hook:</b>
1402         * This hook is invoked when a search has returned the very first result
1403         * from the database. The timing on this call can be a good indicator of how
1404         * performant a query is in general.
1405         * <p>
1406         * Note that this is a performance tracing hook. Use with caution in production
1407         * systems, since calling it may (or may not) carry a cost.
1408         * </p>
1409         * Hooks may accept the following parameters:
1410         * <ul>
1411         * <li>
1412         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1413         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1414         * pulled out of the servlet request. Note that the bean
1415         * properties are not all guaranteed to be populated, depending on how early during processing the
1416         * exception occurred.
1417         * </li>
1418         * <li>
1419         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1420         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1421         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1422         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1423         * </li>
1424         * <li>
1425         * ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails - Contains details about the search being
1426         * performed. Hooks should not modify this object.
1427         * </li>
1428         * </ul>
1429         * <p>
1430         * Hooks should return <code>void</code>.
1431         * </p>
1432         */
1433        JPA_PERFTRACE_SEARCH_FIRST_RESULT_LOADED(void.class,
1434                "ca.uhn.fhir.rest.api.server.RequestDetails",
1435                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1436                "ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails"
1437        ),
1438
1439        /**
1440         * <b>Performance Tracing Hook:</b>
1441         * This hook is invoked when an individual search query SQL SELECT statement
1442         * has completed and no more results are available from that query. Note that this
1443         * doesn't necessarily mean that no more matching results exist in the database,
1444         * since HAPI FHIR JPA batch loads results in to the query cache in chunks in order
1445         * to provide predicable results without overloading memory or the database.
1446         * <p>
1447         * Note that this is a performance tracing hook. Use with caution in production
1448         * systems, since calling it may (or may not) carry a cost.
1449         * </p>
1450         * Hooks may accept the following parameters:
1451         * <ul>
1452         * <li>
1453         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1454         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1455         * pulled out of the servlet request. Note that the bean
1456         * properties are not all guaranteed to be populated, depending on how early during processing the
1457         * exception occurred.
1458         * </li>
1459         * <li>
1460         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1461         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1462         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1463         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1464         * </li>
1465         * <li>
1466         * ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails - Contains details about the search being
1467         * performed. Hooks should not modify this object.
1468         * </li>
1469         * </ul>
1470         * <p>
1471         * Hooks should return <code>void</code>.
1472         * </p>
1473         */
1474        JPA_PERFTRACE_SEARCH_SELECT_COMPLETE(void.class,
1475                "ca.uhn.fhir.rest.api.server.RequestDetails",
1476                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1477                "ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails"
1478        ),
1479
1480
1481        /**
1482         * <b>Performance Tracing Hook:</b>
1483         * This hook is invoked when a search has failed for any reason. When this pointcut
1484         * is invoked, the search has completed unsuccessfully and will not be continued.
1485         * <p>
1486         * Note that this is a performance tracing hook. Use with caution in production
1487         * systems, since calling it may (or may not) carry a cost.
1488         * </p>
1489         * Hooks may accept the following parameters:
1490         * <ul>
1491         * <li>
1492         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1493         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1494         * pulled out of the servlet request. Note that the bean
1495         * properties are not all guaranteed to be populated, depending on how early during processing the
1496         * exception occurred.
1497         * </li>
1498         * <li>
1499         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1500         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1501         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1502         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1503         * </li>
1504         * <li>
1505         * ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails - Contains details about the search being
1506         * performed. Hooks should not modify this object.
1507         * </li>
1508         * </ul>
1509         * <p>
1510         * Hooks should return <code>void</code>.
1511         * </p>
1512         */
1513        JPA_PERFTRACE_SEARCH_FAILED(void.class,
1514                "ca.uhn.fhir.rest.api.server.RequestDetails",
1515                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1516                "ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails"
1517        ),
1518
1519        /**
1520         * <b>Performance Tracing Hook:</b>
1521         * This hook is invoked when a search has failed for any reason. When this pointcut
1522         * is invoked, a pass in the Search Coordinator has completed successfully, but
1523         * not all possible resources have been loaded yet so a future paging request
1524         * may trigger a new task that will load further resources.
1525         * <p>
1526         * Note that this is a performance tracing hook. Use with caution in production
1527         * systems, since calling it may (or may not) carry a cost.
1528         * </p>
1529         * Hooks may accept the following parameters:
1530         * <ul>
1531         * <li>
1532         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1533         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1534         * pulled out of the servlet request. Note that the bean
1535         * properties are not all guaranteed to be populated, depending on how early during processing the
1536         * exception occurred.
1537         * </li>
1538         * <li>
1539         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1540         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1541         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1542         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1543         * </li>
1544         * <li>
1545         * ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails - Contains details about the search being
1546         * performed. Hooks should not modify this object.
1547         * </li>
1548         * </ul>
1549         * <p>
1550         * Hooks should return <code>void</code>.
1551         * </p>
1552         */
1553        JPA_PERFTRACE_SEARCH_PASS_COMPLETE(void.class,
1554                "ca.uhn.fhir.rest.api.server.RequestDetails",
1555                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1556                "ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails"
1557        ),
1558
1559        /**
1560         * <b>Performance Tracing Hook:</b>
1561         * Invoked when the storage engine is about to reuse the results of
1562         * a previously cached search.
1563         * <p>
1564         * Note that this is a performance tracing hook. Use with caution in production
1565         * systems, since calling it may (or may not) carry a cost.
1566         * </p>
1567         * <p>
1568         * Hooks may accept the following parameters:
1569         * </p>
1570         * <ul>
1571         * <li>
1572         * ca.uhn.fhir.jpa.searchparam.SearchParameterMap - Contains the details of the search being checked
1573         * </li>
1574         * <li>
1575         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1576         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1577         * pulled out of the servlet request. Note that the bean
1578         * properties are not all guaranteed to be populated, depending on how early during processing the
1579         * exception occurred. <b>Note that this parameter may be null in contexts where the request is not
1580         * known, such as while processing searches</b>
1581         * </li>
1582         * <li>
1583         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1584         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1585         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1586         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1587         * </li>
1588         * </ul>
1589         * <p>
1590         * Hooks should return <code>void</code>.
1591         * </p>
1592         */
1593        JPA_PERFTRACE_SEARCH_REUSING_CACHED(boolean.class,
1594                "ca.uhn.fhir.jpa.searchparam.SearchParameterMap",
1595                "ca.uhn.fhir.rest.api.server.RequestDetails",
1596                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails"
1597        ),
1598
1599        /**
1600         * <b>Performance Tracing Hook:</b>
1601         * This hook is invoked when a search has failed for any reason. When this pointcut
1602         * is invoked, a pass in the Search Coordinator has completed successfully, and all
1603         * possible results have been fetched and loaded into the query cache.
1604         * <p>
1605         * Note that this is a performance tracing hook. Use with caution in production
1606         * systems, since calling it may (or may not) carry a cost.
1607         * </p>
1608         * Hooks may accept the following parameters:
1609         * <ul>
1610         * <li>
1611         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1612         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1613         * pulled out of the servlet request. Note that the bean
1614         * properties are not all guaranteed to be populated, depending on how early during processing the
1615         * exception occurred.
1616         * </li>
1617         * <li>
1618         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1619         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1620         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1621         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1622         * </li>
1623         * <li>
1624         * ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails - Contains details about the search being
1625         * performed. Hooks should not modify this object.
1626         * </li>
1627         * </ul>
1628         * <p>
1629         * Hooks should return <code>void</code>.
1630         * </p>
1631         */
1632        JPA_PERFTRACE_SEARCH_COMPLETE(void.class,
1633                "ca.uhn.fhir.rest.api.server.RequestDetails",
1634                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1635                "ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails"
1636        ),
1637
1638
1639        /**
1640         * <b>Performance Tracing Hook:</b>
1641         * <p>
1642         * This hook is invoked when a search has found an individual ID.
1643         * </p>
1644         * <p>
1645         * THIS IS AN EXPERIMENTAL HOOK AND MAY BE REMOVED OR CHANGED WITHOUT WARNING.
1646         *      </p>
1647         *      <p>
1648         * Note that this is a performance tracing hook. Use with caution in production
1649         * systems, since calling it may (or may not) carry a cost.
1650         *      </p>
1651         *      <p>
1652         * Hooks may accept the following parameters:
1653         * </p>
1654         * <ul>
1655         * <li>
1656         * java.lang.Integer - The query ID
1657         * </li>
1658         * <li>
1659         * java.lang.Object - The ID
1660         * </li>
1661         * </ul>
1662         * <p>
1663         * Hooks should return <code>void</code>.
1664         * </p>
1665         */
1666        JPA_PERFTRACE_SEARCH_FOUND_ID(void.class,
1667                "java.lang.Integer",
1668                "java.lang.Object"
1669        ),
1670
1671
1672        /**
1673         * <b>Performance Tracing Hook:</b>
1674         * This hook is invoked when a query has executed, and includes the raw SQL
1675         * statements that were executed against the database.
1676         * <p>
1677         * Note that this is a performance tracing hook. Use with caution in production
1678         * systems, since calling it may (or may not) carry a cost.
1679         * </p>
1680         * <p>
1681         * Hooks may accept the following parameters:
1682         * </p>
1683         * <ul>
1684         * <li>
1685         * ca.uhn.fhir.rest.api.server.RequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1686         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1687         * pulled out of the servlet request. Note that the bean
1688         * properties are not all guaranteed to be populated, depending on how early during processing the
1689         * exception occurred.
1690         * </li>
1691         * <li>
1692         * ca.uhn.fhir.rest.server.servlet.ServletRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
1693         * resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
1694         * pulled out of the servlet request. This parameter is identical to the RequestDetails parameter above but will
1695         * only be populated when operating in a RestfulServer implementation. It is provided as a convenience.
1696         * </li>
1697         * <li>
1698         * ca.uhn.fhir.jpa.util.SqlQueryList - Contains details about the raw SQL queries.
1699         * </li>
1700         * </ul>
1701         * <p>
1702         * Hooks should return <code>void</code>.
1703         * </p>
1704         */
1705        JPA_PERFTRACE_RAW_SQL(void.class,
1706                "ca.uhn.fhir.rest.api.server.RequestDetails",
1707                "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails",
1708                "ca.uhn.fhir.jpa.util.SqlQueryList"
1709        ),
1710
1711        /**
1712         * This pointcut is used only for unit tests. Do not use in production code as it may be changed or
1713         * removed at any time.
1714         */
1715        TEST_RB(
1716                boolean.class,
1717                new ExceptionHandlingSpec().addLogAndSwallow(IllegalStateException.class),
1718                String.class.getName(),
1719                String.class.getName()),
1720
1721        /**
1722         * This pointcut is used only for unit tests. Do not use in production code as it may be changed or
1723         * removed at any time.
1724         */
1725        TEST_RO(BaseServerResponseException.class, String.class.getName(), String.class.getName())
1726
1727        ;
1728
1729        private final List<String> myParameterTypes;
1730        private final Class<?> myReturnType;
1731        private final ExceptionHandlingSpec myExceptionHandlingSpec;
1732
1733        Pointcut(@Nonnull String theReturnType, String... theParameterTypes) {
1734                this(toReturnTypeClass(theReturnType), new ExceptionHandlingSpec(), theParameterTypes);
1735        }
1736
1737        Pointcut(@Nonnull Class<?> theReturnType, @Nonnull ExceptionHandlingSpec theExceptionHandlingSpec, String... theParameterTypes) {
1738                myReturnType = theReturnType;
1739                myExceptionHandlingSpec = theExceptionHandlingSpec;
1740                myParameterTypes = Collections.unmodifiableList(Arrays.asList(theParameterTypes));
1741        }
1742
1743        Pointcut(@Nonnull Class<?> theReturnType, String... theParameterTypes) {
1744                this(theReturnType, new ExceptionHandlingSpec(), theParameterTypes);
1745        }
1746
1747        public boolean isShouldLogAndSwallowException(@Nonnull Throwable theException) {
1748                for (Class<? extends Throwable> next : myExceptionHandlingSpec.myTypesToLogAndSwallow) {
1749                        if (next.isAssignableFrom(theException.getClass())) {
1750                                return true;
1751                        }
1752                }
1753                return false;
1754        }
1755
1756        @Nonnull
1757        public Class<?> getReturnType() {
1758                return myReturnType;
1759        }
1760
1761        @Nonnull
1762        public List<String> getParameterTypes() {
1763                return myParameterTypes;
1764        }
1765
1766        private class UnknownType {
1767        }
1768
1769        private static class ExceptionHandlingSpec {
1770
1771                private final Set<Class<? extends Throwable>> myTypesToLogAndSwallow = new HashSet<>();
1772
1773                ExceptionHandlingSpec addLogAndSwallow(@Nonnull Class<? extends Throwable> theType) {
1774                        myTypesToLogAndSwallow.add(theType);
1775                        return this;
1776                }
1777
1778        }
1779
1780        private static Class<?> toReturnTypeClass(String theReturnType) {
1781                try {
1782                        return Class.forName(theReturnType);
1783                } catch (ClassNotFoundException theE) {
1784                        return UnknownType.class;
1785                }
1786        }
1787
1788}