All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.common.GuideTextDraw 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.common;

import com.adobe.aemds.guide.utils.GuideConstants;
import com.adobe.aemds.guide.utils.GuideUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;

import java.util.Map;

/**
 * GuideTextDraw encapsulates basic properties of the Adaptive Form text draw Component.
 */
@Model(
        adaptables = SlingHttpServletRequest.class,
        adapters = GuideTextDraw.class)
public class GuideTextDraw extends GuideField {

    /**
     * Returns the field type of the adaptive forms Component
     * @return String representing guide field type
     */
    public String getGuideFieldType(){
        return GuideConstants.GUIDE_FIELD_TEXTDRAW;
    }

    /**
     * Gets the externalized string configured for text draw component
     * @return value of the text draw component
     */
    public String getValue(){
        String value = resourceProps.get("_value", String.class);
        return externalize(GuideUtils.filterHtml(value, getXssapi()));
    }

    @Override
    public Map getAuthoringConfig(){
        Map authoringConfig = super.getAuthoringConfig();
        Resource items = this.getResource().getChild("items");
        if (items != null) {
            if (items.hasChildren()) {
                Iterable children = items.getChildren();
                for (Resource child : children) {
                    GuideUtils.setMasterAuthoringConfig(authoringConfig, child.getValueMap());
                }
            }
        }
        return  authoringConfig;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy