Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.ifs.admin.actions
Class FileHandlingAction

    java.lang.Object
      oracle.ifs.utils.action.AbstractAction
          oracle.ifs.admin.actions.FileHandlingAction

All Implemented Interfaces:
  Action

    public class FileHandlingAction

extends AbstractAction

The FileHandlingAction class helps modifying text files in different ways. You can copy, append, insert a source file into a destination file. You can put constraints on when to do the append and insertion based on the presence/absence of a string. The file handling can be done dependent on the Operating System. NOTE: All string comparisons are case-sensitive.

This class defines the following keys:
`os` - The possible general values for the Operating System can be "all", "windows", "unix". Or the value can be more specific to a particular Windows platform or unix platform such as "Windows 95", "Windows 98", "Windows NT", "Windows 2000", "Solaris". These values should EXACTLY match the value returned by the System property "os.name" when called from Java.
`file_operation` - The possible general values for the File Operation can be COPY_IF_NOT_EXIST, OVERWRITE, APPEND, APPEND_OR_COPY_IF_NOT_EXIST, APPEND_OR_NOTHING, INSERT, REPLACE, or REMOVE_CONTENT. Descriptive explaination of each of these can be seen below.
`source_file` - Specifies the absolute path to the source file.
`source_string` - The string which is going to be used in either appending, replacing or inserting in the destination file.
`destination_file` - Specifies the absolute path to the destination file.
`check_string` - The string whose existence is checked in the destination file before performaing append or insert. If the string is found in the file then the operation is not done.
`insert_linefeed` - The possible values for this can be "true" or "false". By default it is "false". When set to "true", there would be a linefeed inserted in the destination file before and after the insert file/string and before the appended file.
`insert_around_line_containing` - This string is used in the INSERT file operation. The line before/after which the insertion is to be done is found using this string. The first line in the destination file which contains this string is set to be the target line before/after which the insertion is to be done.
`string_to_replace` - This is the string you want to replace in the destination file.
`insert_after` - The possible values for this can be "true" or "false". By default it is "false". When set to "true", the insertion of the string/file is done before the target line in the destination file.

Modified:
  sgarg 07/19/2001 Created.

Field Summary
`static java.lang.String` | `ALL_OS` Value for the key "os".
`static java.lang.String` | `APPEND` Value for the key "fileoperation".
`static java.lang.String` | `APPEND_OR_COPY_IF_NOT_EXIST` Value for the key "fileoperation".
`static java.lang.String` | `APPEND_OR_NOTHING` Value for the key "fileoperation".
`static java.lang.String` | `CHECKSTRING_KEY` The string to check if the APPEND/INSERT is conditional.
`static java.lang.String` | `COPY_IF_NOT_EXIST` Value for the key "fileoperation".
`static java.lang.String` | `DESTINATION_KEY` The destination file (absolute path) Defined as: "destination_file".
`static java.lang.String` | `FILE_OPERATION_KEY`
`static java.lang.String` | `INSERT` Value for the key "fileoperation".
`static java.lang.String` | `INSERT_AFTER_KEY` A boolean value to tell if you wish to insert after the line specified using INSERT_AROUND_LINE_KEY or before it.
`static java.lang.String` | `INSERT_AROUND_LINE_KEY` This string is used to find the line after/before which the source file/string is to be inserted.
`static java.lang.String` | `INSERT_LINEFEED_KEY` A boolean value to tell if you wish to insert a line feed before APPENDING/INSERTING a file or string.
`static java.lang.String` | `OS_KEY`
`static java.lang.String` | `OVERWRITE` Value for the key "fileoperation".
`static java.lang.String` | `REMOVE_CONTENT` Value for the key "fileoperation".
`static java.lang.String` | `REPLACE` Value for the key "fileoperation".
`static java.lang.String` | `SOURCE_KEY` The source file (absolute path) Defined as: "source_file".
`static java.lang.String` | `SOURCE_STRING_KEY` The source string Defined as: "source_string".
`static java.lang.String` | `STRING_TO_REPLACE_KEY` This is the string which needs to be replaced.
`static java.lang.String` | `UNIX_OS` Value for the key "os".
`static java.lang.String` | `WINDOWS_OS` Value for the key "os".

Fields inherited from class oracle.ifs.utils.action.AbstractAction
`CONTINUE_ON_ERROR, m_defaultOptions, m_options`

Constructor Summary
`FileHandlingAction()`
`FileHandlingAction(java.lang.String[] args)`

Method Summary
`protected void` | `appendFile(java.io.File sourceFile, java.io.File destFile, java.lang.String checkString, boolean insertLinefeed)`
`protected void` | `appendString(java.lang.String stringToAppend, java.io.File destFile, java.lang.String checkString, boolean insertLinefeed)`
`protected void` | `copyFile(java.io.File sourceFile, java.io.File destFile)`
`protected boolean` | `doesFileContainString(java.io.File file, java.lang.String checkString)`
`void` | `failed(java.lang.Throwable t)` Invoked if this Action has failed.
`protected java.io.File` | `getFile(java.lang.String dir, java.lang.String fname, boolean createDir, boolean createFile)` Returns a File object given the directory location and filename.
`protected void` | `insertFile(java.io.File sourceFile, java.io.File destFile, java.lang.String locationString, boolean afterLine, java.lang.String checkString, boolean insertLinefeed)`
`protected void` | `insertString(java.lang.String stringToInsert, java.io.File destFile, java.lang.String locationString, boolean afterLine, java.lang.String checkString, boolean insertLinefeed)`
`static void` | `main(java.lang.String[] args)`
`protected void` | `parseArguments(java.lang.String[] args)`
`void` | `perform()` Performs this Action.
`protected void` | `removeContents(java.io.File sourceFile, java.io.File destFile)`
`protected void` | `replaceString(java.lang.String stringToInsert, java.io.File destFile, java.lang.String stringToReplace)`
`void` | `stop()` Stops this Action.

Methods inherited from class oracle.ifs.utils.action.AbstractAction
`getDescription, getName, getValue, isContinueOnError, putValue, setDefaultOptions, setDescription, setName, setOptions`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### OS_KEY

    public static final java.lang.String OS_KEY

See Also:
  Constant Field Values

### FILE_OPERATION_KEY

    public static final java.lang.String FILE_OPERATION_KEY

See Also:
  Constant Field Values

### SOURCE_KEY

    public static final java.lang.String SOURCE_KEY

  Description copied from class: `FileHandlingAction`
  The source file (absolute path) Defined as: "source_file". The value for this key is mandatory if the SOURCE_STRING_KEY is not specified. If both SOURCE_STRING_KEY and SOURCE_KEY then SOURCE_KEY takes precedence.

  See Also:
    Constant Field Values

### SOURCE_STRING_KEY

    public static final java.lang.String SOURCE_STRING_KEY

  Description copied from class: `FileHandlingAction`
  The source string Defined as: "source_string". The value for this key is mandatory if the SOURCE_KEY is not specified. If both SOURCE_STRING_KEY and SOURCE_KEY then SOURCE_KEY takes precedence.

  See Also:
    Constant Field Values

### DESTINATION_KEY

    public static final java.lang.String DESTINATION_KEY

  Description copied from class: `FileHandlingAction`
  The destination file (absolute path) Defined as: "destination_file". The value for this key is mandatory.

  See Also:
    Constant Field Values

### CHECKSTRING_KEY

    public static final java.lang.String CHECKSTRING_KEY

  Description copied from class: `FileHandlingAction`
  The string to check if the APPEND/INSERT is conditional. APPEND/INSERT would be executed only if either this string is blank or if it is not blank then the destination file should not have this string. Defined as: "check_string". Default value is ""

  See Also:
    Constant Field Values

### INSERT_LINEFEED_KEY

    public static final java.lang.String INSERT_LINEFEED_KEY

  Description copied from class: `FileHandlingAction`
  A boolean value to tell if you wish to insert a line feed before APPENDING/INSERTING a file or string. Defined as: "insert_linefeed". The value for this key should be either "true" or "false" Default is "false"

  See Also:
    Constant Field Values

### INSERT_AROUND_LINE_KEY

    public static final java.lang.String INSERT_AROUND_LINE_KEY

  Description copied from class: `FileHandlingAction`
  This string is used to find the line after/before which the source file/string is to be inserted. If this string is not found in the destination file then the source file is appeneded in the end. Defined as: "insert_around_line_containing". The value for this key is used in conjunction with INSERT FILE_OPERATION_KEY

  See Also:
    Constant Field Values

### STRING_TO_REPLACE_KEY

    public static final java.lang.String STRING_TO_REPLACE_KEY

  Description copied from class: `FileHandlingAction`
  This is the string which needs to be replaced. The string is replaced by the string specified in SOURCE_STRING_KEY. Defined as: "string_to_replace". The value for this key is used in conjunction with REPLACE FILE_OPERATION_KEY

  See Also:
    Constant Field Values

### INSERT_AFTER_KEY

    public static final java.lang.String INSERT_AFTER_KEY

  Description copied from class: `FileHandlingAction`
  A boolean value to tell if you wish to insert after the line specified using INSERT_AROUND_LINE_KEY or before it. Defined as: "insert_after". The value for this key should be either "true" or "false" Default is "false"

  See Also:
    Constant Field Values

### COPY_IF_NOT_EXIST

    public static final java.lang.String COPY_IF_NOT_EXIST

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### OVERWRITE

    public static final java.lang.String OVERWRITE

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### APPEND

    public static final java.lang.String APPEND

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### APPEND_OR_COPY_IF_NOT_EXIST

    public static final java.lang.String APPEND_OR_COPY_IF_NOT_EXIST

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### APPEND_OR_NOTHING

    public static final java.lang.String APPEND_OR_NOTHING

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### INSERT

    public static final java.lang.String INSERT

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### REPLACE

    public static final java.lang.String REPLACE

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### REMOVE_CONTENT

    public static final java.lang.String REMOVE_CONTENT

  Description copied from class: `FileHandlingAction`
  Value for the key "fileoperation".

  See Also:
    Constant Field Values

### ALL_OS

    public static final java.lang.String ALL_OS

  Description copied from class: `FileHandlingAction`
  Value for the key "os". Specifies to run on all Operating Systems.

  See Also:
    Constant Field Values

### WINDOWS_OS

    public static final java.lang.String WINDOWS_OS

  Description copied from class: `FileHandlingAction`
  Value for the key "os". Specifies to run on all Windows Systems.

  See Also:
    Constant Field Values

### UNIX_OS

    public static final java.lang.String UNIX_OS

  Description copied from class: `FileHandlingAction`
  Value for the key "os". Specifies to run on all Unix Systems.

  See Also:
    Constant Field Values

Constructor Detail

### FileHandlingAction

    public FileHandlingAction(java.lang.String[] args)

### FileHandlingAction

    public FileHandlingAction()

Method Detail

### perform

    public void perform()
                 throws ActionFailedException

  Description copied from class: `FileHandlingAction`
  Performs this Action.

  Throws:
    `ActionFailedException` - if the action could not be performed.
  (Unpublished)

### copyFile

    protected void copyFile(java.io.File sourceFile,
                            java.io.File destFile)
                     throws ActionFailedException

  Throws:
    `ActionFailedException`

### appendString

    protected void appendString(java.lang.String stringToAppend,
                                java.io.File destFile,
                                java.lang.String checkString,
                                boolean insertLinefeed)
                         throws ActionFailedException

  Throws:
    `ActionFailedException`

### appendFile

    protected void appendFile(java.io.File sourceFile,
                              java.io.File destFile,
                              java.lang.String checkString,
                              boolean insertLinefeed)
                       throws ActionFailedException

  Throws:
    `ActionFailedException`

### insertString

    protected void insertString(java.lang.String stringToInsert,
                                java.io.File destFile,
                                java.lang.String locationString,
                                boolean afterLine,
                                java.lang.String checkString,
                                boolean insertLinefeed)
                         throws ActionFailedException

  Throws:
    `ActionFailedException`

### insertFile

    protected void insertFile(java.io.File sourceFile,
                              java.io.File destFile,
                              java.lang.String locationString,
                              boolean afterLine,
                              java.lang.String checkString,
                              boolean insertLinefeed)
                       throws ActionFailedException

  Throws:
    `ActionFailedException`

### replaceString

    protected void replaceString(java.lang.String stringToInsert,
                                 java.io.File destFile,
                                 java.lang.String stringToReplace)
                          throws ActionFailedException

  Throws:
    `ActionFailedException`

### removeContents

    protected void removeContents(java.io.File sourceFile,
                                  java.io.File destFile)
                           throws ActionFailedException

  Throws:
    `ActionFailedException`

### doesFileContainString

    protected boolean doesFileContainString(java.io.File file,
                                            java.lang.String checkString)
                                     throws ActionFailedException

  Throws:
    `ActionFailedException`

### getFile

    protected java.io.File getFile(java.lang.String dir,
                                   java.lang.String fname,
                                   boolean createDir,
                                   boolean createFile)
                            throws ActionFailedException

  Description copied from class: `FileHandlingAction`
  Returns a File object given the directory location and filename. It performs the following checks: - Whether the parent directory exists. - Whether the file exists. It provides flags to indicate: - Whether the parent directory should be created. - Whether a new file should be created.

  Parameters:
    `dir` - the parent directory.
    `fname` - the filename.
    `createDir` - whether the parent directory should be created.
    `createFile` - whether a new file should be created.
  Returns:
    the File object.
  Throws:
    `java.lang.Exception` - if an error occurs.
    `ActionFailedException`

### failed

    public void failed(java.lang.Throwable t)

  Description copied from interface: `Action`
  Invoked if this Action has failed. If an exception is caught by the ActionQueue that is executing this Action, this method will be invoked. If necessary, this method should roll back or otherwise reverse the tasks or operations that the `perform` method has executed.

  Parameters:
    `t` - the error that occurred.

### stop

    public void stop()

  Description copied from interface: `Action`
  Stops this Action. Invoking this method should ensure that the call to `perform` will return as soon as possible. This method should do nothing if this Action has already been stopped.

  This method will probably be invoked from within the Thread that created the ActionQueue that this Action is being executed in, rather than from within the Thread that is invoking the `perform` method (the ActionQueue's Action processing Thread). Because of this, clients implementing this interface should provide a way of canceling what is happening in the `perform` method when this `stop` method is invoked.

  Note: this is especially important when the `perform` method executes a tight loop or creates new Threads.

### parseArguments

    protected void parseArguments(java.lang.String[] args)

### main

    public static void main(java.lang.String[] args)
                     throws ActionFailedException

  Throws:
    `ActionFailedException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD