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

com.day.cq.analytics.sitecatalyst.util.AnalyticsConfig Maven / Gradle / Ivy

There is a newer version: 2024.11.18751.20241128T090041Z-241100
Show newest version
package com.day.cq.analytics.sitecatalyst.util;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.day.cq.analytics.sitecatalyst.impl.servlets.SitecatalystServlet;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class AnalyticsConfig {

    private String companyId;
    private String apiKey;
    private String token = null;

    private static final Logger log = LoggerFactory.getLogger(AnalyticsConfig.class);

    public AnalyticsConfig(Map config, TokenProviderProxy tokenProviderProxy)
    {
        companyId = PropertiesUtil.toString(config.get(SitecatalystServlet.PN_COMPANYID), "");
        String imsConfigId = PropertiesUtil.toString(config.get(SitecatalystServlet.IMS_CONFIG_ID), "");
        apiKey = tokenProviderProxy.getApikey(imsConfigId);
        try {
            token = tokenProviderProxy.getAccessToken(imsConfigId);
        } catch (Exception e) {
            log.error("Cannot get the access token for {}", imsConfigId);
        }
    }

    @Nonnull
    public String getCompanyId() {
        return companyId;
    }

    @Nonnull
    public String getApikey() {
        return apiKey;
    }

    @Nullable
    public String getAccessToken()  {
        return token;
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy