MobileHtmlPostResponseCreator.java
2.12 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.ui.components.HtmlResponse
* com.adobe.granite.xss.XSSAPI
* com.day.cq.i18n.I18n
* javax.servlet.http.HttpServletRequest
* org.apache.commons.lang.StringUtils
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.SlingHttpServletRequest
* org.apache.sling.servlets.post.PostResponse
* org.apache.sling.servlets.post.PostResponseCreator
*/
package com.adobe.cq.mobile.platform.impl.operations;
import com.adobe.granite.ui.components.HtmlResponse;
import com.adobe.granite.xss.XSSAPI;
import com.day.cq.i18n.I18n;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.servlets.post.PostResponse;
import org.apache.sling.servlets.post.PostResponseCreator;
@Component(metatype=0, label="Mobile's HTML Post Response Creator", description="Returns a com.adobe.granite.ui.components.HtmlResponse for any PostOperation namespace under mobileapps:")
@Service(value={PostResponseCreator.class})
public class MobileHtmlPostResponseCreator
implements PostResponseCreator {
@Reference
protected XSSAPI xssAPI;
public PostResponse createPostResponse(SlingHttpServletRequest req) {
String operation = req.getParameter(":operation");
if (StringUtils.isNotBlank((String)operation) && StringUtils.startsWith((String)operation, (String)"mobileapps:")) {
I18n i18n = new I18n((HttpServletRequest)req);
return new HtmlResponse(this.xssAPI, i18n, req.getLocale());
}
return null;
}
protected void bindXssAPI(XSSAPI xSSAPI) {
this.xssAPI = xSSAPI;
}
protected void unbindXssAPI(XSSAPI xSSAPI) {
if (this.xssAPI == xSSAPI) {
this.xssAPI = null;
}
}
}