Package com.sos.VirtualFileSystem.Options

Source Code of com.sos.VirtualFileSystem.Options.SOSConnection2OptionsSuperClass

/********************************************************* begin of preamble
**
** Copyright (C) 2003-2010 Software- und Organisations-Service GmbH.
** All rights reserved.
**
** This file may be used under the terms of either the
**
**   GNU General Public License version 2.0 (GPL)
**
**   as published by the Free Software Foundation
**   http://www.gnu.org/licenses/gpl-2.0.txt and appearing in the file
**   LICENSE.GPL included in the packaging of this file.
**
** or the
** 
**   Agreement for Purchase and Licensing
**
**   as offered by Software- und Organisations-Service GmbH
**   in the respective terms of supply that ship with this file.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
** IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
** THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
** BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
** POSSIBILITY OF SUCH DAMAGE.
********************************************************** end of preamble*/
package com.sos.VirtualFileSystem.Options;

import java.util.HashMap;

import org.apache.log4j.Logger;

import com.sos.JSHelper.Annotations.JSOptionClass;
import com.sos.JSHelper.Annotations.JSOptionDefinition;
import com.sos.JSHelper.Exceptions.JSExceptionMandatoryOptionMissing;
import com.sos.JSHelper.Listener.JSListener;
import com.sos.JSHelper.Options.JSOptionsClass;
import com.sos.JSHelper.Options.SOSOptionAuthenticationMethod;
import com.sos.JSHelper.Options.SOSOptionBoolean;
import com.sos.JSHelper.Options.SOSOptionHostName;
import com.sos.JSHelper.Options.SOSOptionInFileName;
import com.sos.JSHelper.Options.SOSOptionPassword;
import com.sos.JSHelper.Options.SOSOptionPortNumber;
import com.sos.JSHelper.Options.SOSOptionString;
import com.sos.JSHelper.Options.SOSOptionTransferMode;
import com.sos.JSHelper.Options.SOSOptionTransferType;
import com.sos.JSHelper.Options.SOSOptionUserName;
import com.sos.VirtualFileSystem.Interfaces.ISOSAuthenticationOptions;
import com.sos.i18n.annotation.I18NResourceBundle;

/**
* \class     SOSConnection2OptionsSuperClass - Options for a connection to an uri (server, site, e.g.)
*
* \brief
* An Options-Super-Class with all Options. This Class will be extended by the "real" Options-class (\see SOSConnection2Options.
* The "real" Option class will hold all the things, which are normaly overwritten at a new generation
* of the super-class.
*
*

*
* see \see j:\e\java\development\com.sos.scheduler\src\sos\scheduler\jobdoc\SOSConnection2.xml for (more) details.
*
* \verbatim ;
* mechanicaly created by  from http://www.sos-berlin.com at 20100917112403
* \endverbatim
* \section OptionsTable Tabelle der vorhandenen Optionen
*
* Tabelle mit allen Optionen
*
* MethodName
* Title
* Setting
* Description
* IsMandatory
* DataType
* InitialValue
* TestValue
*
*
*
* \section TestData Eine Hilfe zum Erzeugen einer HashMap mit Testdaten
*
* Die folgenden Methode kann verwendet werden, um f�r einen Test eine HashMap
* mit sinnvollen Werten f�r die einzelnen Optionen zu erzeugen.
*
* \verbatim
private HashMap <String, String> SetJobSchedulerSSHJobOptions (HashMap <String, String> pobjHM) {
  pobjHM.put ("    SOSConnection2OptionsSuperClass.auth_file", "test");  // This parameter specifies the path and name of a user's pr
    return pobjHM;
  }  //  private void SetJobSchedulerSSHJobOptions (HashMap <String, String> pobjHM)
* \endverbatim
*/
@JSOptionClass(name = "SOSConnection2OptionsSuperClass", description = "SOSConnection2OptionsSuperClass")
@I18NResourceBundle(baseName = "SOSVirtualFileSystem", defaultLocale = "en")
public class SOSConnection2OptionsSuperClass extends JSOptionsClass implements ISOSAuthenticationOptions {
  /**
   *
   */
  private static final long  serialVersionUID  = 1997338600688654140L;
  private final String    conClassName  = "SOSConnection2OptionsSuperClass";
  @SuppressWarnings("unused")
  private static Logger    logger      = Logger.getLogger(SOSConnection2OptionsSuperClass.class);

  /**
   * \var host : Host-Name This parameter specifies th
   * This parameter specifies the hostname or IP address of the server to which a connection has to be made.
   *
   */
  @JSOptionDefinition(name = "host", description = "Host-Name This parameter specifies th", key = "host", type = "SOSOptionHostName", mandatory = false)
  public SOSOptionHostName  host      = new SOSOptionHostName(this, conClassName + ".host", // HashMap-Key
                            "Host-Name This parameter specifies th", // Titel
                            "", // InitValue
                            "", // DefaultValue
                            false // isMandatory
                        );

  /**
   * \brief gethost : Host-Name This parameter specifies th
   *
   * \details
   * This parameter specifies the hostname or IP address of the server to which a connection has to be made.
   *
   * \return Host-Name This parameter specifies th
   *
   */
  public SOSOptionHostName getHost() {
    return host;
  }

  /**
   * \brief sethost : Host-Name This parameter specifies th
   *
   * \details
   * This parameter specifies the hostname or IP address of the server to which a connection has to be made.
   *
   * @param host : Host-Name This parameter specifies th
   */
  public void setHost(SOSOptionHostName p_host) {
    this.host = p_host;
  }

  public SOSOptionHostName  HostName    = (SOSOptionHostName) host.SetAlias(conClassName + ".HostName");
  public SOSOptionHostName  FtpHostName    = (SOSOptionHostName) host.SetAlias(conClassName + ".ftp_host");

  /**
   * \var passive_mode : passive_mode Passive mode for FTP is often used wit
   * Passive mode for FTP is often used with firewalls. Valid values are 0 or 1.
   *
   */
  @JSOptionDefinition(name = "passive_mode", description = "passive_mode Passive mode for FTP is often used wit", key = "passive_mode", type = "SOSOptionBoolean", mandatory = false)
  public SOSOptionBoolean    passive_mode  = new SOSOptionBoolean(this, conClassName + ".passive_mode", // HashMap-Key
                            "passive_mode Passive mode for FTP is often used wit", // Titel
                            "false", // InitValue
                            "false", // DefaultValue
                            false // isMandatory
                        );

  /**
   * \brief getpassive_mode : passive_mode Passive mode for FTP is often used wit
   *
   * \details
   * Passive mode for FTP is often used with firewalls. Valid values are 0 or 1.
   *
   * \return passive_mode Passive mode for FTP is often used wit
   *
   */
  public SOSOptionBoolean getpassive_mode() {
    return passive_mode;
  }

  /**
   * \brief setpassive_mode : passive_mode Passive mode for FTP is often used wit
   *
   * \details
   * Passive mode for FTP is often used with firewalls. Valid values are 0 or 1.
   *
   * @param passive_mode : passive_mode Passive mode for FTP is often used wit
   */
  public void setpassive_mode(SOSOptionBoolean p_passive_mode) {
    this.passive_mode = p_passive_mode;
  }

  public SOSOptionBoolean    FTPTransferModeIsPassive  = (SOSOptionBoolean) passive_mode.SetAlias(conClassName + ".FTPTransferModeIsPassive");
  public SOSOptionBoolean    FTPPassiveMode        = (SOSOptionBoolean) passive_mode.SetAlias(conClassName + ".ftp_passive_mode");

  /**
   * \var port : Port-Number to be used for Data-Transfer
   * Port by which files should be transferred. For FTP this is usually port 21, for SFTP this is usually port 22.
   *
   */
  @JSOptionDefinition(name = "port", description = "Port-Number to be used for Data-Transfer", key = "port", type = "SOSOptionPortNumber", mandatory = true)
  public SOSOptionPortNumber  port            = new SOSOptionPortNumber(this, conClassName + ".port", // HashMap-Key
                                  "Port-Number to be used for Data-Transfer", // Titel
                                  "21", // InitValue
                                  "21", // DefaultValue
                                  true // isMandatory
                              );

  public SOSOptionPortNumber  ftp_port          = (SOSOptionPortNumber) port.SetAlias("ftp_port");

  /**
   * \brief getport : Port-Number to be used for Data-Transfer
   *
   * \details
   * Port by which files should be transferred. For FTP this is usually port 21, for SFTP this is usually port 22.
   *
   * \return Port-Number to be used for Data-Transfer
   *
   */
  public SOSOptionPortNumber getport() {
    return port;
  }

  /**
   * \brief setport : Port-Number to be used for Data-Transfer
   *
   * \details
   * Port by which files should be transferred. For FTP this is usually port 21, for SFTP this is usually port 22.
   *
   * @param port : Port-Number to be used for Data-Transfer
   */
  public void setport(SOSOptionPortNumber p_port) {
    this.port = p_port;
  }

  /**
   * \var protocol : Type of requested Datatransfer The values ftp, sftp
   * The values ftp, sftp or ftps are valid for this parameter. If sftp is used, then the ssh_* parameters will be applied.
   *
   */
  @JSOptionDefinition(name = "protocol", description = "Type of requested Datatransfer The values ftp, sftp", key = "protocol", type = "SOSOptionStringValueList", mandatory = true)
  public SOSOptionTransferType  protocol    = new SOSOptionTransferType(this, conClassName + ".protocol", // HashMap-Key
                              "Type of requested Datatransfer The values ftp, sftp", // Titel
                              "ftp", // InitValue
                              "ftp", // DefaultValue
                              true // isMandatory
                          );
  public SOSOptionTransferType  ftp_protocol  = (SOSOptionTransferType) protocol.SetAlias("ftp_protocol");

  /**
   * \brief getprotocol : Type of requested Datatransfer The values ftp, sftp
   *
   * \details
   * The values ftp, sftp or ftps are valid for this parameter. If sftp is used, then the ssh_* parameters will be applied.
   *
   * \return Type of requested Datatransfer The values ftp, sftp
   *
   */
  public SOSOptionTransferType getprotocol() {
    return protocol;
  }

  /**
   * \brief setprotocol : Type of requested Datatransfer The values ftp, sftp
   *
   * \details
   * The values ftp, sftp or ftps are valid for this parameter. If sftp is used, then the ssh_* parameters will be applied.
   *
   * @param protocol : Type of requested Datatransfer The values ftp, sftp
   */
  public void setprotocol(SOSOptionTransferType p_protocol) {
    this.protocol = p_protocol;
  }

  public SOSOptionTransferType  TransferProtocol    = (SOSOptionTransferType) protocol.SetAlias(conClassName + ".TransferProtocol");

  /**
   * \var transfer_mode : Type of Character-Encoding Transfe
   * Transfer mode is used for FTP exclusively and can be either ascii or binary.
   *
   */
  @JSOptionDefinition(name = "transfer_mode", description = "Type of Character-Encoding Transfe", key = "transfer_mode", type = "SOSOptionTransferMode", mandatory = false)
  public SOSOptionTransferMode  transfer_mode      = new SOSOptionTransferMode(this, conClassName + ".transfer_mode", // HashMap-Key
                                  "Type of Character-Encoding Transfe", // Titel
                                  "binary", // InitValue
                                  "binary", // DefaultValue
                                  false // isMandatory
                              );
  public SOSOptionTransferMode  ftp_transfer_mode    = (SOSOptionTransferMode) transfer_mode.SetAlias("ftp_transfer_mode");
  @SuppressWarnings("unused")
  private String          strAlternativePrefix  = "";

  /**
   * \brief gettransfer_mode : Type of Character-Encoding Transfe
   *
   * \details
   * Transfer mode is used for FTP exclusively and can be either ascii or binary.
   *
   * \return Type of Character-Encoding Transfe
   *
   */
  public SOSOptionTransferMode gettransfer_mode() {
    return transfer_mode;
  }

  /**
   * \brief settransfer_mode : Type of Character-Encoding Transfe
   *
   * \details
   * Transfer mode is used for FTP exclusively and can be either ascii or binary.
   *
   * @param transfer_mode : Type of Character-Encoding Transfe
   */
  public void settransfer_mode(SOSOptionTransferMode p_transfer_mode) {
    this.transfer_mode = p_transfer_mode;
  }

  /**
  * \var user : UserID of user in charge User name
  *
  User name for authentication at the (FTP/SFTP) server.
  *
  */
  @JSOptionDefinition(name = "user", description = "UserID of user in charge User name", key = "user", type = "SOSOptionUserName", mandatory = true)
  public SOSOptionUserName  user  = new SOSOptionUserName(this, conClassName + ".user", // HashMap-Key
                        "UserID of user in charge User name", // Titel
                        "", // InitValue
                        "anonymous", // DefaultValue
                        false // isMandatory
                    );

  /**
   * \brief getuser
   *
   * \details
   *
   * \return
   *
   * @return
   */
  public SOSOptionUserName getUser() {
    return user;
  }

  /**
   * \brief setuser
   *
   * \details
   *
   * \return
   *
   * @param p_user
   */
  public void setUser(SOSOptionUserName p_user) {
    this.user = p_user;
  }

  /**
  * \var password : Password for UserID Password for a
  *
  Password for authentication at the FTP/SFTP server. For SSH/SFTP connections that make use of public/private key authentication the password parameter is specified for the passphrase that optionally secures a private key.
  *
  */
  @JSOptionDefinition(name = "password", description = "Password for UserID Password for a", key = "password", type = "SOSOptionPassword", mandatory = false)
  public SOSOptionPassword  password  = new SOSOptionPassword(this, conClassName + ".password", // HashMap-Key
                          "Password for UserID Password for a", // Titel
                          " ", // InitValue
                          " ", // DefaultValue
                          false // isMandatory
                      );

  /**
   * \brief getpassword
   *
   * \details
   *
   * \return
   *
   * @return
   */
  public SOSOptionPassword getPassword() {
    return password;
  }

  /**
   * \brief setpassword
   *
   * \details
   *
   * \return
   *
   * @param p_password
   */
  public void setPassword(SOSOptionPassword p_password) {
    this.password = p_password;
  }

  public SOSConnection2OptionsSuperClass() {
    objParentClass = this.getClass();
  } // public SOSConnection2OptionsSuperClass

  public SOSConnection2OptionsSuperClass(JSListener pobjListener) {
    this();
//    this.registerMessageListener(pobjListener);
  } // public SOSConnection2OptionsSuperClass

  //

  public SOSConnection2OptionsSuperClass(HashMap<String, String> JSSettings) throws Exception {
    this();
    this.setAllOptions(JSSettings);
  } // public SOSConnection2OptionsSuperClass (HashMap JSSettings)

  /**
   * \brief getAllOptionsAsString - liefert die Werte und Beschreibung aller
   * Optionen als String
   *
   * \details
   *
   * \see toString
   * \see toOut
   */
  private String getAllOptionsAsString() {
    @SuppressWarnings("unused")
    final String conMethodName = conClassName + "::getAllOptionsAsString";
    String strT = conClassName + "\n";
    final StringBuffer strBuffer = new StringBuffer();
    // strT += IterateAllDataElementsByAnnotation(objParentClass, this,
    // JSOptionsClass.IterationTypes.toString, strBuffer);
    // strT += IterateAllDataElementsByAnnotation(objParentClass, this, 13,
    // strBuffer);
    strT += this.toString(); // fix
    //
    return strT;
  } // private String getAllOptionsAsString ()

  /**
   * \brief setAllOptions - �bernimmt die OptionenWerte aus der HashMap
   *
   * \details In der als Parameter anzugebenden HashMap sind Schl�ssel (Name)
   * und Wert der jeweiligen Option als Paar angegeben. Ein Beispiel f�r den
   * Aufbau einer solchen HashMap findet sich in der Beschreibung dieser
   * Klasse (\ref TestData "setJobSchedulerSSHJobOptions"). In dieser Routine
   * werden die Schl�ssel analysiert und, falls gefunden, werden die
   * dazugeh�rigen Werte den Properties dieser Klasse zugewiesen.
   *
   * Nicht bekannte Schl�ssel werden ignoriert.
   *
   * \see JSOptionsClass::getItem
   *
   * @param pobjJSSettings
   * @throws Exception
   */
  public void setAllOptions(HashMap<String, String> pobjJSSettings) throws Exception {
    @SuppressWarnings("unused")
    final String conMethodName = conClassName + "::setAllOptions";
    flgSetAllOptions = true;
    objSettings = pobjJSSettings;
    super.Settings(objSettings);
    super.setAllOptions(pobjJSSettings);
    flgSetAllOptions = false;
  } // public void setAllOptions (HashMap <String, String> JSSettings)

  /**
   * \brief CheckMandatory - pr�ft alle Muss-Optionen auf Werte
   *
   * \details
   * @throws Exception
   *
   * @throws Exception
   * - wird ausgel�st, wenn eine mandatory-Option keinen Wert hat
   */
  @Override
  public void CheckMandatory() throws JSExceptionMandatoryOptionMissing //
      , Exception {
    try {
      super.CheckMandatory();
    }
    catch (Exception e) {
      throw new JSExceptionMandatoryOptionMissing(e.toString());
    }
  } // public void CheckMandatory ()

  /**
   *
   * \brief CommandLineArgs - �bernehmen der Options/Settings aus der
   * Kommandozeile
   *
   * \details Die in der Kommandozeile beim Starten der Applikation
   * angegebenen Parameter werden hier in die HashMap �bertragen und danach
   * den Optionen als Wert zugewiesen.
   *
   * \return void
   *
   * @param pstrArgs
   * @throws Exception
   */
  @Override
  public void CommandLineArgs(String[] pstrArgs) throws Exception {
    super.CommandLineArgs(pstrArgs);
    this.setAllOptions(super.objSettings);
  }

  /**
  * \var ssh_auth_file : This parameter specifies the path and name of a us
  *
  This parameter specifies the path and name of a user's private key file that is used for authentication with an SSH server. This parameter has to be specified should the publickey authentication method have been specified in the ssh_auth_method parameter. Should the private key file be secured by a passphrase, then the passphrase has to be specified using the password parameter.
  *
  */
  @JSOptionDefinition(name = "ssh_auth_file", description = "This parameter specifies the path and name of a us", key = "ssh_auth_file", type = "SOSOptionInFileName", mandatory = false)
  public SOSOptionInFileName  ssh_auth_file  = new SOSOptionInFileName(this, conClassName + ".ssh_auth_file", // HashMap-Key
                            "This parameter specifies the path and name of a us", // Titel
                            " ", // InitValue
                            " ", // DefaultValue
                            false // isMandatory
                        );

  /**
   * \brief getssh_auth_file
   *
   * \details
   *
   * \return
   *
   * @return
   */
  public SOSOptionInFileName getAuth_file() {
    return ssh_auth_file;
  }

  /**
   * \brief setssh_auth_file
   *
   * \details
   *
   * \return
   *
   * @param p_ssh_auth_file
   */
  public void setAuth_file(SOSOptionInFileName p_ssh_auth_file) {
    this.ssh_auth_file = p_ssh_auth_file;
  }

  /**
  * \var ssh_auth_method : This parameter specifies the authentication method
  *
  This parameter specifies the authentication method for the SSH server - the publickey and password methods are supported. Should the publickey authentication method be used, then the path name of the private key file has to be specified with the ssh_auth_file parameter. Should the private key file be secured by a passphrase then the passphrase has to be specified with the password parameter. For the password authentication method the password for the user account has to be specified using the password parameter. The authentication methods that are enabled depend on the SSH server configuration. Not all SSH servers are configured for password authentication.
  *
  */
  @JSOptionDefinition(name = "ssh_auth_method", description = "This parameter specifies the authentication method", key = "ssh_auth_method", type = "SOSOptionStringValueList", mandatory = false)
  public SOSOptionAuthenticationMethod  ssh_auth_method  = new SOSOptionAuthenticationMethod(this, conClassName + ".ssh_auth_method", // HashMap-Key
                                  "This parameter specifies the authentication method", // Titel
                                  "publickey", // InitValue
                                  "publickey", // DefaultValue
                                  false // isMandatory
                              );

  /**
   * \brief getssh_auth_method
   *
   * \details
   *
   * \return
   *
   * @return
   */
  public SOSOptionAuthenticationMethod getAuth_method() {
    return ssh_auth_method;
  }

  /**
   * \brief setssh_auth_method
   *
   * \details
   *
   * \return
   *
   * @param p_ssh_auth_method
   */
  public void setAuth_method(SOSOptionAuthenticationMethod p_ssh_auth_method) {
    this.ssh_auth_method = p_ssh_auth_method;
  }

  /**
   * \brief setUser
   *
   * \details
   *
   * \return
   *
   * @param pobjUser
   */
  @Override
  public void setUser(SOSOptionString pobjUser) {
    // TODO Auto-generated method stub
    this.user.Value(pobjUser.Value());
  }

} // public class SOSConnection2OptionsSuperClass
TOP

Related Classes of com.sos.VirtualFileSystem.Options.SOSConnection2OptionsSuperClass

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.