Package ca.uhn.fhir.rest.method

Examples of ca.uhn.fhir.rest.method.BaseMethodBinding


    Class<?> clazz = theProvider.getClass();
    for (Method m : clazz.getDeclaredMethods()) {
      if (Modifier.isPublic(m.getModifiers()) && !Modifier.isStatic(m.getModifiers())) {
        ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());

        BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
        if (foundMethodBinding != null) {
         
          RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(foundMethodBinding.getResourceName());
          ResourceBinding resourceBinding;
          if (myResourceNameToProvider.containsKey(definition.getName())) {
            resourceBinding = myResourceNameToProvider.get(definition.getName());
          } else {
            resourceBinding = new ResourceBinding();
View Full Code Here


    Class<?> clazz = theSystemProvider.getClass();
    for (Method m : clazz.getDeclaredMethods()) {
      if (Modifier.isPublic(m.getModifiers())) {
        ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());

        BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theSystemProvider);
        if (foundMethodBinding != null) {
          if (foundMethodBinding instanceof ConformanceMethodBinding) {
            myServerConformanceMethod = foundMethodBinding;
          }
          ourLog.info(" * Method: {}#{} is a handler", theSystemProvider.getClass(), m.getName());
View Full Code Here

        throw new MethodNotFoundException("No resource name specified");
      }
      resourceName = tok.nextToken();

      ResourceBinding resourceBinding = null;
      BaseMethodBinding resourceMethod = null;
      if ("metadata".equals(resourceName)) {
        resourceMethod = myServerConformanceMethod;
      } else {
        resourceBinding = myResourceNameToProvider.get(resourceName);
        if (resourceBinding == null) {
          throw new MethodNotFoundException("Unknown resource type '" + resourceName + "' - Server knows how to handle: " + myResourceNameToProvider.keySet());
        }
      }

      if (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (nextString.startsWith("_")) {
          operation = nextString;
        } else {
          id = new IdDt(nextString);
        }
      }

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

      if (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        versionId = new IdDt(nextString);
      }

      // TODO: look for more tokens for version, compartments, etc...

      Request r = new Request();
      r.setResourceName(resourceName);
      r.setId(id);
      r.setVersion(versionId);
      r.setOperation(operation);
      r.setParameters(params);
      r.setRequestType(requestType);
      if ("application/x-www-form-urlencoded".equals(request.getContentType())) {
        r.setInputReader(new StringReader(""));
      } else {
        r.setInputReader(request.getReader());
      }
      r.setFhirServerBase(fhirServerBase);
      r.setCompleteUrl(completeUrl);
      r.setServletRequest(request);

      if (resourceMethod == null && resourceBinding != null) {
        resourceMethod = resourceBinding.getMethod(r);
      }
      if (null == resourceMethod) {
        throw new MethodNotFoundException("No resource method available for the supplied parameters " + params);
      }

      resourceMethod.invokeServer(this, r, response);

    } catch (AuthenticationException e) {
      response.setStatus(e.getStatusCode());
      addHapiHeader(response);
      response.setContentType("text/plain");
View Full Code Here

    ClientInvocationHandler invocationHandler = myInvocationHandlers.get(theClientType);
    if (invocationHandler == null) {
      invocationHandler = new ClientInvocationHandler(client, myContext, serverBase, theClientType);
      for (Method nextMethod : theClientType.getMethods()) {
        BaseMethodBinding binding = BaseMethodBinding.bindMethod(nextMethod, myContext, null);
        invocationHandler.addBinding(nextMethod, binding);
      }
      myInvocationHandlers.put(theClientType, invocationHandler);
    }
   
View Full Code Here

  private void findResourceMethods(Object theProvider, Class<?> clazz) {
    for (Method m : clazz.getDeclaredMethods()) {
      if (Modifier.isPublic(m.getModifiers()) && !Modifier.isStatic(m.getModifiers())) {
        ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());

        BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
        if (foundMethodBinding != null) {

          String resourceName = foundMethodBinding.getResourceName();
          ResourceBinding resourceBinding;
          if (resourceName == null) {
            resourceBinding = myNullResourceBinding;
          } else {
            RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(resourceName);
View Full Code Here

    for (Method m : clazz.getDeclaredMethods()) {
      if (Modifier.isPublic(m.getModifiers())) {
        ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());

        BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theSystemProvider);
        if (foundMethodBinding != null) {
          if (foundMethodBinding instanceof ConformanceMethodBinding) {
            myServerConformanceMethod = foundMethodBinding;
          }
          ourLog.info(" * Method: {}#{} is a handler", theSystemProvider.getClass(), m.getName());
View Full Code Here

        operation = resourceName;
        resourceName = null;
      }

      ResourceBinding resourceBinding = null;
      BaseMethodBinding resourceMethod = null;
      if ("metadata".equals(resourceName)) {
        resourceMethod = myServerConformanceMethod;
      } else if (resourceName == null) {
        resourceBinding = myNullResourceBinding;
      } else {
        resourceBinding = myResourceNameToProvider.get(resourceName);
        if (resourceBinding == null) {
          throw new ResourceNotFoundException("Unknown resource type '" + resourceName + "' - Server knows how to handle: " + myResourceNameToProvider.keySet());
        }
      }

      if (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (nextString.startsWith("_")) {
          operation = nextString;
        } else {
          id = new IdDt(nextString);
        }
      }

      if (tok.hasMoreTokens()) {
        String nextString = tok.nextToken();
        if (nextString.equals(Constants.PARAM_HISTORY)) {
          if (tok.hasMoreTokens()) {
            String versionString = tok.nextToken();
            versionId = new IdDt(versionString);
          } 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");
        if (contentLocation != null) {
          int idx = contentLocation.indexOf("/_history/");
          if (idx != -1) {
            String versionIdString = contentLocation.substring(idx + "/_history/".length());
            versionId = new IdDt(versionIdString);
          }
        }
      }

      // TODO: look for more tokens for version, compartments, etc...

      Request r = new Request();
      r.setResourceName(resourceName);
      r.setId(id);
      r.setVersion(versionId);
      r.setOperation(operation);
      r.setSecondaryOperation(secondaryOperation);
      r.setParameters(params);
      r.setRequestType(theRequestType);
      if ("application/x-www-form-urlencoded".equals(theRequest.getContentType())) {
        r.setInputReader(new StringReader(""));
      } else {
        r.setInputReader(theRequest.getReader());
      }
      r.setFhirServerBase(fhirServerBase);
      r.setCompleteUrl(completeUrl);
      r.setServletRequest(theRequest);
      r.setServletResponse(theResponse);

      if (resourceMethod == null && resourceBinding != null) {
        resourceMethod = resourceBinding.getMethod(r);
      }
      if (null == resourceMethod) {
        throw new ResourceNotFoundException("No resource method available for the supplied parameters " + params);
      }

      resourceMethod.invokeServer(this, r, theResponse);

    } catch (AuthenticationException e) {
      theResponse.setStatus(e.getStatusCode());
      addHeadersToResponse(theResponse);
      theResponse.setContentType("text/plain");
View Full Code Here

    ClientInvocationHandler invocationHandler = myInvocationHandlers.get(theClientType);
    if (invocationHandler == null) {
      invocationHandler = new ClientInvocationHandler(client, myContext, serverBase, theClientType);
      for (Method nextMethod : theClientType.getMethods()) {
        BaseMethodBinding binding = BaseMethodBinding.bindMethod(nextMethod, myContext, null);
        invocationHandler.addBinding(nextMethod, binding);
      }
      myInvocationHandlers.put(theClientType, invocationHandler);
    }
   
View Full Code Here

    Class<?> clazz = theProvider.getClass();
    for (Method m : clazz.getDeclaredMethods()) {
      if (Modifier.isPublic(m.getModifiers())) {
        ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName());

        BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindMethod(theProvider.getResourceType(), m, myFhirContext, theProvider);
        if (foundMethodBinding != null) {
          r.addMethod(foundMethodBinding);
          ourLog.info(" * Method: {}#{} is a handler", theProvider.getClass(), m.getName());
        } else {
          ourLog.debug(" * Method: {}#{} is not a handler", theProvider.getClass(), m.getName());
View Full Code Here

    Class<?> clazz = theSystemProvider.getClass();
    for (Method m : clazz.getDeclaredMethods()) {
      if (Modifier.isPublic(m.getModifiers())) {
        ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());

        BaseMethodBinding foundMethodBinding = BaseMethodBinding.bindSystemMethod(m, myFhirContext);
        if (foundMethodBinding != null) {
          if (foundMethodBinding instanceof ConformanceMethodBinding) {
            myServerConformanceMethod = foundMethodBinding;
          }
          ourLog.info(" * Method: {}#{} is a handler", theSystemProvider.getClass(), m.getName());
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.rest.method.BaseMethodBinding

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.