AbstractDPSClient.java 2.56 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.wcm.webservicesupport.ConfigurationManager
 *  javax.jcr.Session
 *  org.apache.sling.api.adapter.AdapterManager
 *  org.apache.sling.commons.threads.ThreadPool
 *  org.osgi.service.event.EventAdmin
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.cq.mobile.dps.impl.service;

import com.adobe.cq.mobile.dps.DPSException;
import com.adobe.cq.mobile.dps.DPSObject;
import com.adobe.cq.mobile.dps.impl.service.DPSConnectionAdapterFactory;
import com.day.cq.wcm.webservicesupport.ConfigurationManager;
import javax.jcr.Session;
import org.apache.sling.api.adapter.AdapterManager;
import org.apache.sling.commons.threads.ThreadPool;
import org.osgi.service.event.EventAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AbstractDPSClient {
    protected Logger LOGGER = LoggerFactory.getLogger(AbstractDPSClient.class);
    protected Session userSession = null;
    protected ConfigurationManager configurationManagerService = null;
    protected AdapterManager adapterManager = null;
    protected EventAdmin eventAdminService = null;
    protected DPSConnectionAdapterFactory dpsConnectionAdapterFactory = null;
    protected ThreadPool threadPool;

    protected AbstractDPSClient(Session userSession, DPSConnectionAdapterFactory dpsConnectionAdapterFactory, ConfigurationManager configurationManagerService, EventAdmin eventAdminService, AdapterManager adapterManager, ThreadPool threadPool) {
        this.userSession = userSession;
        this.configurationManagerService = configurationManagerService;
        this.eventAdminService = eventAdminService;
        this.adapterManager = adapterManager;
        this.dpsConnectionAdapterFactory = dpsConnectionAdapterFactory;
        this.threadPool = threadPool;
        this.LOGGER = LoggerFactory.getLogger(this.getClass());
    }

    protected String getSharedContentURI(String projectId) {
        String entityName = "SHARED_HTML_RESOURCES";
        return "/publication/" + projectId + "/sharedContent/" + entityName;
    }

    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
        if (Session.class == type) {
            return (AdapterType)this.userSession;
        }
        return null;
    }

    protected String getAndAssertProjectId(DPSObject dpsObject) throws DPSException {
        String projectId = dpsObject.getProjectId();
        if (projectId == null) {
            throw new DPSException("Project not set for " + dpsObject.getPath());
        }
        return projectId;
    }
}