/** * Resolves static content with a given path in a given publication. * <p>Requires localization path to request the content, so resolves it using localization ID if the path is missing. * If you already know publication path, providing it in a request would give you a bit better performance. </p> * If file is resolved, caches the file locally, so won't download it again unless it needs to be refreshed. * * @param requestDto request DTO * @return requested static file * @throws StaticContentNotFoundException if cannot resolve static file for any reason * @dxa.publicApi */ @NotNull public StaticContentItem getStaticContent(@NotNull StaticContentRequestDto requestDto) throws ContentProviderException { log.trace("getStaticContent: {}", requestDto); StaticContentRequestDto adaptedRequest = requestDto.isLocalizationPathSet() ? requestDto : requestDto.toBuilder().localizationPath( _resolveLocalizationPath(requestDto.getLocalizationId())).build(); final String contentPath = _getContentPath(adaptedRequest.getBinaryPath(), adaptedRequest.getLocalizationPath()); return _getStaticContentFile(contentPath, adaptedRequest); }
private static StaticContentRequestDtoBuilder hiddenBuilder() { return new StaticContentRequestDtoBuilder(); }
/** * {@inheritDoc} * * @dxa.publicApi */ @Override public StaticContentItem getStaticContent(final String path, String localizationId, String localizationPath) throws ContentProviderException { return staticContentResolver.getStaticContent( StaticContentRequestDto.builder(path, localizationId) .localizationPath(localizationPath) .baseUrl(webRequestContext.getBaseUrl()) .noMediaCache(!FileUtils.isEssentialConfiguration(path, localizationPath) && webRequestContext.isPreview()) .build()); }
public static StaticContentRequestDtoBuilder builder(String binaryPath, String localizationId) { return hiddenBuilder().localizationId(localizationId).binaryPath(binaryPath); }