package com.workfusion.odf.impl.connector;

import java.net.MalformedURLException;
import javax.inject.Inject;
import javax.inject.Provider;

import jcifs.smb.SmbFile;

import com.workfusion.rpa.core.storage.ShareFolderManager;

/**
 * Provides methods to buld <code>SmbFile</code> instances by path/URL.
 *
 * @author Andrei Urbanovich
 */
public class SmbFileBuilder {
    private ShareFolderManager shareFolderManager;

    @Inject
    public SmbFileBuilder(Provider<ShareFolderManager> shareFolderManager) {
        this.shareFolderManager = shareFolderManager.get();
    }

    /**
     * Create <code>SmbFile</code> by given full path of the SMB file.
     *
     * @param path SMB file full path.
     * @return
     *
     * @throws MalformedURLException
     */
    public SmbFile buildSmbFileByPath(final String path) throws MalformedURLException {
        return new SmbFile(path, shareFolderManager.getNtlmPasswordAuthentication());
    }
}
