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

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


      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());
      }
    }
   
    if (getResourceOperationType() == RestfulOperationTypeEnum.CREATE) {
      if (response == null) {
        throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName() + " returned null, which is not allowed for create operation");
      }
      theResponse.setStatus(Constants.STATUS_HTTP_201_CREATED);
      addLocationHeader(theRequest, theResponse, response);
    } else if (response == null) {
      if (isReturnVoid() == false) {
        throw new InternalErrorException("Method " + getMethod().getName() + " in type " + getMethod().getDeclaringClass().getCanonicalName() + " returned null");
      }
      theResponse.setStatus(Constants.STATUS_HTTP_204_NO_CONTENT);
    } else {
      if (response.getOperationOutcome() == null) {
        theResponse.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");
      }
     
      dt.setValuesAsQueryTokens(theString.get(0));
    } catch (SecurityException e) {
      throw new InternalErrorException(e);
    }
    return dt;
  }
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

      for (Object next : ((Collection<?>) response)) {
        retVal.add((IResource) next);
      }
      return BundleProviders.newList(retVal);
    } else {
      throw new InternalErrorException("Unexpected return type: " + response.getClass().getCanonicalName());
    }
  }
View Full Code Here

    Collection<Include> retValCollection = null;
    if (myInstantiableCollectionType != null) {
      try {
        retValCollection = myInstantiableCollectionType.newInstance();
      } catch (Exception e) {
        throw new InternalErrorException("Failed to instantiate " + myInstantiableCollectionType.getName(), e);
      }
    }

    for (List<String> nextParamList : theString) {
      if (nextParamList.isEmpty()) {
View Full Code Here

      break;
    case RESOURCE:
      if (result.size() == 0) {
        throw new ResourceNotFoundException(theRequest.getId());
      } else if (result.size() > 1) {
        throw new InternalErrorException("Method returned multiple resources");
      }
      RestfulServer.streamResponseAsResource(theServer, theResponse, result.getResources(0, 1).get(0), responseEncoding, prettyPrint, requestIsBrowser, narrativeMode, respondGzip, theRequest.getFhirServerBase());
      break;
    }
  }
View Full Code Here

    String authorizationUnescaped = StringUtils.defaultString(myUsername) + ":" + StringUtils.defaultString(myPassword);
        String encoded;
        try {
                encoded = Base64.encodeBase64String(authorizationUnescaped.getBytes("ISO-8859-1"));
        } catch (UnsupportedEncodingException e) {
                throw new InternalErrorException("Could not find US-ASCII encoding. This shouldn't happen!");
        }
        theRequest.addHeader(Constants.HEADER_AUTHORIZATION, ("Basic " + encoded));
  }
View Full Code Here

      }
    }

    for (IResource next : resourceList) {
      if (next.getId() == null || next.getId().isEmpty()) {
        throw new InternalErrorException("Server method returned resource of type[" + next.getClass().getSimpleName() + "] with no ID specified (IResource#setId(IdDt) must be called)");
      }
    }

    Bundle bundle = createBundleFromResourceList(theServer.getFhirContext(), theServer.getServerName(), resourceList, theServerBase, theCompleteUrl, theResult.size());
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.