/** * Evaluate condition against parameters. The legacy Condition will be evaluated, the UrlReadingCondition will * be evaluated against parameters. * If error will be thrown it will be intercepted and condition evaluated to false. */ public boolean evaluateSafely(RequestCache requestCache, Map<String, String> params) { Boolean result = requestCache.getCachedConditionsEvaluation().get(this); if (result == null) { try { result = condition.shouldDisplay(QueryParams.of(params)); } catch (RuntimeException e) { Support.LOGGER.warn("exception thrown in `shouldDisplay` during condition evaluation", e); return false; } requestCache.getCachedConditionsEvaluation().put(this, result); } return result; }
@Override public boolean shouldDisplayImmediate(Map<String, Object> context, UrlBuildingStrategy urlBuilderStrategy) { DefaultUrlBuilder urlBuilder = new DefaultUrlBuilder(); addToUrl(urlBuilder, urlBuilderStrategy); return shouldDisplay(QueryParams.of(urlBuilder.buildParams())); }
/** * Apply Static Transformers to Resource. * * @param resource resource. * @param content content of resource. * @param params http params. * @param sourceUrl url of source code for resource. * @return resulting content. */ protected static Content applyStaticTransformers(final Globals globals, Resource resource, Content content, Map<String, String> params, String sourceUrl) { if (resource.getParent() instanceof WebResource) { return repairSourceMapChain(content, innerContent -> { return globals.getConfig().getStaticTransformers().transform( innerContent, resource.getParent().getTransformerParameters(), resource.getResourceLocation(), resource.getFilePath(), QueryParams.of(params), sourceUrl ); }); } else { return content; } }
innerLastContent = transformation.transform(globals.getConfig().getCdnResourceUrlTransformer(), globals.getConfig().getTransformerCache(), resource, innerLastContent, resource.getResourceLocation(), resource.getFilePath(), QueryParams.of(params), sourceUrl);