WCMUsePojo.java
7.58 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* aQute.bnd.annotation.ConsumerType
* com.adobe.granite.xss.XSSAPI
* com.day.cq.wcm.api.Page
* com.day.cq.wcm.api.PageManager
* com.day.cq.wcm.api.components.Component
* com.day.cq.wcm.api.components.ComponentContext
* com.day.cq.wcm.api.components.EditContext
* com.day.cq.wcm.api.designer.Design
* com.day.cq.wcm.api.designer.Designer
* com.day.cq.wcm.api.designer.Style
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.SlingHttpServletResponse
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ValueMap
* org.apache.sling.api.scripting.SlingScriptHelper
* org.apache.sling.scripting.sightly.pojo.Use
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.sightly;
import aQute.bnd.annotation.ConsumerType;
import com.adobe.cq.sightly.SightlyWCMMode;
import com.adobe.granite.xss.XSSAPI;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageManager;
import com.day.cq.wcm.api.components.Component;
import com.day.cq.wcm.api.components.ComponentContext;
import com.day.cq.wcm.api.components.EditContext;
import com.day.cq.wcm.api.designer.Design;
import com.day.cq.wcm.api.designer.Designer;
import com.day.cq.wcm.api.designer.Style;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.scripting.SlingScriptHelper;
import org.apache.sling.scripting.sightly.pojo.Use;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.Bindings;
@ConsumerType
public abstract class WCMUsePojo
implements Use {
private static final Logger LOG = LoggerFactory.getLogger(WCMUsePojo.class);
private Bindings bindings;
private SightlyWCMMode wcmMode;
private PageManager pageManager;
private Page currentPage;
private Page resourcePage;
private ValueMap pageProperties;
private ValueMap properties;
private Designer designer;
private Design currentDesign;
private Style currentStyle;
private Component component;
private ValueMap inheritedProperties;
private Resource resource;
private ResourceResolver resourceResolver;
private SlingHttpServletRequest slingHttpServletRequest;
private SlingHttpServletResponse slingHttpServletResponse;
private SlingScriptHelper slingScriptHelper;
private ComponentContext componentContext;
private EditContext editContext;
private Design resourceDesign;
private XSSAPI xssapi;
public final void init(Bindings scriptBindings) {
this.bindings = scriptBindings;
try {
this.activate();
}
catch (Exception e) {
LOG.error("Failed to activate Use class", (Throwable)e);
}
}
public abstract void activate() throws Exception;
public final <T> T get(String name, Class<T> type) {
Object obj = this.bindings.get(name);
try {
return type.cast(obj);
}
catch (ClassCastException e) {
LOG.error("Failed to cast value", (Throwable)e);
return null;
}
}
public final SightlyWCMMode getWcmMode() {
if (this.wcmMode == null) {
this.wcmMode = this.get("wcmmode", SightlyWCMMode.class);
}
return this.wcmMode;
}
public final PageManager getPageManager() {
if (this.pageManager == null) {
this.pageManager = this.get("pageManager", PageManager.class);
}
return this.pageManager;
}
public final Page getCurrentPage() {
if (this.currentPage == null) {
this.currentPage = this.get("currentPage", Page.class);
}
return this.currentPage;
}
public final Page getResourcePage() {
if (this.resourcePage == null) {
this.resourcePage = this.get("resourcePage", Page.class);
}
return this.resourcePage;
}
public final ValueMap getPageProperties() {
if (this.pageProperties == null) {
this.pageProperties = this.get("pageProperties", ValueMap.class);
}
return this.pageProperties;
}
public final ValueMap getProperties() {
if (this.properties == null) {
this.properties = this.get("properties", ValueMap.class);
}
return this.properties;
}
public final Designer getDesigner() {
if (this.designer == null) {
this.designer = this.get("designer", Designer.class);
}
return this.designer;
}
public final Design getCurrentDesign() {
if (this.currentDesign == null) {
this.currentDesign = this.get("currentDesign", Design.class);
}
return this.currentDesign;
}
public final Style getCurrentStyle() {
if (this.currentStyle == null) {
this.currentStyle = this.get("currentStyle", Style.class);
}
return this.currentStyle;
}
public final Component getComponent() {
if (this.component == null) {
this.component = this.get("component", Component.class);
}
return this.component;
}
public final ValueMap getInheritedProperties() {
if (this.inheritedProperties == null) {
this.inheritedProperties = this.get("inheritedPageProperties", ValueMap.class);
}
return this.inheritedProperties;
}
public final Resource getResource() {
if (this.resource == null) {
this.resource = this.get("resource", Resource.class);
}
return this.resource;
}
public final ResourceResolver getResourceResolver() {
if (this.resourceResolver == null) {
this.resourceResolver = this.getRequest().getResourceResolver();
}
return this.resourceResolver;
}
public final SlingHttpServletRequest getRequest() {
if (this.slingHttpServletRequest == null) {
this.slingHttpServletRequest = this.get("request", SlingHttpServletRequest.class);
}
return this.slingHttpServletRequest;
}
public final SlingHttpServletResponse getResponse() {
if (this.slingHttpServletResponse == null) {
this.slingHttpServletResponse = this.get("response", SlingHttpServletResponse.class);
}
return this.slingHttpServletResponse;
}
public final SlingScriptHelper getSlingScriptHelper() {
if (this.slingScriptHelper == null) {
this.slingScriptHelper = this.get("sling", SlingScriptHelper.class);
}
return this.slingScriptHelper;
}
public final ComponentContext getComponentContext() {
if (this.componentContext == null) {
this.componentContext = this.get("componentContext", ComponentContext.class);
}
return this.componentContext;
}
public final EditContext getEditContext() {
if (this.editContext == null) {
this.editContext = this.get("editContext", EditContext.class);
}
return this.editContext;
}
public final Design getResourceDesign() {
if (this.resourceDesign == null) {
this.resourceDesign = this.get("resourceDesign", Design.class);
}
return this.resourceDesign;
}
public final XSSAPI getXSSAPI() {
if (this.xssapi == null) {
this.xssapi = this.get("xssAPI", XSSAPI.class);
}
return this.xssapi;
}
}