/** * Checks whether this path is a part of DXA essential configuration, or some basic files that are required for DXA to start. * * @param path the given path to check * @param localizationPath path of the current localization * @return whether DXA need this file to start */ public static boolean isEssentialConfiguration(@NotNull String path, String localizationPath) { String _path = !"/".equals(localizationPath) && path.startsWith(localizationPath) ? path.replaceFirst(localizationPath, "") : path; return VERSION_JSON.equals(_path) || SYSTEM_FOLDER_PATTERN.matcher(_path).matches() || isFavicon(_path); }
/** * Checks if the given file needs to be refreshed, and, if file doesn't exist, also checks and created if all the folders structure. * Basically performs subsequent calls to {@link #isFileOlderThan(File, long)} and {@link #parentFolderExists(File, boolean)}. * * @param file file to check * @param time time to check * @return whether file needs to be refreshed ({@code time} is older than file creation time * @throws ContentProviderException if case folders cannot be created */ public static boolean isToBeRefreshed(File file, long time) throws ContentProviderException { if (isFileOlderThan(file, time)) { if (!parentFolderExists(file, true)) { throw new ContentProviderException("Failed to create parent directory for file: " + file); } return true; } return false; }
/** * {@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()); }
boolean shouldRefresh = isToBeRefreshed(file, componentTime) || requestDto.isNoMediaCache();