@Test public void evaluateExpression() { final String expression = "${asset.path}.test-selector.${asset.extension}?filename=${asset.name}&rendition=${rendition.name}"; final String expected = "/content/dam/test.png.test-selector.png?filename=test.png&rendition=test-rendition"; final AssetRenditions assetRenditions = ctx.getService(AssetRenditions.class); ctx.requestPathInfo().setResourcePath("/content/dam/test.png"); ctx.requestPathInfo().setExtension("renditions"); ctx.requestPathInfo().setSuffix("/test-rendition/asset.rendition"); String actual = assetRenditions.evaluateExpression(ctx.request(), expression); assertEquals(expected, actual); }
@Override public String evaluateExpression(final SlingHttpServletRequest request, String expression) { final AssetModel assetModel = request.adaptTo(AssetModel.class); final String assetPath = assetModel.getPath(); final String assetUrl = assetModel.getUrl(); final String assetName = assetModel.getName(); final String assetExtension = StringUtils.substringAfterLast(assetName, "."); final String renditionName = new AssetRenditionParameters(request).getRenditionName(); final String dmName = assetModel.getProperties().get(PN_S7_NAME, String.class); final String dmId = assetModel.getProperties().get(PN_S7_ASSET_ID, String.class); final String dmFile = assetModel.getProperties().get(PN_S7_FILE, String.class); final String dmFolder = assetModel.getProperties().get(PN_S7_FOLDER, String.class); final String dmDomain = assetModel.getProperties().get(PN_S7_DOMAIN, String.class); final String dmApiServer = assetModel.getProperties().get(PN_S7_API_SERVER, String.class); expression = StringUtils.replace(expression, VAR_ASSET_PATH, assetPath); expression = StringUtils.replace(expression, VAR_ASSET_URL, assetUrl); expression = StringUtils.replace(expression, VAR_ASSET_NAME, assetName); expression = StringUtils.replace(expression, VAR_ASSET_EXTENSION, assetExtension); expression = StringUtils.replace(expression, VAR_RENDITION_NAME, renditionName); expression = StringUtils.replace(expression, VAR_DM_NAME, dmName); expression = StringUtils.replace(expression, VAR_DM_ID, dmId); expression = StringUtils.replace(expression, VAR_DM_FILE, dmFile); expression = StringUtils.replace(expression, VAR_DM_FOLDER, dmFolder); expression = StringUtils.replace(expression, VAR_DM_DOMAIN, dmDomain); expression = StringUtils.replace(expression, VAR_DM_API_SERVER, dmApiServer); return expression; }
AssetRenditionsImpl implements AssetRenditions { @Override public String evaluateExpression(final SlingHttpServletRequest request, String expression) { final AssetModel assetModel = request.adaptTo(AssetModel.class); final String assetPath = assetModel.getPath(); final String assetUrl = assetModel.getUrl(); final String assetName = assetModel.getName(); final String assetExtension = StringUtils.substringAfterLast(assetName, "."); final String renditionName = new AssetRenditionParameters(request).getRenditionName(); final String dmName = assetModel.getProperties().get(PN_S7_NAME, String.class); final String dmId = assetModel.getProperties().get(PN_S7_ASSET_ID, String.class); final String dmFile = assetModel.getProperties().get(PN_S7_FILE, String.class); final String dmFolder = assetModel.getProperties().get(PN_S7_FOLDER, String.class); final String dmDomain = assetModel.getProperties().get(PN_S7_DOMAIN, String.class); final String dmApiServer = assetModel.getProperties().get(PN_S7_API_SERVER, String.class); expression = StringUtils.replace(expression, VAR_ASSET_PATH, assetPath); expression = StringUtils.replace(expression, VAR_ASSET_URL, assetUrl); expression = StringUtils.replace(expression, VAR_ASSET_NAME, assetName); expression = StringUtils.replace(expression, VAR_ASSET_EXTENSION, assetExtension); expression = StringUtils.replace(expression, VAR_RENDITION_NAME, renditionName); expression = StringUtils.replace(expression, VAR_DM_NAME, dmName); expression = StringUtils.replace(expression, VAR_DM_ID, dmId); expression = StringUtils.replace(expression, VAR_DM_FILE, dmFile); expression = StringUtils.replace(expression, VAR_DM_FOLDER, dmFolder); expression = StringUtils.replace(expression, VAR_DM_DOMAIN, dmDomain); expression = StringUtils.replace(expression, VAR_DM_API_SERVER, dmApiServer); return expression; } }
AssetRenditionsImpl implements AssetRenditions { @Override public String evaluateExpression(final SlingHttpServletRequest request, String expression) { final AssetModel assetModel = request.adaptTo(AssetModel.class); final String assetPath = assetModel.getPath(); final String assetUrl = assetModel.getUrl(); final String assetName = assetModel.getName(); final String assetExtension = StringUtils.substringAfterLast(assetName, "."); final String renditionName = new AssetRenditionParameters(request).getRenditionName(); final String dmName = assetModel.getProperties().get(PN_S7_NAME, String.class); final String dmId = assetModel.getProperties().get(PN_S7_ASSET_ID, String.class); final String dmFile = assetModel.getProperties().get(PN_S7_FILE, String.class); final String dmFolder = assetModel.getProperties().get(PN_S7_FOLDER, String.class); final String dmDomain = assetModel.getProperties().get(PN_S7_DOMAIN, String.class); final String dmApiServer = assetModel.getProperties().get(PN_S7_API_SERVER, String.class); expression = StringUtils.replace(expression, VAR_ASSET_PATH, assetPath); expression = StringUtils.replace(expression, VAR_ASSET_URL, assetUrl); expression = StringUtils.replace(expression, VAR_ASSET_NAME, assetName); expression = StringUtils.replace(expression, VAR_ASSET_EXTENSION, assetExtension); expression = StringUtils.replace(expression, VAR_RENDITION_NAME, renditionName); expression = StringUtils.replace(expression, VAR_DM_NAME, dmName); expression = StringUtils.replace(expression, VAR_DM_ID, dmId); expression = StringUtils.replace(expression, VAR_DM_FILE, dmFile); expression = StringUtils.replace(expression, VAR_DM_FOLDER, dmFolder); expression = StringUtils.replace(expression, VAR_DM_DOMAIN, dmDomain); expression = StringUtils.replace(expression, VAR_DM_API_SERVER, dmApiServer); return expression; }  }
AssetRenditionsImpl implements AssetRenditions { @Override public String evaluateExpression(final SlingHttpServletRequest request, String expression) { final AssetModel assetModel = request.adaptTo(AssetModel.class); final String assetPath = assetModel.getPath(); final String assetUrl = assetModel.getUrl(); final String assetName = assetModel.getName(); final String assetExtension = StringUtils.substringAfterLast(assetName, "."); final String renditionName = new AssetRenditionParameters(request).getRenditionName(); final String dmName = assetModel.getProperties().get(PN_S7_NAME, String.class); final String dmId = assetModel.getProperties().get(PN_S7_ASSET_ID, String.class); final String dmFile = assetModel.getProperties().get(PN_S7_FILE, String.class); final String dmFolder = assetModel.getProperties().get(PN_S7_FOLDER, String.class); final String dmDomain = assetModel.getProperties().get(PN_S7_DOMAIN, String.class); final String dmApiServer = assetModel.getProperties().get(PN_S7_API_SERVER, String.class); expression = StringUtils.replace(expression, VAR_ASSET_PATH, assetPath); expression = StringUtils.replace(expression, VAR_ASSET_URL, assetUrl); expression = StringUtils.replace(expression, VAR_ASSET_NAME, assetName); expression = StringUtils.replace(expression, VAR_ASSET_EXTENSION, assetExtension); expression = StringUtils.replace(expression, VAR_RENDITION_NAME, renditionName); expression = StringUtils.replace(expression, VAR_DM_NAME, dmName); expression = StringUtils.replace(expression, VAR_DM_ID, dmId); expression = StringUtils.replace(expression, VAR_DM_FILE, dmFile); expression = StringUtils.replace(expression, VAR_DM_FOLDER, dmFolder); expression = StringUtils.replace(expression, VAR_DM_DOMAIN, dmDomain); expression = StringUtils.replace(expression, VAR_DM_API_SERVER, dmApiServer); return expression; }  @Override String getUrl(final SlingHttpServletRequest request, final AssetModel asset, final AssetRenditionParameters parameters); @Override Map<String, String> getOptions(final Map<String, ? extends Object> mappings); @Override String evaluateExpression(final SlingHttpServletRequest request, String expression); }
AssetRenditionsImpl implements AssetRenditions { @Override public String evaluateExpression(final SlingHttpServletRequest request, String expression) { final AssetModel assetModel = request.adaptTo(AssetModel.class); final String assetPath = assetModel.getPath(); final String assetUrl = assetModel.getUrl(); final String assetName = assetModel.getName(); final String assetExtension = StringUtils.substringAfterLast(assetName, "."); final String renditionName = new AssetRenditionParameters(request).getRenditionName(); final String dmName = assetModel.getProperties().get(PN_S7_NAME, String.class); final String dmId = assetModel.getProperties().get(PN_S7_ASSET_ID, String.class); final String dmFile = assetModel.getProperties().get(PN_S7_FILE, String.class); final String dmFolder = assetModel.getProperties().get(PN_S7_FOLDER, String.class); final String dmDomain = assetModel.getProperties().get(PN_S7_DOMAIN, String.class); final String dmApiServer = assetModel.getProperties().get(PN_S7_API_SERVER, String.class); expression = StringUtils.replace(expression, VAR_ASSET_PATH, assetPath); expression = StringUtils.replace(expression, VAR_ASSET_URL, assetUrl); expression = StringUtils.replace(expression, VAR_ASSET_NAME, assetName); expression = StringUtils.replace(expression, VAR_ASSET_EXTENSION, assetExtension); expression = StringUtils.replace(expression, VAR_RENDITION_NAME, renditionName); expression = StringUtils.replace(expression, VAR_DM_NAME, dmName); expression = StringUtils.replace(expression, VAR_DM_ID, dmId); expression = StringUtils.replace(expression, VAR_DM_FILE, dmFile); expression = StringUtils.replace(expression, VAR_DM_FOLDER, dmFolder); expression = StringUtils.replace(expression, VAR_DM_DOMAIN, dmDomain); expression = StringUtils.replace(expression, VAR_DM_API_SERVER, dmApiServer); return expression; }  @Override String getUrl(final SlingHttpServletRequest request, final AssetModel asset, final AssetRenditionParameters parameters); @Override Map<String, String> getOptions(final Map<String, ? extends Object> mappings); @Override String evaluateExpression(final SlingHttpServletRequest request, String expression);  }