Class UrlGenerationHelpers
java.lang.Object
com.atlassian.plugin.webresource.impl.helpers.BaseHelpers
com.atlassian.plugin.webresource.impl.helpers.url.UrlGenerationHelpers
- Direct Known Subclasses:
ResourceServingHelpers
Stateless helper functions providing basic support for resource url generation.
- Since:
- v3.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static UrlCache.IncludedExcludedConditionsAndBatchingOptionsbuildIncludedExcludedConditionsAndBatchingOptions(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, Collection<String> topLevelIncluded, Collection<String> topLevelExcluded) Building the cache key of included, excluded and conditions.protected static CalculatedBatchescalculateBatches(RequestCache requestCache, UrlBuildingStrategy urlBuildingStrategy, LinkedHashSet<String> topLevelIncluded, LinkedHashSet<String> allExcluded, Set<String> topLevelExcluded) Groups given web resources and contexts in to batches, taking any content that has already been served in to account.static StringcalculateBundleHash(RawRequest rawRequest, RequestCache requestCache) Calculates URL resource hashes for given request.static StringcalculateBundlesHash(List<Bundle> bundles) protected static List<ResourceUrl>collectUrlStateAndBuildResourceUrls(RequestState requestState, UrlBuildingStrategy urlBuilderStrategy, List<ContextBatch> contextBatches, List<WebResourceBatch> webResourceBatches) Collect URL State for Conditions and Transformers and build Resource URLs.protected static List<ResourceUrl>createResourceUrlsForRedirectResources(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, List<Resource> resources) Creates Resource URLs for redirect resources.protected static StateEncodedUrlResultencodeStateInUrlIfSupported(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, String type, Map<String, String> params, Bundle bundle, List<Bundle> skipped, List<Bundle> excludedWithoutApplyingConditions) Collect and encode URL state for given Resources, it collects resource params, condition params and transformer params.protected static StateEncodedUrlResultencodeStateInUrlIfSupported(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, String type, Map<String, String> params, List<Bundle> bundles, List<Bundle> skipped, List<Bundle> excludedWithoutApplyingConditions) Collect and encode URL state for given Resources, it collects resource params, condition params and transformer params.resolveExcluded(RequestCache requestCache, UrlCache urlCache, UrlBuildingStrategy urlBuilderStrategy, Collection<String> topLevelIncluded, Collection<String> topLevelExcluded) Deprecated.resourcesOfType(Collection<Resource> resources, String type) Get resources of given type.protected static com.atlassian.plugin.webresource.impl.helpers.url.SplitSubBatchessplitBatchIntoSubBatches(RequestCache requestCache, Found found, boolean doSorting) Split batch into sub batches and standalone resources, same code used to split both context and resource batches.static Tuple<List<ContextBatch>,List<WebResourceBatch>> splitIntoSubBatches(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, List<ContextBatchKey> contextBatchKeys, List<String> webResourceBatchKeys, Set<String> allExcluded) Split batches into sub batches grouped by URL parameters and set of standalone resources.Methods inherited from class com.atlassian.plugin.webresource.impl.helpers.BaseHelpers
isConditionsSatisfied, isConditionsSatisfied
-
Constructor Details
-
UrlGenerationHelpers
public UrlGenerationHelpers()
-
-
Method Details
-
buildIncludedExcludedConditionsAndBatchingOptions
protected static UrlCache.IncludedExcludedConditionsAndBatchingOptions buildIncludedExcludedConditionsAndBatchingOptions(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, Collection<String> topLevelIncluded, Collection<String> topLevelExcluded) Building the cache key of included, excluded and conditions. -
resolveExcluded
@Deprecated public static Set<String> resolveExcluded(RequestCache requestCache, UrlCache urlCache, UrlBuildingStrategy urlBuilderStrategy, Collection<String> topLevelIncluded, Collection<String> topLevelExcluded) Deprecated.useDependencyGraphorBundleFinderinstead to avoid generating an entire URL set just to traverse the dependency graph.Uses the set of top-level inclusions and exclusions, as well as a cache of previously-evaluated conditions etc., to determine what content has already been served to the client.- Parameters:
requestCache- request cache. Used to look up previous condition evaluation results.topLevelIncluded- the "entry point" web resources and contexts the client has requested. conditions will be considered when discovering content via these items.topLevelExcluded- the "entry point" web resources and contexts the client has already loaded and should not be served again. Conditions will NOT be considered when disovering content via these items.- Returns:
- list of all items that should be omitted from future requests made by this client.
-
calculateBatches
protected static CalculatedBatches calculateBatches(RequestCache requestCache, UrlBuildingStrategy urlBuildingStrategy, LinkedHashSet<String> topLevelIncluded, LinkedHashSet<String> allExcluded, Set<String> topLevelExcluded) Groups given web resources and contexts in to batches, taking any content that has already been served in to account.- Parameters:
requestCache- request cache.urlBuildingStrategy- how conditions and transformers contribute to generated URLs.topLevelIncluded- the "entry point" web resources and contexts the client has requested.topLevelExcluded- the "entry point" web resources and contexts that were explicitly excluded from the request by the client. Used toallExcluded- all web resources discoverable through the topLevelExcluded set. This should be a superset of topLevelExcluded - that is, all "entry point" web-resources and contexts should also be present here. Used to determine what has already been served to the client and avoid re-serving the same content.- Returns:
- a
CalculatedBatchesthat represents the batch groups to serve to the client, along with a list of all items that should be omitted from subsequent client requests.
-
collectUrlStateAndBuildResourceUrls
protected static List<ResourceUrl> collectUrlStateAndBuildResourceUrls(RequestState requestState, UrlBuildingStrategy urlBuilderStrategy, List<ContextBatch> contextBatches, List<WebResourceBatch> webResourceBatches) Collect URL State for Conditions and Transformers and build Resource URLs.- Returns:
- list of Resource URLs.
-
splitIntoSubBatches
public static Tuple<List<ContextBatch>,List<WebResourceBatch>> splitIntoSubBatches(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, List<ContextBatchKey> contextBatchKeys, List<String> webResourceBatchKeys, Set<String> allExcluded) Split batches into sub batches grouped by URL parameters and set of standalone resources.- Parameters:
contextBatchKeys- keys of context batcheswebResourceBatchKeys- keys of web resource batches.- Returns:
- context batches and web resource batches split into sub batches.
-
calculateBundleHash
Calculates URL resource hashes for given request.- Parameters:
rawRequest- raw request.requestCache- request cache.- Returns:
- calculated resource hashes.
-
calculateBundlesHash
-
splitBatchIntoSubBatches
protected static com.atlassian.plugin.webresource.impl.helpers.url.SplitSubBatches splitBatchIntoSubBatches(RequestCache requestCache, Found found, boolean doSorting) Split batch into sub batches and standalone resources, same code used to split both context and resource batches.- Parameters:
found- list of complete keys that the batch contains.doSorting- some legacy stuff, in some cases it sorted in some not.- Returns:
- batch split into sub batches and
-
resourcesOfType
Get resources of given type. -
encodeStateInUrlIfSupported
protected static StateEncodedUrlResult encodeStateInUrlIfSupported(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, String type, Map<String, String> params, Bundle bundle, List<Bundle> skipped, List<Bundle> excludedWithoutApplyingConditions) Collect and encode URL state for given Resources, it collects resource params, condition params and transformer params. -
encodeStateInUrlIfSupported
protected static StateEncodedUrlResult encodeStateInUrlIfSupported(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, String type, Map<String, String> params, List<Bundle> bundles, List<Bundle> skipped, List<Bundle> excludedWithoutApplyingConditions) Collect and encode URL state for given Resources, it collects resource params, condition params and transformer params. -
createResourceUrlsForRedirectResources
protected static List<ResourceUrl> createResourceUrlsForRedirectResources(RequestCache requestCache, UrlBuildingStrategy urlBuilderStrategy, List<Resource> resources) Creates Resource URLs for redirect resources.
-
DependencyGraphorBundleFinderinstead to avoid generating an entire URL set just to traverse the dependency graph.