InputProcessorFactory.java
3.92 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemfd.docmanager.Document
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Deactivate
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
*/
package com.adobe.aemfd.watchfolder.factory;
import com.adobe.aemfd.docmanager.Document;
import com.adobe.aemfd.watchfolder.config.WatchFolderConfiguration;
import com.adobe.aemfd.watchfolder.job.FileResultHandlerWrapper;
import com.adobe.aemfd.watchfolder.script.ScriptInputProcessor;
import com.adobe.aemfd.watchfolder.service.ServiceInputProcessor;
import com.adobe.aemfd.watchfolder.spi.InputProcessor;
import com.adobe.aemfd.watchfolder.workflow.WorkflowLauncherHandler;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Component(immediate=1)
@Service(value={InputProcessorFactory.class})
public class InputProcessorFactory {
static final String PROCESSOR_TYPE_WORKFLOW = "workflow";
static final String PROCESSOR_TYPE_SCRIPT = "script";
static final String PROCESSOR_TYPE_SERVICE = "service";
@Reference
private WorkflowLauncherHandler workflowLauncherHandler;
@Reference
private ScriptInputProcessor scriptInputProcessor;
@Reference
private ServiceInputProcessor serviceInputProcessor;
private Map<String, InputProcessor> processorMap = new HashMap<String, InputProcessor>();
@Activate
public void activate() {
this.processorMap.put("workflow", this.workflowLauncherHandler);
this.processorMap.put("script", this.scriptInputProcessor);
this.processorMap.put("service", this.serviceInputProcessor);
}
@Deactivate
public void deactivate() {
this.processorMap.clear();
}
public Set<String> getValidProcessorTypes() {
return this.processorMap.keySet();
}
public void processInputs(String jobId, WatchFolderConfiguration config, File source, Map<String, File> inputs) throws Exception {
InputProcessor ip = this.processorMap.get(config.getInputProcessorType());
Object resp = ip.processInputs(jobId, config, source, inputs);
if (ip.isSynch()) {
Map docMap = (Map)resp;
FileResultHandlerWrapper resultHandler = new FileResultHandlerWrapper(config);
resultHandler.handleSuccess(docMap, source, jobId);
}
}
protected void bindWorkflowLauncherHandler(WorkflowLauncherHandler workflowLauncherHandler) {
this.workflowLauncherHandler = workflowLauncherHandler;
}
protected void unbindWorkflowLauncherHandler(WorkflowLauncherHandler workflowLauncherHandler) {
if (this.workflowLauncherHandler == workflowLauncherHandler) {
this.workflowLauncherHandler = null;
}
}
protected void bindScriptInputProcessor(ScriptInputProcessor scriptInputProcessor) {
this.scriptInputProcessor = scriptInputProcessor;
}
protected void unbindScriptInputProcessor(ScriptInputProcessor scriptInputProcessor) {
if (this.scriptInputProcessor == scriptInputProcessor) {
this.scriptInputProcessor = null;
}
}
protected void bindServiceInputProcessor(ServiceInputProcessor serviceInputProcessor) {
this.serviceInputProcessor = serviceInputProcessor;
}
protected void unbindServiceInputProcessor(ServiceInputProcessor serviceInputProcessor) {
if (this.serviceInputProcessor == serviceInputProcessor) {
this.serviceInputProcessor = null;
}
}
}