<commit_before>package org.betteridiots.maven.plugins.ddf;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileNotFoundException;

@Mojo( name = "config-ddf", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST )
public class DDFConfigureMojo extends AbstractMojo
{

    // File containing DDF commands
    @Parameter( property = "config-ddf.paramsFile")
    private String paramsFile;

    // DDF User
    @Parameter( property = "config-ddf.user", defaultValue = "admin" )
    private String user;

    // DDF Password
    @Parameter( property = "config-ddf.password", defaultValue = "<PASSWORD>" )
    private String password;

    // DDF Host
    @Parameter( property = "config-ddf.host", defaultValue = "localhost" )
    private String host;

    // DDF SSH Port
    @Parameter( property = "config-ddf.port", defaultValue = "8101" )
    private int port;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {

        // Log Parameters
        getLog().info( "DDF Host is: " + host );
        getLog().info( "DDF Port is: " + port );
        getLog().info( "DDF user is: " + user );
        getLog().info( "DDF password is: " + password );
        getLog().info( "DDF parameter file is: " + paramsFile );

        // Initialize FileReader
        FileReader fileReader = null;
        try {
            fileReader = new FileReader(paramsFile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        // Initialize BufferedReader and commands ArrayList
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        StringBuffer params = new StringBuffer();
        String line;

        // Parse paramsFile into commands single string
        try {
            while ((line = bufferedReader.readLine()) != null) {
                params.append(line +"; ");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        try
        {
            bufferedReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Disable strict host key checking and set auth method to password
        java.util.Properties config = new java.util.Properties();
        config.put("StrictHostKeyChecking", "no");
        config.put("PreferredAuthentications","password");

        // Build JSch Session
        try
        {
            JSch jsch=new JSch();<commit_msg>Added capability to inline config parameters if the paramsFile is not set:<commit_after>package org.betteridiots.maven.plugins.ddf;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileNotFoundException;

@Mojo( name = "config-ddf", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST )
public class DDFConfigureMojo extends AbstractMojo
{

    // File containing DDF commands
    @Parameter( property = "config-ddf.paramsFile")
    private String paramsFile;

    // Array of parameters to be inserted into ddf config command
    @Parameter( property = "config-ddf.configs")
    private String[] configs;

    // DDF User
    @Parameter( property = "config-ddf.user", defaultValue = "admin" )
    private String user;

    // DDF Password
    @Parameter( property = "config-ddf.password", defaultValue = "<PASSWORD>" )
    private String password;

    // DDF Host
    @Parameter( property = "config-ddf.host", defaultValue = "localhost" )
    private String host;

    // DDF SSH Port
    @Parameter( property = "config-ddf.port", defaultValue = "8101" )
    private int port;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {

        // Log Parameters
        getLog().info( "DDF Host is: " + host );
        getLog().info( "DDF Port is: " + port );
        getLog().info( "DDF user is: " + user );
        getLog().info( "DDF password is: " + password );
        getLog().info( "DDF parameter file is: " + paramsFile );

        // Initialize BufferedReader and commands ArrayList
        StringBuffer params = new StringBuffer();
        String line;
        
        if (paramsFile != null) {
            
            // Initialize FileReader
            FileReader fileReader = null;
            try {
                fileReader = new FileReader(paramsFile);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
            BufferedReader bufferedReader = new BufferedReader(fileReader);


            // Parse paramsFile into commands single string
            try {
                while ((line = bufferedReader.readLine()) != null) {
                    params.append(line +"; ");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

            try
            {
                bufferedReader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
	}else{
            try {
                Iterator<String> configIter = configs.iterator();
                
                while (configIter.hasNext()) {
                  String config = configIter.next();
                  params.append(config+"; ");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        // Disable strict host key checking and set auth method to password
        java.util.Properties config = new java.util.Properties();
        config.put("StrictHostKeyChecking", "no");
        config.put("PreferredAuthentications","password");

        // Build JSch Session
        try
        {
            JSch jsch=new JSch();
{'fraction_non_alphanumeric': 0.10595130748422002, 'fraction_numerical': 0.0012022843402464682, 'mean_word_length': 2.359414437152953, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6001340', 'n_tokens_mistral': 1828, 'n_tokens_neox': 1755, 'n_words': 450}