Tabnine Logo
ResourceParameter
Code IndexAdd Tabnine to your IDE (free)

How to use
ResourceParameter
in
ca.uhn.fhir.rest.server.method

Best Java code snippets using ca.uhn.fhir.rest.server.method.ResourceParameter (Showing top 20 results out of 315)

origin: jamesagnew/hapi-fhir

public static Reader createRequestReader(RequestDetails theRequest) {
  return createRequestReader(theRequest, determineRequestCharset(theRequest));
}
origin: jamesagnew/hapi-fhir

if (next instanceof ResourceParameter) {
  resourceParameter = (ResourceParameter) next;
  if (resourceParameter.getMode() != ResourceParameter.Mode.RESOURCE) {
    continue;
  myResourceType = resourceParameter.getResourceType();
origin: jamesagnew/hapi-fhir

@Override
public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException {
  if (theRequest.getRequestType() == RequestTypeEnum.POST) {
    IBaseResource requestContents = ResourceParameter.loadResourceFromRequest(theRequest, this, null);
    theRequest.getUserData().put(OperationParameter.REQUEST_CONTENTS_USERDATA_KEY, requestContents);
  }
  return super.invokeServer(theServer, theRequest);
}
origin: jamesagnew/hapi-fhir

@Override
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
  switch (myMode) {
    case BODY:
      try {
        return IOUtils.toString(createRequestReader(theRequest));
      } catch (IOException e) {
        // Shouldn't happen since we're reading from a byte array
        throw new InternalErrorException("Failed to load request", e);
      }
    case BODY_BYTE_ARRAY:
      return theRequest.loadRequestContents();
    case ENCODING:
      return RestfulServerUtils.determineRequestEncodingNoDefault(theRequest);
    case RESOURCE:
    default:
      Class<? extends IBaseResource> resourceTypeToParse = myResourceType;
      if (myMethodIsOperation) {
        // Operations typically have a Parameters resource as the body
        resourceTypeToParse = null;
      }
      return parseResourceFromRequest(theRequest, theMethodBinding, resourceTypeToParse);
  }
  // }
}
origin: jamesagnew/hapi-fhir

@Override
protected byte[] getByteStreamRequestContents() {
  return StringUtils.defaultString(myResourceString, "")
      .getBytes(ResourceParameter.determineRequestCharset(this));
}
origin: jamesagnew/hapi-fhir

@Override
protected void populateActionRequestDetailsForInterceptor(RequestDetails theRequestDetails, ActionRequestDetails theDetails, Object[] theMethodParams) {
  super.populateActionRequestDetailsForInterceptor(theRequestDetails, theDetails, theMethodParams);
  /*
   * If the method has no parsed resource parameter, we parse here in order to have something for the interceptor.
   */
  if (myResourceParameterIndex != -1) {
    theDetails.setResource((IBaseResource) theMethodParams[myResourceParameterIndex]);
  } else {
    theDetails.setResource(ResourceParameter.parseResourceFromRequest(theRequestDetails, this, myResourceType));
  }
}
origin: jamesagnew/hapi-fhir

@Override
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
  // TODO: don't use a default encoding, just fail!
  EncodingEnum encoding = RestfulServerUtils.determineRequestEncoding(theRequest);
  IParser parser = encoding.newParser(theRequest.getServer().getFhirContext());
  Reader reader = ResourceParameter.createRequestReader(theRequest);
  try {
    switch (myParamStyle) {
    case RESOURCE_LIST: {
      Class<? extends IBaseResource> type = myContext.getResourceDefinition("Bundle").getImplementingClass();
      IBaseResource bundle = parser.parseResource(type, reader);
      List<IBaseResource> resourceList = BundleUtil.toListOfResources(myContext, (IBaseBundle) bundle);
      return resourceList;
    }
    case RESOURCE_BUNDLE:
      return parser.parseResource(myResourceBundleType, reader);
    }
    throw new IllegalStateException("Unknown type: " + myParamStyle); // should not happen
  } finally {
    IOUtils.closeQuietly(reader);
  }
}
origin: jamesagnew/hapi-fhir

public ValidateMethodBindingDstu2Plus(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider,
    Validate theAnnotation) {
  super(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, true, Constants.EXTOP_VALIDATE, theAnnotation.type(), new OperationParam[0], BundleTypeEnum.COLLECTION);
  List<IParameter> newParams = new ArrayList<IParameter>();
  int idx = 0;
  for (IParameter next : getParameters()) {
    if (next instanceof ResourceParameter) {
      if (IBaseResource.class.isAssignableFrom(((ResourceParameter) next).getResourceType())) {
        Class<?> parameterType = theMethod.getParameterTypes()[idx];
        if (String.class.equals(parameterType) || EncodingEnum.class.equals(parameterType)) {
          newParams.add(next);
        } else {
          OperationParameter parameter = new OperationParameter(theContext, Constants.EXTOP_VALIDATE, Constants.EXTOP_VALIDATE_RESOURCE, 0, 1);
          parameter.initializeTypes(theMethod, null, null, parameterType);
          newParams.add(parameter);
        }
      } else {
        newParams.add(next);
      }
    } else {
      newParams.add(next);
    }
    idx++;
  }
  setParameters(newParams);
}
origin: jamesagnew/hapi-fhir

  param = new ResourceParameter((Class<? extends IBaseResource>) parameterType, theProvider, mode, methodIsOperation);
} else if (nextAnnotation instanceof IdParam) {
  param = new NullParameter();
origin: jamesagnew/hapi-fhir

@Override
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {
  EncodingEnum encoding = RestfulServerUtils.determineRequestEncodingNoDefault(theRequestDetails);
  if (encoding == null) {
    ourLog.trace("Incoming request does not appear to be FHIR, not going to validate");
    return true;
  }
  Charset charset = ResourceParameter.determineRequestCharset(theRequestDetails);
  String requestText = new String(theRequestDetails.loadRequestContents(), charset);
  if (isBlank(requestText)) {
    ourLog.trace("Incoming request does not have a body");
    return true;
  }
  ValidationResult validationResult = validate(requestText, theRequestDetails);
  // The JPA server will use this
  theRequestDetails.getUserData().put(REQUEST_VALIDATION_RESULT, validationResult);
  return true;
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

@Override
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
  switch (myMode) {
    case BODY:
      try {
        return IOUtils.toString(createRequestReader(theRequest));
      } catch (IOException e) {
        // Shouldn't happen since we're reading from a byte array
        throw new InternalErrorException("Failed to load request", e);
      }
    case BODY_BYTE_ARRAY:
      return theRequest.loadRequestContents();
    case ENCODING:
      return RestfulServerUtils.determineRequestEncodingNoDefault(theRequest);
    case RESOURCE:
    default:
      Class<? extends IBaseResource> resourceTypeToParse = myResourceType;
      if (myMethodIsOperation) {
        // Operations typically have a Parameters resource as the body
        resourceTypeToParse = null;
      }
      return parseResourceFromRequest(theRequest, theMethodBinding, resourceTypeToParse);
  }
  // }
}
origin: jamesagnew/hapi-fhir

@Override
protected void populateActionRequestDetailsForInterceptor(RequestDetails theRequestDetails, ActionRequestDetails theDetails, Object[] theMethodParams) {
  super.populateActionRequestDetailsForInterceptor(theRequestDetails, theDetails, theMethodParams);
  /*
   * If the method has no parsed resource parameter, we parse here in order to have something for the interceptor.
   */
  if (myTransactionParamIndex != -1) {
    theDetails.setResource((IBaseResource) theMethodParams[myTransactionParamIndex]);
  } else {
    Class<? extends IBaseResource> resourceType = getContext().getResourceDefinition("Bundle").getImplementingClass();
    theDetails.setResource(ResourceParameter.parseResourceFromRequest(theRequestDetails, this, resourceType));
  }
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

@Override
public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException {
  // TODO: don't use a default encoding, just fail!
  EncodingEnum encoding = RestfulServerUtils.determineRequestEncoding(theRequest);
  IParser parser = encoding.newParser(theRequest.getServer().getFhirContext());
  Reader reader = ResourceParameter.createRequestReader(theRequest);
  try {
    switch (myParamStyle) {
    case RESOURCE_LIST: {
      Class<? extends IBaseResource> type = myContext.getResourceDefinition("Bundle").getImplementingClass();
      IBaseResource bundle = parser.parseResource(type, reader);
      List<IBaseResource> resourceList = BundleUtil.toListOfResources(myContext, (IBaseBundle) bundle);
      return resourceList;
    }
    case RESOURCE_BUNDLE:
      return parser.parseResource(myResourceBundleType, reader);
    }
    throw new IllegalStateException("Unknown type: " + myParamStyle); // should not happen
  } finally {
    IOUtils.closeQuietly(reader);
  }
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

public ValidateMethodBindingDstu2Plus(Class<?> theReturnResourceType, Class<? extends IBaseResource> theReturnTypeFromRp, Method theMethod, FhirContext theContext, Object theProvider,
    Validate theAnnotation) {
  super(theReturnResourceType, theReturnTypeFromRp, theMethod, theContext, theProvider, true, Constants.EXTOP_VALIDATE, theAnnotation.type(), new OperationParam[0], BundleTypeEnum.COLLECTION);
  List<IParameter> newParams = new ArrayList<IParameter>();
  int idx = 0;
  for (IParameter next : getParameters()) {
    if (next instanceof ResourceParameter) {
      if (IBaseResource.class.isAssignableFrom(((ResourceParameter) next).getResourceType())) {
        Class<?> parameterType = theMethod.getParameterTypes()[idx];
        if (String.class.equals(parameterType) || EncodingEnum.class.equals(parameterType)) {
          newParams.add(next);
        } else {
          OperationParameter parameter = new OperationParameter(theContext, Constants.EXTOP_VALIDATE, Constants.EXTOP_VALIDATE_RESOURCE, 0, 1);
          parameter.initializeTypes(theMethod, null, null, parameterType);
          newParams.add(parameter);
        }
      } else {
        newParams.add(next);
      }
    } else {
      newParams.add(next);
    }
    idx++;
  }
  setParameters(newParams);
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

  param = new ResourceParameter((Class<? extends IBaseResource>) parameterType, theProvider, mode, methodIsOperation);
} else if (nextAnnotation instanceof IdParam) {
  param = new NullParameter();
origin: jamesagnew/hapi-fhir

FhirContext ctx = theRequest.getServer().getFhirContext();
final Charset charset = determineRequestCharset(theRequest);
Reader requestReader = createRequestReader(theRequest, charset);
origin: ca.uhn.hapi.fhir/hapi-fhir-server

@Override
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {
  EncodingEnum encoding = RestfulServerUtils.determineRequestEncodingNoDefault(theRequestDetails);
  if (encoding == null) {
    ourLog.trace("Incoming request does not appear to be FHIR, not going to validate");
    return true;
  }
  Charset charset = ResourceParameter.determineRequestCharset(theRequestDetails);
  String requestText = new String(theRequestDetails.loadRequestContents(), charset);
  if (isBlank(requestText)) {
    ourLog.trace("Incoming request does not have a body");
    return true;
  }
  ValidationResult validationResult = validate(requestText, theRequestDetails);
  // The JPA server will use this
  theRequestDetails.getUserData().put(REQUEST_VALIDATION_RESULT, validationResult);
  return true;
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

if (next instanceof ResourceParameter) {
  resourceParameter = (ResourceParameter) next;
  if (resourceParameter.getMode() != ResourceParameter.Mode.RESOURCE) {
    continue;
  myResourceType = resourceParameter.getResourceType();
origin: jamesagnew/hapi-fhir

public static IBaseResource parseResourceFromRequest(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding, Class<? extends IBaseResource> theResourceType) {
  IBaseResource retVal = null;
  if (theResourceType != null && IBaseBinary.class.isAssignableFrom(theResourceType)) {
    String ct = theRequest.getHeader(Constants.HEADER_CONTENT_TYPE);
    if (EncodingEnum.forContentTypeStrict(ct) == null) {
      FhirContext ctx = theRequest.getServer().getFhirContext();
      IBaseBinary binary = BinaryUtil.newBinary(ctx);
      binary.setId(theRequest.getId());
      binary.setContentType(ct);
      binary.setContent(theRequest.loadRequestContents());
      retVal = binary;
      /*
       * Security context header, which is only in
       * DSTU3+
       */
      if (ctx.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
        String securityContext = theRequest.getHeader(Constants.HEADER_X_SECURITY_CONTEXT);
        if (isNotBlank(securityContext)) {
          BinaryUtil.setSecurityContext(ctx, binary, securityContext);
        }
      }
    }
  }
  if (retVal == null) {
    retVal = loadResourceFromRequest(theRequest, theMethodBinding, theResourceType);
  }
  return retVal;
}
origin: ca.uhn.hapi.fhir/hapi-fhir-server

@Override
protected void populateActionRequestDetailsForInterceptor(RequestDetails theRequestDetails, ActionRequestDetails theDetails, Object[] theMethodParams) {
  super.populateActionRequestDetailsForInterceptor(theRequestDetails, theDetails, theMethodParams);
  /*
   * If the method has no parsed resource parameter, we parse here in order to have something for the interceptor.
   */
  if (myResourceParameterIndex != -1) {
    theDetails.setResource((IBaseResource) theMethodParams[myResourceParameterIndex]);
  } else {
    theDetails.setResource(ResourceParameter.parseResourceFromRequest(theRequestDetails, this, myResourceType));
  }
}
ca.uhn.fhir.rest.server.methodResourceParameter

Most used methods

  • determineRequestCharset
  • <init>
  • createRequestReader
  • getMode
  • getResourceType
  • loadResourceFromRequest
  • parseResourceFromRequest

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JOptionPane (javax.swing)
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now