/** * Utility constructor * * @param base the base exception */ public JaxRsResponseException(BaseServerResponseException base) { super(base.getStatusCode(), base.getMessage(), base.getCause(), base.getOperationOutcome()); }
private IBaseOperationOutcome createOperationOutcome(Throwable theException, FhirContext ctx) throws ServletException { IBaseOperationOutcome oo = null; if (theException instanceof BaseServerResponseException) { oo = ((BaseServerResponseException) theException).getOperationOutcome();
IBaseOperationOutcome oo = theException.getOperationOutcome(); if (oo == null) { oo = createOperationOutcome(theException, ctx);
@Override public boolean handleException(RequestDetails theRequestDetails, BaseServerResponseException theException, HttpServletRequest theServletRequest, HttpServletResponse theServletResponse) throws ServletException, IOException { /* * It's not a browser... */ Set<String> accept = RestfulServerUtils.parseAcceptHeaderAndReturnHighestRankedOptions(theServletRequest); if (!accept.contains(Constants.CT_HTML)) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } /* * It's an AJAX request, so no HTML */ String requestedWith = theServletRequest.getHeader("X-Requested-With"); if (requestedWith != null) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } /* * Not a GET */ if (theRequestDetails.getRequestType() != RequestTypeEnum.GET) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } if (theException.getOperationOutcome() == null) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } streamResponse(theRequestDetails, theServletResponse, theException.getOperationOutcome(), theServletRequest, theException.getStatusCode()); return false; }
@Override public BaseServerResponseException preProcessOutgoingException(RequestDetails theRequestDetails, Throwable theException, HttpServletRequest theServletRequest) throws ServletException { BaseServerResponseException retVal; if (theException instanceof DataFormatException) { // Wrapping the DataFormatException as an InvalidRequestException so that it gets sent back to the client as a 400 response. retVal = new InvalidRequestException(theException); } else if (!(theException instanceof BaseServerResponseException)) { retVal = new InternalErrorException(theException); } else { retVal = (BaseServerResponseException) theException; } if (retVal.getOperationOutcome() == null) { retVal.setOperationOutcome(createOperationOutcome(theException, theRequestDetails.getServer().getFhirContext())); } return retVal; }
private IBaseOperationOutcome createOperationOutcome(Throwable theException, FhirContext ctx) throws ServletException { IBaseOperationOutcome oo = null; if (theException instanceof BaseServerResponseException) { oo = ((BaseServerResponseException) theException).getOperationOutcome();
IBaseOperationOutcome oo = theException.getOperationOutcome(); if (oo == null) { oo = createOperationOutcome(theException, ctx);
@Override public boolean handleException(RequestDetails theRequestDetails, BaseServerResponseException theException, HttpServletRequest theServletRequest, HttpServletResponse theServletResponse) throws ServletException, IOException { /* * It's not a browser... */ Set<String> accept = RestfulServerUtils.parseAcceptHeaderAndReturnHighestRankedOptions(theServletRequest); if (!accept.contains(Constants.CT_HTML)) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } /* * It's an AJAX request, so no HTML */ String requestedWith = theServletRequest.getHeader("X-Requested-With"); if (requestedWith != null) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } /* * Not a GET */ if (theRequestDetails.getRequestType() != RequestTypeEnum.GET) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } if (theException.getOperationOutcome() == null) { return super.handleException(theRequestDetails, theException, theServletRequest, theServletResponse); } streamResponse(theRequestDetails, theServletResponse, theException.getOperationOutcome(), theServletRequest, theException.getStatusCode()); return false; }
@Override public BaseServerResponseException preProcessOutgoingException(RequestDetails theRequestDetails, Throwable theException, HttpServletRequest theServletRequest) throws ServletException { BaseServerResponseException retVal; if (theException instanceof DataFormatException) { // Wrapping the DataFormatException as an InvalidRequestException so that it gets sent back to the client as a 400 response. retVal = new InvalidRequestException(theException); } else if (!(theException instanceof BaseServerResponseException)) { retVal = new InternalErrorException(theException); } else { retVal = (BaseServerResponseException) theException; } if (retVal.getOperationOutcome() == null) { retVal.setOperationOutcome(createOperationOutcome(theException, theRequestDetails.getServer().getFhirContext())); } return retVal; }