DTMWorkflowTriggerJob.java 2.7 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.day.cq.workflow.WorkflowException
 *  com.day.cq.workflow.WorkflowService
 *  javax.jcr.PathNotFoundException
 *  org.apache.sling.api.resource.LoginException
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.apache.sling.api.resource.ResourceResolverFactory
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.cq.dtm.impl;

import com.adobe.cq.dtm.impl.constants.DTMServerType;
import com.adobe.cq.dtm.impl.util.DTMConfigurationUtil;
import com.day.cq.workflow.WorkflowException;
import com.day.cq.workflow.WorkflowService;
import java.util.Map;
import javax.jcr.PathNotFoundException;
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DTMWorkflowTriggerJob
implements Runnable {
    private static final Logger LOG = LoggerFactory.getLogger(DTMWorkflowTriggerJob.class);
    private ResourceResolverFactory rrf;
    private WorkflowService workflowService;
    private DTMServerType dtmServerType;
    private String dtmConfigPath;

    public DTMWorkflowTriggerJob(ResourceResolverFactory rrf, WorkflowService workflowService, String dtmConfigPath, DTMServerType dtmServerType) {
        this.rrf = rrf;
        this.workflowService = workflowService;
        this.dtmConfigPath = dtmConfigPath;
        this.dtmServerType = dtmServerType;
    }

    /*
     * WARNING - Removed try catching itself - possible behaviour change.
     */
    @Override
    public void run() {
        ResourceResolver serviceResourceResolver = null;
        try {
            serviceResourceResolver = this.rrf.getServiceResourceResolver(null);
            Resource dtmConfig = serviceResourceResolver.getResource(this.dtmConfigPath);
            DTMConfigurationUtil.triggerDTMWorkflow(this.workflowService, dtmConfig, this.dtmServerType);
            LOG.info("DTM {} bundle download workflow started.", (Object)this.dtmServerType);
        }
        catch (PathNotFoundException e) {
            LOG.error("DTM workflow model not found.", (Throwable)e);
        }
        catch (WorkflowException e) {
            LOG.error("DTM {} bundle download workflow failed.", (Object)this.dtmServerType, (Object)e);
        }
        catch (LoginException e) {
            LOG.error("Could not get a resolver.", (Throwable)e);
        }
        finally {
            if (serviceResourceResolver != null) {
                serviceResourceResolver.close();
            }
        }
    }
}