@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; }
ourLog.info("Delivering {} rest-hook payload {} for {}", theMsg.getOperationType(), thePayloadResource.getIdElement().toUnqualified().getValue(), theSubscription.getIdElement(myFhirContext).toUnqualifiedVersionless().getValue());
return ref.toUnqualifiedVersionless().getValue(); return ref.toUnqualified().getValue();
public boolean unregisterSubscriptionIfRegistered(IBaseResource theSubscription, String theStatusString) { if (hasSubscription(theSubscription.getIdElement()).isPresent()) { ourLog.info("Removing {} subscription {}", theStatusString, theSubscription.getIdElement().toUnqualified().getValue()); unregisterSubscription(theSubscription.getIdElement()); return true; } return false; }
return ref.toUnqualifiedVersionless().getValue(); return ref.toUnqualified().getValue();
public void setPayload(FhirContext theCtx, IBaseResource thePayload) { myPayload = thePayload; myPayloadString = theCtx.newJsonParser().encodeResourceToString(thePayload); myPayloadId = thePayload.getIdElement().toUnqualified().getValue(); }
public synchronized boolean registerSubscriptionUnlessAlreadyRegistered(IBaseResource theSubscription) { Optional<CanonicalSubscription> existingSubscription = hasSubscription(theSubscription.getIdElement()); CanonicalSubscription newSubscription = mySubscriptionCanonicalizer.canonicalize(theSubscription); if (existingSubscription.isPresent()) { if (newSubscription.equals(existingSubscription.get())) { // No changes return false; } ourLog.info("Updating already-registered active subscription {}", theSubscription.getIdElement().toUnqualified().getValue()); unregisterSubscription(theSubscription.getIdElement()); } else { ourLog.info("Registering active subscription {}", theSubscription.getIdElement().toUnqualified().getValue()); } if (Subscription.SubscriptionStatus.ACTIVE.equals(newSubscription.getStatus())) { registerSubscription(theSubscription.getIdElement(), theSubscription); return true; } else { return false; } }
@Override @Transactional(propagation = Propagation.NEVER) public ExpungeOutcome expunge(IIdType theId, ExpungeOptions theExpungeOptions) { TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager); BaseHasResource entity = txTemplate.execute(t->readEntity(theId)); if (theId.hasVersionIdPart()) { BaseHasResource currentVersion; currentVersion = txTemplate.execute(t->readEntity(theId.toVersionless())); if (entity.getVersion() == currentVersion.getVersion()) { throw new PreconditionFailedException("Can not perform version-specific expunge of resource " + theId.toUnqualified().getValue() + " as this is the current version"); } return doExpunge(getResourceName(), entity.getResourceId(), entity.getVersion(), theExpungeOptions); } return doExpunge(getResourceName(), entity.getResourceId(), null, theExpungeOptions); }
case DSTU2_1: default: { ourLog.error("Failed to extract extension with URL {} from subscription {}", theUrl, theSubscription.getIdElement().toUnqualified().getValue()); break; ourLog.error("Failed to extract extension with URL {} from subscription {}", theUrl, theSubscription.getIdElement().toUnqualified().getValue(), theE);
private void setNewPayload(FhirContext theCtx, IBaseResource theNewPayload) { /* * References with placeholders would be invalid by the time we get here, and * would be caught before we even get here. This check is basically a last-ditch * effort to make sure nothing has broken in the various safeguards that * should prevent this from happening (hence it only being an assert as * opposed to something executed all the time). */ assert payloadContainsNoPlaceholderReferences(theCtx, theNewPayload); /* * Note: Don't set myPayloadDecoded in here- This is a false optimization since * it doesn't actually get used if anyone is doing subscriptions at any * scale using a queue engine, and not going through the serialize/deserialize * as we would in a queue engine can mask bugs. * -JA */ myPayload = theCtx.newJsonParser().encodeResourceToString(theNewPayload); myPayloadId = theNewPayload.getIdElement().toUnqualified().getValue(); }
dt = dt.toUnqualified(); } else { ourLog.debug("Searching for resource link with target URL: {}", dt.getValue());
private boolean activateSubscription(String theActiveStatus, final IBaseResource theSubscription, String theRequestedStatus) { IFhirResourceDao subscriptionDao = myDaoRegistry.getSubscriptionDao(); IBaseResource subscription = subscriptionDao.read(theSubscription.getIdElement()); subscription.setId(subscription.getIdElement().toVersionless()); ourLog.info("Activating subscription {} from status {} to {}", subscription.getIdElement().toUnqualified().getValue(), theRequestedStatus, theActiveStatus); try { SubscriptionUtil.setStatus(myFhirContext, subscription, theActiveStatus); subscription = subscriptionDao.update(subscription).getResource(); submitResourceModifiedForUpdate(subscription); return true; } catch (final UnprocessableEntityException e) { ourLog.info("Changing status of {} to ERROR", subscription.getIdElement()); SubscriptionUtil.setStatus(myFhirContext, subscription, "error"); SubscriptionUtil.setReason(myFhirContext, subscription, e.getMessage()); subscriptionDao.update(subscription); return false; } }
@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; }
if (refId != null && refId.hasBaseUrl()) { if (getConfig().getTreatBaseUrlsAsLocal().contains(refId.getBaseUrl())) { IIdType newRefId = refId.toUnqualified(); nextRef.getResourceReference().setReference(newRefId.getValue());
@Override @Transactional(propagation = Propagation.NEVER) public ExpungeOutcome expunge(IIdType theId, ExpungeOptions theExpungeOptions) { TransactionTemplate txTemplate = new TransactionTemplate(myPlatformTransactionManager); BaseHasResource entity = txTemplate.execute(t->readEntity(theId)); if (theId.hasVersionIdPart()) { BaseHasResource currentVersion; currentVersion = txTemplate.execute(t->readEntity(theId.toVersionless())); if (entity.getVersion() == currentVersion.getVersion()) { throw new PreconditionFailedException("Can not perform version-specific expunge of resource " + theId.toUnqualified().getValue() + " as this is the current version"); } return doExpunge(getResourceName(), entity.getResourceId(), entity.getVersion(), theExpungeOptions); } return doExpunge(getResourceName(), entity.getResourceId(), null, theExpungeOptions); }
dt = dt.toUnqualified(); } else { ourLog.debug("Searching for resource link with target URL: {}", dt.getValue());
private boolean activateSubscription(String theActiveStatus, final IBaseResource theSubscription, String theRequestedStatus) { IFhirResourceDao subscriptionDao = myDaoRegistry.getSubscriptionDao(); IBaseResource subscription = subscriptionDao.read(theSubscription.getIdElement()); subscription.setId(subscription.getIdElement().toVersionless()); ourLog.info("Activating subscription {} from status {} to {}", subscription.getIdElement().toUnqualified().getValue(), theRequestedStatus, theActiveStatus); try { SubscriptionUtil.setStatus(myFhirContext, subscription, theActiveStatus); subscription = subscriptionDao.update(subscription).getResource(); submitResourceModifiedForUpdate(subscription); return true; } catch (final UnprocessableEntityException e) { ourLog.info("Changing status of {} to ERROR", subscription.getIdElement()); SubscriptionUtil.setStatus(myFhirContext, subscription, "error"); SubscriptionUtil.setReason(myFhirContext, subscription, e.getMessage()); subscriptionDao.update(subscription); return false; } }
if (refId != null && refId.hasBaseUrl()) { if (getConfig().getTreatBaseUrlsAsLocal().contains(refId.getBaseUrl())) { IIdType newRefId = refId.toUnqualified(); nextRef.getResourceReference().setReference(newRefId.getValue());