AbstractSyncInputProcessor.java 2.24 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemfd.docmanager.Document
 */
package com.adobe.aemfd.watchfolder.util;

import com.adobe.aemfd.docmanager.Document;
import com.adobe.aemfd.watchfolder.config.WatchFolderConfiguration;
import com.adobe.aemfd.watchfolder.service.ProcessorContextImpl;
import com.adobe.aemfd.watchfolder.service.api.ProcessorContext;
import com.adobe.aemfd.watchfolder.spi.InputProcessor;
import com.adobe.aemfd.watchfolder.util.DocUtil;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/*
 * This class specifies class file version 49.0 but uses Java 6 signatures.  Assumed Java 6.
 */
public abstract class AbstractSyncInputProcessor
implements InputProcessor {
    @Override
    public boolean isSynch() {
        return true;
    }

    protected Map<String, Document> toDocumentMap(Map<String, File> inputs) throws Exception {
        if (inputs == null) {
            return null;
        }
        HashMap<String, Document> result = new HashMap<String, Document>(inputs.size());
        for (Map.Entry<String, File> ie : inputs.entrySet()) {
            result.put(ie.getKey(), new Document(ie.getValue()));
        }
        return result;
    }

    protected abstract void doProcess(String var1, WatchFolderConfiguration var2, File var3, ProcessorContext var4) throws Exception;

    @Override
    public Object processInputs(String jobId, WatchFolderConfiguration config, File source, Map<String, File> inputs) throws Exception {
        ProcessorContextImpl ctxt = new ProcessorContextImpl();
        try {
            ctxt.watchFolderId = config.getId();
            ctxt.inputMap = this.toDocumentMap(inputs);
            ctxt.configParameters = config.getParams();
            try {
                this.doProcess(jobId, config, source, ctxt);
                Map<String, Document> map = ctxt.resultMap;
                return map;
            }
            catch (Exception e) {
                DocUtil.disposeAll(ctxt.resultMap);
                throw e;
            }
        }
        finally {
            Map<String, Document> toDispose = DocUtil.pruneForDisposal(ctxt.inputMap, ctxt.resultMap);
            DocUtil.disposeAll(toDispose);
        }
    }
}