ExportData.java 2.93 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemfd.docmanager.Document
 *  com.adobe.fd.forms.api.DataFormat
 *  com.adobe.fd.forms.api.FormsService
 *  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.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.Service
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.fd.workflow.forms.impl;

import com.adobe.aemfd.docmanager.Document;
import com.adobe.fd.forms.api.DataFormat;
import com.adobe.fd.forms.api.FormsService;
import com.adobe.fd.workflow.forms.internal.common.FormsUtil;
import com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess;
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.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component
@Service
@Properties(value={@Property(name="service.description", value={"ExportData"}), @Property(name="service.vendor", value={"Adobe"}), @Property(name="process.label", value={"ExportData"})})
public class ExportData
extends AEMFDWorkflowProcess {
    private static Logger logger = LoggerFactory.getLogger(ExportData.class);
    private static final String DATA_PARAM = "inputpath";
    private static final String DATA_FORMAT = "dataFormat";
    private static final String OUTPUT_PARAM = "output";
    @Reference
    private FormsService formsService;

    @Override
    protected void internal_execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
        try {
            Document dataDoc = FormsUtil.getDocument(workItem, "inputpath");
            DataFormat dataFormat = DataFormat.valueOf((String)((String)metaDataMap.get("dataFormat", String.class)));
            Document document = this.formsService.exportData(dataDoc, dataFormat);
            FormsUtil.saveDocument(workItem, workflowSession, document, "output");
        }
        catch (Exception e) {
            throw new WorkflowException((Throwable)e);
        }
    }

    protected void bindFormsService(FormsService formsService) {
        this.formsService = formsService;
    }

    protected void unbindFormsService(FormsService formsService) {
        if (this.formsService == formsService) {
            this.formsService = null;
        }
    }
}