AEMForm.java
4.5 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
/*
* 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.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ValueMap
*/
package com.adobe.aemds.guide.common;
import com.adobe.aemds.guide.service.GuideException;
import com.adobe.cq.sightly.WCMUse;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
public class AEMForm
extends WCMUse {
public static final int NO_FORM_SELECTED = -1;
public static final int MOBILE_FORM = 1;
public static final int ADAPTIVE_FORM = 2;
public static final int MOBILE_FORMSET = 3;
public static final int INLINE_SUBMIT = 4;
public static final int PAGE_REFRESH_SUBMIT = 5;
private static final int THANKYOU_PAGE = 6;
private static final int THANKYOU_MESSAGE = 7;
protected Resource mResource;
protected ValueMap mResourceProps;
public void activate() throws Exception {
this.mResource = this.getResource();
this.mResourceProps = this.getProperties();
SlingHttpServletRequest request = this.getRequest();
request.setAttribute("formContainerPath", (Object)this.mResource.getPath());
}
protected String getClientLibCategory(String themePath) {
if ("".equals(themePath)) {
return "";
}
Resource themeResource = this.getResource().getResourceResolver().getResource(themePath + "/jcr:content/metadata");
if (themeResource == null) {
throw new GuideException("Invalid Theme Name " + themePath);
}
ValueMap themeProps = themeResource.getValueMap();
return (String)themeProps.get("clientlibCategory", (Object)"");
}
public String getThemeName() {
return this.getClientLibCategory(this.getThemeRef());
}
public String getFormPath() {
return (String)this.mResourceProps.get("formRef", (Object)"");
}
protected String getThemeRef() {
return (String)this.mResourceProps.get("themeRef", (Object)"");
}
public String getFormEditPagePath() {
return this.getFormPath();
}
public int getFormType() {
if ("".equals(this.getFormPath())) {
return -1;
}
ResourceResolver resolver = this.mResource.getResourceResolver();
Resource formResource = resolver.getResource(this.getFormPath());
if (formResource == null) {
throw new GuideException("Invalid Form Path set");
}
Resource jcrContent = formResource.getChild("jcr:content");
if (jcrContent == null) {
throw new GuideException("Invalid Form Path set. No jcr:content node inside Form");
}
ValueMap props = jcrContent.getValueMap();
if ((Integer)props.get("guide", (Object)0) == 1 || (Integer)props.get("adaptivedocument", (Object)0) == 1) {
return 2;
}
return 1;
}
public boolean getIsAdaptiveForm() {
return this.getFormType() == 2;
}
public boolean getIsMobileForm() {
return this.getFormType() == 1;
}
public boolean getIsMobileFormset() {
return this.getFormType() == 3;
}
public boolean getIsFormSelected() {
return this.getFormType() != -1;
}
public String getSubmitType() {
if ("message".equals(this.getThankyouConfig())) {
return "inline";
}
return (String)this.mResourceProps.get("submitType", (Object)"inline");
}
public String getThankyouMessage() {
return (String)this.mResourceProps.get("thankyouMessage", (Object)"");
}
public String getThankyouPage() {
return (String)this.mResourceProps.get("thankyouPage", (Object)"");
}
public String getThankyouConfig() {
return (String)this.mResourceProps.get("thankyouConfig", (Object)"page");
}
public String getHeight() {
String height = (String)this.mResourceProps.get("height", (Object)"auto");
if (!"auto".equals(height)) {
try {
height = "" + Integer.parseInt(height) + "px";
}
catch (NumberFormatException ex) {
height = "auto";
}
}
return height;
}
public String getCssClientlib() {
return (String)this.mResourceProps.get("cssClientlib", (Object)"");
}
}