FolderPreviewResourceProviderImpl.java
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
* 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;
}
}