GuideProgressiveDataCapture.java
5.17 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.cq.sightly.WCMUse
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.api.request.RequestParameter
* org.apache.sling.api.request.RequestParameterMap
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ValueMap
* org.apache.sling.api.scripting.SlingScriptHelper
*/
package com.adobe.aemds.guide.progressive;
import com.adobe.aemds.guide.common.GuideContainer;
import com.adobe.aemds.guide.service.GuideProgressiveStrategy;
import com.adobe.aemds.guide.service.GuideProgressiveStrategyManager;
import com.adobe.aemds.guide.taglibs.GuideELUtils;
import com.adobe.aemds.guide.utils.GuideProgressiveUtils;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.adobe.cq.sightly.WCMUse;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.request.RequestParameter;
import org.apache.sling.api.request.RequestParameterMap;
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;
public class GuideProgressiveDataCapture
extends WCMUse {
private static final String DEFAULT_HEIGHT = "400";
private static final String DEFAULT_WIDTH = "300";
private GuideContainer guideContainer;
private String allSectionJson = null;
private String afLocale;
private String afRuntimeLocale;
private String tmpRoot;
private Boolean enableAutoSave;
private Boolean addTestData = false;
public void activate() throws Exception {
Map<String, String> paramMap;
SlingHttpServletRequest request = this.getRequest();
RequestParameterMap requestParams = request.getRequestParameterMap();
if (GuideUtils.paramToString(requestParams.getValue("addTestData")) != null) {
this.addTestData = Boolean.valueOf(GuideUtils.paramToString(requestParams.getValue("addTestData")));
}
ValueMap properties = this.getProperties();
String type = (String)properties.get("guideStrategyType", (Object)"");
String progressiveStrategyName = (String)properties.get("strategyName", (Object)"");
if (progressiveStrategyName.length() == 0) {
progressiveStrategyName = (String)properties.get("guideStrategy", (Object)"");
}
String progressiveStrategyJcrPath = (String)properties.get("strategyJcrPath", (Object)"");
String progressiveStrategyParams = (String)properties.get("guideProgressiveStrategyParams", (Object)"");
if (progressiveStrategyParams.length() == 0) {
progressiveStrategyParams = (String)properties.get("guideStrategyParams", (Object)"");
}
if ((paramMap = GuideUtils.convertStringToMap(progressiveStrategyParams)).get("strategyJcrPath") == null) {
paramMap.put("strategyJcrPath", progressiveStrategyJcrPath);
}
String afAssetPath = (String)properties.get("guideRef", (Object)"");
String afResourcePath = GuideUtils.guideRefToGuidePath(afAssetPath);
Resource afResource = this.getResourceResolver().getResource(afResourcePath);
this.guideContainer = new GuideContainer(request, afResource);
this.afLocale = "guides.I18N." + GuideELUtils.getLocale(request, afResource);
this.afRuntimeLocale = GuideUtils.getGuideRuntimeLocale(request, afResource);
this.tmpRoot = UUID.randomUUID().toString();
this.enableAutoSave = (Boolean)properties.get("enableAutoSave", (Object)false);
if ("service".equals(type) && progressiveStrategyName.length() > 0) {
GuideProgressiveStrategyManager guideProgressiveStrategyManager = (GuideProgressiveStrategyManager)this.getSlingScriptHelper().getService(GuideProgressiveStrategyManager.class);
GuideProgressiveStrategy guideProgressiveStrategy = guideProgressiveStrategyManager.getGuideProgressiveStrategyService(progressiveStrategyName);
List<Object> allSections = guideProgressiveStrategy.getAllSections(paramMap);
this.allSectionJson = GuideProgressiveUtils.convertToJson(allSections);
}
}
public String getAllSectionsJson() {
return this.allSectionJson;
}
public String getProgressiveGuideInitializationState() {
if (this.addTestData.booleanValue()) {
return this.guideContainer.getGuideInitializationState();
}
return "";
}
public GuideContainer getGuideContainer() {
return this.guideContainer;
}
public String getAfLocale() {
return this.afLocale;
}
public String getAfRuntimeLocale() {
return this.afRuntimeLocale;
}
public String getTmpRoot() {
return this.tmpRoot;
}
public Boolean getEnableAutoSave() {
return this.enableAutoSave;
}
public String getHeight() {
return (String)this.getProperties().get("height", (Object)"400");
}
public String getWidth() {
return (String)this.getProperties().get("width", (Object)"300");
}
}