<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">
    <!--
     Share Folder connector component.

     Input parameters:
       sf_host - SMB host name. This may be the host name (like "aaa.domain.com") or IP address. The host name is the SMB URL part right after the 'smb://' protocol.
       sf_path - SMB path to retrieve the files/folders from. Example: smb_storage/intake/. The files/folders inside the 'Path' are retrieved by 'File Mask' parameter value.
       sf_alias - Secrets Vault entry alias which stores SMB user name and password.
       sf_wildcard - The file mask (wildcard) to retrieve the files and 1-st level folders from the path identified by the 'Path' parameter.
       sf_action_on_read - Indicates if SMB files/folders are removed after successful read. Mark a file as read after processing so it will be ignored next time.
     -->

    <script><![CDATA[
        import com.workfusion.odf.impl.connector.ShareFolderTransactionSupplier;
        import com.workfusion.odf.core.Intake;

        def params = [:];
        params.put(ShareFolderTransactionSupplier.PARAM_HOST, sf_host.toString());
        params.put(ShareFolderTransactionSupplier.PARAM_PATH, sf_path.toString());
        params.put(ShareFolderTransactionSupplier.PARAM_ALIAS, sf_alias.toString());
        params.put(ShareFolderTransactionSupplier.PARAM_WILDCARD, sf_wildcard.toString());
        params.put(ShareFolderTransactionSupplier.PARAM_ACTION_ON_READ, sf_action_on_read.toString());

        def transactions = Intake.init(binding).params(params).get().loadTransactions(ShareFolderTransactionSupplier.class);

        result = [];
        transactions.each {
            result << ['transaction_id': it.id];
        }
        ]]></script>

    <export include-original-data="false">
        <multi-column list="${result}" split-results="true">
            <put-to-column-getter name="_sys_transaction_id" property="transaction_id"/>
        </multi-column>
    </export>
</config>
