LCSubmitActionService.java
6.5 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemds.guide.model.FormSubmitInfo
* com.adobe.aemds.guide.service.FormSubmitActionService
* com.adobe.aemds.guide.service.GuideLCServiceConnector
* com.adobe.aemds.guide.utils.GuideUtils
* com.adobe.forms.common.service.FileAttachmentWrapper
* com.adobe.idp.Document
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ResourceResolverFactory
* org.apache.sling.api.resource.ValueMap
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.aemds.guide.addon.service.impl;
import com.adobe.aemds.guide.model.FormSubmitInfo;
import com.adobe.aemds.guide.service.FormSubmitActionService;
import com.adobe.aemds.guide.service.GuideLCServiceConnector;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.adobe.forms.common.service.FileAttachmentWrapper;
import com.adobe.idp.Document;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.api.resource.ValueMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0, immediate=0)
@Service(value={FormSubmitActionService.class})
public class LCSubmitActionService
implements FormSubmitActionService {
private static final String serviceName = "LC";
protected static Logger logger = LoggerFactory.getLogger(LCSubmitActionService.class);
@Reference
protected ResourceResolverFactory resourceResolverFactory;
@Reference
protected GuideLCServiceConnector guideLCServiceConnector;
public String getServiceName() {
return "LC";
}
public Map<String, Object> submit(FormSubmitInfo formSubmitInfo) {
HashMap<String, Object> result = new HashMap<String, Object>();
result.put("FormSubmissionComplete", Boolean.FALSE);
ResourceResolver resourceResolver = null;
Resource formContainerResource = formSubmitInfo.getFormContainerResource();
if (formContainerResource == null) {
resourceResolver = GuideUtils.getServiceResourceResolver((ResourceResolverFactory)this.resourceResolverFactory);
formContainerResource = resourceResolver.getResource(formSubmitInfo.getFormContainerPath());
}
ValueMap properties = formContainerResource.getValueMap();
String processName = (String)properties.get("processName", (Object)"");
Boolean isDorSubmit = Boolean.valueOf((String)properties.get("enableDoRSubmission", (Object)""));
if (processName != null && processName.length() > 0) {
Set keys;
List attachmentWrapperList;
String dataXmlParamterName = this.guideLCServiceConnector.getXmlParameterName();
String fileListParameterName = this.guideLCServiceConnector.getFileListParameterName();
String documentOfRecordParameterName = this.guideLCServiceConnector.getDocumentOfRecordParameterName();
HashMap<String, Object> inputParams = new HashMap<String, Object>();
Document dataXml = null;
if (formSubmitInfo.getData() != null) {
dataXml = new Document(formSubmitInfo.getData().getBytes());
}
inputParams.put(dataXmlParamterName, dataXml);
ArrayList<Document> fileAttachments = new ArrayList<Document>();
FileAttachmentWrapper dorPdfWrapper = formSubmitInfo.getDocumentOfRecord();
if (dorPdfWrapper != null && isDorSubmit.booleanValue()) {
Document dorDoc = new Document(dorPdfWrapper.getInputStream());
dorDoc.setContentType(dorPdfWrapper.getContentType());
dorDoc.setAttribute("file", (Serializable)((Object)dorPdfWrapper.getFileName()));
inputParams.put(documentOfRecordParameterName, (Object)dorDoc);
}
if ((attachmentWrapperList = formSubmitInfo.getFileAttachments()) != null) {
for (FileAttachmentWrapper attachmentWrapper : attachmentWrapperList) {
Document doc = new Document(attachmentWrapper.getInputStream());
doc.setContentType(attachmentWrapper.getContentType());
doc.setAttribute("file", (Serializable)((Object)attachmentWrapper.getFileName()));
fileAttachments.add(doc);
}
}
inputParams.put(fileListParameterName, fileAttachments);
Map outputParams = this.guideLCServiceConnector.invokeProcess(processName, inputParams);
if (outputParams != null && (keys = outputParams.keySet()) != null) {
for (Object key : keys) {
Object value = outputParams.get(key);
if (value.getClass().isPrimitive()) {
result.put((String)key, value);
continue;
}
logger.info("Ignoring " + (String)key + " because the value is not primitive");
}
}
result.put("FormSubmissionComplete", Boolean.TRUE);
} else {
logger.error("There is no Forms and Document Workflow associated with this Adaptive Form.");
}
return result;
}
protected void bindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
this.resourceResolverFactory = resourceResolverFactory;
}
protected void unbindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
if (this.resourceResolverFactory == resourceResolverFactory) {
this.resourceResolverFactory = null;
}
}
protected void bindGuideLCServiceConnector(GuideLCServiceConnector guideLCServiceConnector) {
this.guideLCServiceConnector = guideLCServiceConnector;
}
protected void unbindGuideLCServiceConnector(GuideLCServiceConnector guideLCServiceConnector) {
if (this.guideLCServiceConnector == guideLCServiceConnector) {
this.guideLCServiceConnector = null;
}
}
}