GuideProgressiveDataCapture.java 5.17 KB
/*
 * 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");
    }
}