WCMUse.java
3.92 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* aQute.bnd.annotation.ConsumerType
* com.day.cq.wcm.api.Page
* com.day.cq.wcm.api.PageManager
* com.day.cq.wcm.api.components.Component
* com.day.cq.wcm.api.designer.Design
* com.day.cq.wcm.api.designer.Designer
* com.day.cq.wcm.api.designer.Style
* io.sightly.java.api.Use
* 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.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.sightly;
import aQute.bnd.annotation.ConsumerType;
import com.adobe.cq.sightly.SightlyWCMMode;
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.designer.Design;
import com.day.cq.wcm.api.designer.Designer;
import com.day.cq.wcm.api.designer.Style;
import io.sightly.java.api.Use;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.Bindings;
@Deprecated
@ConsumerType
public abstract class WCMUse
implements Use {
private static final Logger LOG = LoggerFactory.getLogger(WCMUse.class);
private Bindings bindings;
public 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 <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 SightlyWCMMode getWcmMode() {
return this.get("wcmmode", SightlyWCMMode.class);
}
public PageManager getPageManager() {
return this.get("pageManager", PageManager.class);
}
public Page getCurrentPage() {
return this.get("currentPage", Page.class);
}
public Page getResourcePage() {
return this.get("resourcePage", Page.class);
}
public ValueMap getPageProperties() {
return this.get("pageProperties", ValueMap.class);
}
public ValueMap getProperties() {
return this.get("properties", ValueMap.class);
}
public Designer getDesigner() {
return this.get("designer", Designer.class);
}
public Design getCurrentDesign() {
return this.get("currentDesign", Design.class);
}
public Style getCurrentStyle() {
return this.get("currentStyle", Style.class);
}
public Component getComponent() {
return this.get("component", Component.class);
}
public ValueMap getInheritedProperties() {
return this.get("inheritedPageProperties", ValueMap.class);
}
public Resource getResource() {
return this.get("resource", Resource.class);
}
public ResourceResolver getResourceResolver() {
return this.getRequest().getResourceResolver();
}
public SlingHttpServletRequest getRequest() {
return this.get("request", SlingHttpServletRequest.class);
}
public SlingHttpServletResponse getResponse() {
return this.get("response", SlingHttpServletResponse.class);
}
public SlingScriptHelper getSlingScriptHelper() {
return this.get("sling", SlingScriptHelper.class);
}
}