CommentResource.java 1.78 KB
/*
 * 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);
    }
}