@Override public boolean isResourceModified(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { final Date resourceLastModifiedDate = (plugin.getDateLoaded() == null) ? new Date() : plugin.getDateLoaded(); final LastModifiedHandler lastModifiedHandler = new LastModifiedHandler(resourceLastModifiedDate); return !lastModifiedHandler.checkRequest(httpServletRequest, httpServletResponse); }
/** * For SNAPSHOT plugins will return install time instead of the version. * Needed to simplify working with SNAPSHOT plugins and flushing cache when new SNAPSHOT plugin installed * with same version but different content. */ public static String getPluginVersionOrInstallTime(Plugin plugin, boolean usePluginInstallTimeInsteadOfTheVersionForSnapshotPlugins) { PluginInformation pluginInfo = plugin.getPluginInformation(); // Seems like we need to guard against pluginInfo being null, this check has been taken from // `WebResourceUrlProviderImpl.getStaticPluginResourceUrl` in WRM@3.5.9. final String version = pluginInfo != null ? pluginInfo.getVersion() : "unknown"; if (usePluginInstallTimeInsteadOfTheVersionForSnapshotPlugins && SNAPSHOT_PLUGIN_REGEX.matcher(version).find()) { final Date loadedAt = plugin.getDateLoaded() == null ? new Date() : plugin.getDateLoaded(); return version + "-" + loadedAt.getTime(); } else { return version; } }
/** * Get not declared Resource. */ public Resource getModuleResource(String completeKey, String name) { // Confluence throws error if trying to query module with not complete key (with the plugin key for example). if (!isWebResourceKey(completeKey)) { return null; } ModuleDescriptor<?> moduleDescriptor = integration.getPluginAccessor().getEnabledPluginModule(completeKey); // In case of virtual context or super batch resource there would be null returned. if (moduleDescriptor == null) { return null; } ResourceLocation resourceLocation = moduleDescriptor.getResourceLocation(DOWNLOAD_PARAM_VALUE, name); if (resourceLocation == null) { return null; } Plugin plugin = moduleDescriptor.getPlugin(); Date updatedAt = (plugin.getDateLoaded() == null) ? new Date() : plugin.getDateLoaded(); PluginResourceContainer resourceContainer = new PluginResourceContainer(new Snapshot(this), completeKey, updatedAt, getPluginVersionOrInstallTime(plugin, usePluginInstallTimeInsteadOfTheVersionForSnapshotPlugins)); return buildResource(resourceContainer, resourceLocation); }
Date updatedAt = (plugin.getDateLoaded() == null) ? new Date() : plugin.getDateLoaded(); String version = getPluginVersionOrInstallTime(plugin, usePluginInstallTimeInsteadOfTheVersionForSnapshotPlugins);
Date updatedAt = (plugin.getDateLoaded() == null) ? new Date() : plugin.getDateLoaded();
/** * Get Resource for Plugin. */ public Resource getPluginResource(String pluginKey, String name) { Plugin plugin = integration.getPluginAccessor().getPlugin(pluginKey); if (plugin == null) { return null; } ResourceLocation resourceLocation = plugin.getResourceLocation(DOWNLOAD_PARAM_VALUE, name); if (resourceLocation == null) { return null; } PluginResourceContainer resourceContainer = new PluginResourceContainer(new Snapshot(this), pluginKey, plugin.getDateLoaded(), getPluginVersionOrInstallTime(plugin, usePluginInstallTimeInsteadOfTheVersionForSnapshotPlugins)); Resource resource = buildResource(resourceContainer, resourceLocation); return resource; }