public static boolean isValidPid(IIdType theId) { if (theId == null || theId.getIdPart() == null) { return false; } String idPart = theId.getIdPart(); for (int i = 0; i < idPart.length(); i++) { char nextChar = idPart.charAt(i); if (nextChar < '0' || nextChar > '9') { return false; } } return true; } }
private Optional<CanonicalSubscription> hasSubscription(IIdType theId) { Validate.notNull(theId); Validate.notBlank(theId.getIdPart()); Optional<ActiveSubscription> activeSubscription = Optional.ofNullable(myActiveSubscriptionCache.get(theId.getIdPart())); return activeSubscription.map(ActiveSubscription::getSubscription); }
protected String getPreferredId(IBaseResource theResource, String theId) { if (isNotBlank(theId)) { return theId; } return theResource.getIdElement().getIdPart(); }
public void unregisterSubscription(IIdType theId) { Validate.notNull(theId); String subscriptionId = theId.getIdPart(); myActiveSubscriptionCache.remove(subscriptionId); }
@Override public IReadExecutable withId(IIdType theId) { Validate.notNull(theId, "The ID can not be null"); Validate.notBlank(theId.getIdPart(), "The ID can not be blank"); myId = theId.toUnqualified(); return this; }
@Override public IAuthRuleFinished instance(IIdType theId) { Validate.notNull(theId, "theId must not be null"); Validate.notBlank(theId.getValue(), "theId.getValue() must not be null or empty"); Validate.notBlank(theId.getIdPart(), "theId must contain an ID part"); List<IIdType> instances = Lists.newArrayList(theId); return instances(instances); }
private void setIdInternal(IIdType theId) { Validate.notBlank(theId.getResourceType(), "theId must contain a resource type"); Validate.notBlank(theId.getIdPart(), "theId must contain an ID part"); myOnType = theId.getResourceType(); myId = theId; }
@Override public IAuthRuleBuilderOperationNamedAndScoped onInstance(IIdType theInstanceId) { Validate.notNull(theInstanceId, "theInstanceId must not be null"); Validate.notBlank(theInstanceId.getResourceType(), "theInstanceId does not have a resource type"); Validate.notBlank(theInstanceId.getIdPart(), "theInstanceId does not have an ID part"); OperationRule rule = createRule(); ArrayList<IIdType> ids = new ArrayList<>(); ids.add(theInstanceId); rule.appliesToInstances(ids); return new RuleBuilderOperationNamedAndScoped(rule); }
private void addLocationHeader(RequestDetails theRequest, HttpServletResponse theResponse, MethodOutcome response, String headerLocation, String resourceName) { StringBuilder b = new StringBuilder(); b.append(theRequest.getFhirServerBase()); b.append('/'); b.append(resourceName); b.append('/'); b.append(response.getId().getIdPart()); if (response.getId().hasVersionIdPart()) { b.append("/" + Constants.PARAM_HISTORY + "/"); b.append(response.getId().getVersionIdPart()); } theResponse.addHeader(headerLocation, b.toString()); }
@Delete public MethodOutcome delete(@IdParam IIdType theId) { TreeMap<Long, T> versions = myIdToVersionToResourceMap.get(theId.getIdPart()); if (versions == null || versions.isEmpty()) { throw new ResourceNotFoundException(theId); } long nextVersion = versions.lastEntry().getKey() + 1L; IIdType id = store(null, theId.getIdPart(), nextVersion); myDeleteCount.incrementAndGet(); return new MethodOutcome() .setId(id); }
@History public List<T> historyInstance(@IdParam IIdType theId) { LinkedList<T> retVal = myIdToHistory.get(theId.getIdPart()); if (retVal == null) { throw new ResourceNotFoundException(theId); } return retVal; }
private void filterBundle(org.hl7.fhir.dstu3.model.Bundle theBundle) { for (Iterator<BundleEntryComponent> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
private void filterBundle(ca.uhn.fhir.model.dstu2.resource.Bundle theBundle) { for (Iterator<Entry> iter = theBundle.getEntry().iterator(); iter.hasNext(); ) { IBaseResource next = iter.next().getResource(); for (IIdType nextExclude : myExcludes) { if (nextExclude.hasResourceType() && nextExclude.toUnqualifiedVersionless().getValue().equals(next.getIdElement().toUnqualifiedVersionless().getValue())) { iter.remove(); continue; } else if (nextExclude.getIdPart().equals(next.getIdElement().getIdPart())) { iter.remove(); continue; } } } }
protected ResourceTable readEntityLatestVersion(IIdType theId) { ResourceTable entity = myEntityManager.find(ResourceTable.class, myIdHelperService.translateForcedIdToPid(getResourceName(), theId.getIdPart())); if (entity == null) { throw new ResourceNotFoundException(theId); } validateGivenIdIsAppropriateToRetrieveResource(theId, entity); return entity; }
private void deliver() { try { String payload = "ping " + myActiveSubscription.getIdElement(myCtx).getIdPart(); ourLog.info("Sending WebSocket message: {}", payload); mySession.sendMessage(new TextMessage(payload)); } catch (IOException e) { handleFailure(e); } }
public static HttpGetClientInvocation createReadInvocation(FhirContext theContext, IIdType theId, String theResourceName) { return new HttpGetClientInvocation(theContext, new IdDt(theResourceName, theId.getIdPart()).getValue()); }
@Override public SubscriptionMatchResult match(CanonicalSubscription theSubscription, ResourceModifiedMessage theMsg) { IIdType id = theMsg.getId(myCtx); String resourceType = id.getResourceType(); String resourceId = id.getIdPart(); String criteria = theSubscription.getCriteriaString(); // run the subscriptions query and look for matches, add the id as part of the criteria to avoid getting matches of previous resources rather than the recent resource criteria += "&_id=" + resourceType + "/" + resourceId; IBundleProvider results = performSearch(criteria); ourLog.debug("Subscription check found {} results for query: {}", results.size(), criteria); return SubscriptionMatchResult.fromBoolean(results.size() > 0); }
public static BaseHttpClientInvocation createValidateInvocation(FhirContext theContext, IBaseResource theResource) { IBaseParameters parameters = (IBaseParameters) theContext.getResourceDefinition("Parameters").newInstance(); ParametersUtil.addParameterToParameters(theContext, parameters, "resource", theResource); String resourceName = theContext.getResourceDefinition(theResource).getName(); String resourceId = theResource.getIdElement().getIdPart(); BaseHttpClientInvocation retVal = createOperationInvocation(theContext, resourceName, resourceId, null,Constants.EXTOP_VALIDATE, parameters, false); return retVal; }
@Override public IBaseResource getResource(IIdType payloadId) throws ResourceGoneException { RuntimeResourceDefinition resourceDef = myFhirContext.getResourceDefinition(payloadId.getResourceType()); return myClient.search().forResource(resourceDef.getName()).withIdAndCompartment(payloadId.getIdPart(), payloadId.getResourceType()).execute(); } }