public static void isTrueOrThrowInvalidRequest(boolean theSuccess, String theMessage) { if (theSuccess == false) { throw new InvalidRequestException(theMessage); } }
public static void isNotBlankOrThrowInvalidRequest(String theString, String theMessage) { if (isBlank(theString)) { throw new InvalidRequestException(theMessage); } }
public static void validateFulltextSearchEnabled(IFulltextSearchSvc theSearchDao) { if (theSearchDao == null || theSearchDao.isDisabled()) { throw new InvalidRequestException("Fulltext searching is disabled on this server"); } }
private void verifyNoDuplicates(Collection<TermConcept> theConcepts, Set<String> theCodes) { for (TermConcept next : theConcepts) { if (!theCodes.add(next.getCode())) { throw new InvalidRequestException("Duplicate code " + next.getCode() + " found in codesystem after checking " + theCodes.size() + " codes"); } verifyNoDuplicates(next.getChildren().stream().map(TermConceptParentChildLink::getChild).collect(Collectors.toList()), theCodes); } }
@Override public T parse(FhirContext theContext, String theName, List<QualifiedParamList> theParams) throws InternalErrorException, InvalidRequestException { if (theParams.size() == 0 || theParams.get(0).size() == 0) { return null; } if (theParams.size() > 1 || theParams.get(0).size() > 1) { throw new InvalidRequestException("Multiple values detected for non-repeatable parameter '" + theName + "'. This server is not configured to allow multiple (AND) values for this param."); } T value = doParse(theParams.get(0).get(0)); return value; }
private String extractTransactionUrlOrThrowException(BUNDLEENTRY nextEntry, String verb) { String url = myVersionAdapter.getEntryRequestUrl(nextEntry); if (isBlank(url)) { throw new InvalidRequestException(myContext.getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionMissingUrl", verb)); } return url; }
private boolean addToSet(Set<TermConcept> theSetToPopulate, TermConcept theConcept) { boolean retVal = theSetToPopulate.add(theConcept); if (retVal) { if (theSetToPopulate.size() >= myDaoConfig.getMaximumExpansionSize()) { String msg = myContext.getLocalizer().getMessage(BaseHapiTerminologySvcImpl.class, "expansionTooLarge", myDaoConfig.getMaximumExpansionSize()); throw new InvalidRequestException(msg); } } return retVal; }
private void validateIncludes(String name, List<ConceptSetComponent> listToValidate) { for (ConceptSetComponent nextExclude : listToValidate) { if (isBlank(nextExclude.getSystem()) && !ElementUtil.isEmpty(nextExclude.getConcept(), nextExclude.getFilter())) { throw new InvalidRequestException("ValueSet contains " + name + " criteria with no system defined"); } } }
@Override public EncodingEnum getResourceAsStringEncoding() { if (myEncoding == null) { myEncoding = EncodingEnum.detectEncodingNoDefault(theResourceBody); if (myEncoding == null) { throw new InvalidRequestException(theContext.getLocalizer().getMessage(ValidationContext.class, "unableToDetermineEncoding")); } } return myEncoding; }
private void validateIncludes(String name, List<ConceptSetComponent> listToValidate) { for (ConceptSetComponent nextExclude : listToValidate) { if (isBlank(nextExclude.getSystem()) && !ElementUtil.isEmpty(nextExclude.getConcept(), nextExclude.getFilter())) { throw new InvalidRequestException("ValueSet contains " + name + " criteria with no system defined"); } } }
@Override public ValueSetExpander.ValueSetExpansionOutcome expandValueSet(FhirContext theCtx, ConceptSetComponent theInclude) { for (IValidationSupport next : myChain) { if (next.isCodeSystemSupported(theCtx, theInclude.getSystem())) { return next.expandValueSet(theCtx, theInclude); } } throw new InvalidRequestException("unable to find code system " + theInclude.getSystem()); }
private String extractTransactionUrlOrThrowException(Entry nextEntry, HTTPVerbEnum verb) { String url = nextEntry.getRequest().getUrl(); if (isBlank(url)) { throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseHapiFhirSystemDao.class, "transactionMissingUrl", verb.name())); } return url; }
protected DateRangeParam processSinceOrAt(Date theSince, DateRangeParam theAt) { boolean haveAt = theAt != null && (theAt.getLowerBoundAsInstant() != null || theAt.getUpperBoundAsInstant() != null); if (haveAt && theSince != null) { String msg = getContext().getLocalizer().getMessage(BaseJpaProvider.class, "cantCombintAtAndSince"); throw new InvalidRequestException(msg); } if (haveAt) { return theAt; } return new DateRangeParam(theSince, null); }
@Override public void setValuesAsQueryTokens(FhirContext theContext, String theParamName, QualifiedParamList theParameters) { setMissing(null); setPrefix(null); setValueAsString(null); if (theParameters.size() == 1) { setValueAsString(theParameters.get(0)); } else if (theParameters.size() > 1) { throw new InvalidRequestException("This server does not support multi-valued dates for this parameter: " + theParameters); } }
@Operation(name = OPERATION_META_ADD, idempotent = true, returnParameters = { @OperationParam(name = "return", type = MetaDt.class) }) public Parameters metaAdd(@IdParam IdDt theId, @OperationParam(name = "meta") MetaDt theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); MetaDt metaAddOperation = getDao().metaAddOperation(theId, theMeta, theRequestDetails); parameters.addParameter().setName("return").setValue(metaAddOperation); return parameters; }
@Operation(name = OPERATION_META_DELETE, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters metaDelete(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); parameters.addParameter().setName("return").setValue(getDao().metaDeleteOperation(theId, theMeta, theRequestDetails)); return parameters; }
@Operation(name = OPERATION_META_ADD, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters metaAdd(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); Meta metaAddOperation = getDao().metaAddOperation(theId, theMeta, theRequestDetails); parameters.addParameter().setName("return").setValue(metaAddOperation); return parameters; }
@Operation(name = OPERATION_META_ADD, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters metaAdd(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); Meta metaAddOperation = getDao().metaAddOperation(theId, theMeta, theRequestDetails); parameters.addParameter().setName("return").setValue(metaAddOperation); return parameters; }
@Operation(name = OPERATION_META_DELETE, idempotent = true, returnParameters = { @OperationParam(name = "return", type = Meta.class) }) public Parameters metaDelete(@IdParam IdType theId, @OperationParam(name = "meta") Meta theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); parameters.addParameter().setName("return").setValue(getDao().metaDeleteOperation(theId, theMeta, theRequestDetails)); return parameters; }
@Operation(name = OPERATION_META_DELETE, idempotent = true, returnParameters = { @OperationParam(name = "return", type = MetaDt.class) }) public Parameters metaDelete(@IdParam IdDt theId, @OperationParam(name = "meta") MetaDt theMeta, RequestDetails theRequestDetails) { if (theMeta == null) { throw new InvalidRequestException("Input contains no parameter with name 'meta'"); } Parameters parameters = new Parameters(); parameters.addParameter().setName("return").setValue(getDao().metaDeleteOperation(theId, theMeta, theRequestDetails)); return parameters; }