PageResource.java 1.31 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ValueMap
 */
package com.adobe.cq.rest.content.impl;

import com.adobe.cq.rest.content.impl.AbstractPageResource;
import com.adobe.cq.rest.content.impl.PageValueMapDecorator;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;

public class PageResource
extends AbstractPageResource {
    public static final String RESOURCE_TYPE = "mac/rest/content/page";
    private final ValueMap valueMap;

    public PageResource(Resource resource, String path) {
        ValueMap base;
        super(resource, path);
        Resource metadata = resource;
        if (resource.getChild("jcr:content") != null) {
            metadata = resource.getChild("jcr:content");
        }
        this.valueMap = (base = (ValueMap)metadata.adaptTo(ValueMap.class)) != null ? new PageValueMapDecorator(metadata, base, new String[0]) : ValueMap.EMPTY;
    }

    public String getResourceType() {
        return "mac/rest/content/page";
    }

    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
        if (type == ValueMap.class) {
            return (AdapterType)this.valueMap;
        }
        return (AdapterType)super.adaptTo(type);
    }
}