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

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


      InternalErrorException {
    IResource conf;
    try {
      conf = (Conformance) getMethod().invoke(theResourceProvider);
    } catch (Exception e) {
      throw new InternalErrorException("Failed to call access method", e);
    }

    return Collections.singletonList(conf);
  }
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

   
    Object response= invokeServerMethod(theMethodParams);
    IBundleProvider retVal = toResourceList(response);
   
    if (retVal.size() != resources.size()) {
      throw new InternalErrorException("Transaction bundle contained " + resources.size() + " entries, but server method response contained " + retVal.size() + " entries (must be the same)");
    }
   
    List<IResource> retResources = retVal.getResources(0, retVal.size());
    for (int i =0; i < resources.size(); i++) {
      IdDt oldId = oldIds.get(i);
      IResource newRes = retResources.get(i);
      if (newRes.getId() == null || newRes.getId().isEmpty()) {
        throw new InternalErrorException("Transaction method returned resource at index " + i + " with no id specified - IResource#setId(IdDt)");
      }
     
      if (oldId != null && !oldId.isEmpty()) {
        if (!oldId.getId().equals(newRes.getId())) {
          newRes.getResourceMetadata().put(ResourceMetadataKeyEnum.PREVIOUS_ID, oldId.getId());
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

        throw new InvalidRequestException("Multiple values detected");
      }
     
      dt.setValueAsQueryToken(theParams.get(0).getQualifier(), value);
    } catch (InstantiationException e) {
      throw new InternalErrorException(e);
    } catch (IllegalAccessException e) {
      throw new InternalErrorException(e);
    } catch (SecurityException e) {
      throw new InternalErrorException(e);
    }
    return dt;
  }
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

      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;
    }

    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

      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);
      break;
    }
  }
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.