private String createUnknownResourceNameError(String theResourceName, FhirVersionEnum theVersion) { return getLocalizer().getMessage(FhirContext.class, "unknownResourceName", theResourceName, theVersion); }
@CoverageIgnore public static boolean isSchematronAvailable(FhirContext theFhirContext) { try { Class.forName("com.helger.schematron.ISchematronResource"); return true; } catch (ClassNotFoundException e) { ourLog.info(theFhirContext.getLocalizer().getMessage(I18N_KEY_NO_PH_WARNING)); return false; } }
@Override public IReadTyped<IBaseResource> resource(String theResourceAsText) { Validate.notBlank(theResourceAsText, "You must supply a value for theResourceAsText"); myType = myContext.getResourceDefinition(theResourceAsText); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theResourceAsText)); } return this; }
@Override public <T extends IBaseConformance> IFetchConformanceTyped<T> ofType(Class<T> theResourceType) { Validate.notNull(theResourceType, "theResourceType must not be null"); myType = myContext.getResourceDefinition(theResourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theResourceType)); } return this; }
private void processUrl() { String resourceType = myId.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, myId)); } myType = myContext.getResourceDefinition(resourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, myId)); } }
@Override public <T extends IBaseResource> IReadTyped<T> resource(Class<T> theResourceType) { Validate.notNull(theResourceType, "theResourceType must not be null"); myType = myContext.getResourceDefinition(theResourceType); if (myType == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theResourceType)); } return this; }
public TransactionExecutable(String theBundle) { myRawBundle = theBundle; myRawBundleEncoding = EncodingEnum.detectEncodingNoDefault(myRawBundle); if (myRawBundleEncoding == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } }
private void validateHaveBundleProvider(String thePagingAction, IBundleProvider theBundleProvider) { // Return an HTTP 410 if the search is not known if (theBundleProvider == null) { ourLog.info("Client requested unknown paging ID[{}]", thePagingAction); String msg = getContext().getLocalizer().getMessage(PageMethodBinding.class, "unknownSearchId", thePagingAction); throw new ResourceGoneException(msg); } }
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; }
@Override public <T extends IBaseResource> T vread(final Class<T> theType, IdDt theId) { if (theId.hasVersionIdPart() == false) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_NO_VERSION_ID_FOR_VREAD, theId.getValue())); } return doReadOrVRead(theType, theId, true, null, null, false, null, null, null, null); }
protected IBaseResource parseResourceBody(String theResourceBody) { EncodingEnum encoding = EncodingEnum.detectEncodingNoDefault(theResourceBody); if (encoding == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(GenericClient.class, "cantDetermineRequestType")); } return encoding.newParser(myContext).parseResource(theResourceBody); }
@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; }
@Override public IBaseResource read(UriDt theUrl) { IdDt id = new IdDt(theUrl); String resourceType = id.getResourceType(); if (isBlank(resourceType)) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_INCOMPLETE_URI_FOR_READ, theUrl.getValueAsString())); } RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType); if (def == null) { throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_CANNOT_DETEMINE_RESOURCE_TYPE, theUrl.getValueAsString())); } return read(def.getImplementingClass(), id); }
public static void throwUnknownFhirOperationException(RequestDetails requestDetails, String requestPath, RequestTypeEnum theRequestType, FhirContext theFhirContext) { throw new InvalidRequestException(theFhirContext.getLocalizer().getMessage(RestfulServer.class, "unknownMethod", theRequestType.name(), requestPath, requestDetails.getParameters().keySet())); }
@Override public void extractTenant(UrlPathTokenizer theUrlPathTokenizer, RequestDetails theRequestDetails) { String tenantId = null; if (theUrlPathTokenizer.hasMoreTokens()) { tenantId = defaultIfBlank(theUrlPathTokenizer.nextTokenUnescapedAndSanitized(), null); ourLog.trace("Found tenant ID {} in request string", tenantId); theRequestDetails.setTenantId(tenantId); } if (tenantId == null) { HapiLocalizer localizer = theRequestDetails.getServer().getFhirContext().getLocalizer(); throw new InvalidRequestException(localizer.getMessage(RestfulServer.class, "rootRequest.multitenant")); } }
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; }
@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); } }
public static void configureEntityManagerFactory(LocalContainerEntityManagerFactoryBean theFactory, FhirContext theCtx) { theFactory.setJpaDialect(hibernateJpaDialect(theCtx.getLocalizer())); theFactory.setPackagesToScan("ca.uhn.fhir.jpa.model.entity", "ca.uhn.fhir.jpa.entity"); theFactory.setPersistenceProvider(new HibernatePersistenceProvider()); }
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); }