コード例 #1
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
  @Override
  public Conformance conformance() {
    HttpGetClientInvocation invocation = MethodUtil.createConformanceInvocation();
    if (isKeepResponses()) {
      myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding());
    }

    ResourceResponseHandler<Conformance> binding =
        new ResourceResponseHandler<Conformance>(Conformance.class, null);
    Conformance resp = invokeClient(myContext, binding, invocation, myLogRequestAndResponse);
    return resp;
  }
コード例 #2
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
  @Override
  public MethodOutcome update(IdDt theIdDt, IResource theResource) {
    BaseHttpClientInvocation invocation =
        MethodUtil.createUpdateInvocation(theResource, null, theIdDt, myContext);
    if (isKeepResponses()) {
      myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding());
    }

    RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);
    final String resourceName = def.getName();

    OutcomeResponseHandler binding = new OutcomeResponseHandler(resourceName);
    MethodOutcome resp = invokeClient(myContext, binding, invocation, myLogRequestAndResponse);
    return resp;
  }
コード例 #3
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
    @Override
    public MethodOutcome execute() {
      if (myResource == null) {
        myResource = parseResourceBody(myResourceBody);
      }
      myId = getPreferredId(myResource, myId);

      BaseHttpClientInvocation invocation =
          MethodUtil.createCreateInvocation(myResource, myResourceBody, myId, myContext);

      RuntimeResourceDefinition def = myContext.getResourceDefinition(myResource);
      final String resourceName = def.getName();

      OutcomeResponseHandler binding = new OutcomeResponseHandler(resourceName);

      Map<String, List<String>> params = new HashMap<String, List<String>>();
      return invoke(params, binding, invocation);
    }
コード例 #4
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
 @Override
 public MethodOutcome invokeClient(
     String theResponseMimeType,
     Reader theResponseReader,
     int theResponseStatusCode,
     Map<String, List<String>> theHeaders)
     throws IOException, BaseServerResponseException {
   MethodOutcome response =
       MethodUtil.process2xxResponse(
           myContext,
           myResourceName,
           theResponseStatusCode,
           theResponseMimeType,
           theResponseReader,
           theHeaders);
   if (theResponseStatusCode == Constants.STATUS_HTTP_201_CREATED) {
     response.setCreated(true);
   }
   return response;
 }
コード例 #5
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
    @Override
    public T invokeClient(
        String theResponseMimeType,
        Reader theResponseReader,
        int theResponseStatusCode,
        Map<String, List<String>> theHeaders)
        throws IOException, BaseServerResponseException {
      EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
      if (respType == null) {
        throw NonFhirResponseException.newInstance(
            theResponseStatusCode, theResponseMimeType, theResponseReader);
      }
      IParser parser = respType.newParser(myContext);
      T retVal = parser.parseResource(myType, theResponseReader);

      if (myId != null) {
        retVal.setId(myId);
      }

      MethodUtil.parseClientRequestResourceHeaders(theHeaders, retVal);

      return retVal;
    }
コード例 #6
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
    @Override
    public OperationOutcome invokeClient(
        String theResponseMimeType,
        Reader theResponseReader,
        int theResponseStatusCode,
        Map<String, List<String>> theHeaders)
        throws IOException, BaseServerResponseException {
      EncodingEnum respType = EncodingEnum.forContentType(theResponseMimeType);
      if (respType == null) {
        return null;
      }
      IParser parser = respType.newParser(myContext);
      OperationOutcome retVal;
      try {
        retVal = parser.parseResource(OperationOutcome.class, theResponseReader);
      } catch (DataFormatException e) {
        ourLog.warn("Failed to parse OperationOutcome response", e);
        return null;
      }
      MethodUtil.parseClientRequestResourceHeaders(theHeaders, retVal);

      return retVal;
    }
コード例 #7
0
ファイル: GenericClient.java プロジェクト: face4011/hapi-fhir
    @Override
    public MethodOutcome execute() {
      if (myResource == null) {
        myResource = parseResourceBody(myResourceBody);
      }
      if (myId == null) {
        myId = myResource.getId();
      }
      if (myId == null || myId.hasIdPart() == false) {
        throw new InvalidRequestException(
            "No ID supplied for resource to update, can not invoke server");
      }

      BaseHttpClientInvocation invocation =
          MethodUtil.createUpdateInvocation(myResource, myResourceBody, myId, myContext);

      RuntimeResourceDefinition def = myContext.getResourceDefinition(myResource);
      final String resourceName = def.getName();

      OutcomeResponseHandler binding = new OutcomeResponseHandler(resourceName);

      Map<String, List<String>> params = new HashMap<String, List<String>>();
      return invoke(params, binding, invocation);
    }