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

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


      dt = newInstance();
      if (theString.size() == 0 || theString.get(0).size() == 0) {
        return dt;
      }
      if (theString.size() > 1) {
        throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND/OR) values for this param.");
      }
     
      dt.setValuesAsQueryTokens(theString.get(0));
    } catch (SecurityException e) {
      throw new InternalErrorException(e);
View Full Code Here


          } else {
            operation = Constants.PARAM_HISTORY;
          }
        } else if (nextString.startsWith("_")) {
          if (operation != null) {
            throw new InvalidRequestException("URL Path contains two operations (part beginning with _): " + requestPath);
          }
          operation = nextString;
        }
      }

      // Secondary is for things like ..../_tags/_delete
      String secondaryOperation=null;
     
      while (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (operation == null) {
          operation = nextString;
        }else if (secondaryOperation==null) {
          secondaryOperation=nextString;
        }else {
          throw new InvalidRequestException("URL path has unexpected token '"+nextString + "' at the end: " + requestPath);
        }
      }

      if (theRequestType == RequestType.PUT && versionId == null) {
        String contentLocation = theRequest.getHeader("Content-Location");
View Full Code Here

  public BaseClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    PostClientInvocation 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

      }
      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

    String locationHeader = theRequest.getServletRequest().getHeader(Constants.HEADER_CONTENT_LOCATION);
    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

  }

  private void addParam(QualifiedDateParam theParsed) throws InvalidRequestException {
    if (theParsed.getComparator() == null) {
      if (myLowerBound != null || myUpperBound != null) {
        throw new InvalidRequestException("Can not have multiple date range parameters for the same param without a qualifier");
      }

      myLowerBound = theParsed;
      myUpperBound = theParsed;
      // TODO: in this case, should set lower and upper to exact moments using specified precision
    } else {

      switch (theParsed.getComparator()) {
      case GREATERTHAN:
      case GREATERTHAN_OR_EQUALS:
        if (myLowerBound != null) {
          throw new InvalidRequestException("Can not have multiple date range parameters for the same param that specify a lower bound");
        }
        myLowerBound = theParsed;
        break;
      case LESSTHAN:
      case LESSTHAN_OR_EQUALS:
        if (myUpperBound != null) {
          throw new InvalidRequestException("Can not have multiple date range parameters for the same param that specify an upper bound");
        }
        myUpperBound = theParsed;
        break;
      default:
        throw new InvalidRequestException("Unknown comparator: " + theParsed.getComparator());
      }

    }
  }
View Full Code Here

    for (List<String> paramList : theParameters) {
      if (paramList.size() == 0) {
        continue;
      }
      if (paramList.size() > 1) {
        throw new InvalidRequestException("DateRange parameter does not suppport OR queries");
      }
      String param = paramList.get(0);
      QualifiedDateParam parsed = new QualifiedDateParam();
      parsed.setValueAsQueryToken(param);
      addParam(parsed);
View Full Code Here

      dt = myType.newInstance();
      if (theString.size() == 0 || theString.get(0).size() == 0) {
        return dt;
      }
      if (theString.size() > 1 || theString.get(0).size() > 1) {
        throw new InvalidRequestException("Multiple values detected");
      }
     
      dt.setValueAsQueryToken(theString.get(0).get(0));
    } 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

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.