RenditionUtils.java
2.35 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
51
52
53
54
55
56
57
58
59
60
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.asset.api.AssetException
* com.adobe.granite.asset.api.RenditionHandler
* javax.jcr.RepositoryException
* org.apache.commons.lang.StringUtils
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ValueMap
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.granite.asset.core.impl;
import com.adobe.granite.asset.api.AssetException;
import com.adobe.granite.asset.api.RenditionHandler;
import com.adobe.granite.asset.core.impl.RHWhiteBoard;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public final class RenditionUtils {
private static final Logger log = LoggerFactory.getLogger(RenditionUtils.class);
public static String getRenditionHandlerId(Map<String, Object> map, String defaultId) {
String handlerId = (String)map.get("rendition.handler.id");
return StringUtils.isNotEmpty((String)handlerId) ? handlerId : defaultId;
}
public static String getRenditionHandlerId(Resource rendition, String defaultId) {
Resource contentResource = rendition.getChild("jcr:content");
String handlerId = null;
if (contentResource != null && (handlerId = (String)((ValueMap)contentResource.adaptTo(ValueMap.class)).get("rendition.handler.id", String.class)) == null) {
log.debug("Rendition Handler property does not exist: {}", (Object)rendition.getPath());
}
return StringUtils.isNotEmpty((String)handlerId) ? handlerId : defaultId;
}
public static RenditionHandler getRenditionHandler(String handlerId) {
RenditionHandler rh = RHWhiteBoard.getRenditionHandler(handlerId);
if (rh == null) {
throw new AssetException("No Rendition Handler is registered with id [" + handlerId + "]");
}
return rh;
}
public static boolean isRendition(Resource resource) throws RepositoryException {
Resource parent = resource.getParent();
return parent != null && parent.getName().equals("renditions");
}
}