@Test public void getRenditionNames() { ctx.registerInjectActivateService(new AssetRenditionsDownloadServlet()); AssetRenditionsDownloadServlet servlet = (AssetRenditionsDownloadServlet) ctx.getService(Servlet.class); ctx.currentResource("/content/allowed-rendition-names"); ctx.request().setQueryString("renditionName=one&renditionName=four"); List<String> actual = servlet.getRenditionNames(ctx.request()); assertEquals(1, actual.size()); assertEquals("one", actual.get(0)); }
protected List<String> getRenditionNames(final SlingHttpServletRequest request) { final String[] allowedRenditionNames = request.getResource().getValueMap().get(PN_ALLOWED_RENDITION_NAMES, new String[]{}); if (allowedRenditionNames == null) { return EMPTY_LIST; } final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_RENDITION_NAMES); if (requestParameters != null) { return Arrays.stream(requestParameters).map(RequestParameter::getString) .filter(renditionName -> allowedRenditionNames.length == 0 || ArrayUtils.contains(allowedRenditionNames, renditionName)) .distinct() .collect(Collectors.toList()); } else { return emptyList(); } }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<String> getRenditionNames(final SlingHttpServletRequest request) { final String[] allowedRenditionNames = request.getResource().getValueMap().get(PN_ALLOWED_RENDITION_NAMES, new String[]{}); if (allowedRenditionNames == null) { return EMPTY_LIST; } final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_RENDITION_NAMES); if (requestParameters != null) { return Arrays.stream(requestParameters).map(RequestParameter::getString) .filter(renditionName -> allowedRenditionNames.length == 0 || ArrayUtils.contains(allowedRenditionNames, renditionName)) .distinct() .collect(Collectors.toList()); } else { return emptyList(); } } }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<String> getRenditionNames(final SlingHttpServletRequest request) { final String[] allowedRenditionNames = request.getResource().getValueMap().get(PN_ALLOWED_RENDITION_NAMES, new String[]{}); if (allowedRenditionNames == null) { return EMPTY_LIST; } final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_RENDITION_NAMES); if (requestParameters != null) { return Arrays.stream(requestParameters).map(RequestParameter::getString) .filter(renditionName -> allowedRenditionNames.length == 0 || ArrayUtils.contains(allowedRenditionNames, renditionName)) .distinct() .collect(Collectors.toList()); } else { return emptyList(); } }  }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<String> getRenditionNames(final SlingHttpServletRequest request) { final String[] allowedRenditionNames = request.getResource().getValueMap().get(PN_ALLOWED_RENDITION_NAMES, new String[]{}); if (allowedRenditionNames == null) { return EMPTY_LIST; } final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_RENDITION_NAMES); if (requestParameters != null) { return Arrays.stream(requestParameters).map(RequestParameter::getString) .filter(renditionName -> allowedRenditionNames.length == 0 || ArrayUtils.contains(allowedRenditionNames, renditionName)) .distinct() .collect(Collectors.toList()); } else { return emptyList(); } }  final AssetRenditionsDownloadOrchestrator getAssetRenditionsDownloadOrchestrator(final String id); }
AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<String> getRenditionNames(final SlingHttpServletRequest request) { final String[] allowedRenditionNames = request.getResource().getValueMap().get(PN_ALLOWED_RENDITION_NAMES, new String[]{}); if (allowedRenditionNames == null) { return EMPTY_LIST; } final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_RENDITION_NAMES); if (requestParameters != null) { return Arrays.stream(requestParameters).map(RequestParameter::getString) .filter(renditionName -> allowedRenditionNames.length == 0 || ArrayUtils.contains(allowedRenditionNames, renditionName)) .distinct() .collect(Collectors.toList()); } else { return emptyList(); } }  final AssetRenditionsDownloadOrchestrator getAssetRenditionsDownloadOrchestrator(final String id);  }