Package ca.uhn.fhir.model.dstu.resource

Examples of ca.uhn.fhir.model.dstu.resource.OperationOutcome


      theResponse.setCharacterEncoding("UTF-8");
      theResponse.getWriter().write(e.getMessage());

    } catch (Throwable e) {

      OperationOutcome oo = null;
      int statusCode = 500;

      if (e instanceof BaseServerResponseException) {
        oo = ((BaseServerResponseException) e).getOperationOutcome();
        statusCode = ((BaseServerResponseException) e).getStatusCode();
      }

      if (oo == null) {
        oo = new OperationOutcome();
        Issue issue = oo.addIssue();
        issue.getSeverity().setValueAsEnum(IssueSeverityEnum.ERROR);
        if (e instanceof InternalErrorException) {
          ourLog.error("Failure during REST processing", e);
          issue.getDetails().setValue(e.toString() + "\n\n" + ExceptionUtils.getStackTrace(e));
        } else if (e instanceof BaseServerResponseException) {
View Full Code Here


      EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
      if (respType == null) {
        return null;
      }
      IParser parser = respType.newParser(myContext);
      OperationOutcome retVal;
      try {
        retVal = parser.parseResource(OperationOutcome.class, theResponseReader);
      } catch (DataFormatException e) {
        ourLog.warn("Failed to parse OperationOutcome response", e);
        return null;
View Full Code Here

    return myFhirContext;
  }

  public OperationOutcome getOperationOutcome() {
    if (myOperationOutcome == null) {
      myOperationOutcome = new OperationOutcome();
    }
    return myOperationOutcome;
  }
View Full Code Here

        } finally {
          IOUtils.closeQuietly(reader);
        }

        String message = "HTTP " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase();
        OperationOutcome oo=null;
        if (Constants.CT_TEXT.equals(mimeType)) {
          message = message + ": " + body;
        } else {
          EncodingEnum enc = EncodingEnum.forContentType(mimeType);
          if (enc != null) {
            IParser p = enc.newParser(theContext);
            try {
              oo = p.parseResource(OperationOutcome.class, body);
              if (oo.getIssueFirstRep().getDetails().isEmpty()==false) {
                message = message + ": " + oo.getIssueFirstRep().getDetails().getValue();
              }
            } catch (Exception e) {
              ourLog.debug("Failed to process OperationOutcome response");
            }
          }
View Full Code Here

 
  /**
   * Constructor which accepts an {@link OperationOutcome} resource which will be supplied in the response
   */
  public UnprocessableEntityException(OperationOutcome theOperationOutcome) {
    super(STATUS_CODE, DEFAULT_MESSAGE, theOperationOutcome == null ? new OperationOutcome() : theOperationOutcome);
  }
View Full Code Here

  public UnprocessableEntityException(String... theMessage) {
    super(STATUS_CODE, DEFAULT_MESSAGE, toOperationOutcome(theMessage));
  }

  private static OperationOutcome toOperationOutcome(String... theMessage) {
    OperationOutcome operationOutcome = new OperationOutcome();
    if (theMessage != null) {
      for (String next : theMessage) {
        operationOutcome.addIssue().setDetails(next);
      }
    }
    return operationOutcome;
  }
View Full Code Here

      if (getContext().getResourceDefinition(response.getId().getResourceType()) == null) {
        throw new InternalErrorException("Server method returned invalid resource ID: " + response.getId().getValue());
      }
    }
   
    OperationOutcome outcome = response != null ? response.getOperationOutcome():null;
    for (int i = theServer.getInterceptors().size() - 1; i >= 0; i--) {
      IServerInterceptor next = theServer.getInterceptors().get(i);
      boolean continueProcessing = next.outgoingResponse(theRequest, outcome, theRequest.getServletRequest(), theRequest.getServletResponse());
      if (!continueProcessing) {
        return;
View Full Code Here

    case Constants.STATUS_HTTP_412_PRECONDITION_FAILED:
      ex = new ResourceVersionNotSpecifiedException("Server responded with HTTP 412");
      break;
    case Constants.STATUS_HTTP_422_UNPROCESSABLE_ENTITY:
      IParser parser = createAppropriateParserForParsingResponse(theResponseMimeType, theResponseReader, theStatusCode);
      OperationOutcome operationOutcome = parser.parseResource(OperationOutcome.class, theResponseReader);
      ex = new UnprocessableEntityException(operationOutcome);
      break;
    default:
      ex = new UnclassifiedServerFailureException(theStatusCode, "Server responded with HTTP " + theStatusCode);
      break;
View Full Code Here

            reader = null;
          }

          if (reader != null) {
            IParser parser = ct.newParser(getContext());
            OperationOutcome outcome = parser.parseResource(OperationOutcome.class, reader);
            retVal.setOperationOutcome(outcome);
          }

        } else {
          ourLog.debug("Ignoring response content of type: {}", theResponseMimeType);
        }
      }
      return retVal;
    case Constants.STATUS_HTTP_400_BAD_REQUEST:
      throw new InvalidRequestException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_404_NOT_FOUND:
      throw new ResourceNotFoundException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED:
      throw new MethodNotAllowedException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_409_CONFLICT:
      throw new ResourceVersionConflictException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_412_PRECONDITION_FAILED:
      throw new ResourceVersionNotSpecifiedException("Server responded with: " + IOUtils.toString(theResponseReader));
    case Constants.STATUS_HTTP_422_UNPROCESSABLE_ENTITY:
      IParser parser = createAppropriateParser(theResponseMimeType, theResponseReader, theResponseStatusCode);
      OperationOutcome operationOutcome = parser.parseResource(OperationOutcome.class, theResponseReader);
      throw new UnprocessableEntityException(operationOutcome);
    default:
      throw new UnclassifiedServerFailureException(theResponseStatusCode, IOUtils.toString(theResponseReader));
    }
View Full Code Here

    theServer.addHapiHeader(theResponse);

    Writer writer = theResponse.getWriter();
    try {
      if (response != null) {
        OperationOutcome outcome = new OperationOutcome();
        if (response.getOperationOutcome() != null && response.getOperationOutcome().getIssue() != null) {
          outcome.getIssue().addAll(response.getOperationOutcome().getIssue());
        }
        EncodingUtil encoding = BaseMethodBinding.determineResponseEncoding(theRequest.getServletRequest(), theRequest.getParameters());
        theResponse.setContentType(encoding.getResourceContentType());
        IParser parser = encoding.newParser(getContext());
        parser.encodeResourceToWriter(outcome, writer);
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.dstu.resource.OperationOutcome

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.