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

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


      public List<IResource> getResources(int theFromIndex, int theToIndex) {
        List<IResource> retVal = resources.getResources(theFromIndex, theToIndex);
        int index = theFromIndex;
        for (IResource nextResource : retVal) {
          if (nextResource.getId() == null || isBlank(nextResource.getId().getIdPart())) {
            throw new InternalErrorException("Server provided resource at index " + index + " with no ID set (using IResource#setId(IdDt))");
          }
          if (isBlank(nextResource.getId().getVersionIdPart())) {
            IdDt versionId = (IdDt) ResourceMetadataKeyEnum.VERSION_ID.get(nextResource);
            if (versionId == null || versionId.isEmpty()) {
              throw new InternalErrorException("Server provided resource at index " + index + " with no Version ID set (using IResource#setId(IdDt))");
            }
          }
          index++;
        }
        return retVal;
View Full Code Here


        return (IdDt) retValObj;
      }
    } else if (retValObj instanceof Number) {
      return new IdDt(((Number)retValObj).toString());
    }
    throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected " + IdDt.class.getCanonicalName());
  }
View Full Code Here

          return null;
        } else {
          return (InstantDt) retValObj;
        }
      }
      throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected " + InstantDt.class.getCanonicalName());
    }
View Full Code Here

          return null;
        } else {
          return (String) retValObj;
        }
      }
      throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected " + String.class.getCanonicalName());
    }
View Full Code Here

      return;
    }

    if (response != null && response.getId() != null && response.getId().hasResourceType()) {
      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;
      }
    }
   
    switch (getResourceOperationType()) {
    case CREATE:
      if (response == null) {
        throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName()
            + " returned null, which is not allowed for create operation");
      }
      if (response.getCreated() == null || Boolean.TRUE.equals(response.getCreated())) {
        servletResponse.setStatus(Constants.STATUS_HTTP_201_CREATED);
      } else {
        servletResponse.setStatus(Constants.STATUS_HTTP_200_OK);
      }
      addLocationHeader(theRequest, servletResponse, response);
      break;

    case UPDATE:
      if (response.getCreated() == null || Boolean.FALSE.equals(response.getCreated())) {
        servletResponse.setStatus(Constants.STATUS_HTTP_200_OK);
      } else {
        servletResponse.setStatus(Constants.STATUS_HTTP_201_CREATED);
      }
      addLocationHeader(theRequest, servletResponse, response);
      break;

    case VALIDATE:
    case DELETE:
    default:
      if (response == null) {
        if (isReturnVoid() == false) {
          throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName() + " returned null");
        }
        servletResponse.setStatus(Constants.STATUS_HTTP_204_NO_CONTENT);
      } else {
        if (response.getOperationOutcome() == null) {
          servletResponse.setStatus(Constants.STATUS_HTTP_204_NO_CONTENT);
View Full Code Here

      }
     
      T dt = myConstructor.newInstance(args);
      return dt;
    } catch (final InstantiationException e) {
      throw new InternalErrorException(e);
    } catch (final IllegalAccessException e) {
      throw new InternalErrorException(e);
    } catch (final SecurityException e) {
      throw new InternalErrorException(e);
    } catch (final IllegalArgumentException e) {
      throw new InternalErrorException(e);
    } catch (final InvocationTargetException e) {
      throw new InternalErrorException(e);
    }
  }
View Full Code Here

    IQueryParameterAnd<?> dt;
    try {
      dt = newInstance();
      dt.setValuesAsQueryTokens(theString);
    } catch (SecurityException e) {
      throw new InternalErrorException(e);
    }
    return dt;
  }
View Full Code Here

        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);
    }
    return dt;
  }
View Full Code Here

        parameters.add(new BasicNameValuePair(nextParam.getKey(), StringUtils.join(nextParam.getValue(), ',')));
      }
      try {
        entity = new UrlEncodedFormEntity(parameters, "UTF-8");
      } catch (UnsupportedEncodingException e) {
        throw new InternalErrorException("Server does not support UTF-8 (should not happen)", e);
      }
    } else {
      String contents;
      if (myTagList != null) {
        contents = parser.encodeTagListToString(myTagList);
View Full Code Here

      return method.invoke(getProvider(), theMethodParams);
    } catch (InvocationTargetException e) {
      if (e.getCause() instanceof BaseServerResponseException) {
        throw (BaseServerResponseException) e.getCause();
      } else {
        throw new InternalErrorException("Failed to call access method", e);
      }
    } catch (Exception e) {
      throw new InternalErrorException("Failed to call access method", e);
    }
  }
View Full Code Here

TOP

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

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.