@Update public MethodOutcome update(@IdParam IdType theId, @ResourceParam Patient thePatient) { String resourceId = theId.getIdPart(); String versionId = theId.getVersionIdPart(); // this will contain the ETag String currentVersion = "1"; // populate this with the current version if (!versionId.equals(currentVersion)) { throw new ResourceVersionConflictException("Expected version " + currentVersion); } // ... perform the update ... return new MethodOutcome(); } //END SNIPPET: updateEtag
@Override public boolean hasVersionIdPart() { return isNotBlank(getVersionIdPart()); }
public Long getVersionIdPartAsLong() { if (!hasVersionIdPart()) { return null; } else { return Long.parseLong(getVersionIdPart()); } }
@Override public boolean isVersionIdPartValidLong() { return isValidLong(getVersionIdPart()); }
String versionId = theId.getVersionIdPart(); if (versionId != null) {
/** * Returns true if this IdType matches the given IdType in terms of resource * type and ID, but ignores the URL base */ @SuppressWarnings("deprecation") public boolean equalsIgnoreBase(IdType theId) { if (theId == null) { return false; } if (theId.isEmpty()) { return isEmpty(); } return ObjectUtils.equals(getResourceType(), theId.getResourceType()) && ObjectUtils.equals(getIdPart(), theId.getIdPart()) && ObjectUtils.equals(getVersionIdPart(), theId.getVersionIdPart()); }
@Override public IdType withResourceType(String theResourceName) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theResourceName, getIdPart(), getVersionIdPart()); }
/** * Returns a new IdType containing this IdType's values but with no server * base URL if one is present in this IdType. For example, if this IdType * contains the ID "http://foo/Patient/1", this method will return a new * IdType containing ID "Patient/1". */ @Override public IdType toUnqualified() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart(), getVersionIdPart()); }
/** * Returns a view of this ID as a fully qualified URL, given a server base and * resource name (which will only be used if the ID does not already contain * those respective parts). Essentially, because IdType can contain either a * complete URL or a partial one (or even jut a simple ID), this method may be * used to translate into a complete URL. * * @param theServerBase * The server base (e.g. "http://example.com/fhir") * @param theResourceType * The resource name (e.g. "Patient") * @return A fully qualified URL for this ID (e.g. * "http://example.com/fhir/Patient/1") */ @Override public IdType withServerBase(String theServerBase, String theResourceType) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theServerBase, theResourceType, getIdPart(), getVersionIdPart()); }
} else { String resourceType = myContext.getResourceDefinition(next).getName(); nextEntry.getRequest().setUrl(new IdType(theServerBase, resourceType, next.getIdElement().getIdPart(), next.getIdElement().getVersionIdPart()).getValue());