TemplateInfoProvider.java
1.87 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
/*
* 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));
}
}
}