Package ca.uhn.fhir.rest.server.exceptions

Source Code of ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException

package ca.uhn.fhir.rest.server.exceptions;

import ca.uhn.fhir.model.dstu.resource.OperationOutcome;

/**
* Represents an <b>HTTP 422 Unprocessable Entity</b> response, which means that a resource was rejected by the server because it "violated applicable FHIR profiles or server business rules".
*
* <p>
* This exception will generally contain an {@link OperationOutcome} instance which details the failure.
* </p>
*/
public class UnprocessableEntityException extends BaseServerResponseException {

  private OperationOutcome myOperationOutcome;

  public UnprocessableEntityException(OperationOutcome theOperationOutcome) {
    super(422, "Unprocessable Entity");

    myOperationOutcome = theOperationOutcome;
  }

  public UnprocessableEntityException(String theMessage) {
    super(422, theMessage);

    myOperationOutcome = new OperationOutcome();
    myOperationOutcome.addIssue().setDetails(theMessage);
  }

  public UnprocessableEntityException(String... theMessage) {
    super(422, theMessage != null && theMessage.length > 0 ? theMessage[0] : "");

    myOperationOutcome = new OperationOutcome();
    if (theMessage != null) {
      for (String next : theMessage) {
        myOperationOutcome.addIssue().setDetails(next);
      }
    }
  }

  public OperationOutcome getOperationOutcome() {
    return myOperationOutcome;
  }

  private static final long serialVersionUID = 1L;

}
TOP

Related Classes of ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException

TOP
Copyright © 2018 www.massapi.com. 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.