if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) {
public ResponseEncoding(FhirContext theCtx, EncodingEnum theEncoding, String theContentType) { super(); myEncoding = theEncoding; myContentType = theContentType; if (theContentType != null) { FhirVersionEnum ctxtEnum = theCtx.getVersion().getVersion(); if (theContentType.equals(EncodingEnum.JSON_PLAIN_STRING) || theContentType.equals(EncodingEnum.XML_PLAIN_STRING)) { myNonLegacy = ctxtEnum.isNewerThan(FhirVersionEnum.DSTU2_1); } else { myNonLegacy = ctxtEnum.isNewerThan(FhirVersionEnum.DSTU2_1) && !EncodingEnum.isLegacy(theContentType); } } else { FhirVersionEnum ctxtEnum = theCtx.getVersion().getVersion(); if (ctxtEnum.isOlderThan(FhirVersionEnum.DSTU3)) { myNonLegacy = null; } else { myNonLegacy = Boolean.TRUE; } } }
private String getContentType(EncodingEnum encoding) { if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { // application/xml+fhir return encoding.getResourceContentType(); } else { // application/fhir+xml return encoding.getResourceContentTypeNonLegacy(); } }
@Override protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) { if (isNotBlank(theUrlId)) { String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInUrlForCreate", theUrlId); throw new InvalidRequestException(msg); } if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { if (isNotBlank(theResourceId)) { String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInBodyForCreate", theResourceId); throw new InvalidRequestException(msg); } } else { theResource.setId((IIdType)null); } }
@Override protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) { if (isNotBlank(theUrlId)) { String msg = getContext().getLocalizer() .getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInUrlForCreate", theUrlId); throw new InvalidRequestException(msg); } if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { if (isNotBlank(theResourceId)) { String msg = getContext().getLocalizer().getMessage( BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInBodyForCreate", theResourceId); throw new InvalidRequestException(msg); } } else { theResource.setId((IIdType) null); } }
@Override public DaoMethodOutcome create(T theResource, String theIfNoneExist, boolean thePerformIndexing, Date theUpdateTimestamp, RequestDetails theRequestDetails) { if (isNotBlank(theResource.getIdElement().getIdPart())) { if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getIdElement().getIdPart()); throw new InvalidRequestException(message, createErrorOperationOutcome(message, "processing")); } else { // As of DSTU3, ID and version in the body should be ignored for a create/update theResource.setId(""); } } if (myDaoConfig.getResourceServerIdStrategy() == DaoConfig.IdStrategyEnum.UUID) { theResource.setId(UUID.randomUUID().toString()); } return doCreate(theResource, theIfNoneExist, thePerformIndexing, theUpdateTimestamp, theRequestDetails); }
@Override protected void addParametersForServerRequest(RequestDetails theRequest, Object[] theParams) { if (myIdParamIndex != null) { theParams[myIdParamIndex] = ParameterUtil.convertIdToType(theRequest.getId(), myIdParamType); } if (myResourceParameterIndex != -1) { IBaseResource resource = ((IBaseResource) theParams[myResourceParameterIndex]); String resourceId = resource.getIdElement().getIdPart(); String urlId = theRequest.getId() != null ? theRequest.getId().getIdPart() : null; if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3) == false) { resource.setId(theRequest.getId()); } String matchUrl = null; if (myConditionalUrlIndex != -1) { matchUrl = (String) theParams[myConditionalUrlIndex]; matchUrl = defaultIfBlank(matchUrl, null); } validateResourceIdAndUrlIdForNonConditionalOperation(resource, resourceId, urlId, matchUrl); } }
try { String capabilityStatementResourceName = "CapabilityStatement"; if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { capabilityStatementResourceName = "Conformance"; implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); } catch (DataFormatException e) { if (!myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { capabilityStatementResourceName = "Conformance"; implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); conformance = (IBaseResource) client.fetchConformance().ofType(implementingClass).execute(); } catch (FhirClientConnectionException e) { if (!myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3) && e.getCause() instanceof DataFormatException) { capabilityStatementResourceName = "CapabilityStatement"; implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass();
if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) {
public ResponseEncoding(FhirContext theCtx, EncodingEnum theEncoding, String theContentType) { super(); myEncoding = theEncoding; myContentType = theContentType; if (theContentType != null) { FhirVersionEnum ctxtEnum = theCtx.getVersion().getVersion(); if (theContentType.equals(EncodingEnum.JSON_PLAIN_STRING) || theContentType.equals(EncodingEnum.XML_PLAIN_STRING)) { myNonLegacy = ctxtEnum.isNewerThan(FhirVersionEnum.DSTU2_1); } else { myNonLegacy = ctxtEnum.isNewerThan(FhirVersionEnum.DSTU2_1) && !EncodingEnum.isLegacy(theContentType); } } else { FhirVersionEnum ctxtEnum = theCtx.getVersion().getVersion(); if (ctxtEnum.isOlderThan(FhirVersionEnum.DSTU3)) { myNonLegacy = null; } else { myNonLegacy = Boolean.TRUE; } } }
private String getContentType(EncodingEnum encoding) { if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { // application/xml+fhir return encoding.getResourceContentType(); } else { // application/fhir+xml return encoding.getResourceContentTypeNonLegacy(); } }
@Override protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) { if (isNotBlank(theUrlId)) { String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInUrlForCreate", theUrlId); throw new InvalidRequestException(msg); } if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { if (isNotBlank(theResourceId)) { String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInBodyForCreate", theResourceId); throw new InvalidRequestException(msg); } } else { theResource.setId((IIdType)null); } }
@Override public DaoMethodOutcome create(T theResource, String theIfNoneExist, boolean thePerformIndexing, Date theUpdateTimestamp, RequestDetails theRequestDetails) { if (isNotBlank(theResource.getIdElement().getIdPart())) { if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { String message = getContext().getLocalizer().getMessage(BaseHapiFhirResourceDao.class, "failedToCreateWithClientAssignedId", theResource.getIdElement().getIdPart()); throw new InvalidRequestException(message, createErrorOperationOutcome(message, "processing")); } else { // As of DSTU3, ID and version in the body should be ignored for a create/update theResource.setId(""); } } if (myDaoConfig.getResourceServerIdStrategy() == DaoConfig.IdStrategyEnum.UUID) { theResource.setId(UUID.randomUUID().toString()); } return doCreate(theResource, theIfNoneExist, thePerformIndexing, theUpdateTimestamp, theRequestDetails); }
@Override protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) { if (isNotBlank(theUrlId)) { String msg = getContext().getLocalizer() .getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInUrlForCreate", theUrlId); throw new InvalidRequestException(msg); } if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { if (isNotBlank(theResourceId)) { String msg = getContext().getLocalizer().getMessage( BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInBodyForCreate", theResourceId); throw new InvalidRequestException(msg); } } else { theResource.setId((IIdType) null); } }
@Override protected void addParametersForServerRequest(RequestDetails theRequest, Object[] theParams) { if (myIdParamIndex != null) { theParams[myIdParamIndex] = ParameterUtil.convertIdToType(theRequest.getId(), myIdParamType); } if (myResourceParameterIndex != -1) { IBaseResource resource = ((IBaseResource) theParams[myResourceParameterIndex]); String resourceId = resource.getIdElement().getIdPart(); String urlId = theRequest.getId() != null ? theRequest.getId().getIdPart() : null; if (getContext().getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3) == false) { resource.setId(theRequest.getId()); } String matchUrl = null; if (myConditionalUrlIndex != -1) { matchUrl = (String) theParams[myConditionalUrlIndex]; matchUrl = defaultIfBlank(matchUrl, null); } validateResourceIdAndUrlIdForNonConditionalOperation(resource, resourceId, urlId, matchUrl); } }
try { String capabilityStatementResourceName = "CapabilityStatement"; if (myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { capabilityStatementResourceName = "Conformance"; implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); } catch (DataFormatException e) { if (!myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) { capabilityStatementResourceName = "Conformance"; implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass(); conformance = (IBaseResource) client.fetchConformance().ofType(implementingClass).execute(); } catch (FhirClientConnectionException e) { if (!myContext.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3) && e.getCause() instanceof DataFormatException) { capabilityStatementResourceName = "CapabilityStatement"; implementingClass = myContext.getResourceDefinition(capabilityStatementResourceName).getImplementingClass();