CommentResource.java
1.78 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.rest.utils.DeepModifiableValueMapDecorator
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ValueMap
*/
package com.adobe.granite.rest.assets.impl;
import com.adobe.granite.rest.assets.impl.AbstractAssetResource;
import com.adobe.granite.rest.assets.impl.AttachmentResource;
import com.adobe.granite.rest.utils.DeepModifiableValueMapDecorator;
import java.util.Map;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
public class CommentResource
extends AbstractAssetResource {
public static final String RESOURCE_TYPE = "granite/rest/assets/comment";
private ValueMap valueMap;
public CommentResource(Resource resource, String path) {
super(resource, path);
ValueMap base = (ValueMap)resource.adaptTo(ValueMap.class);
this.valueMap = new DeepModifiableValueMapDecorator((Resource)this, (Map)base);
}
public String getResourceType() {
return "granite/rest/assets/comment";
}
public AttachmentResource getAttachment(String name) {
ResourceResolver resolver = this.resource.getResourceResolver();
Resource attachmentResource = resolver.getResource(this.resource, name);
if (attachmentResource != null) {
return new AttachmentResource(attachmentResource, this.getPath() + "/" + name);
}
return null;
}
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
if (type == ValueMap.class) {
return (AdapterType)this.valueMap;
}
return (AdapterType)super.adaptTo(type);
}
}