GuidePanel.java
13.3 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.xss.XSSAPI
* com.day.cq.wcm.api.WCMMode
* javax.servlet.ServletRequest
* org.apache.commons.lang.StringUtils
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.resource.ModifiableValueMap
* org.apache.sling.api.resource.PersistenceException
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ResourceUtil
* org.apache.sling.api.resource.ValueMap
* org.slf4j.Logger
*/
package com.adobe.aemds.guide.common;
import com.adobe.aemds.guide.common.GuideItemsContainer;
import com.adobe.aemds.guide.taglibs.GuideELUtils;
import com.adobe.aemds.guide.utils.GuideConstants;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.adobe.granite.xss.XSSAPI;
import com.day.cq.wcm.api.WCMMode;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.api.resource.ValueMap;
import org.slf4j.Logger;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class GuidePanel
extends GuideItemsContainer
implements Serializable {
public int getMinOccur() {
return (Integer)this.resourceProps.get("minOccur", (Object)1);
}
public int getMaxOccur() {
return (Integer)this.resourceProps.get("maxOccur", (Object)1);
}
public int getInitialOccur() {
return (Integer)this.resourceProps.get("initialOccur", (Object)1);
}
public String getFragRefPropertyFromResource() {
return (String)this.resourceProps.get("fragRef", (Object)"");
}
public String getFragRef() {
String fragRefAssetPath = this.getFragRefPropertyFromResource();
String fragRefContainerPath = "";
String fragRefRootPanelPath = "";
if (fragRefAssetPath.length() > 0) {
fragRefContainerPath = GuideUtils.convertFMAssetPathToContainerPath(fragRefAssetPath);
Resource fragRefRootPanel = GuideUtils.getRootPanel(this.resource.getResourceResolver().getResource(fragRefContainerPath));
if (fragRefRootPanel != null) {
fragRefRootPanelPath = fragRefRootPanel.getPath();
}
}
return fragRefRootPanelPath;
}
public boolean isFragmentAvailable() {
String fragRefAssetPath = this.getFragRefPropertyFromResource();
ResourceResolver resourceResolver = this.resource.getResourceResolver();
Resource fragmentContainer = resourceResolver.getResource(fragRefAssetPath);
if (fragmentContainer != null) {
String fragRefContainerPath = GuideUtils.convertFMAssetPathToContainerPath(fragRefAssetPath);
Resource fragRefRootPanel = GuideUtils.getRootPanel(this.resource.getResourceResolver().getResource(fragRefContainerPath));
if (fragRefRootPanel != null) {
return true;
}
}
return false;
}
public Map<String, String> getFragmentDetails() {
ResourceResolver resourceResolver;
HashMap<String, String> fragDetails = new HashMap<String, String>();
String fragRef = this.getFragRef();
XSSAPI xssApi = this.getXssapi();
StringBuilder fragFieldDetails = new StringBuilder("");
if (fragRef.length() > 0 && (resourceResolver = this.getResource().getResourceResolver()) != null) {
Resource fragment = resourceResolver.getResource(fragRef.substring(0, fragRef.indexOf("guideContainer") - 1));
String title = (String)((ValueMap)fragment.adaptTo(ValueMap.class)).get((Object)"jcr:title");
fragDetails.put("title", GuideELUtils.encodeForHtml(title, xssApi));
Resource fragRefRootPanel = fragment.getChild("guideContainer").getChild("rootPanel");
if (fragRefRootPanel != null) {
int numberOfFieldsListed = 0;
for (Resource itemResource : fragRefRootPanel.getChild("items").getChildren()) {
ValueMap itemValueMap = ResourceUtil.getValueMap((Resource)itemResource);
String fieldLabel = (String)itemValueMap.get("jcr:title", (Object)"");
if (fieldLabel == null || fieldLabel.length() == 0) {
fieldLabel = (String)itemValueMap.get("name", (Object)"");
}
if (!StringUtils.isEmpty((String)fieldLabel)) {
GuideELUtils.encodeForHtml(fieldLabel, xssApi);
fragFieldDetails.append(fieldLabel).append("<br>");
}
if (++numberOfFieldsListed != GuideConstants.NO_OF_FIELDS_TO_DISPLAY_FOR_FRAG_PLACEHOLDER) continue;
break;
}
fragDetails.put("fieldDetails", fragFieldDetails.toString());
}
}
return fragDetails;
}
public String getOptimizeRenderPerformance() {
return (String)this.resourceProps.get("optimizeRenderPerformance", (Object)"");
}
public String getAssetRef() {
String fragRefAssetPath = this.getFragRefPropertyFromResource();
String optimizeRenderLayout = this.getOptimizeRenderPerformance();
if (StringUtils.isNotEmpty((String)fragRefAssetPath) && StringUtils.isNotEmpty((String)optimizeRenderLayout)) {
return fragRefAssetPath;
}
return null;
}
public String getLayoutFromFragRootPanel() {
Resource fragRefRootPanel;
Resource layout;
ResourceResolver resourceResolver;
String fragRef = this.getFragRef();
if (fragRef.length() > 0 && (fragRefRootPanel = (resourceResolver = this.resource.getResourceResolver()).getResource(fragRef)) != null && (layout = fragRefRootPanel.getChild("layout")) != null) {
return (String)((ValueMap)layout.adaptTo(ValueMap.class)).get((Object)"sling:resourceType");
}
return null;
}
public String getAfFragmentMarker() {
String afFragmentClass = "";
SlingHttpServletRequest request = this.slingRequest;
String fragRefAssetPath = this.getFragRefPropertyFromResource();
if (fragRefAssetPath.length() > 0 && WCMMode.EDIT.equals((Object)WCMMode.fromRequest((ServletRequest)request))) {
afFragmentClass = "afFragmentMarker";
}
return afFragmentClass;
}
@Override
public Map<String, Object> getAuthoringConfig() {
Map<String, Object> authoringConfig = super.getAuthoringConfig();
Boolean nonNavigable = Boolean.FALSE;
try {
nonNavigable = Boolean.valueOf((String)this.getLayoutProperty("nonNavigable"));
}
catch (PersistenceException e) {
this.logger.error("AF: Unable to fetch nonNavigable property" + e.getMessage(), (Throwable)e);
}
authoringConfig.put("nonNavigable", nonNavigable);
return authoringConfig;
}
public String getPanelInlineStyles() {
return this.getInlineStyles("Panel");
}
public String getPanelDescriptionInlineStyles() {
return this.getInlineStyles("PanelDescription");
}
@Override
public boolean getIsRepeatable() {
return this.getMinOccur() != 1 || this.getMaxOccur() != 1;
}
public boolean isHasToolbar() {
return this.resource.getChild("toolbar") != null;
}
public String getLongDescription() {
return this.externalize((String)this.resourceProps.get("longDescription", (Object)""));
}
public GuideItemsContainer getToolbar() {
Resource toolbarResource = this.resource.getChild("toolbar");
if (toolbarResource != null) {
GuideItemsContainer guideItemsContainer = new GuideItemsContainer();
guideItemsContainer.setResource(toolbarResource);
guideItemsContainer.setSlingRequest(this.slingRequest);
return guideItemsContainer;
}
return null;
}
public void updateCompletionAndSummary(Resource layoutNode) throws PersistenceException {
ModifiableValueMap layoutproperties = (ModifiableValueMap)layoutNode.adaptTo(ModifiableValueMap.class);
if (layoutproperties == null) {
return;
}
String layoutCmpPath = (String)layoutproperties.get((Object)"sling:resourceType");
if (layoutCmpPath != null) {
ResourceResolver resolver = this.resource.getResourceResolver();
Resource panel = layoutNode.getParent();
if (panel != null) {
Resource getChildrenResource = panel.getChild("items");
if (getChildrenResource != null) {
Iterator it = getChildrenResource.listChildren();
while (it.hasNext()) {
Resource child = (Resource)it.next();
ModifiableValueMap childMap = (ModifiableValueMap)child.adaptTo(ModifiableValueMap.class);
String guideNodeClass = (String)childMap.get("guideNodeClass", (Object)"");
if (!guideNodeClass.equals("rootPanelNode") && !guideNodeClass.equals("guidePanel")) continue;
String oldValue = (String)childMap.get("summaryExpVisible", (Object)"");
if (layoutCmpPath.equals("fd/af/layouts/panel/accordion")) {
if (oldValue.length() != 0 && oldValue.equals("yes")) continue;
childMap.put((Object)"summaryExpVisible", (Object)"yes");
continue;
}
if (oldValue.length() <= 0) continue;
childMap.remove((Object)"summaryExpVisible");
}
}
String wizardTabLayout = (String)layoutproperties.get((Object)"guideNavigatorTab");
ModifiableValueMap panelValueMap = (ModifiableValueMap)panel.adaptTo(ModifiableValueMap.class);
boolean compOldValue = (Boolean)panelValueMap.get("completionExpReq", (Object)false);
if ("wizard-tab".equals(wizardTabLayout)) {
if (!compOldValue) {
panelValueMap.put((Object)"completionExpReq", (Object)true);
}
} else if (compOldValue) {
panelValueMap.put((Object)"completionExpReq", (Object)false);
}
resolver.commit();
}
}
}
private void setLayoutProperties(Resource layoutNode) throws PersistenceException {
if (layoutNode != null) {
ResourceResolver resolver;
Resource layoutCmp;
ModifiableValueMap layoutproperties = (ModifiableValueMap)layoutNode.adaptTo(ModifiableValueMap.class);
if (layoutproperties == null) {
return;
}
String layoutCmpPath = (String)layoutproperties.get((Object)"sling:resourceType");
if (layoutCmpPath != null && (layoutCmp = (resolver = this.resource.getResourceResolver()).getResource(layoutCmpPath)) != null) {
String isNonNavigable;
String currentVal;
String currentIsNonNavigable;
Boolean currentEnableLayoutOptimization;
Boolean enableLayoutOptimization;
ValueMap layoutCmpProps = ResourceUtil.getValueMap((Resource)layoutCmp);
String tabType = (String)layoutCmpProps.get("guideNavigatorTab", (Object)"tab");
if (!StringUtils.equals((String)tabType, (String)(currentVal = (String)layoutproperties.get("guideNavigatorTab", (Object)"tab")))) {
layoutproperties.put((Object)"guideNavigatorTab", (Object)tabType);
}
if (!StringUtils.equals((String)(isNonNavigable = (String)layoutCmpProps.get("nonNavigable", (Object)"false")), (String)(currentIsNonNavigable = (String)layoutproperties.get("nonNavigable", (Object)"false")))) {
layoutproperties.put((Object)"nonNavigable", (Object)isNonNavigable);
}
if ((enableLayoutOptimization = (Boolean)layoutCmpProps.get("enableLayoutOptimization", (Object)false)) != (currentEnableLayoutOptimization = (Boolean)layoutproperties.get("enableLayoutOptimization", (Object)false))) {
layoutproperties.put((Object)"enableLayoutOptimization", (Object)enableLayoutOptimization);
}
resolver.commit();
}
}
}
@Override
public void setSlingRequest(SlingHttpServletRequest slingRequest) {
super.setSlingRequest(slingRequest);
Resource layout = this.resource.getChild("layout");
if (this.getIsEditMode().booleanValue() && layout != null) {
try {
this.setLayoutProperties(layout);
this.updateCompletionAndSummary(layout);
}
catch (PersistenceException e) {
this.logger.error("AF: Unable to set layout Properties" + e.getMessage(), (Throwable)e);
}
}
}
}