package org.apache.maven.deploy;

/* ====================================================================
 *   Copyright 2001-2004 The Apache Software Foundation.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 * ====================================================================
 */

/**
 * Contatins the set of poperties  which are necessery 
 * for esatblishing connection to remote hosts and to 
 * perform a deployment.
 * 
 * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a> 
 * @version $Id: RepositoryInfo.java,v 1.2 2004/03/02 14:59:31 evenisse Exp $
 */
public class RepositoryInfo
{

    /** Idicates that port has not been set */
    public final static int UNKNOWN_PORT = -1;

    /** The nickname (alias) of the repository*/
    private String repositoryAlias;

    /** URL of the remote host*/
    private String url;

    /** Port of remote host */
    private int port = UNKNOWN_PORT;

    /** The login name of the user in @ remote host*/
    private String userName;

    /** Password */
    private String password;

    /** Remote group name */
    private String group;

    /** The passpharse of the user's private key file */
    private String passphrase;

    /** The absoluth path to private key file */
    private String privateKey;

    /**  Proxy Server host*/
    private String proxyHost = null;

    /** the login name of the user @ Proxy Server host*/
    private String proxyUserName = null;

    /** the password user @ Proxy Server host*/
    private String proxyPassword = null;

    /** Proxy server port */
    private int proxyPort = UNKNOWN_PORT;

    /** Indicates if debug mode should be used*/
    private boolean debugOn = true;
    
    /** basedir  */
    private String basedir;

    /**
     * @return
     */
    public String getBasedir()
    {
        return basedir;
    }

    /**
     * @param basedir
     */
    public void setBasedir(String basedir)
    {
        this.basedir = basedir;
    }

    /**
     * Set the alias of the repository
     * @param repositoryAlias
     */
    public void setRepositoryAlias(String repositoryAlias)
    {
        this.repositoryAlias = repositoryAlias;
    }

    /**
     * Get the port of the host 
     * @return the port of the remote host where repository resides.
     */
    public int getPort()
    {
        return port;
    }

    /**
     * Set the port of the remote host
     * @param port
     */
    public void setPort(int port)
    {
        this.port = port;
    }

    /**
     * Get the passphrase of the private key file.
     * Passphrase is used only when host/protocol supports
     * authetification via exchange of private/public keys
     * and private key was provided.
     * 
     * @return the passphrase of the private key file
     */
    public String getPassphrase()
    {
        return passphrase;
    }

    /**
     * Set the passphrase of the private key file
     * @param passphrase the passphrase of the private key file
     */
    public void setPassphrase(String passphrase)
    {
        this.passphrase = passphrase;
    }

    /**
     * Get the absoluth path to the private key
     * @return the path to private key
     */
    public String getPrivateKey()
    {
        return privateKey;
    }

    /**
     * Set the aboluth path to private key
     * @param privateKey The path to private key in local file system
     */
    public void setPrivateKey(String privateKey)
    {
        this.privateKey = privateKey;
    }

    /**
     * Get the remote group to which will belong to
     * after deployemnt. Not all protolcols support
     * allow to change the group of the artifact
     * @return remote group
     */
    public String getGroup()
    {
        return group;
    }

    /**
     * Set the remote group for artifact which is deployed
     * @param group  The remote group to which 
     *                artifact which is deployed will belong
     */
    public void setGroup(String group)
    {
        this.group = group;
    }
    
    /**
     * Get the password to be used when user will be authetificated
     * while connection to remote host is established
     * @return the password of user 
     */
    public String getPassword()
    {
        return password;
    }

    /**
     * 
     * 
     * @param password
     */
    public void setPassword(String pass)
    {
        this.password = pass;
    }

    /**
     * Returhn proxy server host name
     * @return proxy server host name
     */
    public String getProxyHost()
    {
        return proxyHost;
    }

    /**
     * Set proxy host name
     * @param proxyHost
     */
    public void setProxyHost(String proxyHost)
    {
        this.proxyHost = proxyHost;
    }

    /**
     * Get user's password used to login to proxy server 
     * @return the user's password at proxy host 
     */
    public String getProxyPassword()
    {
        return proxyPassword;
    }

    /**
     * Set the proxy server password
     * @param proxyPassword teh epassword to use to login to a proxy server
     */
    public void setProxyPassword(String proxyPass)
    {
        this.proxyPassword = proxyPass;
    }

    /**
     * Get the proxy port
     * @return Poroxy server port
     */
    public int getProxyPort()
    {
        return proxyPort;
    }

    /**
     * Set the proxy port
     * @param proxyPort
     */
    public void setProxyPort(int proxyPort)
    {
        this.proxyPort = proxyPort;
    }

    /**
     * 
     * Get the proxy user name
     * @return
     */
    public String getProxyUserName()
    {
        return proxyUserName;
    }

    /**
     * Set the proxy user name
     * @param proxyUserName the proxy user name
     */
    public void setProxyUserName(String proxyUser)
    {
        this.proxyUserName = proxyUser;
    }

    /**
     * Get url of remote host
     * @return URL (with protocol) of remote host
     */
    public String getUrl()
    {
        return url;
    }

    /**
     * Set url of remote host
     * @param url url of remote host
     */
    public void setUrl(String url)
    {
        this.url = url;
    }

    /**
     * Get user login name at remote host 
     * @return user name at remote host
     */
    public String getUserName()
    {
        return userName;
    }

    /**
     * Set user name at remote host
     * @param userName
     */
    public void setUserName(String user)
    {
        this.userName = user;
    }

    /**
     * Return the host name (Cuts of protocol from the URL)
     * @return The host name 
     */
    public String getHost()
    {
        if (url == null)
        {
            return "localhost";
        }
        return url.substring(url.indexOf("://") + 3).trim();
    }

    /**
     * Get the name of the repository to which deploy attempt will be made  
     * 
     * @return the name (nickname, alias) of the repository 
     */
    public String getRepositoryAlias()
    {

        return repositoryAlias;
    }

    /**
     * Get Debug mode
     * @return the debug mode
     */
    public boolean isDebugOn()
    {
        return debugOn;
    }

    /**
     * Set deplyer in debug mode - more messages will be wriiten 
     * @param debugOn
     */
    public void setDebugOn(boolean debugOn)
    {
        this.debugOn = debugOn;
    }

}
