Class DCNodeConfigData

java.lang.Object
com.nt.udc.ndk.gui.DCNodeConfigData
All Implemented Interfaces:
ConfigIfc, Serializable, Cloneable
Direct Known Subclasses:
FtpEIConfigData, FtpFileEIConfigData, SoapXmlEIConfigData

public class DCNodeConfigData extends Object implements ConfigIfc, Serializable, Cloneable
See Also:
  • Field Details

  • Constructor Details

    • DCNodeConfigData

      public DCNodeConfigData()
      Constructor to be used by GUI to create a DCNodeConfigData with initial set of default values
    • DCNodeConfigData

      public DCNodeConfigData(String inUdcHome, String inNodeId) throws IOException
      Constructor to be used by NodeManager which is aware of the udcHome and nodeId
      Throws:
      IOException
  • Method Details

    • getDirty

      public boolean getDirty()
      Returns:
      value of dirtyFlag
    • setDirty

      public void setDirty(boolean d)
      Sets value of dirtyFlag to d
    • getConfigDir

      public String getConfigDir() throws IOException
      Returns the absolute path name for the config directory for the node represented by this DCNodeConfigData Object.
      Returns:
      Absolute path name for the node's config directory. Default is: udcHome/config/ nodeId
      Throws:
      IOException - If udcHome or nodeId have not been set.
    • getBackupDir

      public String getBackupDir() throws IOException
      Returns the absolute path name for the backup directory for the node represented by this DCNodeConfigData Object.
      Returns:
      Absolute path name for the node's back up directory. Default is: udcHome/backup/ nodeId
      Throws:
      IOException - If udcHome or nodeId have not been set.
    • getUseFile

      public boolean getUseFile()
    • setUseFile

      public void setUseFile(boolean useFile)
    • getRuleFilePathName

      public String getRuleFilePathName() throws IOException
      Returns the absolute path name of the rules file being used for the node associated with this DCNodeConfigData Object.
      Returns:
      Absolute path name of the rules file. Default is:
        invalid input: '&nbsp' getConfigDir() + File.separator + "rules.cfg".
      Throws:
      IOException
    • getRuleName

      public String getRuleName()
      Returns the name of the rule file. Default is rules.cfg
    • setRuleFileName

      public void setRuleFileName(String name)
      Sets the name of the rule file. Default is rules.cfg
    • setRuleFilePathName

      public void setRuleFilePathName(String inRuleFilePathName)
      Sets the absolute path name of the rules file being used for the node associated with this DCNodeConfigData Object.
      Parameters:
      inRuleFilePathName - Absolute path name of the rules file.
    • getRules

      public byte[] getRules()
    • setRules

      public void setRules(byte[] rules)
    • getRuleClass

      public byte[] getRuleClass()
    • setRuleClass

      public void setRuleClass(byte[] ruleClass)
    • getPrefRulesFilePathName

      public String getPrefRulesFilePathName() throws IOException
      Returns the absolute path name of the file containing the preferred rules file names being used for the node associated with this DCNodeConfigData Object.
      Returns:
      Absolute path name of the preferred rules file. Default is:
        invalid input: '&nbsp' getConfigDir() + File.separator + "preferredRules.cfg".
      Throws:
      IOException
    • getGenConfigFilePathName

      public String getGenConfigFilePathName() throws IOException
      Returns the absolute path name of the rules file containing the "General" information being used for the node associated with this DCNodeConfigData Object.
      Returns:
      Absolute path name of the General config file. Default is:
        invalid input: '&nbsp' getConfigDir() + File.separator + "general.cfg".
      Throws:
      IOException
    • defaultValue

      public void defaultValue(String name, String value)
      Sets the default value for the given key
      Parameters:
      name - name of the configuration parameter
      value - default value
    • getHomeDir

      public String getHomeDir() throws IOException
      Returns the directory location of the UDC installation.
      Returns:
      Value of udcHome
      Throws:
      IOException - If udcHome has not been set
    • setHomeDir

      public void setHomeDir(String inUdcHome)
      Sets udcHome. This is used by the NodeManager to set the directory location of the UDC installation.
      Parameters:
      inUdcHome - Directory where the UDC program is installed
    • setNodeId

      public void setNodeId(String inNodeId)
      Used by the NodeManager to set the nodeId for the node associated with this DCNodeConfigData Object.
      Parameters:
      inNodeId - String identifier for the node
    • getNodeId

      public String getNodeId()
    • setRulesFromFile

      public void setRulesFromFile(String inRuleFileName) throws IOException
      Used by the AdminServer to read the given rules file.
      Parameters:
      inRuleFileName - name of the rules file to read
      Throws:
      IOException
    • setRulesFromClass

      public void setRulesFromClass(File ruleClassFile, String classString) throws ClassNotFoundException
      Reads the contents of the given file and sets the rule name to the given String.
      Parameters:
      ruleClassFile - File object representing the NPL class file to be used.
      classString - Name of the Java class for ruleClassFile
      Throws:
      ClassNotFoundException
    • setRulesFromClass

      public void setRulesFromClass(String inRuleClassName, String asHostName, int urlPort) throws ClassNotFoundException
      Used by the AdminServer to set the given Class file.
      Parameters:
      inRuleClassName - name of the Class to load
      Throws:
      ClassNotFoundException
    • load

      public void load() throws IOException
      Used by the NodeManager to load the general configuration and rules files into memory.
      The path for the general config file is always
      udcHome/config/nodeId/general.cfg
      Throws:
      IOException - If either the general.cfg or ruleName file could not be read
    • load

      public void load(boolean getPasswords) throws IOException
      Throws:
      IOException
    • save

      public void save() throws IOException
      Used by the NodeManager to persist the general configuration and rules files to disk.
      The path for the general config file is always
      udcHome/config/nodeId/general.cfg
      Throws:
      IOException - If the config directory does not exist, or either the general.cfg or rules.cfg file could not be written to
    • writeDefaultFields

      public void writeDefaultFields(String nodeContext)
      This method writes default fields and their values in the general.cfg
      Parameters:
      nodeContext - is the id used to determine the default fields for any particular cartridge
    • deleteItem

      public void deleteItem(String itemName)
      Removes the given item from varTable
    • getConfigFileNames

      public Enumeration getConfigFileNames()
      Returns the names of secondary configuration files used by this node.
      Returns:
      an Enumeration of the filenames
      See Also:
    • setConfigFile

      public void setConfigFile(String filename, byte[] data)
      Stores a secondary configuration file in this DCNodeConfigData object
      Parameters:
      filename - The name of the secondary configuration file
      data - A byte array representing the contenst of the file
    • getConfigFile

      public byte[] getConfigFile(String filename)
      Returns the contents of given secondary configuration file name
      Parameters:
      filename - name of the secondary configuration file
      Returns:
      a byte[] representing the contents of the file
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getItem

      public String getItem(String itemName)
      Called by the GUI to retrieve items from varTable
      Specified by:
      getItem in interface ConfigIfc
    • setItem

      public void setItem(String itemName, String value)
      Called by the GUI to add items to varTable . Calls setDirty if value is different from the current value stored at itemName by calling the equals() method.
      Specified by:
      setItem in interface ConfigIfc
    • setPreferredRules

      public void setPreferredRules(Vector prefRules)
      Sets the preferred rule set for this node.
      This Vector holds display-name/file-name pairs for the set of rules files that are appropriate for this node given its market segment (which is set at node creation time). The set of rules available to this node are the intersection of the files named in this Vector and the files physically present on disk. The display names are used in the configuration GUI.
      Vector format is as follows:
        [0] display name 1
        [1] file name 1
      ...
      When this data is written to and read from disk, it is NOT placed in varTable. Rather, the prefix "preferredRules" is used for each key, and this is stored via a Properties object.
    • getPreferredRules

      public Vector getPreferredRules()
      Returns the preferred rule set for this node
    • getSettingsKeys

      public Enumeration getSettingsKeys()
      Returns the set of String keys used for setting values of this node.
      Returns:
      an Enumeration of the keys used
      See Also:
    • readFile

      protected byte[] readFile(String fileSpec) throws IOException
      Returns the contents of the given configuration filename
      Returns:
      Contents of fileSpec; an empty byte array is returned if the file could not be found.
      Throws:
      IOException
    • writeFile

      protected void writeFile(String outputFile, byte[] bytes) throws IOException
      Writes the given byte stream to the given configuration filename
      Parameters:
      outputFile - Name of the file to write to
      bytes - Contents of the file to be written
      Throws:
      IOException
    • addDeviceListPasswordToWallet

      public void addDeviceListPasswordToWallet(String nodeContext)
      This method extracts the password from DeviceListVersionOne and adds it to the wallet, specifically for EI SMDR node
      Parameters:
      nodeContext - is the ID used to determine the node context.
      deviceList - a colon-separated string containing device details, including the password to be added to the wallet.
    • setBaseDefaults

      protected void setBaseDefaults()
      Sets the default values for this DCNodeConfigData's general configuration parameters.
      These are:
          DEBUG = 1
          DATAFILESIZE = 2000
          PUSHTIME = 60
          PULLTIME = 20
          LOGFILESIZE = 10000
          BACKUP = false
          SECONDARYCFG = "secondary.cfg"
    • setDefaults

      protected void setDefaults()
      Should be overridden by derived classes to set node specific default values. Default implementation is empty.
    • writeConfigFiles

      protected void writeConfigFiles() throws IOException
      Writes out the secondary configuration files to disk. The default file location is the value returned by getConfigDir(), which is generally the node's config directory.
      Throws:
      IOException
    • readConfigFiles

      protected void readConfigFiles() throws IOException
      Builds the configFiles Hashtable based on the contents of the "secondary.cfg" file. The "secondary.cfg" file contains a list of all of the filenames originally stored in configFiles. By default, this method assumes that all files were stored in the node's config directory (the value returned by getConfigDir(). If the "secondary.cfg" file does not exist (indicating that no secondary files were designated, then the configFiles Hashtable is initialized to an empty table.
      Throws:
      IOException
    • clone

      public Object clone()
      Deep clone the HashTable (varTable)
      Overrides:
      clone in class Object