@Override public IHistoryUntyped onInstance(IIdType theId) { if (theId.hasResourceType() == false) { throw new IllegalArgumentException("Resource ID does not have a resource type: " + theId.getValue()); } myId = theId; return this; }
@Override public IDeleteTyped resourceById(IIdType theId) { Validate.notNull(theId, "theId can not be null"); if (theId.hasResourceType() == false || theId.hasIdPart() == false) { throw new IllegalArgumentException("theId must contain a resource type and logical ID at a minimum (e.g. Patient/1234)found: " + theId.getValue()); } myId = theId; return this; }
private void validateResourceTypeAndThrowIllegalArgumentException(IIdType theId) { if (theId.hasResourceType() && !theId.getResourceType().equals(myResourceName)) { throw new IllegalArgumentException("Incorrect resource type (" + theId.getResourceType() + ") for this DAO, wanted: " + myResourceName); } }
@Override public IDeleteTyped resource(IBaseResource theResource) { Validate.notNull(theResource, "theResource can not be null"); IIdType id = theResource.getIdElement(); Validate.notNull(id, "theResource.getIdElement() can not be null"); if (id.hasResourceType() == false || id.hasIdPart() == false) { throw new IllegalArgumentException("theResource.getId() must contain a resource type and logical ID at a minimum (e.g. Patient/1234), found: " + id.getValue()); } myId = id; return this; }
public void setTargetResourceUrl(IIdType theTargetResourceUrl) { Validate.isTrue(theTargetResourceUrl.hasBaseUrl()); Validate.isTrue(theTargetResourceUrl.hasResourceType()); if (theTargetResourceUrl.hasIdPart()) { // do nothing } else { // Must have set an url like http://example.org/something // We treat 'something' as the resource type because of fix for #659. Prior to #659 fix, 'something' was // treated as the id and 'example.org' was treated as the resource type // TODO: log a warning? } myTargetResourceType = theTargetResourceUrl.getResourceType(); myTargetResourceUrl = theTargetResourceUrl.getValue(); }
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; } } } }
private void filterBundle(org.hl7.fhir.r4.model.Bundle theBundle) { for (Iterator<org.hl7.fhir.r4.model.Bundle.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; } } } }
static List<Long> translateForcedIdToPids(DaoConfig theDaoConfig, IIdType theId, IForcedIdDao theForcedIdDao) { Validate.isTrue(theId.hasIdPart()); if (theDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY && isValidPid(theId)) { return Collections.singletonList(theId.getIdPartAsLong()); } else { List<ForcedId> forcedId; if (theId.hasResourceType()) { forcedId = theForcedIdDao.findByTypeAndForcedId(theId.getResourceType(), theId.getIdPart()); } else { forcedId = theForcedIdDao.findByForcedId(theId.getIdPart()); } if (!forcedId.isEmpty()) { List<Long> retVal = new ArrayList<>(forcedId.size()); for (ForcedId next : forcedId) { retVal.add(next.getResourcePid()); } return retVal; } else { throw new ResourceNotFoundException(theId); } } }
IFhirResourceDao<?> subscriptionDao = myDaoRegistry.getSubscriptionDao(); IIdType subscriptionId = theSubscriptionId; if (!subscriptionId.hasResourceType()) { subscriptionId = subscriptionId.withResourceType(ResourceTypeEnum.SUBSCRIPTION.getCode());
@Override public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException { IIdType idDt = (IIdType) theArgs[getIdParameterIndex()]; if (idDt == null) { throw new NullPointerException("ID can not be null"); } if (idDt.hasResourceType() == false) { idDt = idDt.withResourceType(getResourceName()); } else if (getResourceName().equals(idDt.getResourceType()) == false) { throw new InvalidRequestException("ID parameter has the wrong resource type, expected '" + getResourceName() + "', found: " + idDt.getResourceType()); } HttpDeleteClientInvocation retVal = createDeleteInvocation(getContext(), idDt); for (int idx = 0; idx < theArgs.length; idx++) { IParameter nextParam = getParameters().get(idx); nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, null); } return retVal; }
public void notifyInterceptors(RestOperationTypeEnum theOperationType, ActionRequestDetails theRequestDetails) { if (theRequestDetails.getId() != null && theRequestDetails.getId().hasResourceType() && isNotBlank(theRequestDetails.getResourceType())) { if (theRequestDetails.getId().getResourceType().equals(theRequestDetails.getResourceType()) == false) { throw new InternalErrorException( "Inconsistent server state - Resource types don't match: " + theRequestDetails.getId().getResourceType() + " / " + theRequestDetails.getResourceType()); } } if (theRequestDetails.getUserData().get(PROCESSING_SUB_REQUEST) == Boolean.TRUE) { theRequestDetails.notifyIncomingRequestPreHandled(theOperationType); } List<IServerInterceptor> interceptors = getConfig().getInterceptors(); for (IServerInterceptor next : interceptors) { next.incomingRequestPreHandled(theOperationType, theRequestDetails); } }
@Override public BaseHttpClientInvocation invokeClient(Object[] theArgs) throws InternalErrorException { IIdType idDt = (IIdType) theArgs[getIdParameterIndex()]; if (idDt == null) { throw new NullPointerException("ID can not be null"); } if (idDt.hasResourceType() == false) { idDt = idDt.withResourceType(getResourceName()); } else if (getResourceName().equals(idDt.getResourceType()) == false) { throw new InvalidRequestException("ID parameter has the wrong resource type, expected '" + getResourceName() + "', found: " + idDt.getResourceType()); } PatchTypeEnum patchType = (PatchTypeEnum) theArgs[myPatchTypeParameterIndex]; String body = (String) theArgs[myResourceParamIndex]; HttpPatchClientInvocation retVal = createPatchInvocation(getContext(), idDt, patchType, body); for (int idx = 0; idx < theArgs.length; idx++) { IParameter nextParam = getParameters().get(idx); nextParam.translateClientArgumentIntoQueryArgument(getContext(), theArgs[idx], null, null); } return retVal; }
if (id.hasResourceType() == false) { String resName = myContext.getResourceDefinition(nextRes).getName(); id = id.withResourceType(resName);
if (id.hasResourceType() == false) { String resName = myContext.getResourceDefinition(nextRes).getName(); id = id.withResourceType(resName);
reference = refId.getValue(); } else { if (!refId.hasResourceType()) { refId = refId.withResourceType(myContext.getResourceDefinition(theRef.getResource()).getName()); if (!ref.hasResourceType() && !ref.isLocal() && theRef.getResource() != null) { ref = ref.withResourceType(myContext.getResourceDefinition(theRef.getResource()).getName());
@Override public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException { Object[] params = createParametersForServerRequest(theRequest); addParametersForServerRequest(theRequest, params); /* * No need to catch and handle exceptions here, we already handle them one level up including invoking interceptors * on them */ MethodOutcome response; Object methodReturn = invokeServerMethod(theServer, theRequest, params); if (methodReturn instanceof IBaseOperationOutcome) { response = new MethodOutcome(); response.setOperationOutcome((IBaseOperationOutcome) methodReturn); } else { response = (MethodOutcome) methodReturn; } if (response != null && response.getId() != null && response.getId().hasResourceType()) { if (getContext().getResourceDefinition(response.getId().getResourceType()) == null) { throw new InternalErrorException("Server method returned invalid resource ID: " + response.getId().getValue()); } } IBaseOperationOutcome outcome = response != null ? response.getOperationOutcome() : null; IBaseResource resource = response != null ? response.getResource() : null; return returnResponse(theServer, theRequest, response, outcome, resource); }
protected void updateResourceMetadata(IBaseResourceEntity theEntity, IBaseResource theResource) { IIdType id = theEntity.getIdDt(); if (getContext().getVersion().getVersion().isRi()) { id = getContext().getVersion().newIdType().setValue(id.getValue()); } if (id.hasResourceType() == false) { id = id.withResourceType(theEntity.getResourceType()); } theResource.setId(id); if (theResource instanceof IResource) { ResourceMetadataKeyEnum.VERSION.put((IResource) theResource, id.getVersionIdPart()); ResourceMetadataKeyEnum.UPDATED.put((IResource) theResource, theEntity.getUpdated()); } else { IBaseMetaType meta = theResource.getMeta(); meta.setVersionId(id.getVersionIdPart()); meta.setLastUpdated(theEntity.getUpdatedDate()); } }
if (theId != null && theId.hasResourceType() && theId.hasIdPart()) { Class<? extends IBaseResource> type = getContext().getResourceDefinition(theId.getResourceType()).getImplementingClass(); IFhirResourceDao<? extends IBaseResource> dao = getDao(type);
if (theId != null && theId.hasResourceType() && theId.hasIdPart()) { Class<? extends IBaseResource> type = getContext().getResourceDefinition(theId.getResourceType()).getImplementingClass(); IFhirResourceDao<? extends IBaseResource> dao = getDao(type);