<commit_before>/**
 * asadmin-glassfish-plugin : a maven plugin for glassfish administratives tasks
 * 
 * Copyright (C) 2008  <NAME>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.n0pe.mojo.asadmin;


import java.io.File;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;

import org.n0pe.asadmin.AsAdmin;
import org.n0pe.asadmin.AsAdminException;
import org.n0pe.asadmin.AsAdminCmdList;
import org.n0pe.asadmin.IAsAdminConfig;


/**
 * Base class of all asadmin mojos.
 * Provides common parameters and basic check configuration, implements asadmin configuration provider.
 * 
 * @author <NAME> <<EMAIL>>
 */
public abstract class AbstractAsadminMojo
        extends AbstractMojo
        implements IAsAdminConfig {


    /**
     * 
     * @parameter default-value="ENV"
     * @required
     */
    private String glassfishHome;


    private File glassfishHomeDir;


    /**
     * @parameter default-value="admin"
     * @required
     */
    private String user;


    /**
     * @parameter default-value="HOME"
     * @required
     */
    private String passwordfile;


    /**
     * @parameter default-value="localhost"
     * @required
     */
    private String host;


    /**
     * @parameter default-value="4848"
     * @required
     */
    private String port;


    /**
     * @parameter default-value="domain1"
     * @required
     */
    protected String domain;


    /**
     * @parameter expression="${project.build.directory}/${project.build.finalName}.${project.packaging}"
     * @required
     */
    protected String appArchive;


    /**
     * @parameter expression="${project.build.finalName}"
     * @required
     */
    protected String appName;


    /**
     * Overrided context root for WAR archives, default to project.build.finalName.
     * 
     * @parameter expression="${project.build.finalName}"
     */
    protected String contextRoot;


    /**
     * @parameter expression="${project}"
     * @required
     * @readonly
     */
    protected MavenProject mavenProject;


    public final void execute()
            throws MojoExecutionException, MojoFailureException {
        try {

            checkConfig();

            AsAdmin.getInstance(this).run(getAsCommandList());

        } catch (AsAdminException ex) {
            throw new MojoExecutionException(ex.getMessage(), ex);
        }
    }


    public final String getGlassfishHome() {
        return glassfishHome;
    }


    public final String getUser() {
        return user;
    }


    public final String getPasswordFile() {
        return passwordfile;
    }


    /**
     * Build and return a list of IAsCommand to be executed.
     * 
     * AbstractAsadminMojo subclasses need to implement this method.<commit_msg>added a skip parameter<commit_after>/**
 * asadmin-glassfish-plugin : a maven plugin for glassfish administratives tasks
 * 
 * Copyright (C) 2008  <NAME>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.n0pe.mojo.asadmin;


import java.io.File;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.SystemUtils;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;

import org.n0pe.asadmin.AsAdmin;
import org.n0pe.asadmin.AsAdminException;
import org.n0pe.asadmin.AsAdminCmdList;
import org.n0pe.asadmin.IAsAdminConfig;


/**
 * Base class of all asadmin mojos.
 * Provides common parameters and basic check configuration, implements asadmin configuration provider.
 * 
 * @author <NAME> <<EMAIL>>
 */
public abstract class AbstractAsadminMojo
        extends AbstractMojo
        implements IAsAdminConfig {


    /**
     * @parameter default-value="false"
     */
    private boolean skip;


    /**
     * @parameter default-value="ENV"
     * @required
     */
    private String glassfishHome;


    private File glassfishHomeDir;


    /**
     * @parameter default-value="admin"
     * @required
     */
    private String user;


    /**
     * @parameter default-value="HOME"
     * @required
     */
    private String passwordfile;


    /**
     * @parameter default-value="localhost"
     * @required
     */
    private String host;


    /**
     * @parameter default-value="4848"
     * @required
     */
    private String port;


    /**
     * @parameter default-value="domain1"
     * @required
     */
    protected String domain;


    /**
     * @parameter expression="${project.build.directory}/${project.build.finalName}.${project.packaging}"
     * @required
     */
    protected String appArchive;


    /**
     * @parameter expression="${project.build.finalName}"
     * @required
     */
    protected String appName;


    /**
     * Overrided context root for WAR archives, default to project.build.finalName.
     * 
     * @parameter expression="${project.build.finalName}"
     */
    protected String contextRoot;


    /**
     * @parameter expression="${project}"
     * @required
     * @readonly
     */
    protected MavenProject mavenProject;


    public final void execute()
            throws MojoExecutionException, MojoFailureException {
        if (skip) {
            getLog().info("asadmin-maven-plugin execution is skipped");
            return;
        }
        try {

            checkConfig();

            AsAdmin.getInstance(this).run(getAsCommandList());

        } catch (AsAdminException ex) {
            throw new MojoExecutionException(ex.getMessage(), ex);
        }
    }


    public final String getGlassfishHome() {
        return glassfishHome;
    }


    public final String getUser() {
        return user;
    }


    public final String getPasswordFile() {
        return <PASSWORD>;
    }


    /**
     * Build and return a list of IAsCommand to be executed.
     * 
     * AbstractAsadminMojo subclasses need to implement this method.
{'fraction_non_alphanumeric': 0.09917578705580327, 'fraction_numerical': 0.004053506282934738, 'mean_word_length': 2.682587064676617, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4336152', 'n_tokens_mistral': 2090, 'n_tokens_neox': 1974, 'n_words': 590}