Search in sources :

Example 36 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project halyard by spinnaker.

the class KubernetesV2Service method getResourceYaml.

default String getResourceYaml(AccountDeploymentDetails<KubernetesAccount> details, GenerateService.ResolvedConfiguration resolvedConfiguration) {
    ServiceSettings settings = resolvedConfiguration.getServiceSettings(getService());
    String namespace = getNamespace(settings);
    List<ConfigSource> configSources = stageConfig(details, resolvedConfiguration);
    Map<String, String> env = configSources.stream().map(ConfigSource::getEnv).map(Map::entrySet).flatMap(Collection::stream).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
    env.putAll(settings.getEnv());
    List<String> volumes = configSources.stream().map(c -> {
        TemplatedResource volume = new JinjaJarResource("/kubernetes/manifests/volume.yml");
        volume.addBinding("name", c.getId());
        return volume.toString();
    }).collect(Collectors.toList());
    List<String> volumeMounts = configSources.stream().map(c -> {
        TemplatedResource volume = new JinjaJarResource("/kubernetes/manifests/volumeMount.yml");
        volume.addBinding("name", c.getId());
        volume.addBinding("mountPath", c.getMountPath());
        return volume.toString();
    }).collect(Collectors.toList());
    TemplatedResource probe;
    if (StringUtils.isNotEmpty(settings.getHealthEndpoint())) {
        probe = new JinjaJarResource("/kubernetes/manifests/execReadinessProbe.yml");
        probe.addBinding("command", getReadinessExecCommand(settings));
    } else {
        probe = new JinjaJarResource("/kubernetes/manifests/tcpSocketReadinessProbe.yml");
        probe.addBinding("port", settings.getPort());
    }
    TemplatedResource container = new JinjaJarResource("/kubernetes/manifests/container.yml");
    container.addBinding("name", getService().getCanonicalName());
    container.addBinding("imageId", settings.getArtifactId());
    container.addBinding("port", settings.getPort());
    container.addBinding("volumeMounts", volumeMounts);
    container.addBinding("probe", probe.toString());
    container.addBinding("env", env);
    List<String> containers = Collections.singletonList(container.toString());
    TemplatedResource podSpec = new JinjaJarResource("/kubernetes/manifests/podSpec.yml").addBinding("containers", containers).addBinding("volumes", volumes);
    return new JinjaJarResource("/kubernetes/manifests/deployment.yml").addBinding("name", getService().getCanonicalName()).addBinding("namespace", namespace).addBinding("replicas", settings.getTargetSize()).addBinding("podAnnotations", settings.getKubernetes().getPodAnnotations()).addBinding("podSpec", podSpec.toString()).toString();
}
Also used : ConfigSource(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource) Arrays(java.util.Arrays) KubernetesUtil(com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.KubernetesUtil) KubernetesAccount(com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesAccount) HashMap(java.util.HashMap) ArtifactService(com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService) SecretMountPair(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubernetesV2Utils.SecretMountPair) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AccountDeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails) Map(java.util.Map) KubernetesImageDescription(com.netflix.spinnaker.clouddriver.kubernetes.v1.deploy.description.servergroup.KubernetesImageDescription) JinjaJarResource(com.netflix.spinnaker.halyard.core.resource.v1.JinjaJarResource) Strings(io.fabric8.utils.Strings) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) Collection(java.util.Collection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) GenerateService(com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) Collectors(java.util.stream.Collectors) File(java.io.File) HasServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings) List(java.util.List) Profile(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.Profile) Paths(java.nio.file.Paths) KubernetesSharedServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings) Entry(java.util.Map.Entry) ConfigSource(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ConfigSource) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) Collections(java.util.Collections) JinjaJarResource(com.netflix.spinnaker.halyard.core.resource.v1.JinjaJarResource) HasServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.HasServiceSettings) KubernetesSharedServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.KubernetesSharedServiceSettings) ServiceSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings) TemplatedResource(com.netflix.spinnaker.halyard.core.resource.v1.TemplatedResource) HashMap(java.util.HashMap) Map(java.util.Map)

Example 37 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project Asqatasun by Asqatasun.

the class Rgaa30Rule110103 method check.

@Override
protected void check(SSPHandler sspHandler, TestSolutionHandler testSolutionHandler) {
    /* If the page has no input form element, the test is not applicable */
    if (inputFormMap.entrySet().isEmpty()) {
        testSolutionHandler.addTestSolution(TestSolution.NOT_APPLICABLE);
        return;
    }
    for (Map.Entry<Element, ElementHandler<Element>> entry : inputFormMap.entrySet()) {
        /* The attribute Emptiness Checker. Keep default value i.e failed 
             when attribute is empty
             */
        ElementChecker attributeEmptinessChecker = new TextEmptinessChecker(new TextAttributeOfElementBuilder(ARIA_LABELLEDBY_ATTR), ARIA_LABELLEDBY_EMPTY_MSG, null);
        attributeEmptinessChecker.check(sspHandler, entry.getValue(), testSolutionHandler);
        ElementHandler<Element> inputWithoutLabel = new ElementHandlerImpl();
        ElementHandler<Element> notUniqueLabel = new ElementHandlerImpl();
        for (Element el : entry.getValue().get()) {
            if (StringUtils.isNotEmpty(el.attr(ARIA_LABELLEDBY_ATTR))) {
                ElementHandler<Element> labelHandler = new ElementHandlerImpl();
                labelHandler.addAll(entry.getKey().select(CssLikeSelectorBuilder.buildSelectorFromAttributeTypeAndValue(ID_ATTR, el.attr(ARIA_LABELLEDBY_ATTR))));
                if (labelHandler.get().isEmpty()) {
                    inputWithoutLabel.add(el);
                } else if (labelHandler.get().size() > 1) {
                    notUniqueLabel.add(el);
                    notUniqueLabel.addAll(labelHandler.get());
                }
            }
        }
        /* Check if the form element has a label associated */
        ElementChecker elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, FORM_ELEMENT_WITHOUT_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
        elementPresenceChecker.check(sspHandler, inputWithoutLabel, testSolutionHandler);
        /* Check if the id attr of the label associated to the form element is unique */
        elementPresenceChecker = new ElementPresenceChecker(new ImmutablePair(TestSolution.FAILED, FORM_ELEMENT_WITH_NOT_UNIQUE_LABEL_MSG), new ImmutablePair(TestSolution.PASSED, ""));
        elementPresenceChecker.check(sspHandler, notUniqueLabel, testSolutionHandler);
    }
}
Also used : ElementPresenceChecker(org.asqatasun.rules.elementchecker.element.ElementPresenceChecker) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) TextAttributeOfElementBuilder(org.asqatasun.rules.textbuilder.TextAttributeOfElementBuilder) Element(org.jsoup.nodes.Element) TextEmptinessChecker(org.asqatasun.rules.elementchecker.text.TextEmptinessChecker) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) ElementChecker(org.asqatasun.rules.elementchecker.ElementChecker) HashMap(java.util.HashMap) Map(java.util.Map)

Example 38 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class Utils method getWrappedImageResourceWithInheritance.

/**
 * Wraps an image resource with the properties and child resources of the inherited featured image of either
 * the linked page or the page containing the resource.
 *
 * @param resource The image resource
 * @param linkHandler The link handler
 * @param currentStyle The style of the image resource
 * @param currentPage The page containing the image resource
 * @return The wrapped image resource augmented with inherited properties and child resource if inheritance is enabled, the plain image resource otherwise.
 */
public static Resource getWrappedImageResourceWithInheritance(Resource resource, LinkHandler linkHandler, Style currentStyle, Page currentPage) {
    if (resource == null) {
        LOGGER.error("The resource is not defined");
        return null;
    }
    if (linkHandler == null) {
        LOGGER.error("The link handler is not defined");
        return null;
    }
    ValueMap properties = resource.getValueMap();
    String fileReference = properties.get(DownloadResource.PN_REFERENCE, String.class);
    Resource fileResource = resource.getChild(DownloadResource.NN_FILE);
    boolean imageFromPageImage = properties.get(PN_IMAGE_FROM_PAGE_IMAGE, StringUtils.isEmpty(fileReference) && fileResource == null);
    boolean altValueFromPageImage = properties.get(PN_ALT_VALUE_FROM_PAGE_IMAGE, imageFromPageImage);
    if (imageFromPageImage) {
        Resource inheritedResource = null;
        String linkURL = properties.get(ImageResource.PN_LINK_URL, String.class);
        boolean actionsEnabled = (currentStyle != null) ? !currentStyle.get(Teaser.PN_ACTIONS_DISABLED, !properties.get(Teaser.PN_ACTIONS_ENABLED, true)) : properties.get(Teaser.PN_ACTIONS_ENABLED, true);
        Resource firstAction = Optional.of(resource).map(res -> res.getChild(Teaser.NN_ACTIONS)).map(actions -> actions.getChildren().iterator().next()).orElse(null);
        if (StringUtils.isNotEmpty(linkURL)) {
            // the inherited resource is the featured image of the linked page
            Optional<Link> link = linkHandler.getLink(resource);
            inheritedResource = link.map(link1 -> (Page) link1.getReference()).map(ComponentUtils::getFeaturedImage).orElse(null);
        } else if (actionsEnabled && firstAction != null) {
            // the inherited resource is the featured image of the first action's page (the resource is assumed to be a teaser)
            inheritedResource = Optional.of(linkHandler.getLink(firstAction, Teaser.PN_ACTION_LINK)).map(link1 -> {
                if (link1.isPresent()) {
                    Page linkedPage = (Page) link1.get().getReference();
                    return Optional.ofNullable(linkedPage).map(ComponentUtils::getFeaturedImage).orElse(null);
                }
                return null;
            }).orElse(null);
        } else {
            // the inherited resource is the featured image of the current page
            inheritedResource = Optional.ofNullable(currentPage).map(page -> {
                Template template = page.getTemplate();
                // make sure the resource is part of the currentPage or of its template
                if (StringUtils.startsWith(resource.getPath(), currentPage.getPath()) || (template != null && StringUtils.startsWith(resource.getPath(), template.getPath()))) {
                    return ComponentUtils.getFeaturedImage(currentPage);
                }
                return null;
            }).orElse(null);
        }
        Map<String, String> overriddenProperties = new HashMap<>();
        Map<String, Resource> overriddenChildren = new HashMap<>();
        String inheritedFileReference = null;
        Resource inheritedFileResource = null;
        String inheritedAlt = null;
        String inheritedAltValueFromDAM = null;
        if (inheritedResource != null) {
            // Define the inherited properties
            ValueMap inheritedProperties = inheritedResource.getValueMap();
            inheritedFileReference = inheritedProperties.get(DownloadResource.PN_REFERENCE, String.class);
            inheritedFileResource = inheritedResource.getChild(DownloadResource.NN_FILE);
            inheritedAlt = inheritedProperties.get(ImageResource.PN_ALT, String.class);
            inheritedAltValueFromDAM = inheritedProperties.get(PN_ALT_VALUE_FROM_DAM, String.class);
        }
        overriddenProperties.put(DownloadResource.PN_REFERENCE, inheritedFileReference);
        overriddenChildren.put(DownloadResource.NN_FILE, inheritedFileResource);
        // don't inherit the image title from the page image
        overriddenProperties.put(PN_TITLE_VALUE_FROM_DAM, "false");
        if (altValueFromPageImage) {
            overriddenProperties.put(ImageResource.PN_ALT, inheritedAlt);
            overriddenProperties.put(PN_ALT_VALUE_FROM_DAM, inheritedAltValueFromDAM);
        } else {
            overriddenProperties.put(PN_ALT_VALUE_FROM_DAM, "false");
        }
        return new CoreResourceWrapper(resource, resource.getResourceType(), null, overriddenProperties, overriddenChildren);
    }
    return resource;
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) ModelFactory(org.apache.sling.models.factory.ModelFactory) LinkHandler(com.adobe.cq.wcm.core.components.internal.link.LinkHandler) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) LoggerFactory(org.slf4j.LoggerFactory) AllowedComponentList(com.day.cq.wcm.foundation.AllowedComponentList) HashMap(java.util.HashMap) DownloadResource(com.day.cq.commons.DownloadResource) StringUtils(org.apache.commons.lang3.StringUtils) Page(com.day.cq.wcm.api.Page) SlingHttpServletRequest(org.apache.sling.api.SlingHttpServletRequest) HashSet(java.util.HashSet) JSONException(org.json.JSONException) Style(com.day.cq.wcm.api.designer.Style) JSONObject(org.json.JSONObject) Image(com.adobe.cq.wcm.core.components.models.Image) Map(java.util.Map) Link(com.adobe.cq.wcm.core.components.commons.link.Link) LinkedHashSet(java.util.LinkedHashSet) Logger(org.slf4j.Logger) ImmutableSet(com.google.common.collect.ImmutableSet) Designer(com.day.cq.wcm.api.designer.Designer) Collection(java.util.Collection) Set(java.util.Set) Resource(org.apache.sling.api.resource.Resource) ExperienceFragment(com.adobe.cq.wcm.core.components.models.ExperienceFragment) CoreResourceWrapper(com.adobe.cq.wcm.core.components.internal.resource.CoreResourceWrapper) ComponentUtils(com.adobe.cq.wcm.core.components.util.ComponentUtils) PageManager(com.day.cq.wcm.api.PageManager) Nullable(org.jetbrains.annotations.Nullable) Template(com.day.cq.wcm.api.Template) Optional(java.util.Optional) ImageResource(com.day.cq.commons.ImageResource) NotNull(org.jetbrains.annotations.NotNull) Teaser(com.adobe.cq.wcm.core.components.models.Teaser) Collections(java.util.Collections) HashMap(java.util.HashMap) ValueMap(org.apache.sling.api.resource.ValueMap) DownloadResource(com.day.cq.commons.DownloadResource) Resource(org.apache.sling.api.resource.Resource) ImageResource(com.day.cq.commons.ImageResource) CoreResourceWrapper(com.adobe.cq.wcm.core.components.internal.resource.CoreResourceWrapper) Page(com.day.cq.wcm.api.Page) Template(com.day.cq.wcm.api.Template) ComponentUtils(com.adobe.cq.wcm.core.components.util.ComponentUtils) Link(com.adobe.cq.wcm.core.components.commons.link.Link)

Example 39 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class LinkHandler method resolvePage.

/**
 * Attempts to resolve a Link URL and page for the given page. Redirect chains are followed, if
 * shadowing is not disabled.
 *
 * @param page Page
 * @return A pair of {@link String} and {@link Page} the page resolves to.
 */
@NotNull
private Pair<Page, String> resolvePage(@Nullable final Page page) {
    Page resolved = page;
    String redirectTarget = null;
    String linkURL = null;
    if (!isShadowingDisabled()) {
        Pair<Page, String> pair = resolveRedirects(page);
        resolved = pair.getLeft();
        redirectTarget = pair.getRight();
    }
    if (resolved == null) {
        if (StringUtils.isNotEmpty(redirectTarget)) {
            return new ImmutablePair<>(page, redirectTarget);
        } else {
            resolved = page;
        }
    }
    if (resolved != null) {
        linkURL = getPageLinkURL(resolved);
    }
    return new ImmutablePair<>(resolved, linkURL);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Page(com.day.cq.wcm.api.Page) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with StringUtils.isNotEmpty

use of org.apache.commons.lang3.StringUtils.isNotEmpty in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class AdaptiveImageServlet method doGet.

@Override
protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) throws IOException {
    Timer.Context requestDuration = metrics.startDurationRecording();
    try {
        metrics.markServletInvocation();
        RequestPathInfo requestPathInfo = request.getRequestPathInfo();
        List<String> selectorList = selectorToList(requestPathInfo.getSelectorString());
        String suffix = requestPathInfo.getSuffix();
        String imageName = StringUtils.isNotEmpty(suffix) ? FilenameUtils.getName(suffix) : "";
        if (StringUtils.isNotEmpty(suffix)) {
            String suffixExtension = FilenameUtils.getExtension(suffix);
            if (StringUtils.isNotEmpty(suffixExtension)) {
                if (!suffixExtension.equals(requestPathInfo.getExtension())) {
                    LOGGER.error("The suffix part defines a different extension than the request: {}.", suffix);
                    metrics.markImageErrors();
                    response.sendError(HttpServletResponse.SC_NOT_FOUND);
                    return;
                }
            } else {
                LOGGER.error("Invalid suffix: {}.", suffix);
                metrics.markImageErrors();
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
        }
        Resource component = request.getResource();
        ResourceResolver resourceResolver = request.getResourceResolver();
        if (!component.isResourceType(IMAGE_RESOURCE_TYPE)) {
            // image coming from template; need to switch resource
            Resource componentCandidate = null;
            PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
            if (pageManager != null) {
                Page page = pageManager.getContainingPage(component);
                if (page != null) {
                    Template template = page.getTemplate();
                    if (template != null) {
                        if (StringUtils.isNotEmpty(suffix)) {
                            long lastModifiedSuffix = getRequestLastModifiedSuffix(suffix);
                            String relativeTemplatePath = lastModifiedSuffix == 0 ? // no timestamp info, but extension is valid; get resource name
                            suffix.substring(0, suffix.lastIndexOf('.')) : // timestamp info, get parent path from suffix
                            suffix.substring(0, suffix.lastIndexOf("/" + String.valueOf(lastModifiedSuffix)));
                            String imagePath = ResourceUtil.normalize(template.getPath() + relativeTemplatePath);
                            if (StringUtils.isNotEmpty(imagePath) && !template.getPath().equals(imagePath)) {
                                componentCandidate = resourceResolver.getResource(imagePath);
                            }
                        }
                    }
                }
            }
            if (componentCandidate == null) {
                LOGGER.error("Unable to retrieve an image from this page's template.");
                metrics.markImageErrors();
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
            component = componentCandidate;
        }
        LinkHandler linkHandler = request.adaptTo(LinkHandler.class);
        Style currentStyle = WCMUtils.getStyle(request);
        Page currentPage = Optional.ofNullable(resourceResolver.adaptTo(PageManager.class)).map(pageManager -> pageManager.getContainingPage(request.getResource())).orElse(null);
        Resource wrappedImageResourceWithInheritance = getWrappedImageResourceWithInheritance(component, linkHandler, currentStyle, currentPage);
        ImageComponent imageComponent = new ImageComponent(wrappedImageResourceWithInheritance);
        if (imageComponent.source == Source.NOCONTENT || imageComponent.source == Source.NONEXISTING) {
            LOGGER.error("Either the image from {} does not have a valid file reference" + " or the containing page does not have a valid featured image", component.getPath());
            metrics.markImageErrors();
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
        ValueMap componentProperties = component.getValueMap();
        long lastModifiedEpoch = 0;
        Calendar lastModifiedDate = componentProperties.get(JcrConstants.JCR_LASTMODIFIED, Calendar.class);
        if (lastModifiedDate == null) {
            lastModifiedDate = componentProperties.get(NameConstants.PN_PAGE_LAST_MOD, Calendar.class);
        }
        if (lastModifiedDate != null) {
            lastModifiedEpoch = lastModifiedDate.getTimeInMillis();
        }
        Asset asset = null;
        if (imageComponent.source == Source.ASSET) {
            asset = imageComponent.imageResource.adaptTo(Asset.class);
            if (asset == null) {
                LOGGER.error("Unable to adapt resource {} used by image {} to an asset.", imageComponent.imageResource.getPath(), component.getPath());
                metrics.markImageErrors();
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
            long assetLastModifiedEpoch = asset.getLastModified();
            if (assetLastModifiedEpoch > lastModifiedEpoch) {
                lastModifiedEpoch = assetLastModifiedEpoch;
            }
        }
        long requestLastModifiedSuffix = getRequestLastModifiedSuffix(suffix);
        if (requestLastModifiedSuffix >= 0 && requestLastModifiedSuffix != lastModifiedEpoch) {
            String redirectLocation = getRedirectLocation(request, lastModifiedEpoch);
            if (StringUtils.isNotEmpty(redirectLocation)) {
                response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
                response.setHeader("Location", redirectLocation);
                return;
            } else {
                LOGGER.error("Unable to determine correct redirect location.");
                metrics.markImageErrors();
                response.setStatus(HttpServletResponse.SC_NOT_FOUND);
                return;
            }
        }
        if (!handleIfModifiedSinceHeader(request, response, lastModifiedEpoch)) {
            Map<String, Integer> transformationMap = getTransformationMap(selectorList, component);
            Integer jpegQualityInPercentage = transformationMap.get(SELECTOR_QUALITY_KEY);
            double quality = jpegQualityInPercentage / 100.0d;
            int resizeWidth = transformationMap.get(SELECTOR_WIDTH_KEY);
            String imageType = getImageType(requestPathInfo.getExtension());
            if (imageComponent.source == Source.FILE) {
                transformAndStreamFile(response, componentProperties, resizeWidth, quality, imageComponent.imageResource, imageType, imageName);
            } else if (imageComponent.source == Source.ASSET) {
                transformAndStreamAsset(response, componentProperties, resizeWidth, quality, asset, imageType, imageName);
            }
            metrics.markImageStreamed();
        }
    } catch (IllegalArgumentException e) {
        LOGGER.error("Invalid image request", e.getMessage());
        metrics.markImageErrors();
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    } finally {
        requestDuration.stop();
    }
}
Also used : ValueMap(org.apache.sling.api.resource.ValueMap) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) SortedSet(java.util.SortedSet) ResourceUtil(org.apache.sling.api.resource.ResourceUtil) ContentPolicyManager(com.day.cq.wcm.api.policies.ContentPolicyManager) LoggerFactory(org.slf4j.LoggerFactory) DownloadResource(com.day.cq.commons.DownloadResource) StringUtils(org.apache.commons.lang3.StringUtils) Page(com.day.cq.wcm.api.Page) Layer(com.day.image.Layer) SlingHttpServletRequest(org.apache.sling.api.SlingHttpServletRequest) WCMUtils(com.day.cq.wcm.commons.WCMUtils) Matcher(java.util.regex.Matcher) Image(com.adobe.cq.wcm.core.components.models.Image) CharEncoding(org.apache.commons.lang3.CharEncoding) Map(java.util.Map) MimeTypeService(org.apache.sling.commons.mime.MimeTypeService) Splitter(com.google.common.base.Splitter) JcrConstants(org.apache.jackrabbit.JcrConstants) BufferedImage(java.awt.image.BufferedImage) HttpConstants(org.apache.sling.api.servlets.HttpConstants) SlingHttpServletResponse(org.apache.sling.api.SlingHttpServletResponse) DamConstants(com.day.cq.dam.api.DamConstants) CoreResourceWrapper(com.adobe.cq.wcm.core.components.internal.resource.CoreResourceWrapper) PageManager(com.day.cq.wcm.api.PageManager) IOUtils(org.apache.commons.io.IOUtils) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) RequestPathInfo(org.apache.sling.api.request.RequestPathInfo) Optional(java.util.Optional) SlingSafeMethodsServlet(org.apache.sling.api.servlets.SlingSafeMethodsServlet) Pattern(java.util.regex.Pattern) NotNull(org.jetbrains.annotations.NotNull) FilenameUtils(org.apache.commons.io.FilenameUtils) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Utils.getWrappedImageResourceWithInheritance(com.adobe.cq.wcm.core.components.internal.Utils.getWrappedImageResourceWithInheritance) Joiner(com.google.common.base.Joiner) ComponentManager(com.day.cq.wcm.api.components.ComponentManager) LinkHandler(com.adobe.cq.wcm.core.components.internal.link.LinkHandler) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Style(com.day.cq.wcm.api.designer.Style) Calendar(java.util.Calendar) Lists(com.google.common.collect.Lists) WCMRenditionPicker(com.day.cq.wcm.foundation.WCMRenditionPicker) Timer(org.apache.sling.commons.metrics.Timer) Asset(com.day.cq.dam.api.Asset) Logger(org.slf4j.Logger) Rendition(com.day.cq.dam.api.Rendition) HttpServletResponse(javax.servlet.http.HttpServletResponse) Resource(org.apache.sling.api.resource.Resource) IOException(java.io.IOException) AbstractImageDelegatingModel(com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageDelegatingModel) java.awt(java.awt) URLEncoder(java.net.URLEncoder) Template(com.day.cq.wcm.api.Template) NameConstants(com.day.cq.wcm.api.NameConstants) Text(org.apache.jackrabbit.util.Text) AssetStore(com.day.cq.dam.api.handler.store.AssetStore) AssetHandler(com.day.cq.dam.api.handler.AssetHandler) ContentPolicy(com.day.cq.wcm.api.policies.ContentPolicy) ImageResource(com.day.cq.commons.ImageResource) Comparator(java.util.Comparator) InputStream(java.io.InputStream) ValueMap(org.apache.sling.api.resource.ValueMap) Calendar(java.util.Calendar) DownloadResource(com.day.cq.commons.DownloadResource) Resource(org.apache.sling.api.resource.Resource) ImageResource(com.day.cq.commons.ImageResource) Page(com.day.cq.wcm.api.Page) Template(com.day.cq.wcm.api.Template) RequestPathInfo(org.apache.sling.api.request.RequestPathInfo) PageManager(com.day.cq.wcm.api.PageManager) Timer(org.apache.sling.commons.metrics.Timer) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Style(com.day.cq.wcm.api.designer.Style) Asset(com.day.cq.dam.api.Asset) LinkHandler(com.adobe.cq.wcm.core.components.internal.link.LinkHandler)

Aggregations

StringUtils (org.apache.commons.lang3.StringUtils)42 List (java.util.List)31 Map (java.util.Map)28 Collectors (java.util.stream.Collectors)21 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)19 IOException (java.io.IOException)17 LoggerFactory (org.slf4j.LoggerFactory)15 Set (java.util.Set)14 Autowired (org.springframework.beans.factory.annotation.Autowired)14 Logger (org.slf4j.Logger)13 Collections (java.util.Collections)12 HashSet (java.util.HashSet)12 Optional (java.util.Optional)12 Arrays (java.util.Arrays)11 File (java.io.File)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 java.util (java.util)7 Collection (java.util.Collection)7 Pattern (java.util.regex.Pattern)7