FolderPreviewResourceProviderImpl.java 1.34 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.cq.commerce.api.Product
 *  com.day.cq.commons.ImageResource
 *  com.day.cq.commons.folderpreview.FolderPreviewResourceProvider
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 */
package com.adobe.cq.commerce.pim.impl;

import com.adobe.cq.commerce.api.Product;
import com.day.cq.commons.ImageResource;
import com.day.cq.commons.folderpreview.FolderPreviewResourceProvider;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;

@Component(metatype=0)
@Service
public class FolderPreviewResourceProviderImpl
implements FolderPreviewResourceProvider {
    public Resource getPreviewResource(Resource folderChild) {
        ImageResource image;
        String imageReference;
        Product product = (Product)folderChild.adaptTo(Product.class);
        if (product != null && (image = product.getImage()) != null && (imageReference = image.getFileReference()) != null) {
            return folderChild.getResourceResolver().getResource(imageReference);
        }
        return null;
    }
}