CreatePdfProcess.java
5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemfd.docmanager.Document
* com.adobe.granite.workflow.WorkflowException
* com.adobe.granite.workflow.WorkflowSession
* com.adobe.granite.workflow.exec.WorkItem
* com.adobe.granite.workflow.metadata.MetaDataMap
* com.adobe.pdfg.result.CreatePDFResult
* com.adobe.pdfg.service.api.GeneratePDFService
* 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.pdfg;
import com.adobe.aemfd.docmanager.Document;
import com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess;
import com.adobe.fd.workflow.utils.DocumentUtils;
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 com.adobe.pdfg.result.CreatePDFResult;
import com.adobe.pdfg.service.api.GeneratePDFService;
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={"CreatePdfProcess"}), @Property(name="service.vendor", value={"Adobe"}), @Property(name="process.label", value={"CreatePdfProcess"})})
public class CreatePdfProcess
extends AEMFDWorkflowProcess {
private static Logger LOGGER = LoggerFactory.getLogger(CreatePdfProcess.class);
private static final String INDOC_PARAM = "inDoc";
private static final String FILE_EXTENSION_PARAM = "fileExtension";
private static final String FILETYPE_SETTINGS_PARAM = "filetypeSettings";
private static final String PDF_SETTINGS_PARAM = "pdfSettings";
private static final String SECURITY_SETTINGS_PARAM = "securitySettings";
private static final String SETTINGS_DOC_PARAM = "settingsDoc";
private static final String XMP_DOC_PARAM = "xmpDoc";
private static final String OUT_DOC_PARAM = "outDoc";
@Reference
GeneratePDFService generatePdfService;
@Override
protected void internal_execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
try {
CreatePDFResult conversionResult;
Document inputDoc = DocumentUtils.getInputDocument(workItem, "inDoc");
String inputFileExtension = null;
String fileTypeSettings = null;
String pdfSettings = null;
String securitySettings = null;
Document settingsDoc = null;
Document xmpDoc = null;
if (metaDataMap.get("fileExtension", String.class) != null) {
inputFileExtension = (String)metaDataMap.get("fileExtension", String.class);
LOGGER.debug("fileExtension= " + inputFileExtension);
}
if (metaDataMap.get("filetypeSettings", String.class) != null) {
fileTypeSettings = (String)metaDataMap.get("filetypeSettings", String.class);
LOGGER.debug("filetypeSettings= " + fileTypeSettings);
}
if (metaDataMap.get("pdfSettings", String.class) != null) {
pdfSettings = (String)metaDataMap.get("pdfSettings", String.class);
LOGGER.debug("pdfSettings= " + pdfSettings);
}
if (metaDataMap.get("securitySettings", String.class) != null) {
securitySettings = (String)metaDataMap.get("securitySettings", String.class);
LOGGER.debug("securitySettings= " + securitySettings);
}
if (metaDataMap.get("settingsDoc", Document.class) != null) {
settingsDoc = (Document)metaDataMap.get("settingsDoc", Document.class);
}
if (metaDataMap.get("xmpDoc", Document.class) != null) {
xmpDoc = (Document)metaDataMap.get("xmpDoc", Document.class);
}
if ((conversionResult = this.generatePdfService.createPDF2(inputDoc, inputFileExtension, fileTypeSettings, pdfSettings, securitySettings, settingsDoc, xmpDoc)).getCreatedDocument() != null) {
DocumentUtils.saveOutputDocument(workItem, workflowSession, "outDoc", conversionResult.getCreatedDocument());
}
}
catch (Exception e) {
throw new WorkflowException((Throwable)e);
}
}
protected void bindGeneratePdfService(GeneratePDFService generatePDFService) {
this.generatePdfService = generatePDFService;
}
protected void unbindGeneratePdfService(GeneratePDFService generatePDFService) {
if (this.generatePdfService == generatePDFService) {
this.generatePdfService = null;
}
}
}