MobileAbstractOperation.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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.granite.ui.components.HtmlResponse
* com.adobe.granite.xss.XSSAPI
* javax.jcr.RepositoryException
* 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.AbstractPostOperation
* org.apache.sling.servlets.post.Modification
* org.apache.sling.servlets.post.PostResponse
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.mobile.platform.impl.operations;
import com.adobe.cq.mobile.appcache.impl.AppCacheManagerAdapterFactory;
import com.adobe.granite.ui.components.HtmlResponse;
import com.adobe.granite.xss.XSSAPI;
import java.util.List;
import javax.jcr.RepositoryException;
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.AbstractPostOperation;
import org.apache.sling.servlets.post.Modification;
import org.apache.sling.servlets.post.PostResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0, label="Mobile Abstract Operation")
@Service
public abstract class MobileAbstractOperation
extends AbstractPostOperation {
@Reference
protected XSSAPI xssAPI;
@Reference
protected AppCacheManagerAdapterFactory appCacheManagerAdapterFactory;
public static final String NS_MOBILE = "mobileapps:";
public static final Logger LOGGER = LoggerFactory.getLogger(MobileAbstractOperation.class);
protected void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes) throws RepositoryException {
this.perform(request, (HtmlResponse)response, changes);
}
protected abstract void perform(SlingHttpServletRequest var1, HtmlResponse var2, List<Modification> var3);
protected void generateResponse(HtmlResponse response, int statusCode, String message, String title, String redirectLink, String linkTitle) {
response.setStatus(statusCode, message);
response.setTitle(title);
response.setDescription(message);
if (StringUtils.isNotBlank((String)redirectLink)) {
response.addRedirectLink(redirectLink, linkTitle);
}
}
protected void addLink(HtmlResponse response, String rel, String url, String title) {
response.addLink(rel, url, title);
}
protected void generateResponse(HtmlResponse response, int statusCode, String message, String title) {
this.generateResponse(response, statusCode, message, title, null, null);
}
protected void generateError(HtmlResponse response, String message, String title) {
this.generateError(response, message, title, null);
}
protected void generateError(HtmlResponse response, String message, String title, Throwable exception) {
if (exception == null) {
LOGGER.error(title + ":" + message);
} else {
LOGGER.error(title + ":" + message, exception);
}
this.generateResponse(response, 500, message, title);
}
protected void generateError(HtmlResponse response, String message, String title, Throwable exception, String redirect, String redirectTitle) {
if (exception == null) {
LOGGER.error(title + ":" + message);
} else {
LOGGER.error(title + ":" + message, exception);
}
this.generateResponse(response, 500, message, title, redirect, redirectTitle);
}
protected String getRedirect(SlingHttpServletRequest request) {
return request.getParameter("redirectTo");
}
protected void bindXssAPI(XSSAPI xSSAPI) {
this.xssAPI = xSSAPI;
}
protected void unbindXssAPI(XSSAPI xSSAPI) {
if (this.xssAPI == xSSAPI) {
this.xssAPI = null;
}
}
protected void bindAppCacheManagerAdapterFactory(AppCacheManagerAdapterFactory appCacheManagerAdapterFactory) {
this.appCacheManagerAdapterFactory = appCacheManagerAdapterFactory;
}
protected void unbindAppCacheManagerAdapterFactory(AppCacheManagerAdapterFactory appCacheManagerAdapterFactory) {
if (this.appCacheManagerAdapterFactory == appCacheManagerAdapterFactory) {
this.appCacheManagerAdapterFactory = null;
}
}
}