MobileHtmlPostResponseCreator.java 2.12 KB
/*
 * 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;
        }
    }
}