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

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


            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

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

    } catch (Throwable e) {

      OperationOutcome oo = new OperationOutcome();
      Issue issue = oo.addIssue();
      issue.getSeverity().setValueAsEnum(IssueSeverityEnum.ERROR);

      int statusCode = 500;
      if (e instanceof InternalErrorException) {
        ourLog.error("Failure during REST processing", e);
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

  /**
   * 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

    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

    this(theProblem, IssueSeverityEnum.FATAL, theCause);
  }

  public ValidationFailureException(String theProblem, IssueSeverityEnum theSeverity, Exception theCause) {
    super(theProblem, theCause);
    myOperationOutcome = new OperationOutcome();
    myOperationOutcome.addIssue().setSeverity(theSeverity).setDetails(theProblem);
  }
View Full Code Here

    for (IValidator next : myValidators) {
      next.validateBundle(ctx);
    }

    OperationOutcome oo = ctx.getOperationOutcome();
    if (oo != null && oo.getIssue().size() > 0) {
      throw new ValidationFailureException(oo);
    }

  }
View Full Code Here

    for (IValidator next : myValidators) {
      next.validateResource(ctx);
    }

    OperationOutcome oo = ctx.getOperationOutcome();
    if (oo != null && oo.getIssue().size() > 0) {
      throw new ValidationFailureException(oo);
    }

  }
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.