Class DiagnosticsViewerTransformHelper


  • public class DiagnosticsViewerTransformHelper
    extends java.lang.Object
    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
    Since:
    MicroStrategy Web 7.3.1 or earlier
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int FILE_READING_EXCEPTION
      Identifier for exceptions generated related with problems reading a file on the specified path location
      static int WRONG_PARAMETERS_EXCEPTION
      Identifier for exceptions generated related with wrong parameters received in the method call
      static int XML_PARSING_EXCEPTION
      Identifier for exceptions generated related with XML Parsing of a String or a File
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static HashList generateNumericComboContents​(int start, int end)
      Generate a combo box with the value range specified.
      static java.io.BufferedReader getDiagnosticHTMLContent​(DiagnosticsBean bean, java.lang.String xslPath, org.w3c.dom.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 org.w3c.dom.NodeList getSingleFileContent​(DOMSupport domSupport, org.w3c.dom.Document xmlDocument, java.lang.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 java.lang.String getXMLLogFileContents​(DiagnosticsBean bean, DOMSupport domSupport, org.w3c.dom.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, java.io.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, java.lang.String formatString, int year, int month, int day, java.lang.String paramYear, java.lang.String paramMonth, java.lang.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 org.w3c.dom.Document sortDiagnosticXMLFile​(DiagnosticsBean bean, java.lang.String xslPath, org.w3c.dom.Document originalXML)
      Given an original XML file, it transforms it with the xsl file specified.
      static boolean validateDate​(java.util.Calendar fromDate, java.util.Calendar toDate, DiagnosticsBean bean)
      Validate the dates specified by the user.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • XML_PARSING_EXCEPTION

        public static final int XML_PARSING_EXCEPTION
        Identifier for exceptions generated related with XML Parsing of a String or a File
        See Also:
        Constant Field Values
      • WRONG_PARAMETERS_EXCEPTION

        public static final int WRONG_PARAMETERS_EXCEPTION
        Identifier for exceptions generated related with wrong parameters received in the method call
        See Also:
        Constant Field Values
      • FILE_READING_EXCEPTION

        public static final int FILE_READING_EXCEPTION
        Identifier for exceptions generated related with problems reading a file on the specified path location
        See Also:
        Constant Field Values
    • Constructor Detail

      • DiagnosticsViewerTransformHelper

        public DiagnosticsViewerTransformHelper()
    • Method Detail

      • getSingleFileContent

        public static org.w3c.dom.NodeList getSingleFileContent​(DOMSupport domSupport,
                                                                org.w3c.dom.Document xmlDocument,
                                                                java.lang.String filePath)
                                                         throws WebAppException
        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.
      • getXMLLogFileContents

        public static java.lang.String getXMLLogFileContents​(DiagnosticsBean bean,
                                                             DOMSupport domSupport,
                                                             org.w3c.dom.Document xmlDocument)
                                                      throws WebAppException
        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.
        Throws:
        WebAppException
      • validateDate

        public static boolean validateDate​(java.util.Calendar fromDate,
                                           java.util.Calendar toDate,
                                           DiagnosticsBean bean)
                                    throws WebAppException
        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.
      • generateNumericComboContents

        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
      • sortDiagnosticXMLFile

        public static org.w3c.dom.Document sortDiagnosticXMLFile​(DiagnosticsBean bean,
                                                                 java.lang.String xslPath,
                                                                 org.w3c.dom.Document originalXML)
                                                          throws WebAppException
        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:
        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
      • getDiagnosticHTMLContent

        public static java.io.BufferedReader getDiagnosticHTMLContent​(DiagnosticsBean bean,
                                                                      java.lang.String xslPath,
                                                                      org.w3c.dom.Document originalXML)
                                                               throws WebAppException
        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:
        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.
      • renderDateComboBoxes

        public static void renderDateComboBoxes​(MarkupOutput out,
                                                java.lang.String formatString,
                                                int year,
                                                int month,
                                                int day,
                                                java.lang.String paramYear,
                                                java.lang.String paramMonth,
                                                java.lang.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
      • renderBufferedReaderContents

        public static void renderBufferedReaderContents​(MarkupOutput out,
                                                        java.io.BufferedReader bufferedReader)
                                                 throws WebAppException
        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.