@Test public void getAssets() { ctx.registerInjectActivateService(new AssetRenditionsDownloadServlet()); AssetRenditionsDownloadServlet servlet = (AssetRenditionsDownloadServlet) ctx.getService(Servlet.class); ctx.request().setQueryString("path=/content/dam/test.png&path=/content/dam/test-2.png&path=/content/dam/test-3.png"); List<com.adobe.aem.commons.assetshare.content.AssetModel> actual = servlet.getAssets(ctx.request()); assertEquals(1, actual.size()); assertEquals("/content/dam/test.png", actual.get(0).getPath()); }
protected List<AssetModel> getAssets(final SlingHttpServletRequest request) { final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_ASSET_PATHS); if (requestParameters == null) { return EMPTY_LIST; } return Arrays.stream(requestParameters) .map(RequestParameter::getString) .map(path -> request.getResourceResolver().getResource(path)) .filter(Objects::nonNull) .map(resource -> modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class)) .filter(Objects::nonNull) .collect(Collectors.toList()); }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<AssetModel> getAssets(final SlingHttpServletRequest request) { final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_ASSET_PATHS); if (requestParameters == null) { return EMPTY_LIST; } return Arrays.stream(requestParameters) .map(RequestParameter::getString) .map(path -> request.getResourceResolver().getResource(path)) .filter(Objects::nonNull) .map(resource -> modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class)) .filter(Objects::nonNull) .collect(Collectors.toList()); } }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<AssetModel> getAssets(final SlingHttpServletRequest request) { final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_ASSET_PATHS); if (requestParameters == null) { return EMPTY_LIST; } return Arrays.stream(requestParameters) .map(RequestParameter::getString) .map(path -> request.getResourceResolver().getResource(path)) .filter(Objects::nonNull) .map(resource -> modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<AssetModel> getAssets(final SlingHttpServletRequest request) { final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_ASSET_PATHS); if (requestParameters == null) { return EMPTY_LIST; } return Arrays.stream(requestParameters) .map(RequestParameter::getString) .map(path -> request.getResourceResolver().getResource(path)) .filter(Objects::nonNull) .map(resource -> modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  final AssetRenditionsDownloadOrchestrator getAssetRenditionsDownloadOrchestrator(final String id); }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<AssetModel> getAssets(final SlingHttpServletRequest request) { final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_ASSET_PATHS); if (requestParameters == null) { return EMPTY_LIST; } return Arrays.stream(requestParameters) .map(RequestParameter::getString) .map(path -> request.getResourceResolver().getResource(path)) .filter(Objects::nonNull) .map(resource -> modelFactory.getModelFromWrappedRequest(request, resource, AssetModel.class)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  final AssetRenditionsDownloadOrchestrator getAssetRenditionsDownloadOrchestrator(final String id);  }