public class

DiagnosticsViewerTransformHelper

extends Object
java.lang.Object
   ↳ com.microstrategy.web.admin.transforms.DiagnosticsViewerTransformHelper

Class Overview

Title: DiagnosticsViewerTransformHelper This class provides a series of helper methods for building up the XML that will be displayed to the user as Log Diagnostic information

Summary

Constants
int FILE_READING_EXCEPTION Identifier for exceptions generated related with problems reading a file on the specified path location
int WRONG_PARAMETERS_EXCEPTION Identifier for exceptions generated related with wrong parameters received in the method call
int XML_PARSING_EXCEPTION Identifier for exceptions generated related with XML Parsing of a String or a File
Public Constructors
DiagnosticsViewerTransformHelper()
Public Methods
static HashList generateNumericComboContents(int start, int end)
Generate a combo box with the value range specified.
static BufferedReader getDiagnosticHTMLContent(TransformerFactory tFactory, DiagnosticsBean bean, String xslPath, Document originalXML)
Based on the XML received, transform it with the XSL indicated and return the result of the transform on a BufferedReader instance.
static NodeList getSingleFileContent(DOMSupport domSupport, Document xmlDocument, String filePath)
Reads the contents of the file specified on the path, adds a beginning and ending tag for it to be translated into an XML Document format.
static String getXMLLogFileContents(DiagnosticsBean bean, DOMSupport domSupport, Document xmlDocument)
Given the DiagnosticsBean instance properties regarding start and end dates to display log files, get the file information and gather it on a Document instance.
static void renderBufferedReaderContents(MarkupOutput out, BufferedReader bufferedReader)
Save the contents of the BufferedReader instance into the MarkupOutput instance so they can be displayed to the user.
static void renderDateComboBoxes(MarkupOutput out, String formatString, int year, int month, int day, String paramYear, String paramMonth, String paramDay)
For the given year, month and day information, the format and the name of the parameters to use, generate three combo boxes for allowing users to select dates.
static Document sortDiagnosticXMLFile(TransformerFactory tFactory, DiagnosticsBean bean, String xslPath, Document originalXML)
Given an original XML file, it transforms it with the xsl file specified.
static boolean validateDate(Calendar fromDate, Calendar toDate, DiagnosticsBean bean)
Validate the dates specified by the user.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int FILE_READING_EXCEPTION

Identifier for exceptions generated related with problems reading a file on the specified path location

Constant Value: 3 (0x00000003)

public static final int WRONG_PARAMETERS_EXCEPTION

Identifier for exceptions generated related with wrong parameters received in the method call

Constant Value: 2 (0x00000002)

public static final int XML_PARSING_EXCEPTION

Identifier for exceptions generated related with XML Parsing of a String or a File

Constant Value: 1 (0x00000001)

Public Constructors

public DiagnosticsViewerTransformHelper ()

Public Methods

public static HashList generateNumericComboContents (int start, int end)

Generate a combo box with the value range specified. Used for building up combo boxes for representing days, months or years.

Parameters
start number where to start the list (inclusive)
end number where to end the list (inclusive)
Returns
  • a HashList with the contents for the combo box to generate. For example, if specifying start = 1 and end = 30, it will generate a combo box that can be used for representing months like April, June, etc. This combo box can later on be input argument for one of the display combo boxes methods available on HTMLHelper

public static BufferedReader getDiagnosticHTMLContent (TransformerFactory tFactory, DiagnosticsBean bean, String xslPath, Document originalXML)

Based on the XML received, transform it with the XSL indicated and return the result of the transform on a BufferedReader instance. Used normally for getting HTML from the XML and later on display it to the user.

Parameters
tFactory a TransformerFactory initialized instance
bean DiagnosticsBean currently being transformed
xslPath a String with the location of the XSL file to use for transforming the XML. Commonly, /WEB-INF/xml/DisplayErrors.xsl can be used.
originalXML the original XML containing the log information to be sorted
Returns
  • a BufferedReader instance with the contents of the XML transformed. If it could not be performed, it will return null.
Throws
WebAppException if any error happened while transforming the XML.

public static NodeList getSingleFileContent (DOMSupport domSupport, Document xmlDocument, String filePath)

Reads the contents of the file specified on the path, adds a beginning and ending tag for it to be translated into an XML Document format.

Parameters
domSupport DOMSupport initialized instance
xmlDocument original Document instance where the generated XML node list will be copied over.
filePath String with the location and name of the file to read
Returns
  • a NodeList instance initialized with the contents of the file. The tags added for it to be a valid XML Document are removed, so the original children are the ones returned
Throws
WebAppException if any problem happens while reading the file contents or building up the XML structure. The exceptions will use codes such as XML_PARSING_EXCEPTION, WRONG_PARAMETERS_EXCEPTION, etc.

public static String getXMLLogFileContents (DiagnosticsBean bean, DOMSupport domSupport, Document xmlDocument)

Given the DiagnosticsBean instance properties regarding start and end dates to display log files, get the file information and gather it on a Document instance.

Parameters
bean DiagnosticsBean currently being transformed
domSupport initialized DOMSupport instance
xmlDocument Document instance where the XML contents of the files will be saved.
Returns
  • a String with the information of those log files that was not possible to read. By specification, if there are log file contents to display even that some files failed, an empty string will be returned.

public static void renderBufferedReaderContents (MarkupOutput out, BufferedReader bufferedReader)

Save the contents of the BufferedReader instance into the MarkupOutput instance so they can be displayed to the user.

Parameters
out MarkupOutput instance where to save the contents to be rendered
bufferedReader BufferedReader instance with the information that should be displayed
Throws
WebAppException if an error happens while processing the BufferedReader instance.

public static void renderDateComboBoxes (MarkupOutput out, String formatString, int year, int month, int day, String paramYear, String paramMonth, String paramDay)

For the given year, month and day information, the format and the name of the parameters to use, generate three combo boxes for allowing users to select dates.

Parameters
out MarkupOutput instance where to save the contents generated
formatString a String like mmddyyyy which specifies in which order year, month and day will be displayed
year the current value selected for year
month the current value selected for month
day the current value selected for day
paramYear the name of the parameter to use for the year combo box to generate
paramMonth the name of the parameter to use for the month combo box to generate
paramDay the name of the parameter to use for the day combo box to generate

public static Document sortDiagnosticXMLFile (TransformerFactory tFactory, DiagnosticsBean bean, String xslPath, Document originalXML)

Given an original XML file, it transforms it with the xsl file specified. This method will mostly be used for sorting the contents of the log XML file given the configuration fields there included as well as the specifications on the XSL to be used.

Parameters
tFactory a TransformerFactory initialized instance
bean DiagnosticsBean currently being transformed
xslPath a String with the location of the XSL file to use for transforming the XML. Commonly, /WEB-INF/xml/SortErrors.xsl can be used.
originalXML the original XML containing the log information to be sorted
Returns
  • a Document instance with the sorted XML
Throws
WebAppException if any error happens while transforming the XML

public static boolean validateDate (Calendar fromDate, Calendar toDate, DiagnosticsBean bean)

Validate the dates specified by the user.

Parameters
fromDate a Calendar instance initialized with the start date, loaded from individual year, month and day values
toDate a Calendar instance initialized with the end date, loaded from individual year, month and day values
bean the DiagnosticsBean instance being transformed, and where the start and end dates are also stored.
Returns
  • True if the dates are valid
Throws
WebAppException if an error happens while analyzing the dates or if the dates are not validated properly. For example, if the start date is after the end date, if a date does not make sense (Feb 30), etc.