Package ca.uhn.fhir.model.primitive

Examples of ca.uhn.fhir.model.primitive.IdDt


      ourLog.info("Request Url: {}", requestUrl);
      ourLog.info("Context Path: {}", servletContextPath);

      servletPath = servletContextPath;

      IdDt id = null;
      IdDt versionId = null;
      String operation = null;

      String requestPath = requestFullPath.substring(servletPath.length());
      if (requestPath.length() > 0 && requestPath.charAt(0) == '/') {
        requestPath = requestPath.substring(1);
      }

      int contextIndex;
      if (servletPath.length() == 0) {
        contextIndex = requestUrl.indexOf(requestPath);
      } else {
        contextIndex = requestUrl.indexOf(servletPath);
      }

      String fhirServerBase = requestUrl.substring(0, contextIndex + servletPath.length());
      if (fhirServerBase.endsWith("/")) {
        fhirServerBase = fhirServerBase.substring(0, fhirServerBase.length() - 1);
      }

      String completeUrl = StringUtils.isNotBlank(request.getQueryString()) ? requestUrl + "?" + request.getQueryString() : requestUrl.toString();

      Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap());

      StringTokenizer tok = new StringTokenizer(requestPath, "/");
      if (!tok.hasMoreTokens()) {
        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();
View Full Code Here


  public BaseClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    StringBuilder b = new StringBuilder();
    if (myResourceName!=null) {
      b.append(myResourceName);
      if (myIdParamIndex!=null) {
        IdDt id = (IdDt)theArgs[myIdParamIndex];
        if (id==null||isBlank(id.getValue())) {
          throw new NullPointerException("ID can not be null");
        }
        b.append('/');
        b.append(id.getValue());
      }
    }
    if (b.length()>0) {
      b.append('/');
    }
View Full Code Here

    int resourceIndex = theLocationHeader.lastIndexOf(resourceNamePart);
    if (resourceIndex > -1) {
      int idIndexStart = resourceIndex + resourceNamePart.length();
      int idIndexEnd = theLocationHeader.indexOf('/', idIndexStart);
      if (idIndexEnd == -1) {
        theOutcomeToPopulate.setId(new IdDt(theLocationHeader.substring(idIndexStart)));
      } else {
        theOutcomeToPopulate.setId(new IdDt(theLocationHeader.substring(idIndexStart, idIndexEnd)));
        String versionIdPart = "/_history/";
        int historyIdStart = theLocationHeader.indexOf(versionIdPart, idIndexEnd);
        if (historyIdStart != -1) {
          theOutcomeToPopulate.setVersionId(new IdDt(theLocationHeader.substring(historyIdStart + versionIdPart.length())));
        }
      }
    }
  }
View Full Code Here

      RestResource resource = rest.addResource();

      String resourceName = next.getResourceName();
      RuntimeResourceDefinition def = myRestfulServer.getFhirContext().getResourceDefinition(resourceName);
      resource.getType().setValue(def.getName());
      resource.getProfile().setId(new IdDt(def.getResourceProfile()));

      Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String, Conformance.RestResourceSearchParam>();
      for (BaseMethodBinding nextMethodBinding : next.getMethodBindings()) {
        RestfulOperationTypeEnum resOp = nextMethodBinding.getResourceOperationType();
        if (resOp != null) {
View Full Code Here

    }
  }

  @Override
  protected BaseClientInvocation createClientInvocation(Object[] theArgs, IResource resource, String resourceName) {
    IdDt idDt = (IdDt) theArgs[myIdParameterIndex];
    if (idDt == null) {
      throw new NullPointerException("ID can not be null");
    }
    String id = idDt.getValue();

    StringBuilder urlExtension = new StringBuilder();
    urlExtension.append(resourceName);
    urlExtension.append('/');
    urlExtension.append(id);
    PutClientInvocation retVal = new PutClientInvocation(getContext(), resource, urlExtension.toString());

    if (myVersionIdParameterIndex != null) {
      IdDt versionIdDt = (IdDt) theArgs[myVersionIdParameterIndex];
      if (versionIdDt != null) {
        String versionId = versionIdDt.getValue();
        if (StringUtils.isNotBlank(versionId)) {
          StringBuilder b = new StringBuilder();
          b.append('/');
          b.append(urlExtension);
          b.append("/_history/");
View Full Code Here

  // return super.matches(theRequest);
  // }

  @Override
  public BaseClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException {
    IdDt idDt = (IdDt) theArgs[myIdParameterIndex];
    if (idDt == null) {
      throw new NullPointerException("ID can not be null");
    }
    String id = idDt.getValue();

    DeleteClientInvocation retVal = new DeleteClientInvocation(getResourceName(), id);

    return retVal;
  }
View Full Code Here

    String id = url.substring(resNameIdx+getResourceName().length() + 1);
    if (id.contains("/")) {
      throw new InvalidRequestException("Invalid request path for a DELETE operation: "+theRequest.getCompleteUrl());
    }
   
    theParams[myIdParameterIndex] = new IdDt(id);
  }
View Full Code Here

    Object retValObj = theResourceMetadata.get(theKey);
    if (retValObj == null) {
      return null;
    } else if (retValObj instanceof String) {
      if (isNotBlank((String) retValObj)) {
        return new IdDt((String) retValObj);
      } else {
        return null;
      }
    } else if (retValObj instanceof IdDt) {
      if (((IdDt) retValObj).isEmpty()) {
View Full Code Here

        /*
         * If this is a history operation, we add the version of the
         * resource to the self link to indicate the version
         */
        if (getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_INSTANCE || getResourceOperationType() == RestfulOperationTypeEnum.HISTORY_TYPE || getSystemOperationType() == RestfulOperationSystemEnum.HISTORY_SYSTEM) {
          IdDt versionId = getIdFromMetadataOrNullIfNone(next.getResourceMetadata(), ResourceMetadataKeyEnum.VERSION_ID);
          if (versionId != null) {
            b.append('/');
            b.append(Constants.PARAM_HISTORY);
            b.append('/');
            b.append(versionId.getValue());
          } else {
            throw new InternalErrorException("Server did not provide a VERSION_ID in the resource metadata for resource with ID " + resId);
          }
        }

View Full Code Here

     * The identifier of this message
     * </p>
   */
  public IdDt getIdentifier() { 
    if (myIdentifier == null) {
      myIdentifier = new IdDt();
    }
    return myIdentifier;
  }
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.primitive.IdDt

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.