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

Examples of ca.uhn.fhir.rest.server.exceptions.InvalidRequestException


      }
      encoding = EncodingEnum.forContentType(contentTypeHeader);
    }

    if (encoding == null) {
      throw new InvalidRequestException("Request contins non-FHIR conent-type header value: " + contentTypeHeader);
    }

    IParser parser = encoding.newParser(getContext());
    return parser;
  }
View Full Code Here


  protected BaseServerResponseException processNon2xxResponseAndReturnExceptionToThrow(int theStatusCode, String theResponseMimeType, Reader theResponseReader) {
    BaseServerResponseException ex;
    switch (theStatusCode) {
    case Constants.STATUS_HTTP_400_BAD_REQUEST:
      ex = new InvalidRequestException("Server responded with HTTP 400");
      break;
    case Constants.STATUS_HTTP_404_NOT_FOUND:
      ex = new ResourceNotFoundException("Server responded with HTTP 404");
      break;
    case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED:
View Full Code Here

      dt = myType.newInstance();
      if (theParams.size() == 0 || theParams.get(0).size() == 0) {
        return dt;
      }
      if (theParams.size() > 1 || theParams.get(0).size() > 1) {
        throw new InvalidRequestException("Multiple values detected");
      }
     
      dt.setValueAsQueryToken(theParams.get(0).getQualifier(), value);
    } catch (InstantiationException e) {
      throw new InternalErrorException(e);
View Full Code Here

    for (List<String> nextParamList : theString) {
      if (nextParamList.isEmpty()) {
        continue;
      }
      if (nextParamList.size() > 1) {
        throw new InvalidRequestException("'OR' query parameters (values containing ',') are not supported in _include parameters");
      }

      String value = nextParamList.get(0);
      if (myAllow != null) {
        if (!myAllow.contains(value)) {
          throw new InvalidRequestException("Invalid _include parameter value: '" + value + "'. Valid values are: " + new TreeSet<String>(myAllow));
        }
      }
      if (retValCollection == null) {
        if (mySpecType == String.class) {
          return value;
View Full Code Here

     */
    String locationHeader = theRequest.getServletRequest().getHeader(Constants.HEADER_CONTENT_LOCATION);
    IdDt id = new IdDt(locationHeader);
    if (isNotBlank(id.getResourceType())) {
      if (!getResourceName().equals(id.getResourceType())) {
        throw new InvalidRequestException("Attempting to update '" + getResourceName() + "' but content-location header specifies different resource type '" + id.getResourceType() + "' - header value: " + locationHeader);
      }
    }

    if (isNotBlank(locationHeader)) {
      MethodOutcome mo = new MethodOutcome();
      parseContentLocation(mo, getResourceName(), locationHeader);
      if (mo.getId() == null || mo.getId().isEmpty()) {
        throw new InvalidRequestException("Invalid Content-Location header for resource " + getResourceName() + ": " + locationHeader);
      }
      if (mo.getVersionId() != null && mo.getVersionId().isEmpty() == false) {
        theRequest.setVersion(mo.getVersionId());
      }
    }
View Full Code Here

  public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    HttpPostClientInvocation retVal;

    IdDt id = (IdDt) theArgs[myIdParamIndex];
    if (id == null || id.isEmpty()) {
      throw new InvalidRequestException("ID must not be null or empty for this operation");
    }

    IdDt versionId = null;
    if (myVersionIdParamIndex != null) {
      versionId = (IdDt) theArgs[myVersionIdParamIndex];
View Full Code Here

        if (StringUtils.isNotBlank(sinceParams[0])) {
          try {
            IntegerDt since = new IntegerDt(sinceParams[0]);
            return ParameterUtil.fromInteger(myType, since);
          } catch (DataFormatException e) {
            throw new InvalidRequestException("Invalid " + Constants.PARAM_COUNT + " value: " + sinceParams[0]);
          }
        }
      }
    }
    return ParameterUtil.fromInteger(myType, null);
View Full Code Here

      dt = myType.newInstance();
      if (theString.size() == 0 || theString.get(0).size() == 0) {
        return dt;
      }
      if (theString.size() > 1) {
        throw new InvalidRequestException("Multiple values detected");
      }
     
      dt.setValuesAsQueryTokens(theString.get(0));
    } catch (InstantiationException e) {
      throw new InternalErrorException(e);
View Full Code Here

  public Object parse(String theName, List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException {
    if (theParams.size() == 0 || theParams.get(0).size() == 0) {
      return "";
    }
    if (theParams.size() > 1 || theParams.get(0).size() > 1) {
      throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND) values for this param.");
    }

    return theParams.get(0).get(0);
  }
View Full Code Here

      }
      encoding = EncodingEnum.forContentType(contentTypeHeader);
    }

    if (encoding == null) {
      throw new InvalidRequestException("Request contins non-FHIR conent-type header value: " + contentTypeHeader);
    }

    IParser parser = encoding.newParser(getContext());
    return parser;
  }
View Full Code Here

TOP

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

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.