public Set<Alert> alerts() { Set<Alert> errors = new HashSet<Alert>(); String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Checking for alerts for the request \"{}\"", currentUri); String[] bundleNames = AssetRequestContext.get(this.request).getBundles(true); errors.addAll(this.context.getBundleStorage().alertsFor(bundleNames)); LOG.debug("-> Errors found: {}", errors.size()); return errors; }
/** * <p> * Returns the content of the given {@link Asset}, using its * {@link Asset#getFinalLocation()} value. * * <p> * Note that this method can be used to access the asset's content after the * {@link AssetProcessor}'s execution. * * @param asset * The asset from which the content should be extracted. * @param request * The current HTTP request. * @return the raw content (unprocessed) of the passed {@link Asset}. */ public String getContent(Asset asset, HttpServletRequest request) { Map<String, Object> parameters = AssetRequestContext.get(request).getParameters(asset.getName()); String content = doGetContent(asset, parameters, request); // Apply variable replacement if (!parameters.isEmpty()) { for (Map.Entry<String, Object> entry : parameters.entrySet()) { content = content.replace(entry.getKey(), entry.getValue().toString()); } } return content; }
@Override protected String doGetContent(Asset asset, Map<String, Object> parameters, HttpServletRequest request) { AssetContentGenerator generator = AssetRequestContext.get(request).getGenerator(asset.getGeneratorUid()); if (generator == null) { throw new DandelionException("No asset generator has been found in the request with the uid \"" + asset.getGeneratorUid() + "\". Ensure to call AssetRequestContext.get(request).addGenerator(\"" + asset.getGeneratorUid() + "\", ...);"); } return generator.getAssetContent(request); } }
public Set<Alert> alerts() { Set<Alert> errors = new HashSet<Alert>(); String currentUri = UrlUtils.getCurrentUri(request).toString(); LOG.debug("Checking for alerts for the request \"{}\"", currentUri); String[] bundleNames = AssetRequestContext.get(this.request).getBundles(true); errors.addAll(this.context.getBundleStorage().alertsFor(bundleNames)); LOG.debug("-> Errors found: {}", errors.size()); return errors; }
@Override protected String doGetContent(Asset asset, Map<String, Object> parameters, HttpServletRequest request) { AssetContentGenerator generator = AssetRequestContext.get(request).getGenerator(asset.getGeneratorUid()); if (generator == null) { throw new DandelionException("No asset generator has been found in the request with the uid \"" + asset.getGeneratorUid() + "\". Ensure to call AssetRequestContext.get(request).addGenerator(\"" + asset.getGeneratorUid() + "\", ...);"); } return generator.getAssetContent(request); } }
public int doEndTag() throws JspException { AssetRequestContext.get(pageContext.getRequest()).addBundles(includes).excludeBundles(excludes); return EVAL_PAGE; }
private Set<AssetStorageUnit> collectAssetStorageUnits() { Set<AssetStorageUnit> asus = new LinkedHashSet<AssetStorageUnit>(); String[] bundleNames = AssetRequestContext.get(this.request).getBundles(true); for (BundleStorageUnit bsu : this.context.getBundleStorage().bundlesFor(bundleNames)) { asus.addAll(bsu.getAssetStorageUnits()); } return asus; } }
public int doEndTag() throws JspException { AssetRequestContext.get(pageContext.getRequest()).addBundles(includes).excludeBundles(excludes); return EVAL_PAGE; }
private Set<AssetStorageUnit> collectAssetStorageUnits() { Set<AssetStorageUnit> asus = new LinkedHashSet<AssetStorageUnit>(); String[] bundleNames = AssetRequestContext.get(this.request).getBundles(true); for (BundleStorageUnit bsu : this.context.getBundleStorage().bundlesFor(bundleNames)) { asus.addAll(bsu.getAssetStorageUnits()); } return asus; } }
/** * Updates the current {@link HttpServletRequest} with the passed * {@link DatatableBundles}. * * @param bundle * The {@link DatatableBundles} to add. */ public void addBundle(DatatableBundles bundle) { AssetRequestContext.get(table.getTableConfiguration().getRequest()).addBundles(bundle); }
/** * Updates the current {@link HttpServletRequest} with the passed * {@link DatatableBundles}. * * @param bundle * The {@link DatatableBundles} to add. */ public void addBundle(DatatableBundles bundle) { AssetRequestContext.get(table.getTableConfiguration().getRequest()).addBundles(bundle); }
public void addBundleParameter(String assetName, String paramName, Object paramValue) { AssetRequestContext.get(table.getTableConfiguration().getRequest()).addParameter(assetName, paramName, paramValue); }
public void addBundleParameter(String assetName, String paramName, Object paramValue) { AssetRequestContext.get(table.getTableConfiguration().getRequest()).addParameter(assetName, paramName, paramValue); }
/** * {@inheritDoc} */ @Override protected ProcessorResult doProcessAttribute(Arguments arguments, Element element, String attributeName) { String strippedAttributeName = AttributesUtil.stripPrefix(attributeName, DandelionDialect.DIALECT_PREFIX); BundleAttributeNames assetsAttributeName = (BundleAttributeNames) AttributesUtil.find(strippedAttributeName, BundleAttributeNames.values()); HttpServletRequest request = ArgumentsUtil.getWebContext(arguments).getHttpServletRequest(); AssetRequestContext context = AssetRequestContext.get(request); switch (assetsAttributeName) { case INCLUDES: context.addBundles(element.getAttributeValue(attributeName)); break; case EXCLUDES: context.excludeBundles(element.getAttributeValue(attributeName)); break; } return ProcessorResult.ok(); } }
/** * {@inheritDoc} */ @Override protected ProcessorResult doProcessAttribute(Arguments arguments, Element element, String attributeName) { String strippedAttributeName = AttributesUtil.stripPrefix(attributeName, DandelionDialect.DIALECT_PREFIX); BundleAttributeNames assetsAttributeName = (BundleAttributeNames) AttributesUtil.find(strippedAttributeName, BundleAttributeNames.values()); HttpServletRequest request = ArgumentsUtil.getWebContext(arguments).getHttpServletRequest(); AssetRequestContext context = AssetRequestContext.get(request); switch (assetsAttributeName) { case INCLUDES: context.addBundles(element.getAttributeValue(attributeName)); break; case EXCLUDES: context.excludeBundles(element.getAttributeValue(attributeName)); break; } return ProcessorResult.ok(); } }
/** * {@inheritDoc} */ @Override protected ProcessorResult doProcessAttribute(Arguments arguments, Element element, String attributeName) { String strippedAttributeName = AttributesUtil.stripPrefix(attributeName, DandelionDialect.DIALECT_PREFIX); AssetAttributeNames assetsAttributeName = (AssetAttributeNames) AttributesUtil.find(strippedAttributeName, AssetAttributeNames.values()); HttpServletRequest request = ArgumentsUtil.getWebContext(arguments).getHttpServletRequest(); AssetRequestContext arc = AssetRequestContext.get(request); switch (assetsAttributeName) { case JS_EXCLUDES: arc.excludeJs(element.getAttributeValue(attributeName)); break; case CSS_EXCLUDES: arc.excludeCss(element.getAttributeValue(attributeName)); break; default: break; } return ProcessorResult.ok(); } }
/** * {@inheritDoc} */ @Override protected ProcessorResult doProcessAttribute(Arguments arguments, Element element, String attributeName) { String strippedAttributeName = AttributesUtil.stripPrefix(attributeName, DandelionDialect.DIALECT_PREFIX); AssetAttributeNames assetsAttributeName = (AssetAttributeNames) AttributesUtil.find(strippedAttributeName, AssetAttributeNames.values()); HttpServletRequest request = ArgumentsUtil.getWebContext(arguments).getHttpServletRequest(); AssetRequestContext arc = AssetRequestContext.get(request); switch (assetsAttributeName) { case JS_EXCLUDES: arc.excludeJs(element.getAttributeValue(attributeName)); break; case CSS_EXCLUDES: arc.excludeCss(element.getAttributeValue(attributeName)); break; default: break; } return ProcessorResult.ok(); } }
@Override protected ProcessorResult doProcessAttribute(Arguments arguments, Element element, String attributeName) { String strippedAttributeName = AttributesUtil.stripPrefix(attributeName, DandelionDialect.DIALECT_PREFIX); PlaceholderAttributeNames placeholderAttributeName = (PlaceholderAttributeNames) AttributesUtil .find(strippedAttributeName, PlaceholderAttributeNames.values()); HttpServletRequest request = ArgumentsUtil.getWebContext(arguments).getHttpServletRequest(); AssetRequestContext arc = AssetRequestContext.get(request); String attributeValue = element.getAttributeValue(attributeName); if (StringUtils.isBlank(attributeValue)) { throw new DandelionException("The \"type\" attribute cannot be blank. Possible values: \"" + PLACEHOLDER_TYPE_JS + "\" or \"" + PLACEHOLDER_TYPE_CSS + "\"."); } String placeholder = "dandelionPlaceholder" + attributeValue; handlePlaceholder(attributeValue, arc, placeholder); switch (placeholderAttributeName) { // Include a new Text node containing the placeholder within the existing // element case PLACEHOLDER_INCLUDE: Text text = new Text(placeholder); element.insertChild(element.getChildren().size(), text); break; // Replace the current element by the placeholder case PLACEHOLDER_REPLACE: text = new Text(placeholder); element.clearChildren(); element.addChild(text); break; } return ProcessorResult.ok(); }