@Override public String toString() { ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); b.append("resPid", myResource.getIdDt().toUnqualifiedVersionless().getValue()); b.append("paramName", myParamName); b.append("present", myPresent); return b.build(); }
public void validateDeleteConflictsEmptyOrThrowException(List<DeleteConflict> theDeleteConflicts) { if (theDeleteConflicts.isEmpty()) { return; } IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext()); String firstMsg = null; for (DeleteConflict next : theDeleteConflicts) { StringBuilder b = new StringBuilder(); b.append("Unable to delete "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" because at least one resource has a reference to this resource. First reference found was resource "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" in path "); b.append(next.getSourcePath()); String msg = b.toString(); if (firstMsg == null) { firstMsg = msg; } OperationOutcomeUtil.addIssue(getContext(), oo, OO_SEVERITY_ERROR, msg, null, "processing"); } throw new ResourceVersionConflictException(firstMsg, oo); }
public void storeCompositeStringUniques(ResourceIndexedSearchParams theParams, ResourceTable theEntity, ResourceIndexedSearchParams existingParams) { // Store composite string uniques if (myDaoConfig.isUniqueIndexesEnabled()) { for (ResourceIndexedCompositeStringUnique next : myDaoSearchParamSynchronizer.subtract(existingParams.compositeStringUniques, theParams.compositeStringUniques)) { ourLog.debug("Removing unique index: {}", next); myEntityManager.remove(next); theEntity.getParamsCompositeStringUnique().remove(next); } for (ResourceIndexedCompositeStringUnique next : myDaoSearchParamSynchronizer.subtract(theParams.compositeStringUniques, existingParams.compositeStringUniques)) { if (myDaoConfig.isUniqueIndexesCheckedBeforeSave()) { ResourceIndexedCompositeStringUnique existing = myResourceIndexedCompositeStringUniqueDao.findByQueryString(next.getIndexString()); if (existing != null) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "uniqueIndexConflictFailure", theEntity.getResourceType(), next.getIndexString(), existing.getResource().getIdDt().toUnqualifiedVersionless().getValue()); throw new PreconditionFailedException(msg); } } ourLog.debug("Persisting unique index: {}", next); myEntityManager.persist(next); } } } }
for (ResourceLink nextLink : linksForCompositePart) { if (linksForCompositePartWantPaths.contains(nextLink.getSourcePath())) { String value = nextLink.getTargetResource().getIdDt().toUnqualifiedVersionless().getValue(); if (isNotBlank(value)) { value = UrlUtil.escapeUrlParam(value);
} else { IdDt resourceId = new IdDt(next.getResource().getResourceType() + "/EX" + next.getResource().getIdElement().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); iterator.remove();
if (!ObjectUtil.equals(codeSystem.getResource().getId(), theCodeSystemVersion.getResource().getId())) { String msg = myContext.getLocalizer().getMessage(BaseHapiTerminologySvcImpl.class, "cannotCreateDuplicateCodeSystemUri", theSystemUri, codeSystem.getResource().getIdDt().toUnqualifiedVersionless().getValue()); throw new UnprocessableEntityException(msg);
private static void handleTransactionCreateOrUpdateOutcome(Map<IdDt, IdDt> idSubstitutions, Map<IdDt, DaoMethodOutcome> idToPersistedOutcome, IdDt nextResourceId, DaoMethodOutcome outcome, Entry newEntry, String theResourceType, IResource theRes) { IdDt newId = (IdDt) outcome.getId().toUnqualifiedVersionless(); IdDt resourceId = isPlaceholder(nextResourceId) ? nextResourceId : nextResourceId.toUnqualifiedVersionless(); if (newId.equals(resourceId) == false) { idSubstitutions.put(resourceId, newId); if (isPlaceholder(resourceId)) { /* * The correct way for substitution IDs to be is to be with no resource type, but we'll accept the qualified kind too just to be lenient. */ idSubstitutions.put(new IdDt(theResourceType + '/' + resourceId.getValue()), newId); } } idToPersistedOutcome.put(newId, outcome); if (outcome.getCreated().booleanValue()) { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_201_CREATED)); } else { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_200_OK)); } newEntry.getResponse().setLastModified(ResourceMetadataKeyEnum.UPDATED.get(theRes)); }
} else { IdDt resourceId = new IdDt(next.getResource().getResourceName() + "/EX" + next.getResource().getId().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); iterator.remove();
} else { IdDt resourceId = new IdDt(next.getResource().getResourceType() + "/EX" + next.getResource().getIdElement().getIdPart()); if (!fullIds.add(resourceId.toUnqualifiedVersionless().getValue())) { ourLog.info("Discarding duplicate resource: " + resourceId.getValue()); iterator.remove();
if (nextRef.getReference().isEmpty() == false) { if (nextRef.getReference().hasVersionIdPart()) { nextRef.setReference(nextRef.getReference().toUnqualifiedVersionless());
List<ResourceTable> allDeleted = deleteOutcome.getDeletedEntities(); for (ResourceTable deleted : allDeleted) { deletedResources.add(deleted.getIdDt().toUnqualifiedVersionless().getValueAsString()); deletedResources.contains(next.getTargetId().toUnqualifiedVersionless().getValue())); myDao.validateDeleteConflictsEmptyOrThrowException(deleteConflicts);
"Invalid resource ID[" + entity.getIdDt().toUnqualifiedVersionless() + "] of type[" + entity.getResourceType() + "] - Does not match expected [" + getResourceName() + "]");
if (isNotBlank(theEntity.getResourceType()) && !theEntity.getResourceType().equals(resourceType)) { throw new UnprocessableEntityException( "Existing resource ID[" + theEntity.getIdDt().toUnqualifiedVersionless() + "] is of type[" + theEntity.getResourceType() + "] - Cannot update with [" + resourceType + "]");
IdDt nextId = nextResourceId.toUnqualifiedVersionless(); if (!theAllIds.add(nextId)) { throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionContainsMultipleWithDuplicateId", nextId)); List<ResourceTable> allDeleted = deleteOutcome.getDeletedEntities(); for (ResourceTable deleted : allDeleted) { theDeletedResources.add(deleted.getIdDt().toUnqualifiedVersionless());
"cannotCreateDuplicateConceptMapUrl", conceptMapUrl, existingTermConceptMap.getResource().getIdDt().toUnqualifiedVersionless().getValue());
public void validateDeleteConflictsEmptyOrThrowException(List<DeleteConflict> theDeleteConflicts) { if (theDeleteConflicts.isEmpty()) { return; } IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext()); String firstMsg = null; for (DeleteConflict next : theDeleteConflicts) { StringBuilder b = new StringBuilder(); b.append("Unable to delete "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" because at least one resource has a reference to this resource. First reference found was resource "); b.append(next.getTargetId().toUnqualifiedVersionless().getValue()); b.append(" in path "); b.append(next.getSourcePath()); String msg = b.toString(); if (firstMsg == null) { firstMsg = msg; } OperationOutcomeUtil.addIssue(getContext(), oo, OO_SEVERITY_ERROR, msg, null, "processing"); } throw new ResourceVersionConflictException(firstMsg, oo); }
for (ResourceLink nextLink : linksForCompositePart) { if (linksForCompositePartWantPaths.contains(nextLink.getSourcePath())) { String value = nextLink.getTargetResource().getIdDt().toUnqualifiedVersionless().getValue(); if (isNotBlank(value)) { value = UrlUtil.escapeUrlParam(value);
public void storeCompositeStringUniques(ResourceIndexedSearchParams theParams, ResourceTable theEntity, ResourceIndexedSearchParams existingParams) { // Store composite string uniques if (myDaoConfig.isUniqueIndexesEnabled()) { for (ResourceIndexedCompositeStringUnique next : myDaoSearchParamSynchronizer.subtract(existingParams.compositeStringUniques, theParams.compositeStringUniques)) { ourLog.debug("Removing unique index: {}", next); myEntityManager.remove(next); theEntity.getParamsCompositeStringUnique().remove(next); } for (ResourceIndexedCompositeStringUnique next : myDaoSearchParamSynchronizer.subtract(theParams.compositeStringUniques, existingParams.compositeStringUniques)) { if (myDaoConfig.isUniqueIndexesCheckedBeforeSave()) { ResourceIndexedCompositeStringUnique existing = myResourceIndexedCompositeStringUniqueDao.findByQueryString(next.getIndexString()); if (existing != null) { String msg = myContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "uniqueIndexConflictFailure", theEntity.getResourceType(), next.getIndexString(), existing.getResource().getIdDt().toUnqualifiedVersionless().getValue()); throw new PreconditionFailedException(msg); } } ourLog.debug("Persisting unique index: {}", next); myEntityManager.persist(next); } } } }
private static void handleTransactionCreateOrUpdateOutcome(Map<IdDt, IdDt> idSubstitutions, Map<IdDt, DaoMethodOutcome> idToPersistedOutcome, IdDt nextResourceId, DaoMethodOutcome outcome, Entry newEntry, String theResourceType, IResource theRes) { IdDt newId = (IdDt) outcome.getId().toUnqualifiedVersionless(); IdDt resourceId = isPlaceholder(nextResourceId) ? nextResourceId : nextResourceId.toUnqualifiedVersionless(); if (newId.equals(resourceId) == false) { idSubstitutions.put(resourceId, newId); if (isPlaceholder(resourceId)) { /* * The correct way for substitution IDs to be is to be with no resource type, but we'll accept the qualified kind too just to be lenient. */ idSubstitutions.put(new IdDt(theResourceType + '/' + resourceId.getValue()), newId); } } idToPersistedOutcome.put(newId, outcome); if (outcome.getCreated().booleanValue()) { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_201_CREATED)); } else { newEntry.getResponse().setStatus(toStatusString(Constants.STATUS_HTTP_200_OK)); } newEntry.getResponse().setLastModified(ResourceMetadataKeyEnum.UPDATED.get(theRes)); }
if (!ObjectUtil.equals(codeSystem.getResource().getId(), theCodeSystemVersion.getResource().getId())) { String msg = myContext.getLocalizer().getMessage(BaseHapiTerminologySvcImpl.class, "cannotCreateDuplicateCodeSystemUri", theSystemUri, codeSystem.getResource().getIdDt().toUnqualifiedVersionless().getValue()); throw new UnprocessableEntityException(msg);