MCMConfiguration.java 4.06 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Activate
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Modified
 *  org.apache.felix.scr.annotations.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.PropertyUnbounded
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.commons.osgi.OsgiUtil
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.day.cq.mcm.impl;

import java.util.Arrays;
import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Modified;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyUnbounded;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.OsgiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component(configurationFactory=1, metatype=1)
@Service(value={MCMConfiguration.class})
@Properties(value={@Property(name="experience.indirection", unbounded=PropertyUnbounded.ARRAY), @Property(name="touchpoint.indirection", unbounded=PropertyUnbounded.ARRAY)})
public class MCMConfiguration
implements Cloneable {
    private static final Logger log = LoggerFactory.getLogger(MCMConfiguration.class);
    private String[] experienceIndirectionConfig;
    private String[] touchpointIndirectionConfig;

    @Activate
    protected void activate(Map<String, Object> params) {
        this.readParams(params);
    }

    private void readParams(Map<String, Object> params) {
        String[] touchpointIndConfig;
        Object servicePid = params.get("service.pid");
        String[] experienceIndConfig = OsgiUtil.toStringArray((Object)params.get("experience.indirection"));
        if (experienceIndConfig != null) {
            if (experienceIndConfig.length == 2 && experienceIndConfig[0].length() != 0 && experienceIndConfig[1].length() != 0) {
                this.experienceIndirectionConfig = experienceIndConfig;
            } else {
                experienceIndConfig = null;
                log.error("Wrong configuration for {} in {}, need exactly 2 non-empty strings in array!", (Object)"experience.indirection", servicePid);
            }
        }
        if (experienceIndConfig == null) {
            this.experienceIndirectionConfig = null;
        }
        if ((touchpointIndConfig = OsgiUtil.toStringArray((Object)params.get("touchpoint.indirection"))) != null) {
            if (touchpointIndConfig.length == 2 && touchpointIndConfig[0].length() != 0 && touchpointIndConfig[1].length() != 0) {
                this.touchpointIndirectionConfig = touchpointIndConfig;
            } else {
                log.error("Wrong configuration for {} in {}, need exactly 2 non-empty strings in array!", (Object)"touchpoint.indirection", servicePid);
            }
        }
        if (touchpointIndConfig == null) {
            this.touchpointIndirectionConfig = null;
        }
    }

    @Modified
    protected void modified(Map<String, Object> params) {
        this.readParams(params);
    }

    public String[] getExperienceIndirectionConfig() {
        return this.experienceIndirectionConfig;
    }

    public String[] getTouchpointIndirectionConfig() {
        return this.touchpointIndirectionConfig;
    }

    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public boolean equals(Object obj) {
        if (obj != null && obj instanceof MCMConfiguration) {
            MCMConfiguration other = (MCMConfiguration)obj;
            return (this.experienceIndirectionConfig == null && other.experienceIndirectionConfig == null || Arrays.equals(this.experienceIndirectionConfig, other.experienceIndirectionConfig)) && (this.touchpointIndirectionConfig == null && other.touchpointIndirectionConfig == null || Arrays.equals(this.touchpointIndirectionConfig, other.touchpointIndirectionConfig));
        }
        return false;
    }
}