@Test public void testWithData() { final ActionHelper actionHelper = ctx.getService(ActionHelper.class); final Map<String, Object> requestParameters = new HashMap<>(); final String[] assets = { "/content/dam/asset-1.png", "/content/dam/asset-2.png" }; requestParameters.put(ASSETS_REQUEST_PARAMETER_NAME, assets); ctx.request().setParameterMap(requestParameters); final Collection<AssetModel> models = actionHelper.getAssetsFromQueryParameter(ctx.request(), ASSETS_REQUEST_PARAMETER_NAME); assertNotNull(models); assertEquals(2, models.size()); assertEquals("asset-1.png", models.toArray(new AssetModel[2])[0].getName()); assertEquals("asset-2.png", models.toArray(new AssetModel[2])[1].getName()); }
public final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName) { final RequestParameter[] requestParameters = request.getRequestParameters(parameterName); final Collection<AssetModel> assets = new ArrayList<>(); if (requestParameters != null) { for (final RequestParameter requestParameter : requestParameters) { final Resource resource = request.getResourceResolver().getResource(requestParameter.getString()); if (resource != null) { final AssetModel asset = modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class); if (asset != null) { assets.add(asset); } } } } return assets; }
ActionHelperImpl implements ActionHelper { public final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName) { final RequestParameter[] requestParameters = request.getRequestParameters(parameterName); final Collection<AssetModel> assets = new ArrayList<>(); if (requestParameters != null) { for (final RequestParameter requestParameter : requestParameters) { final Resource resource = request.getResourceResolver().getResource(requestParameter.getString()); if (resource != null) { final AssetModel asset = modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class); if (asset != null) { assets.add(asset); } } } } return assets; } }
ActionHelperImpl implements ActionHelper { public final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName) { final RequestParameter[] requestParameters = request.getRequestParameters(parameterName); final Collection<AssetModel> assets = new ArrayList<>(); if (requestParameters != null) { for (final RequestParameter requestParameter : requestParameters) { final Resource resource = request.getResourceResolver().getResource(requestParameter.getString()); if (resource != null) { final AssetModel asset = modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class); if (asset != null) { assets.add(asset); } } } } return assets; }  }
ActionHelperImpl implements ActionHelper { public final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName) { final RequestParameter[] requestParameters = request.getRequestParameters(parameterName); final Collection<AssetModel> assets = new ArrayList<>(); if (requestParameters != null) { for (final RequestParameter requestParameter : requestParameters) { final Resource resource = request.getResourceResolver().getResource(requestParameter.getString()); if (resource != null) { final AssetModel asset = modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class); if (asset != null) { assets.add(asset); } } } } return assets; }  final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName); final Collection<AssetModel> getPlaceholderAsset(final SlingHttpServletRequest request); }
ActionHelperImpl implements ActionHelper { public final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName) { final RequestParameter[] requestParameters = request.getRequestParameters(parameterName); final Collection<AssetModel> assets = new ArrayList<>(); if (requestParameters != null) { for (final RequestParameter requestParameter : requestParameters) { final Resource resource = request.getResourceResolver().getResource(requestParameter.getString()); if (resource != null) { final AssetModel asset = modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class); if (asset != null) { assets.add(asset); } } } } return assets; }  final Collection<AssetModel> getAssetsFromQueryParameter(final SlingHttpServletRequest request, final String parameterName); final Collection<AssetModel> getPlaceholderAsset(final SlingHttpServletRequest request);  }