// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/servlet/AdaptiveImageConfig.java
// @Service(value = AdaptiveImageConfig.class)
// @Component(label = "ironsites - Adaptive Image Configurations",
//     description = "Adaptive Image width support configurations",
//     immediate = true)
// public class AdaptiveImageConfig {
//     // statics
//     private static final Logger LOG = LoggerFactory.getLogger(AdaptiveImageConfig.class);
//     private static final String ADAPTIVEIMAGE_SERVLET = "com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet";
//     
//     // services
//     @Reference 
//     private ConfigurationAdmin configAdmin;
// 
//     // locals
//     private List<Integer> widths = null;
//     
//     // properties
//     @Property(label = "Additional Supported Widths",
//             description = "In addition Adobe CQ Adaptive Image Component Servlet dimensions",
//             value = {
//             "320", // iPhone 1 portrait
//             "420",
//             "480", // iPhone 1 landscape
//             "620", // iPad 1 landscape
//             "640",
//             "768",
//             "800",
//             "992",
//             "1024",
//             "1200",
//             "1280",
//             "1400",
//             "1440",
//             "1920" })
//     private static final String PN_SUPPORTED_WIDTHS = "adapt.supported.widths";
// 
//     @Activate
//     protected void activate(ComponentContext componentContext) {
//         Configuration config = null;
//         Dictionary<?, ?> parentProperties = null;
//         Dictionary<?, ?> properties = componentContext.getProperties();
//         // acquire parent servlet properties
//         try {
//             config = (Configuration) configAdmin.getConfiguration(ADAPTIVEIMAGE_SERVLET);
//             parentProperties = config.getProperties();
//         } catch (IOException ioe) {
//             LOG.debug("Cannot retrieve AdaptiveImageComponentServlet configuration", ioe.getMessage());
//         }
// 
//         // acquire parent servlet widths
//         String[] parentWidths = null;
//         if (null != parentProperties) {
//             parentWidths = PropertiesUtil.toStringArray(parentProperties.get(PN_SUPPORTED_WIDTHS));
//             if (ArrayUtils.getLength(parentWidths) > 0) {
//                 for (String width : parentWidths) {
//                     getWidths().add(Integer.parseInt(width));
//                 }
//             }
//         }
// 
//         // acquire local servlet widths
//         String[] localWidths = PropertiesUtil.toStringArray(properties.get(PN_SUPPORTED_WIDTHS));
//         if (ArrayUtils.getLength(localWidths) > 0) {
//             for (String width : localWidths) {
//                 getWidths().add(Integer.parseInt(width));
//             }
//         }
//     }
// 
//     /**
//      * @return lazily invoke/return set of configurable widths
//      */
//     public List<Integer> getWidths() {
//         if (null == widths) {
//             widths = new LinkedList<Integer>();
//         }
//         return widths;
//     }
// }


import java.util.List;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.commons.lang.ArrayUtils;
import org.apache.sling.api.resource.Resource;
import com.adobe.cq.sightly.WCMUse;
import com.steeleforge.aem.ironsites.wcm.servlet.AdaptiveImageConfig;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
     * 
     * @return
     * @throws RepositoryException
     */
    private List<Integer> setWidths(List<Integer> configWidths) {
        widths = new LinkedList<Integer>();
        Object[] optionWidths = get(PN_WIDTHS_IMAGE, Object[].class);
        if (ArrayUtils.getLength(optionWidths) > 0) {
            // loop through Use width options for a given image
            // allow only those matching configWidths
            for(Object width : optionWidths) {
                // allow only those matching configWidths
                if (null != width && configWidths.contains(Integer.parseInt(width.toString()))) {
                    widths.add(Integer.parseInt(width.toString()));
                }
            }
        } else {
            // no widths provided to ImageUse
            widths.addAll(configWidths);
        }
        Collections.sort(widths);
        return widths;
    }
    
    /**
     * initialize source tag data
     * 
     * @param widths
     * @return
     */
// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/servlet/AdaptiveImageConfig.java
// @Service(value = AdaptiveImageConfig.class)
// @Component(label = "ironsites - Adaptive Image Configurations",
//     description = "Adaptive Image width support configurations",
//     immediate = true)
// public class AdaptiveImageConfig {
//     // statics
//     private static final Logger LOG = LoggerFactory.getLogger(AdaptiveImageConfig.class);
//     private static final String ADAPTIVEIMAGE_SERVLET = "com.day.cq.wcm.foundation.impl.AdaptiveImageComponentServlet";
//     
//     // services
//     @Reference 
//     private ConfigurationAdmin configAdmin;
// 
//     // locals
//     private List<Integer> widths = null;
//     
//     // properties
//     @Property(label = "Additional Supported Widths",
//             description = "In addition Adobe CQ Adaptive Image Component Servlet dimensions",
//             value = {
//             "320", // iPhone 1 portrait
//             "420",
//             "480", // iPhone 1 landscape
//             "620", // iPad 1 landscape
//             "640",
//             "768",
//             "800",
//             "992",
//             "1024",
//             "1200",
//             "1280",
//             "1400",
//             "1440",
//             "1920" })
//     private static final String PN_SUPPORTED_WIDTHS = "adapt.supported.widths";
// 
//     @Activate
//     protected void activate(ComponentContext componentContext) {
//         Configuration config = null;
//         Dictionary<?, ?> parentProperties = null;
//         Dictionary<?, ?> properties = componentContext.getProperties();
//         // acquire parent servlet properties
//         try {
//             config = (Configuration) configAdmin.getConfiguration(ADAPTIVEIMAGE_SERVLET);
//             parentProperties = config.getProperties();
//         } catch (IOException ioe) {
//             LOG.debug("Cannot retrieve AdaptiveImageComponentServlet configuration", ioe.getMessage());
//         }
// 
//         // acquire parent servlet widths
//         String[] parentWidths = null;
//         if (null != parentProperties) {
//             parentWidths = PropertiesUtil.toStringArray(parentProperties.get(PN_SUPPORTED_WIDTHS));
//             if (ArrayUtils.getLength(parentWidths) > 0) {
//                 for (String width : parentWidths) {
//                     getWidths().add(Integer.parseInt(width));
//                 }
//             }
//         }
// 
//         // acquire local servlet widths
//         String[] localWidths = PropertiesUtil.toStringArray(properties.get(PN_SUPPORTED_WIDTHS));
//         if (ArrayUtils.getLength(localWidths) > 0) {
//             for (String width : localWidths) {
//                 getWidths().add(Integer.parseInt(width));
//             }
//         }
//     }
// 
//     /**
//      * @return lazily invoke/return set of configurable widths
//      */
//     public List<Integer> getWidths() {
//         if (null == widths) {
//             widths = new LinkedList<Integer>();
//         }
//         return widths;
//     }
// }


// Path: core/src/main/java/com/steeleforge/aem/ironsites/wcm/components/ImageUse.java
import java.util.List;
import java.util.Map;
import javax.jcr.RepositoryException;
import org.apache.commons.lang.ArrayUtils;
import org.apache.sling.api.resource.Resource;
import com.adobe.cq.sightly.WCMUse;
import com.steeleforge.aem.ironsites.wcm.servlet.AdaptiveImageConfig;
import java.text.MessageFormat;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;

     * 
     * @return
     * @throws RepositoryException
     */
    private List<Integer> setWidths(List<Integer> configWidths) {
        widths = new LinkedList<Integer>();
        Object[] optionWidths = get(PN_WIDTHS_IMAGE, Object[].class);
        if (ArrayUtils.getLength(optionWidths) > 0) {
            // loop through Use width options for a given image
            // allow only those matching configWidths
            for(Object width : optionWidths) {
                // allow only those matching configWidths
                if (null != width && configWidths.contains(Integer.parseInt(width.toString()))) {
                    widths.add(Integer.parseInt(width.toString()));
                }
            }
        } else {
            // no widths provided to ImageUse
            widths.addAll(configWidths);
        }
        Collections.sort(widths);
        return widths;
    }
    
    /**
     * initialize source tag data
     * 
     * @param widths
     * @return
     */
    private List<Map<String, String>> setSources(List<Integer> widths) {