com.xmatters.ca.servicedesk.util
Class ParseCAFile

java.lang.Object
  extended by com.xmatters.ca.servicedesk.util.ParseCAFile

public class ParseCAFile
extends java.lang.Object

This class parses the CA notification file generated by CA Service Desk when the 'Write to file' check box is selected in the xMatters Notification Method Detail page.

This class follows the description of the Notification File as described in the CA Service Desk Manager Implementation Guide r12.5, Chapter 6: Customising, Subsection: The Notification File, page 241.

The file is parsed into three maps representing each section of the file. The parse method of this class returns a map containing the three maps. The key for each map is the name of each section. Within each section map the attributes in the notification file are the keys.


Constructor Summary
ParseCAFile()
           
ParseCAFile(java.lang.String file)
           
 
Method Summary
 void copyFileTo(java.io.File destFile, boolean preserveFileDate)
          Exposing the raw copy operation so that clients can implement their own 'markedProcessed' logic.
 java.lang.String getEncoding()
           
 java.lang.String getEQUALS()
           
 java.lang.String getFILE_SECTION_DIVIDER()
           
 java.lang.String getFILE_SECTION_HEADER()
           
 java.lang.String getFile()
           
 java.lang.String getNEW_KEY_PREFIX()
           
 java.lang.String getNEWLINE()
           
 java.lang.String getProcessedFile()
           
 boolean isCopyAfterProcessing()
           
 void markProcessed()
          Convenience method that provides a default processed file location and file name.
 void markProcessed(java.lang.String directory)
          Convenience method that provides a default processed file name.
 void markProcessed(java.lang.String directory, java.lang.String file)
          This method is provided to either copy or move the parsed CA SDM notification method file once it has been processed.
 void moveFile(java.io.File destFile)
          Exposing the raw move operation so that clients can implement their own 'markedProcessed' logic.
 java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> parse()
          Parse a CA Service Desk notification method file.
 void setCopyAfterProcessing(boolean copyAfterProcessing)
           
 void setEncoding(java.lang.String fileEncoding)
           
 void setEQUALS(java.lang.String eQUALS)
           
 void setFILE_SECTION_DIVIDER(java.lang.String fILESECTIONDIVIDER)
           
 void setFILE_SECTION_HEADER(java.lang.String fILESECTIONHEADER)
           
 void setFile(java.lang.String file)
           
 void setNEW_KEY_PREFIX(java.lang.String nEWKEYPREFIX)
           
 void setNEWLINE(java.lang.String nEWLINE)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseCAFile

public ParseCAFile()

ParseCAFile

public ParseCAFile(java.lang.String file)
Method Detail

parse

public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> parse()
                                                                                       throws java.io.FileNotFoundException
Parse a CA Service Desk notification method file.

Returns:
Map containing the notification file sections and their key value pairs
Throws:
java.io.FileNotFoundException

markProcessed

public void markProcessed(java.lang.String directory,
                          java.lang.String file)
                   throws java.io.IOException
This method is provided to either copy or move the parsed CA SDM notification method file once it has been processed. This is not a required operation but provided to help differeniate CA SDM notification method files that have been processed by CA SDM versus notification method files that belong to processes outside of the integration. By default this method will attempt to copy the processed file to a subdirectory of the current location of the notification method file called xmatters. If the directory is not present it should be created. The setter methods: setProcessedDirectory and setCopyAfterProcessing can be used to alter this behaviour. If the user does not want this behaviour at all, this method should be removed from caservicedesk.js.

Parameters:
directory - A string representing the target directory for the processed file.
file - A string representing the target file name for the processed file.
Throws:
java.io.IOException

markProcessed

public void markProcessed(java.lang.String directory)
                   throws java.io.IOException
Convenience method that provides a default processed file name.

Throws:
java.io.IOException

markProcessed

public void markProcessed()
                   throws java.io.IOException
Convenience method that provides a default processed file location and file name.

Throws:
java.io.IOException

copyFileTo

public void copyFileTo(java.io.File destFile,
                       boolean preserveFileDate)
                throws java.io.IOException
Exposing the raw copy operation so that clients can implement their own 'markedProcessed' logic.

Parameters:
destFile - A java File object that represents the target file to copy to.
preserveFileDate - Expose Apache Commons FileUtils.copyFile preserveFileDate parameter so clients can choose behaviour.
Throws:
java.io.IOException

moveFile

public void moveFile(java.io.File destFile)
              throws java.io.IOException
Exposing the raw move operation so that clients can implement their own 'markedProcessed' logic.

Parameters:
destFile - A java File object that represents the target file to move to.
Throws:
java.io.IOException

getFile

public java.lang.String getFile()

setFile

public final void setFile(java.lang.String file)

getProcessedFile

public java.lang.String getProcessedFile()

isCopyAfterProcessing

public boolean isCopyAfterProcessing()

setCopyAfterProcessing

public void setCopyAfterProcessing(boolean copyAfterProcessing)

setEncoding

public void setEncoding(java.lang.String fileEncoding)

getEncoding

public java.lang.String getEncoding()

getNEWLINE

public java.lang.String getNEWLINE()

setNEWLINE

public void setNEWLINE(java.lang.String nEWLINE)

getEQUALS

public java.lang.String getEQUALS()

setEQUALS

public void setEQUALS(java.lang.String eQUALS)

getFILE_SECTION_DIVIDER

public java.lang.String getFILE_SECTION_DIVIDER()

setFILE_SECTION_DIVIDER

public void setFILE_SECTION_DIVIDER(java.lang.String fILESECTIONDIVIDER)

getFILE_SECTION_HEADER

public java.lang.String getFILE_SECTION_HEADER()

setFILE_SECTION_HEADER

public void setFILE_SECTION_HEADER(java.lang.String fILESECTIONHEADER)

getNEW_KEY_PREFIX

public java.lang.String getNEW_KEY_PREFIX()

setNEW_KEY_PREFIX

public void setNEW_KEY_PREFIX(java.lang.String nEWKEYPREFIX)