
com.adobe.aemds.guide.progressive.GuideProgressiveDataCapture Maven / Gradle / Ivy
/************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2014 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*************************************************************************/
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.utils.GuideConstants;
import com.adobe.aemds.guide.utils.GuideProgressiveUtils;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.adobe.cq.sightly.WCMUsePojo;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.request.RequestParameterMap;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import java.util.*;
public class GuideProgressiveDataCapture extends WCMUsePojo {
private static final String DEFAULT_HEIGHT = "400";
private static final String DEFAULT_WIDTH = "300";
private GuideContainer guideContainer;
// This would be available only if the type of section is static
private String allSectionJson = null;
/** Locale specific clientlib to be used while rendering progressive data capture */
private String afLocale;
/** Locale used for caching of adaptive form at server */
private String afRuntimeLocale;
/** Used for file upload operations */
private String tmpRoot;
/**
* Used for indicating whether autoSave is enabled or not
*/
private Boolean enableAutoSave;
private Boolean addTestData = false;
@Override
public void activate() throws Exception {
SlingHttpServletRequest request = getRequest();
RequestParameterMap requestParams = request.getRequestParameterMap();
if(GuideUtils.paramToString(requestParams.getValue("addTestData")) != null) {
addTestData = Boolean.valueOf(GuideUtils.paramToString(requestParams.getValue("addTestData")));
}
ValueMap properties = getProperties();
// Get the service type
String type = properties.get(GuideConstants.GUIDE_PROGRESSIVE_STRATEGY_TYPE, "");
// Get the name of the service, so that we can ask the manager about this
String progressiveStrategyName = properties.get(GuideConstants.GUIDE_PROGRESSIVE_STRATEGY_NAME, "");
// if we don't find progressive strategy name fallback use case
if(progressiveStrategyName.length() == 0){
progressiveStrategyName = properties.get("guideStrategy", "");
}
String progressiveStrategyJcrPath = properties.get(GuideConstants.GUIDE_PROGRESSIVE_STRATEGY_JCR_PATH, "");
// Get the service params
String progressiveStrategyParams = properties.get(GuideConstants.GUIDE_PROGRESSIVE_STRATEGY_PARAMS, "");
// if we don't find progressive strategy name fallback use case
if(progressiveStrategyParams.length() == 0){
progressiveStrategyParams = properties.get("guideStrategyParams", "");
}
Map paramMap = GuideUtils.convertStringToMap(progressiveStrategyParams);
// fallback use case
if(paramMap.get(GuideConstants.GUIDE_PROGRESSIVE_STRATEGY_JCR_PATH) == null) {
paramMap.put(GuideConstants.GUIDE_PROGRESSIVE_STRATEGY_JCR_PATH,progressiveStrategyJcrPath);
}
// Other configuration
String afAssetPath = properties.get(GuideConstants.GUIDE_PROGRESSIVE_REF, "");
String afResourcePath = GuideUtils.guideRefToGuidePath(afAssetPath);
Resource afResource = getResourceResolver().getResource(afResourcePath);
guideContainer = GuideContainer.from(request, afResource);
afLocale = "guides.I18N." + GuideUtils.getLocale(request, afResource);
afRuntimeLocale = GuideUtils.getGuideRuntimeLocale(request, afResource);
tmpRoot = UUID.randomUUID().toString();
enableAutoSave = properties.get(GuideConstants.ENABLE_AUTO_SAVE, false);
// If it is service, use that service to get all the section
// todo: would fetchFromService impact here ?
if ("service".equals(type) && progressiveStrategyName.length() > 0) {
GuideProgressiveStrategyManager guideProgressiveStrategyManager = getSlingScriptHelper().getService(GuideProgressiveStrategyManager.class);
GuideProgressiveStrategy guideProgressiveStrategy = guideProgressiveStrategyManager.getGuideProgressiveStrategyService(progressiveStrategyName);
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy