TemplateInfoProvider.java 1.87 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.wcm.api.Page
 *  com.day.cq.wcm.api.PageInfoProvider
 *  com.day.cq.wcm.api.Template
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.api.SlingHttpServletRequest
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ValueMap
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.JSONObject
 */
package com.day.cq.wcm.core.impl;

import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageInfoProvider;
import com.day.cq.wcm.api.Template;
import com.day.cq.wcm.core.impl.TemplateUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;

@Component(metatype=0)
@Property(name="service.description", value={"Export meta data related to a page under an authored template"})
@Service(value={PageInfoProvider.class})
public class TemplateInfoProvider
implements PageInfoProvider {
    public void updatePageInfo(SlingHttpServletRequest request, JSONObject info, Resource resource) throws JSONException {
        Template template;
        Page page = (Page)resource.adaptTo(Page.class);
        if (page != null && (template = page.getTemplate()) != null && template.hasStructureSupport() && TemplateUtils.isPageOfAuthoredTemplate(page)) {
            info.put("title", (Object)template.getTitle());
            info.put("templateStatus", template.getProperties().get("status", String.class));
        }
    }
}