RenditionImpl.java
2.37 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.asset.api.Rendition
* com.day.cq.dam.api.Asset
* com.day.cq.dam.api.Rendition
* com.day.cq.dam.commons.util.DamUtil
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ResourceUtil
* org.apache.sling.api.resource.ResourceWrapper
* org.apache.sling.api.resource.ValueMap
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.day.cq.dam.core.impl;
import com.day.cq.dam.api.Asset;
import com.day.cq.dam.api.Rendition;
import com.day.cq.dam.commons.util.DamUtil;
import java.io.InputStream;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ResourceWrapper;
import org.apache.sling.api.resource.ValueMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RenditionImpl
extends ResourceWrapper
implements Rendition {
private static final Logger log = LoggerFactory.getLogger(Rendition.class);
private final ValueMap properties;
private final com.adobe.granite.asset.api.Rendition graniteRendition;
public RenditionImpl(Resource resource) {
super(resource);
this.graniteRendition = (com.adobe.granite.asset.api.Rendition)resource.adaptTo(com.adobe.granite.asset.api.Rendition.class);
Resource content = resource.getResourceResolver().getResource(resource, "jcr:content");
this.properties = ResourceUtil.getValueMap((Resource)content);
}
public String getMimeType() {
return this.graniteRendition.getMimeType();
}
public String getName() {
return ResourceUtil.getName((String)this.getPath());
}
public ValueMap getProperties() {
return this.properties;
}
public InputStream getStream() {
return this.graniteRendition.getStream();
}
public Asset getAsset() {
return DamUtil.resolveToAsset((Resource)this.getResource());
}
public long getSize() {
return this.graniteRendition.getSize();
}
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
if (type == Resource.class) {
return (AdapterType)this.getResource();
}
return (AdapterType)super.adaptTo(type);
}
}