SendToPrinter.java 3.11 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemfd.docmanager.Document
 *  com.adobe.fd.stp.api.PrinterSpec
 *  com.adobe.fd.stp.api.SendToPrinterService
 *  com.adobe.granite.workflow.WorkflowException
 *  com.adobe.granite.workflow.WorkflowSession
 *  com.adobe.granite.workflow.exec.WorkItem
 *  com.adobe.granite.workflow.metadata.MetaDataMap
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 *  org.apache.sling.jcr.api.SlingRepository
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.fd.workflow.sendtoprinter;

import com.adobe.aemfd.docmanager.Document;
import com.adobe.fd.stp.api.PrinterSpec;
import com.adobe.fd.stp.api.SendToPrinterService;
import com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess;
import com.adobe.fd.workflow.sendtoprinter.internal.utils.SendToPrinterUtils;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.jcr.api.SlingRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component
@Service
public class SendToPrinter
extends AEMFDWorkflowProcess {
    @Reference
    private SendToPrinterService sendToPrinterService;
    @Reference
    private SlingRepository slingRepository;
    private static final Logger log = LoggerFactory.getLogger(SendToPrinter.class);

    @Override
    protected void internal_execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {
        try {
            Document inDoc = SendToPrinterUtils.getInputDoc(item, args);
            if (inDoc == null) {
                log.debug("Input Document is null");
                throw new WorkflowException("Input Document can not be null");
            }
            PrinterSpec printerSpec = SendToPrinterUtils.getPrinterSpec(args);
            this.sendToPrinterService.print(inDoc, printerSpec);
        }
        catch (Exception e) {
            log.error("Exception in Send To Printer Service", (Throwable)e);
            throw new WorkflowException("Exception in Send To Printer Service", (Throwable)e);
        }
    }

    protected void bindSendToPrinterService(SendToPrinterService sendToPrinterService) {
        this.sendToPrinterService = sendToPrinterService;
    }

    protected void unbindSendToPrinterService(SendToPrinterService sendToPrinterService) {
        if (this.sendToPrinterService == sendToPrinterService) {
            this.sendToPrinterService = null;
        }
    }

    protected void bindSlingRepository(SlingRepository slingRepository) {
        this.slingRepository = slingRepository;
    }

    protected void unbindSlingRepository(SlingRepository slingRepository) {
        if (this.slingRepository == slingRepository) {
            this.slingRepository = null;
        }
    }
}