ProjectThumbnailProvider.java
1.92 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
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.cq.projects.api.Project
* com.day.cq.commons.thumbnail.ThumbnailProvider
* com.day.cq.dam.api.Asset
* com.day.cq.dam.api.Rendition
* com.day.cq.dam.commons.util.UIHelper
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
*/
package com.adobe.cq.projects.impl.servlet.image;
import com.adobe.cq.projects.api.Project;
import com.day.cq.commons.thumbnail.ThumbnailProvider;
import com.day.cq.dam.api.Asset;
import com.day.cq.dam.api.Rendition;
import com.day.cq.dam.commons.util.UIHelper;
import java.util.Map;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
@Component(metatype=0)
@Service
@Property(name="thumbnail.provider.name", value={"cq/gui/components/projects/admin/card/projectcard"})
public class ProjectThumbnailProvider
implements ThumbnailProvider {
private static String DEFAULT_PROJECT_ICON = "/libs/cq/ui/widgets/themes/default/icons/240x180/page.png";
public String getThumbnailPath(Resource resource, int width, int height, Map<String, Object> additionalConf) {
Asset asset;
Rendition rendition = null;
Project project = (Project)resource.adaptTo(Project.class);
Resource projectCover = project.getProjectCover();
if (projectCover != null && (asset = (Asset)projectCover.adaptTo(Asset.class)) != null) {
rendition = UIHelper.getBestfitRendition((Asset)asset, (int)width);
Rendition rendition2 = rendition = rendition == null ? asset.getOriginal() : rendition;
}
if (rendition == null) {
return DEFAULT_PROJECT_ICON;
}
return rendition.getPath();
}
}