/** * Do some fancy logging to create a nice access log that has details about each incoming request. */ public IServerInterceptor loggingInterceptor() { LoggingInterceptor retVal = new LoggingInterceptor(); retVal.setLoggerName("fhirtest.access"); retVal.setMessageFormat( "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]"); retVal.setLogExceptions(true); retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}"); return retVal; }
/** * Sets the name of the response header to add validation failures to * * @see #DEFAULT_RESPONSE_HEADER_NAME * @see #setAddResponseHeaderOnSeverity(ResultSeverityEnum) */ @Override public void setResponseHeaderName(String theResponseHeaderName) { super.setResponseHeaderName(theResponseHeaderName); }
/** * The default constructor */ public JaxRsExceptionInterceptor() { this.exceptionHandler = new ExceptionHandlingInterceptor(); }
/** * This interceptor adds some pretty syntax highlighting in responses when a browser is detected */ @Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor responseHighlighterInterceptor() { ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); return retVal; }
@Bean public LoggingInterceptor loggingInterceptor() { return new LoggingInterceptor(); } }
@Override protected void initialize() throws ServletException { // ... define your resource providers here ... // Now register the interceptor ExceptionHandlingInterceptor interceptor = new ExceptionHandlingInterceptor(); registerInterceptor(interceptor); // Return the stack trace to the client for the following exception types interceptor.setReturnStackTracesForExceptionTypes(InternalErrorException.class, NullPointerException.class); }
@Override public IBundleProvider patientInstanceEverything(HttpServletRequest theServletRequest, IIdType theId, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative, RequestDetails theRequestDetails) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, getResourceName(), null); notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_INSTANCE, requestDetails); return doEverythingOperation(theId, theCount, theLastUpdated, theSort, theContent, theNarrative, theRequestDetails); }
@Override public void resourcePreUpdate(IBaseResource theOldResource, IBaseResource theNewResource) { for (IServerInterceptor next : getInterceptors()) { if (next instanceof IServerOperationInterceptor) { ((IServerOperationInterceptor) next).resourcePreUpdate(RequestDetails.this, theOldResource, theNewResource); } } }
@Override public void resourceCreated(IBaseResource theResource) { for (IServerInterceptor next : getInterceptors()) { if (next instanceof IServerOperationInterceptor) { ((IServerOperationInterceptor) next).resourceCreated(RequestDetails.this, theResource); } } }
@Override public void resourceDeleted(IBaseResource theResource) { for (IServerInterceptor next : getInterceptors()) { if (next instanceof IServerOperationInterceptor) { ((IServerOperationInterceptor) next).resourceDeleted(RequestDetails.this, theResource); } } }
@Override public void resourcePreDelete(IBaseResource theResource) { for (IServerInterceptor next : getInterceptors()) { if (next instanceof IServerOperationInterceptor) { ((IServerOperationInterceptor) next).resourcePreDelete(RequestDetails.this, theResource); } } }
@Override public boolean outgoingResponse(RequestDetails theRequestDetails) { ServletRequestDetails details = (ServletRequestDetails) theRequestDetails; return outgoingResponse(theRequestDetails, details.getServletRequest(), details.getServletResponse()); }
/** * Do some fancy logging to create a nice access log that has details about each incoming request. */ public IServerInterceptor loggingInterceptor() { LoggingInterceptor retVal = new LoggingInterceptor(); retVal.setLoggerName("fhirtest.access"); retVal.setMessageFormat( "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]"); retVal.setLogExceptions(true); retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}"); return retVal; }
/** * This interceptor adds some pretty syntax highlighting in responses when a browser is detected */ @Bean(autowire = Autowire.BY_TYPE) public IServerInterceptor responseHighlighterInterceptor() { ResponseHighlighterInterceptor retVal = new ResponseHighlighterInterceptor(); return retVal; }
@Override public IBundleProvider patientTypeEverything(HttpServletRequest theServletRequest, IPrimitiveType<Integer> theCount, DateRangeParam theLastUpdated, SortSpec theSort, StringAndListParam theContent, StringAndListParam theNarrative, RequestDetails theRequestDetails) { // Notify interceptors ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, getResourceName(), null); notifyInterceptors(RestOperationTypeEnum.EXTENDED_OPERATION_TYPE, requestDetails); return doEverythingOperation(null, theCount, theLastUpdated, theSort, theContent, theNarrative, theRequestDetails); }
@Override public boolean outgoingResponse(RequestDetails theRequestDetails, IBaseResource theResponseObject) { ServletRequestDetails details = (ServletRequestDetails) theRequestDetails; return outgoingResponse(details, theResponseObject, details.getServletRequest(), details.getServletResponse()); }
/** * Sets the name of the response header to add validation failures to * * @see #DEFAULT_RESPONSE_HEADER_NAME * @see #setAddResponseHeaderOnSeverity(ResultSeverityEnum) */ @Override public void setResponseHeaderName(String theResponseHeaderName) { super.setResponseHeaderName(theResponseHeaderName); }
/** * Do some fancy logging to create a nice access log that has details about each incoming request. */ public IServerInterceptor loggingInterceptor() { LoggingInterceptor retVal = new LoggingInterceptor(); retVal.setLoggerName("fhirtest.access"); retVal.setMessageFormat( "Path[${servletPath}] Source[${requestHeader.x-forwarded-for}] Operation[${operationType} ${operationName} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] ResponseEncoding[${responseEncodingNoDefault}]"); retVal.setLogExceptions(true); retVal.setErrorMessageFormat("ERROR - ${requestVerb} ${requestUrl}"); return retVal; }
@Override protected void initialize() throws ServletException { // ... define your resource providers here ... // Now register the interceptor ResponseHighlighterInterceptor interceptor = new ResponseHighlighterInterceptor(); registerInterceptor(interceptor); }
@Override public boolean outgoingResponse(RequestDetails theRequestDetails, TagList theResponseObject) { ServletRequestDetails details = (ServletRequestDetails) theRequestDetails; return outgoingResponse(details, theResponseObject, details.getServletRequest(), details.getServletResponse()); }