├── .gitignore ├── ERWeb ├── .project ├── bsoauth.sh ├── ersite.cgi ├── getbinaryfile.cgi ├── loadconfig.cgi ├── logs │ ├── my.log │ ├── reset_logs.sh │ ├── stats.log │ └── visits.log ├── properties ├── readme-for-eclipse └── tests │ ├── test_framework.cgi │ ├── test_getbinaryfile.cgi │ └── test_post.cgi ├── LICENSE ├── README.md ├── framework ├── Analytics.xml ├── AnalyticsLegacy.xml ├── build.xml ├── dptransx.xml ├── lib │ ├── apache-mime4j-0.6.jar │ ├── commons-compress-1.8.1.jar │ ├── commons-io-1.2.jar │ ├── commons-lang3-3.1.jar │ ├── commons-logging-1.1.1.jar │ ├── commons-logging-1.2.jar │ ├── ibmjsseprovider2.jar │ ├── icl.jar │ ├── junit-3.8.1.jar │ ├── log4j-api-2.16.0.jar │ ├── log4j-api-2.19.0.jar │ ├── log4j-core-2.16.0.jar │ ├── log4j-core-2.19.0.jar │ ├── org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f.jar │ ├── org.eclipse.swt_3.7.2.v3740f.jar │ ├── swt-4.35M1-cocoa-macosx-aarch64.jar │ ├── swt-4.35M1-cocoa-macosx-x86_64.jar │ ├── swt-4.5-gtk-linux-x86.jar │ ├── swt-4.5-gtk-linux-x86_64.jar │ └── swt.jar ├── postmortem.xml ├── properties │ ├── backtraceonly.properties │ ├── config.properties │ ├── htmldefault.properties │ ├── sidecar.properties │ └── zipfile.properties ├── src │ ├── Analytics │ │ ├── analyticsform.txt │ │ ├── analyticsjsheader.txt │ │ └── latency.analytics.html │ ├── ERMessages.properties │ ├── com │ │ └── ibm │ │ │ └── datapower │ │ │ └── er │ │ │ ├── Analytics │ │ │ ├── AnalyticsFunctions.java │ │ │ ├── AnalyticsProcessor.java │ │ │ ├── AnalyticsResults.java │ │ │ ├── ConditionField.java │ │ │ ├── ConditionSort.java │ │ │ ├── ConditionsNode.java │ │ │ ├── DocSort.java │ │ │ ├── DocumentSection.java │ │ │ ├── ERMimeSection.java │ │ │ ├── MappedCondition.java │ │ │ ├── ObjectComparison.java │ │ │ ├── ReferenceURL.java │ │ │ ├── RegEXPCache.java │ │ │ ├── Structure │ │ │ │ ├── DSCacheEntry.java │ │ │ │ ├── Expression.java │ │ │ │ ├── Formula.java │ │ │ │ ├── ItemObject.java │ │ │ │ ├── ItemStructure.java │ │ │ │ └── RunFormula.java │ │ │ ├── TestAnalytics.java │ │ │ └── XPathCache.java │ │ │ ├── ERCommandLineArgs.java │ │ │ ├── ERException.java │ │ │ ├── ERFramework.java │ │ │ ├── ERFrameworkFileException.java │ │ │ ├── ERFrameworkIOException.java │ │ │ ├── ERFrameworkMimeException.java │ │ │ ├── ERFrameworkParseException.java │ │ │ ├── ERFrameworkRun.java │ │ │ ├── ERFrameworkXMLException.java │ │ │ ├── ERTool.java │ │ │ ├── ERToolLogFormatter.java │ │ │ ├── ErrorReportDetails.java │ │ │ ├── FirmwareInputStream.java │ │ │ ├── IPartInfo.java │ │ │ ├── IPartsProcessor.java │ │ │ ├── PartsProcessorBacktrace.java │ │ │ ├── PartsProcessorBacktraceHTML.java │ │ │ ├── PartsProcessorBacktraceZIP.java │ │ │ ├── PartsProcessorZIP.java │ │ │ ├── PartsProcessorsHTML.java │ │ │ ├── PartsProcessorsXForm.java │ │ │ ├── PrePostProcessorHTML.java │ │ │ ├── PrePostProcessorZip.java │ │ │ ├── PrePostReportProcessor.java │ │ │ ├── ReportProcessor.java │ │ │ ├── ReportProcessorPartInfo.java │ │ │ ├── Transactions │ │ │ ├── LogField.java │ │ │ ├── LogMessage.java │ │ │ ├── LogMessageSort.java │ │ │ ├── LogType.java │ │ │ ├── ParseTransx.java │ │ │ ├── RunTransaction.java │ │ │ ├── TestTransx.java │ │ │ ├── Transaction.java │ │ │ ├── TransactionHistory.java │ │ │ ├── TransactionSort.java │ │ │ └── TransxXML.java │ │ │ ├── erGUI.java │ │ │ └── mgmt │ │ │ ├── Base64.java │ │ │ ├── DeviceProfile.java │ │ │ ├── ERConnection.java │ │ │ ├── ERFailureNotificationStatus.java │ │ │ ├── ERFilestore.java │ │ │ ├── ERMgmtAuthenticationException.java │ │ │ ├── ERMgmtBadResponseException.java │ │ │ ├── ERMgmtCertificateException.java │ │ │ ├── ERMgmtConnectException.java │ │ │ ├── ERMgmtException.java │ │ │ ├── ERMgmtFileException.java │ │ │ ├── ERMgmtHttpNotOKException.java │ │ │ ├── ERMgmtIOException.java │ │ │ ├── ERMgmtInvalidPortException.java │ │ │ ├── ERMgmtNoHttpResponseException.java │ │ │ ├── ERMgmtNoRouteToHostException.java │ │ │ ├── ERMgmtSAXException.java │ │ │ ├── ERMgmtUnknownHostException.java │ │ │ ├── ERTrustManager.java │ │ │ ├── ERTrustManagerCertificateException.java │ │ │ ├── ERXmlMgmt.java │ │ │ ├── Message.java │ │ │ ├── SoapEnvelope.java │ │ │ ├── SoapManagementRequest.java │ │ │ └── TraceHelper.java │ ├── erCSV.xsl │ ├── erHTML.xsl │ ├── erTEXT.xsl │ └── internal │ │ └── ERBacktrace.java ├── syscall.cgi └── tools │ └── internal │ └── ERBacktrace.java └── post-processing-error-reports ├── README.txt └── errReportPostProcessing.pl /.gitignore: -------------------------------------------------------------------------------- 1 | framework/bin/ 2 | framework/dist/ 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /ERWeb/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ERWeb 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | 19 | src 20 | 2 21 | PARENT-1-PROJECT_LOC/framework/src 22 | 23 | 24 | -------------------------------------------------------------------------------- /ERWeb/getbinaryfile.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | ##used for getting background packet capture objects 4 | 5 | use CGI; 6 | use HTTP::Request::Common; 7 | use LWP::Simple; 8 | use LWP; 9 | 10 | my $cgi = new CGI; 11 | my $path = "framework/tmp/"; 12 | my $fullfile = $cgi->param("filename"); 13 | my @fileholder; 14 | 15 | #my $filename = substr($fullfile, rindex($fullfile, '/')); 16 | my $filename = $path.$fullfile; 17 | 18 | #open(FILE, "<$fullfile") || die ('cannot open file'); 19 | #@fileholder = ; 20 | #close (FILE) or die ('error closing file'); 21 | 22 | print $cgi->header(-type=>"application/octet-stream; name=\"$fullfile\"", -content_disposition=> "attachment; filename=\"$fullfile\""); 23 | print `cat $filename`; 24 | exit; 25 | -------------------------------------------------------------------------------- /ERWeb/loadconfig.cgi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/ERWeb/loadconfig.cgi -------------------------------------------------------------------------------- /ERWeb/logs/my.log: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /ERWeb/logs/reset_logs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT=$(readlink -f $0) 4 | SCRIPTPATH=`dirname $SCRIPT` 5 | 6 | OLD="[0-9]\{1,2\}" 7 | NEW="0" 8 | DPATH="./*" 9 | FILES=($SCRIPTPATH/stats.log $SCRIPTPATH/visits.log) 10 | 11 | TFILE="out.tmp.$$" 12 | 13 | for f in "${FILES[@]}" 14 | do 15 | if [ -f $f -a -r $f ]; then 16 | TEMP=$(sed "s/$OLD/$NEW/g" "$f") 17 | echo "$TEMP" > $f 18 | #$TFILE && mv $TFILE "$f" 19 | else 20 | echo "Error: Cannot read $f" 21 | fi 22 | 23 | done 24 | /bin/rm $TFILE 2> "/dev/null" 25 | 26 | LOG="$SCRIPTPATH/my.log" 27 | 28 | echo "" > $LOG 29 | 30 | -------------------------------------------------------------------------------- /ERWeb/logs/stats.log: -------------------------------------------------------------------------------- 1 | Full Error Reports: 0 2 | Backtrace Only Error Reports: 0 3 | Failed Backtraces: 0 4 | Java Failures: 0 5 | -------------------------------------------------------------------------------- /ERWeb/logs/visits.log: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /ERWeb/properties: -------------------------------------------------------------------------------- 1 | ../framework/properties/ -------------------------------------------------------------------------------- /ERWeb/readme-for-eclipse: -------------------------------------------------------------------------------- 1 | This directory simply houses some eclipse project files and symbolic links to the src and bin directories of the ER Tool codebase. 2 | When built using jmake, the Java binaries (class files) are archived into a jar and written to the dist directory. 3 | 4 | The tool is executed with a small shell script, name ertool, that builds and exports the Java class path and runs the 5 | executable class com.ibm.datapower.er.ERFrameworkRun. A list of acceptable options is available by running the tool without 6 | positional parameters. The ertool script sets up the class path to be the dist directory so that it can load a distribution 7 | approved build from the jar files in it. For development purposes, there is a statement, commented out by default, to set the class path 8 | to the bin directory, which is where eclipse will output all build artifacts. It may or may not be a good idea to just make a special 9 | development copy of ertool that just looks at the bin directory, but at this point the first option seems more fitting. 10 | -------------------------------------------------------------------------------- /ERWeb/tests/test_framework.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | #used for testing framework outside of perl ersite.cgi 4 | 5 | use DBI; 6 | use CGI; 7 | use strict; 8 | use CGI::Carp qw(fatalsToBrowser); 9 | 10 | 11 | my $path = "../framework/"; 12 | my $cgi = new CGI; 13 | 14 | chdir($path) or die "Cant chdir to $path $!"; 15 | 16 | 17 | 18 | my $file = $ARGV[0]; 19 | my $mode = $ARGV[1]; 20 | my $property_file = "properties/zipfile.properties"; 21 | 22 | if(defined($ARGV[2])){ 23 | #property_file = $ARGV[2]; 24 | } 25 | 26 | if(index($mode, "-")<0){ 27 | $mode = "-".$mode; 28 | } 29 | 30 | #my $result = `./alex_ertool -i $file -p $process_property_file`; 31 | #my $result = `./alex_ertool -i ../$file -z 2>&1`; 32 | my $result = `./alex_ertool -i ../$file $mode -p $property_file 2>&1`; 33 | 34 | 35 | #open FILE, "mreport.html" or die $!; 36 | #my $output = ""; 37 | #my $ch; 38 | #while () { 39 | # chomp; 40 | # $output = $output.$_."\n"; 41 | #} 42 | #close (FILE); 43 | 44 | 45 | 46 | print $cgi->header(-type=>"application/x-zip; name=\"$file.zip\"", 47 | -content_disposition=> "attachment; filename=\"$file.zip\""); 48 | print $result; 49 | 50 | -------------------------------------------------------------------------------- /ERWeb/tests/test_getbinaryfile.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | ##used for testing the processing of binary data 4 | 5 | use CGI; 6 | use HTTP::Request::Common; 7 | use LWP::Simple; 8 | use LWP; 9 | 10 | my $cgi = new CGI; 11 | my $path = "tmp/"; 12 | my $filename = $cgi->param("filename"); 13 | my @fileholder; 14 | 15 | my $fullfile = $path.$filename; 16 | 17 | 18 | #open(FILE, "<$fullfile") || die ('cannot open file'); 19 | #@fileholder = ; 20 | #close (FILE) or die ('error closing file'); 21 | 22 | print $cgi->header(-type=>"application/octet-stream; name=\"$filename\"", -content_disposition=> "attachment; filename=\"$filename\""); 23 | print `cat $fullfile`; 24 | exit; 25 | -------------------------------------------------------------------------------- /ERWeb/tests/test_post.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | ###used to test LWP Posting to a site 4 | 5 | use CGI; 6 | use HTTP::Request::Common; 7 | use LWP::Simple; 8 | use LWP; 9 | 10 | my $thedata = ""; 11 | 12 | my ($bytesread, $buffer); 13 | my $numbytes = 1024; 14 | my $totalbytes = 0; 15 | my $filename = "error-report.130025Z.20110513144220EDT.txt.gz"; 16 | open FILE, "<$filename" or die $!; 17 | 18 | while ($bytesread = read(FILE, $buffer, $numbytes)) { 19 | $totalbytes += $bytesread; 20 | $thedata = $thedata . $buffer; 21 | } 22 | 23 | my %URLParameters = ( 24 | "contents" => "$thedata", 25 | "filename" => "posted-stream", 26 | "process_type" => "fullHTML", 27 | ); 28 | 29 | 30 | my $LWPAgent = LWP::UserAgent->new; 31 | my $url = "http://localhost/ertool/ersite.cgi"; 32 | my $Request = POST($url, Content_Type => 'form-data', Content => \%URLParameters); 33 | my $Response = $LWPAgent->request($Request); 34 | print "Content-type: text/html\n\n"; 35 | print($Response->content); 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Error Report Tool (ERTool) 2 | 3 | ERTool is a java package for data analysis which simplifies processing large data-sets. This primarily focuses on the multipart-data obtained in a DataPower Error Report (.txt.gz), MQ Appliance (txt.gz) through Analytics.xml. Additionally supports Cast Iron/API Management (.tar.gz formatted files/directory lists) through postmortem.xml. 4 | 5 | ## Prerequisites 6 | 7 | * JDK 11 or later 8 | * Apache Ant (Tested with 1.10.7) 9 | 10 | ## Building 11 | 12 | After you obtain the source either via a Git client or by downloading the repository zip file, you can build the code using Apache Ant. Enter the framework directory and issue the command below (assumes Apache Ant is in the path): 13 | 14 | ``` 15 | ant -buildfile build.xml 16 | ``` 17 | 18 | The `ErrorReport.jar` will be found in `dist/`. 19 | 20 | ## Running 21 | 22 | For GUI: 23 | 24 | ``` 25 | java -jar ErrorReport.jar -gui 26 | ``` 27 | 28 | Special note regarding running the GUI on macOS: You will need to specify `-XstartOnFirstThread` in the vmargs: 29 | 30 | ``` 31 | java -XstartOnFirstThread -jar ErrorReport.jar -gui 32 | ``` 33 | 34 | For Text/CLI with no logging: 35 | 36 | ``` 37 | java -jar ErrorReport.jar -file "error-report.txt.gz" -analyticsfile Analytics.xml -loglevel none 1> "destinationfile.txt" 38 | ``` 39 | 40 | For Text/CLI with logging: 41 | 42 | ``` 43 | java -jar ErrorReport.jar -file "error-report.txt.gz" -analyticsfile Analytics.xml -loglevel info -outfile "destinationfile.txt" 44 | ``` 45 | 46 | - In the CLI the `-format HTML` argument can be used to generate an HTML report to the destination file. 47 | * If `ErrorReport.jar` runs out of memory, increase the available JVM by adding `-Xmx8096m` as an argument to `java`. 48 | * If Stack Overflow Exceptions occur increase the stack size of the JVM by adding `-Xss8m` as an argument to `java`. 49 | * In cases of Stack Overflow some formulas will require large stack sizes, in testing some have required 512M for 100K lines parsed in regular expressions. 50 | * The `loglevel` argument can be set to `none`|`info`|`debug` to provide more information when testing formulas. 51 | 52 | ## Contributing 53 | 54 | If you want to contribute to the project, you will need to fill in the appropriate Contributor License agreement which can be found under the CLA directory. Follow the directions inside the document so that any submissions can be properly accepted into the repository. 55 | 56 | ## License 57 | 58 | The code is licensed under the terms of the Apache License 2.0. See the acompanying 'LICENSE' file for further details. 59 | -------------------------------------------------------------------------------- /framework/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ANT script for ErrorReporting framework 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /framework/lib/apache-mime4j-0.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/apache-mime4j-0.6.jar -------------------------------------------------------------------------------- /framework/lib/commons-compress-1.8.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/commons-compress-1.8.1.jar -------------------------------------------------------------------------------- /framework/lib/commons-io-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/commons-io-1.2.jar -------------------------------------------------------------------------------- /framework/lib/commons-lang3-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/commons-lang3-3.1.jar -------------------------------------------------------------------------------- /framework/lib/commons-logging-1.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/commons-logging-1.1.1.jar -------------------------------------------------------------------------------- /framework/lib/commons-logging-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/commons-logging-1.2.jar -------------------------------------------------------------------------------- /framework/lib/ibmjsseprovider2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/ibmjsseprovider2.jar -------------------------------------------------------------------------------- /framework/lib/icl.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/icl.jar -------------------------------------------------------------------------------- /framework/lib/junit-3.8.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/junit-3.8.1.jar -------------------------------------------------------------------------------- /framework/lib/log4j-api-2.16.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/log4j-api-2.16.0.jar -------------------------------------------------------------------------------- /framework/lib/log4j-api-2.19.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/log4j-api-2.19.0.jar -------------------------------------------------------------------------------- /framework/lib/log4j-core-2.16.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/log4j-core-2.16.0.jar -------------------------------------------------------------------------------- /framework/lib/log4j-core-2.19.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/log4j-core-2.19.0.jar -------------------------------------------------------------------------------- /framework/lib/org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f.jar -------------------------------------------------------------------------------- /framework/lib/org.eclipse.swt_3.7.2.v3740f.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/org.eclipse.swt_3.7.2.v3740f.jar -------------------------------------------------------------------------------- /framework/lib/swt-4.35M1-cocoa-macosx-aarch64.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/swt-4.35M1-cocoa-macosx-aarch64.jar -------------------------------------------------------------------------------- /framework/lib/swt-4.35M1-cocoa-macosx-x86_64.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/swt-4.35M1-cocoa-macosx-x86_64.jar -------------------------------------------------------------------------------- /framework/lib/swt-4.5-gtk-linux-x86.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/swt-4.5-gtk-linux-x86.jar -------------------------------------------------------------------------------- /framework/lib/swt-4.5-gtk-linux-x86_64.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/swt-4.5-gtk-linux-x86_64.jar -------------------------------------------------------------------------------- /framework/lib/swt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ibm-datapower/ertool/00553d4ba3836807783c97ef1ccbd980ad89c3df/framework/lib/swt.jar -------------------------------------------------------------------------------- /framework/properties/backtraceonly.properties: -------------------------------------------------------------------------------- 1 | # NLS_ENCODING=UNICODE 2 | # NLS_MESSAGEFORMAT_VAR 3 | 4 | = com.ibm.datapower.er.PartsProcessorBacktrace 5 | = com.ibm.datapower.er.PartsProcessorBacktrace 6 | -------------------------------------------------------------------------------- /framework/properties/config.properties: -------------------------------------------------------------------------------- 1 | # NLS_ENCODING=UNICODE 2 | # NLS_MESSAGEFORMAT_VAR 3 | 4 | 5 | # Production. This CGI is on the releng server, so it has access to backtrace symbol files. 6 | decodeurl = http://releng.dp.swg.usma.ibm.com/.decode/erframeworkdecode.cgi 7 | 8 | # For development purposes. Not on releng server, so there is no access to backtrace symbol files. 9 | # Edits in this location have free reign but should only be to design and test CGI script logic. 10 | #decodeurl = http://testweb.dp.swg.usma.ibm.com/dev-er-backend/.decode/erframeworkdecode.cgi 11 | 12 | 13 | getbinaryfileurl = http://localhost/erweb/getbinaryfile.cgi 14 | -------------------------------------------------------------------------------- /framework/properties/htmldefault.properties: -------------------------------------------------------------------------------- 1 | # NLS_ENCODING=UNICODE 2 | # NLS_MESSAGEFORMAT_VAR 3 | report.prepostprocessor = com.ibm.datapower.er.PrePostProcessorHTML 4 | PartsProcessor.default = com.ibm.datapower.er.PartsProcessorsHTML 5 | PartsProcessor. = com.ibm.datapower.er.PartsProcessorBacktraceHTML 6 | PartsProcessor. = com.ibm.datapower.er.PartsProcessorBacktraceHTML 7 | -------------------------------------------------------------------------------- /framework/properties/sidecar.properties: -------------------------------------------------------------------------------- 1 | # NLS_ENCODING=UNICODE 2 | # NLS_MESSAGEFORMAT_VAR 3 | 4 | order = db2cli llmprocess mq odbc soliddb sshdprocess tam tibco wtxprocess xml sshprocess 5 | db2cli = db2cli 6 | llmprocess = llm 7 | mq = MQ PROCESS 8 | odbc = odbc 9 | soliddb = PERSISTENCE STORE PROCESS 10 | sshdprocess = Platform 1.0 SSHd 11 | tam = TAM PROCESS 12 | tibco = TIBCO PROCESS 13 | wtxprocess = WTX TASK 14 | xms = XMS PROCESS 15 | sshprocess = Platform 1.0 SSH -------------------------------------------------------------------------------- /framework/properties/zipfile.properties: -------------------------------------------------------------------------------- 1 | # NLS_ENCODING=UNICODE 2 | # NLS_MESSAGEFORMAT_VAR 3 | report.prepostprocessor = com.ibm.datapower.er.PrePostProcessorZip 4 | PartsProcessor.default = com.ibm.datapower.er.PartsProcessorZIP 5 | = com.ibm.datapower.er.PartsProcessorBacktraceZIP 6 | = com.ibm.datapower.er.PartsProcessorBacktraceZIP 7 | -------------------------------------------------------------------------------- /framework/src/Analytics/analyticsform.txt: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 38 | 39 |
40 | 41 |
-------------------------------------------------------------------------------- /framework/src/ERMessages.properties: -------------------------------------------------------------------------------- 1 | token_error=Error processing MIME tokens 2 | bad_filename=File not found 3 | bad_format=Unrecognized format 4 | no_xslname=Required XSL path name missing 5 | mime_error=Error parsing MIME 6 | printing_msg=Printing section 7 | file_msg=from file 8 | ERTOOL001I=Usage: 9 | ERTOOL002I=ertool { -help } | 10 | ERTOOL003I= [ [ -file | 11 | ERTOOL004I= -capture {:} { -user } { -password } | 12 | ERTOOL005I= -generate {:} { -user } { -password } ] 13 | ERTOOL006I= { -section } 14 | ERTOOL007I= { -explode } 15 | ERTOOL008I= { [ -format HTML -xsl ,,{!,,{!...}} ] | 16 | ERTOOL009I= [ -format [ TEXT | CSV ] { -xsl ,,{!,,{!...}}} ] } 17 | ERTOOL010I= { -analyticsfile } 18 | ERTOOL011I= ] 19 | ERTOOL012I= 20 | ERTOOL013I=Options: 21 | ERTOOL014I=-help Display this help string 22 | ERTOOL015I=-file Local ErrorReport to read 23 | ERTOOL016I=-section Print a section identified by Content ID 24 | ERTOOL017I=-explode Write report sections to individual files 25 | ERTOOL018I=-capture : Retrive one or more Error Reports 26 | ERTOOL019I=-generate : Create one more Error Report 27 | ERTOOL020I=-user User name for -capture or -generate options. 28 | ERTOOL021I=-password Password for -capture or -generate options. 29 | ERTOOL022I=-format HTML|TEXT|CSV Format for output report 30 | ERTOOL023I=-xsl ,, Style sheet path and file name for given format and content. 31 | ERTOOL024I= Wildcards(*) allowed for format and content. Separate multiple files with ! like -xsl *,*,x.xsl!HTML,Hardware,y.xsl 32 | ERTOOL025I= 33 | ERTOOL026I=Analytics Options: 34 | ERTOOL027I=-analyticsfile Local Analytics.xml file used to parse error report 35 | ERTOOL028I=-outfile Destination file for output of analyticsfile processing 36 | ERTOOL029I=-transactions Parses input using dptransx.xml to generate transactions.txt, add -transxml to get an xml format. 37 | ERTOOL030I=-timeformat EST|UTC|MNT|... Time format for transactions output (EST/UTC/MNT/etc.) 38 | ERTOOL031I=-printconditions showall|hidedefault|hideall Generates detailed output for formula debugging 39 | ERTOOL032I=-loglevel debug|info Log level for command line output in analytics formula processing 40 | ERTOOL033I=-gui Presents analytics GUI prompt 41 | ERTOOL034I=-formulamaxrunseconds [#] Set the maximum time in seconds an analytics formula attempts to run, default: 300 seconds 42 | ERTOOL035I=-retrieveallfiles [true|false] In Analytics extract all sections from input data to related_files directory, despite formula match. 43 | ERTOOL036I 44 | ERTOOL037I=Defaults: 45 | ERTOOL038I=-help is the default option. 46 | ERTOOL039I=5550 is the default port. 47 | ERTOOL040I=TEXT is the default format used with the -file option. 48 | ERTOOL041I="admin" is default for both -user and -password options. 49 | ERTOOL042I=UTF-8 is the default encoding. 50 | ERTOOL043I=Gzip is the assumed format for report files ending in .gz 51 | ERTOOL044I=Text is the assumed format for report files not ending in .gz 52 | ERTOOL045I=All sections are formatted when the -section option is omitted. 53 | ERTOOL046I= 54 | ERTOOL047I=Examples: 55 | ERTOOL048I=1. Display the command line usage. 56 | ERTOOL049I=ertool -help 57 | ERTOOL050I=2. Copy an existing error report from an appliance. 58 | ERTOOL051I=ertool -capture 9.22.73.157:3478 -user guest -password Guest 59 | ERTOOL052I=3. Generate and copy a new error report from an appliance default port as user "admin". 60 | ERTOOL053I=ertool -generate 11.22.33.44 -password Administrator1 61 | ERTOOL054I=4. Format a saved report as HTML. 62 | ERTOOL055I=ertool -file error-report.txt.gz -format HTML -xsl HTML,*,./src/erHTML.xsl >report.htm 63 | ERTOOL056I=5. Format the Hardware section of a saved report as CSV. 64 | ERTOOL057I=ertool -file error-report.txt.gz -format CSV -section LicenseStatus -xsl CSV,Hardware,./src/erCSV.xsl >Hardware.csv 65 | ERTOOL058I=6. Run Analytics Parser to review error report. 66 | ERTOOL059I=ertool -file error-report.txt.gz -analyticsfile analytics.xml 67 | ERTOOL001E=Missing file name. Usage: -file 68 | ERTOOL002E=Unrecognized format {0}. Usage: -format HTML|TEXT|CSV 69 | ERTOOL003E=Firmware {0} not detected. Exiting. 70 | ERTOOL004E=SOAP interface error {0} 71 | ERTOOL005E=Invalid port number 72 | ERTOOL006E=Error expanding file {0} 73 | ERTOOL007E=Unable to format given section as {0} 74 | ERTOOL008E=Unable to display contents of section {0} 75 | ERTOOL009E=Error parsing MIME {0} 76 | ERTOOL010E=Unable to display summary {0} 77 | ERTOOL011E=Content ID missing. Usage: -section 78 | ERTOOL012E=Required TCP port missing. Usage: -capture [:] 79 | ERTOOL013E=No user name specified. Usage: -user 80 | ERTOOL014E=No password specified. Usage: -password 81 | ERTOOL015E=Unrecognized command line option {0} 82 | ERTOOL016E=Required XSL path name missing. Usage: -xsl 83 | ERTOOL017E=Error reading stream 84 | ERTOOL018E={0} 85 | ERTOOL019E=File prefix required. Usage: -explode 86 | ERTOOL020E=Analytics failed to load and parse 87 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/ConditionField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import com.ibm.datapower.er.Analytics.MappedCondition.MAPPED_TABLE_POSITION; 20 | 21 | public class ConditionField { 22 | private int mFieldPosition = 0; 23 | private String mFieldValue = ""; 24 | private String mParsedFieldValue = ""; 25 | private boolean mIsParsedFieldValue = false; 26 | 27 | public enum REG_GROUP_TYPE { 28 | MATCH_ENUMERATION(0), 29 | MATCH_ALLREGGROUP(1), 30 | MATCH_ORDERED(2), 31 | MATCH_ALL_RESULT(3), // ALL_RESULT and ORDERED inherit ALLREGGROUP, COUNT and NONE do not use regular expression grouping 32 | MATCH_COUNT(4), 33 | MATCH_SUM(5), 34 | MATCH_NONE(6); 35 | 36 | private final int type; 37 | private REG_GROUP_TYPE(int type) { 38 | this.type = type; 39 | } 40 | 41 | public int getType() { 42 | return type; 43 | } 44 | } 45 | private String mRegGroup = ""; 46 | private REG_GROUP_TYPE mRegGroupType = REG_GROUP_TYPE.MATCH_NONE; 47 | private String mConditionName = ""; 48 | private String mOperation = ""; 49 | private String mValue = ""; 50 | private String mCondRegExp = ""; 51 | private String mCondNextOperation = ""; 52 | private boolean mConditionOperAnd = false; 53 | 54 | private String mConversionType = ""; 55 | 56 | private String mOverrideValue = ""; 57 | 58 | private int mMappedTablePosition = MAPPED_TABLE_POSITION.AUTO_SET.getType(); 59 | 60 | public ConditionField(int fieldPos, String fieldPosValue, String reggroup, String condName, String oper, String value, String condRegEXP, String nextOper, 61 | String conversionType, String overrideValueSetting, int mappedTablePosition) 62 | { 63 | setFieldPosition(fieldPos); 64 | setFieldValue(fieldPosValue); 65 | setRegGroup(reggroup); 66 | setConditionName(condName); 67 | setOperation(oper); 68 | setValue(value); 69 | setConditionRegEXP(condRegEXP); 70 | setConditionNextOperation(nextOper); 71 | setConversionType(conversionType); 72 | setOverrideValue(overrideValueSetting); 73 | mMappedTablePosition = mappedTablePosition; 74 | } 75 | 76 | public ConditionField() 77 | { 78 | 79 | } 80 | 81 | public void setFieldPosition(int pos) 82 | { 83 | mFieldPosition = pos; 84 | } 85 | 86 | public void setFieldValue(String fieldpos) 87 | { 88 | mFieldValue = fieldpos; 89 | if ( getFieldValue().startsWith("{") ) 90 | { 91 | try 92 | { 93 | mParsedFieldValue = getFieldValue().substring(1, getFieldValue().length() - 1); 94 | mIsParsedFieldValue = true; 95 | }catch(Exception ex) { } // catching just in case this substring pull fails 96 | } 97 | } 98 | 99 | public void setRegGroup(String reggroup) 100 | { 101 | mRegGroup = reggroup; 102 | String regGroupLwr = mRegGroup.toLowerCase(); 103 | 104 | switch(regGroupLwr) 105 | { 106 | case "all": 107 | mRegGroupType = REG_GROUP_TYPE.MATCH_ALLREGGROUP; 108 | break; 109 | case "allresult": 110 | mRegGroupType = REG_GROUP_TYPE.MATCH_ALL_RESULT; 111 | break; 112 | case "ordered": 113 | mRegGroupType = REG_GROUP_TYPE.MATCH_ORDERED; 114 | break; 115 | case "count": 116 | mRegGroupType = REG_GROUP_TYPE.MATCH_COUNT; 117 | break; 118 | case "sum": 119 | mRegGroupType = REG_GROUP_TYPE.MATCH_SUM; 120 | break; 121 | case "enumeration": 122 | mRegGroupType = REG_GROUP_TYPE.MATCH_ENUMERATION; 123 | break; 124 | } 125 | } 126 | 127 | public void setConditionName(String condName) 128 | { 129 | mConditionName = condName; 130 | } 131 | 132 | public void setOperation(String oper) 133 | { 134 | mOperation = oper; 135 | } 136 | 137 | public void setValue(String val) 138 | { 139 | mValue = val; 140 | } 141 | 142 | public void setConditionRegEXP(String regexp) 143 | { 144 | mCondRegExp = regexp; 145 | } 146 | 147 | public void setConditionNextOperation(String nextOper) 148 | { 149 | mCondNextOperation = nextOper; 150 | 151 | // this is for determining whether the next condition must be 152 | // met (AND) or if otherwise it is optional (OR) 153 | // in the case of an OR statement if the first condition fails 154 | // we can try the second if one is available 155 | if (mCondNextOperation.toLowerCase().equals("and")) 156 | mConditionOperAnd = true; 157 | } 158 | public void setConversionType(String convType) 159 | { 160 | mConversionType = convType; 161 | } 162 | 163 | public void setOverrideValue(String value) 164 | { 165 | mOverrideValue = value; 166 | } 167 | 168 | public void setMappedTablePosition(int mappedTablePos) 169 | { 170 | mMappedTablePosition = mappedTablePos; 171 | } 172 | 173 | public int getFieldPosition() { return mFieldPosition; } 174 | public String getFieldValue() { return mFieldValue; } 175 | public String getParsedFieldValue() { return mParsedFieldValue; } 176 | public boolean isParsedFieldValue() { return mIsParsedFieldValue; } 177 | public String getRegGroup() { return mRegGroup; } 178 | public REG_GROUP_TYPE getRegGroupType() { return mRegGroupType; } 179 | public String getConditionName() { return mConditionName; } 180 | public String getOperation() { return mOperation; } 181 | public String getValue() { return mValue; } 182 | public String getConditionRegEXP() { return mCondRegExp; } 183 | public String getConditionNextOperation() { return mCondNextOperation; } 184 | public boolean getConditionOperAnd() { return mConditionOperAnd; } 185 | public String getConversionType() { return mConversionType; } 186 | public String getOverrideValue() { return mOverrideValue; } 187 | public int getMappedTablePosition() { return mMappedTablePosition; } 188 | } 189 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/ConditionSort.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import java.text.SimpleDateFormat; 20 | import java.util.Comparator; 21 | 22 | import com.ibm.datapower.er.Analytics.ConditionsNode.ConditionSortType; 23 | 24 | public class ConditionSort implements Comparator { 25 | @Override 26 | public int compare(ConditionsNode o1, ConditionsNode o2) { 27 | // if no sort condition is given, we will use the internal conditions node ID which we instantiate when the node is created 28 | if (o1.getSortConditionName().length() < 1 || o2.getSortConditionName().length() < 1) 29 | { 30 | if (!o1.getSortMethod().equals("descending")) { 31 | if ( o1.getConditionID() > o2.getConditionID() ) 32 | return 1; 33 | else 34 | return 0; 35 | } 36 | else 37 | { 38 | if ( o1.getConditionID() > o2.getConditionID() ) 39 | return -1; 40 | else 41 | return 0; 42 | } 43 | } 44 | 45 | String condO1 = ""; 46 | String condO2 = ""; 47 | if (o1.getSortConditionName().equals("condensecondition") 48 | && o2.getSortConditionName().equals("condensecondition")) { 49 | condO1 = Integer.toString(o1.getCondenseCount()); 50 | condO2 = Integer.toString(o2.getCondenseCount()); 51 | } else { 52 | condO1 = o1.getCondition(o1.getSortConditionName()); 53 | condO2 = o2.getCondition(o2.getSortConditionName()); 54 | } 55 | boolean useTimestampCompare = false; 56 | 57 | SimpleDateFormat fmt = null; 58 | if (o1.getSortType() == ConditionSortType.TIMESTAMP && o1.getSortOption().length() > 0) { 59 | fmt = new SimpleDateFormat(o1.getSortOption()); 60 | useTimestampCompare = true; 61 | } 62 | 63 | try { 64 | if (condO1 != null && condO2 != null) { 65 | if (!o1.getSortMethod().equals("descending")) { 66 | if (useTimestampCompare) { 67 | return fmt.parse(condO1).compareTo(fmt.parse(condO2)); 68 | } else { 69 | try { 70 | double num1 = Double.parseDouble(condO1); 71 | double num2 = Double.parseDouble(condO2); 72 | if (num1 > num2) 73 | return 1; 74 | else if (num2 > num1) 75 | return -1; 76 | else 77 | return 0; 78 | 79 | } catch (Exception ex) { 80 | } 81 | return condO1.compareTo(condO2); 82 | } 83 | } else { 84 | if (useTimestampCompare) { 85 | try { 86 | int parseValue = fmt.parse(condO2).compareTo(fmt.parse(condO1)); 87 | return parseValue; 88 | } catch (Exception ex) { 89 | if (!o1.getSortMethod().equals("descending")) 90 | return -1; 91 | else 92 | return 1; 93 | } 94 | } else { 95 | try { 96 | double num1 = Double.parseDouble(condO1); 97 | double num2 = Double.parseDouble(condO2); 98 | if (num2 > num1) 99 | return 1; 100 | else if (num1 > num2) 101 | return -1; 102 | else 103 | return 0; 104 | } catch (Exception ex) { 105 | } 106 | return condO2.compareTo(condO1); 107 | } 108 | } 109 | } 110 | } catch (Exception ex) { 111 | 112 | } 113 | return 0; 114 | } 115 | } -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/DocSort.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import java.util.Comparator; 20 | 21 | public class DocSort implements Comparator { 22 | @Override 23 | public int compare(DocumentSection o1, DocumentSection o2) { 24 | return o1.GetSectionName().compareTo(o2.GetSectionName()); 25 | } 26 | } -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/DocumentSection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import javax.xml.transform.Source; 20 | import javax.xml.transform.Transformer; 21 | import javax.xml.transform.TransformerConfigurationException; 22 | import javax.xml.transform.TransformerException; 23 | import javax.xml.transform.TransformerFactory; 24 | import javax.xml.transform.TransformerFactoryConfigurationError; 25 | import javax.xml.transform.dom.DOMSource; 26 | import javax.xml.transform.stream.StreamResult; 27 | import java.io.ByteArrayOutputStream; 28 | 29 | import org.w3c.dom.Document; 30 | import org.w3c.dom.NodeList; 31 | 32 | import com.ibm.datapower.er.ERFramework; 33 | 34 | public class DocumentSection { 35 | public DocumentSection(Document doc, String cidName, String outFileExtension, ERFramework framework, int phase, 36 | String phaseFileName) { 37 | mCidDoc = doc; 38 | // need to remove the tags so it shows up in HTML 39 | mOrigCidName = cidName; 40 | mCidName = cidName.replace("<", "[").replace(">", "]"); 41 | 42 | String removedCidName = GetSectionName().replace("[", "").replace("]", ""); 43 | 44 | String resSectionName = removedCidName; 45 | if (resSectionName.contains("@datapower.ibm.com")) { 46 | resSectionName = resSectionName.replace("@datapower.ibm.com", ""); 47 | } 48 | 49 | mParsedCidName = resSectionName; 50 | 51 | if (outFileExtension != null) 52 | mOutExtension = outFileExtension; 53 | 54 | NodeList nl = doc.getElementsByTagName("Root"); 55 | if (nl.getLength() == 0) { 56 | mIsXML = true; 57 | 58 | synchronized (ERFramework.mDocBuilderFactory) { 59 | Transformer transformer; 60 | try { 61 | transformer = TransformerFactory.newInstance().newTransformer(); 62 | 63 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); 64 | Source input = new DOMSource(doc); 65 | 66 | transformer.transform(input, new StreamResult(outputStream)); 67 | 68 | byte[] bytes = outputStream.toByteArray(); 69 | SetBytes(bytes); 70 | } catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) { 71 | // TODO Auto-generated catch block 72 | e.printStackTrace(); 73 | } catch (TransformerException e) { 74 | // TODO Auto-generated catch block 75 | e.printStackTrace(); 76 | } 77 | } 78 | } else { 79 | byte[] data = nl.item(0).getTextContent().getBytes(); 80 | SetBytes(data); 81 | } 82 | 83 | mFramework = framework; 84 | 85 | mPhase = phase; 86 | 87 | mPhaseFileName = phaseFileName; 88 | } 89 | 90 | public Document GetDocument() { 91 | return mCidDoc; 92 | } 93 | 94 | public String GetSectionName() { 95 | return mCidName; 96 | } 97 | 98 | public String GetOriginalSectionName() { 99 | return mOrigCidName; 100 | } 101 | 102 | public boolean IsXMLSection() { 103 | return mIsXML; 104 | } 105 | 106 | public int GetCacheHits() { 107 | return mCacheHits; 108 | } 109 | 110 | public void HitCache() { 111 | mCacheHits++; 112 | } 113 | 114 | public String GetOutExtension() { 115 | return mOutExtension; 116 | } 117 | 118 | public ERFramework GetFramework() { 119 | return mFramework; 120 | } 121 | 122 | public int GetPhase() { 123 | return mPhase; 124 | } 125 | 126 | public String GetPhaseFileName() { 127 | return mPhaseFileName; 128 | } 129 | 130 | public void SetBytes(byte[] bytes) { 131 | mData = bytes; 132 | } 133 | 134 | public byte[] GetBytes() { 135 | return mData; 136 | } 137 | 138 | public String GetParsedSectionName() { 139 | return mParsedCidName; 140 | } 141 | 142 | private Document mCidDoc = null; 143 | private String mCidName = ""; 144 | private String mOrigCidName = ""; 145 | private boolean mIsXML = false; 146 | private int mCacheHits = 0; 147 | private String mOutExtension = ""; 148 | private ERFramework mFramework = null; 149 | public int mPhase = 0; 150 | private String mPhaseFileName = ""; 151 | private String mParsedCidName = ""; 152 | private byte[] mData = null; 153 | } -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/ERMimeSection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import java.io.InputStream; 20 | 21 | public class ERMimeSection { 22 | public InputStream mInput = null; 23 | public int mPhase = 0; 24 | public int mIterator = 0; 25 | public String mCidName = ""; 26 | 27 | public ERMimeSection(InputStream input, int phase) { 28 | mInput = input; 29 | mPhase = phase; 30 | } 31 | 32 | public ERMimeSection(InputStream input, int phase, int itr, String cidName) { 33 | mInput = input; 34 | mPhase = phase; 35 | mIterator = itr; 36 | mCidName = cidName; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/MappedCondition.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | public class MappedCondition implements Cloneable, java.io.Serializable { 20 | public String MappedConditionName = ""; 21 | public String MappedConditionValue = ""; 22 | public String MappedConditionNameOriginalCase = ""; 23 | public int MappedConditionPosition = 0; 24 | 25 | public enum MAPPED_TABLE_POSITION { 26 | NO_SET(-2), 27 | AUTO_SET(-1); 28 | 29 | private final int type; 30 | private MAPPED_TABLE_POSITION(int type) { 31 | this.type = type; 32 | } 33 | 34 | public int getType() { 35 | return type; 36 | } 37 | } 38 | 39 | public MappedCondition(String lowercaseConditionName, String conditionValue, String originalcaseConditionName, int conditionPosition ) 40 | { 41 | MappedConditionName = lowercaseConditionName; 42 | MappedConditionValue = conditionValue; 43 | MappedConditionNameOriginalCase = originalcaseConditionName; 44 | MappedConditionPosition = conditionPosition; 45 | } 46 | 47 | @SuppressWarnings("unchecked") 48 | public Object clone() throws CloneNotSupportedException { 49 | MappedCondition mapCond = new MappedCondition(MappedConditionName, MappedConditionValue, MappedConditionNameOriginalCase, MappedConditionPosition); 50 | return mapCond; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/ObjectComparison.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.FileInputStream; 21 | import java.io.IOException; 22 | import java.io.ObjectInputStream; 23 | import java.io.ObjectOutputStream; 24 | import java.util.ArrayList; 25 | 26 | 27 | public class ObjectComparison { 28 | 29 | public static boolean CompareObjectToFile(ArrayList results, String file) 30 | { 31 | for(int i=0;i 0 ) 59 | return true; 60 | 61 | return false; 62 | } 63 | 64 | public static ByteArrayOutputStream WriteObjectToBuffer(Object obj) 65 | { 66 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 67 | 68 | try { 69 | ObjectOutputStream outStream = new ObjectOutputStream(buffer); 70 | outStream.writeObject(obj); 71 | outStream.close(); // should we do this despite writeObject failing? I am not sure, then it will need another try catch 72 | } catch (IOException e) { 73 | 74 | } 75 | 76 | return buffer; 77 | } 78 | 79 | public static Object ReadObjectToBuffer(ObjectInputStream inputStream) 80 | { 81 | Object obj = null; 82 | try { 83 | obj = inputStream.readObject(); 84 | if ( obj instanceof ConditionsNode ) 85 | return obj; 86 | } catch (IOException e) { 87 | // TODO Auto-generated catch block 88 | e.printStackTrace(); 89 | } catch (ClassNotFoundException e) { 90 | // TODO Auto-generated catch block 91 | e.printStackTrace(); 92 | } 93 | 94 | return null; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/ReferenceURL.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | public class ReferenceURL implements java.io.Serializable { 20 | public ReferenceURL(String description, String url) 21 | { 22 | mDescription = description; 23 | mURL = url; 24 | } 25 | 26 | @Override public String toString() 27 | { 28 | return mDescription + mURL; 29 | } 30 | 31 | public String mDescription = "NA"; 32 | public String mURL = "NA"; 33 | } 34 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/RegEXPCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import java.util.regex.Matcher; 20 | 21 | import com.ibm.datapower.er.Analytics.Structure.RunFormula; 22 | 23 | public class RegEXPCache { 24 | public RegEXPCache(RunFormula formula, String regexp, String invalue, Matcher inmatch) 25 | { 26 | regEXPQuery = regexp; 27 | matcher = inmatch; 28 | queryValue = invalue; 29 | rFormula = formula; 30 | } 31 | 32 | public void setRunFormula(RunFormula formula) { rFormula = formula; } 33 | 34 | public Matcher getMatcher() { return matcher; } 35 | public String getRegEXPQuery() { return regEXPQuery; } 36 | public String getQueryValue() { return queryValue; } 37 | public RunFormula getRunFormula() { return rFormula; } 38 | 39 | private RunFormula rFormula = null; 40 | private Matcher matcher = null; 41 | private String regEXPQuery = ""; 42 | private String queryValue = ""; 43 | } 44 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/Structure/DSCacheEntry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics.Structure; 18 | 19 | import java.util.ArrayList; 20 | 21 | import com.ibm.datapower.er.Analytics.DocumentSection; 22 | 23 | public class DSCacheEntry { 24 | // keeping data quickly accessible so we can pull it out and re-use for formula processing 25 | public String cidName = ""; 26 | public ArrayList documentSet = new ArrayList(); 27 | public boolean wildcardValue = false; 28 | public String extension = ""; 29 | } 30 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/Structure/Expression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics.Structure; 18 | 19 | import org.w3c.dom.Element; 20 | import com.ibm.datapower.er.Analytics.Structure.ItemObject.OBJECT_TYPE; 21 | import com.ibm.datapower.er.Analytics.AnalyticsFunctions; 22 | 23 | public class Expression extends ItemStructure { 24 | 25 | public Expression(Element eElement) 26 | { 27 | // Used to determine the importance if this expression is matched 28 | String logLevel = eElement.getAttribute("LogLevel"); 29 | addItem("LogLevel", logLevel.toLowerCase(), OBJECT_TYPE.STRING); 30 | 31 | // this is used to determine if the next expression in the formula 32 | // needs to be met with this one (AND) 33 | // or if otherwise either can be matched independently (OR) if a 34 | // second expression exists in the formula. 35 | String expNextOperation = eElement.getAttribute("NextOperation").toLowerCase(); 36 | 37 | if ( expNextOperation.equals("and") ) 38 | addItem("NextOperationAnd", true, OBJECT_TYPE.BOOLEAN); 39 | else 40 | addItem("NextOperationAnd", false, OBJECT_TYPE.BOOLEAN); 41 | 42 | // Used to determine the importance if this expression is matched 43 | addItem("FormulaIDMatch", eElement.getAttribute("FormulaIDMatch"), OBJECT_TYPE.STRING); 44 | 45 | // Used to determine the importance if this expression is matched 46 | addItem("RequiredFile", eElement.getAttribute("RequiredFile"), OBJECT_TYPE.STRING); 47 | 48 | 49 | // this will determine what grouping of expressions we are using in 50 | // this formula 51 | // when we see the expression group change from its previous value 52 | // then we restart the expressions/conditions matched 53 | // we require these to be in order (eg. expressiongroup1, 54 | // expressiongroup2) in the xml file 55 | addItem("ExpressionGroup", eElement.getAttribute("ExpressionGroup"), OBJECT_TYPE.STRING); 56 | 57 | 58 | // this is the CID Section in the document that we need to parse 59 | // from XML to determine 60 | // if the expression is a valid match 61 | addItem("CIDSectionName", AnalyticsFunctions.getAttributeByTag("Section", "Name", eElement, 0), OBJECT_TYPE.STRING); 62 | 63 | // this is if the section is a wildcard meaning it is not an exact 64 | // match, eg. 65 | // Domain sections such as WSMAgentStatus 66 | // (TestDomain-WSMAgentStatus). 67 | addItem("SectionWildcard", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "Wildcard",eElement, 0)), OBJECT_TYPE.BOOLEAN); 68 | 69 | addItem("SectionMIME", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "MIME", eElement, 0)), OBJECT_TYPE.BOOLEAN); 70 | 71 | addItem("SectionBase64", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "Base64", eElement, 0)), OBJECT_TYPE.BOOLEAN); 72 | 73 | addItem("SectionLineReturn", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "LineReturn", eElement, 0)), OBJECT_TYPE.BOOLEAN); 74 | 75 | addItem("Decode", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "Decode", eElement, 0)), OBJECT_TYPE.BOOLEAN); 76 | 77 | addItem("Extension", AnalyticsFunctions.getAttributeByTag("Section", "Extension", eElement, 0), OBJECT_TYPE.STRING); 78 | 79 | addItem("NoDecodeCache", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "NoDecodeCache", eElement, 0)), OBJECT_TYPE.BOOLEAN); 80 | 81 | addItem("NoEnumeration", Boolean.parseBoolean(AnalyticsFunctions.getAttributeByTag("Section", "NoEnumeration", eElement, 0)), OBJECT_TYPE.BOOLEAN); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/Structure/Formula.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics.Structure; 18 | 19 | import org.w3c.dom.Element; 20 | 21 | import com.ibm.datapower.er.FirmwareInputStream; 22 | import com.ibm.datapower.er.Analytics.Structure.ItemObject.OBJECT_TYPE; 23 | 24 | public class Formula extends ItemStructure { 25 | 26 | public Formula(Element fElement, int id, boolean multiDocs) { 27 | addItem("ID", id, OBJECT_TYPE.INTEGER); 28 | 29 | addItem("Element", fElement, OBJECT_TYPE.ELEMENT); 30 | // the header 'name' of the formula, this will require parsing of { 31 | // } tag sections which denote XML sections we pull from 32 | // expressions 33 | // This is an error! 34 | 35 | String dispName = FirmwareInputStream.getValueByTag("Name", fElement); 36 | mMultiDocs = multiDocs; 37 | if (multiDocs && dispName != null && dispName.length() > 0) { 38 | addItem("Name", "{Condition:ReportFile} - " + dispName, OBJECT_TYPE.STRING); 39 | } else { 40 | addItem("Name", dispName, OBJECT_TYPE.STRING); 41 | } 42 | 43 | // This is the description message which serves as a subnode to 44 | // provide more detail of the error, it also requires parsing of { } 45 | // tags. 46 | // data for more detail 47 | addItem("DisplayMessage", FirmwareInputStream.getValueByTag("DisplayMessage", fElement), OBJECT_TYPE.STRING); 48 | 49 | // List of URLs the user can use to understand the problem better 50 | // http://somelink/ 51 | addItem("UrlNodes", fElement.getElementsByTagName("URL"), OBJECT_TYPE.NODELIST); 52 | 53 | // If set to 'true' then we omit printing the conditions met by the 54 | // formula 55 | String omitPrintedConditions = fElement.getAttribute("OmitPrintingMetConditions"); 56 | addItem("OmitConditions", Boolean.parseBoolean(omitPrintedConditions), OBJECT_TYPE.BOOLEAN); 57 | 58 | // Used to determine if we want to override the position 59 | String topPositionRes = fElement.getAttribute("TopPositionResult"); 60 | addItem("TopPosition", Boolean.parseBoolean(topPositionRes), OBJECT_TYPE.BOOLEAN); 61 | 62 | // Expressions to match on, LogLevel: Critical, Error, Warning, Notice. 63 | // NextOperation of And / Or. 64 | // 0) 110 | return mIdent; 111 | 112 | String formulaID = (String) getItem("FormulaID").getObject(); 113 | if (formulaID != null && formulaID.length() > 0) { 114 | mIdent = formulaID; 115 | return formulaID; 116 | } 117 | 118 | String shortFormulaName = (String) getItem("Name").getObject(); 119 | 120 | if (shortFormulaName == null || shortFormulaName.length() < 1) 121 | shortFormulaName = "Unknown"; 122 | 123 | int length = 20; 124 | if (shortFormulaName.length() > length) 125 | shortFormulaName = shortFormulaName.substring(0, length); 126 | 127 | mIdent = shortFormulaName; 128 | 129 | return shortFormulaName; 130 | } 131 | 132 | private String mIdent = ""; 133 | public boolean mMultiDocs = false; 134 | } 135 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/Structure/ItemObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics.Structure; 18 | 19 | public class ItemObject { 20 | public enum OBJECT_TYPE 21 | { 22 | OBJECT, 23 | BOOLEAN, 24 | STRING, 25 | INTEGER, 26 | ELEMENT, 27 | NODELIST 28 | }; 29 | 30 | private String mObjectName = ""; 31 | private Object mObject = null; 32 | private OBJECT_TYPE mType = OBJECT_TYPE.OBJECT; 33 | 34 | public ItemObject(String objName, Object object, OBJECT_TYPE type) 35 | { 36 | setObjectName(objName); 37 | setObject(object); 38 | setType(type); 39 | } 40 | 41 | public String getObjectName() { return mObjectName; } 42 | private void setObjectName(String name) { mObjectName = name; } 43 | 44 | public Object getObject() { return mObject; } 45 | private void setObject(Object obj) { mObject = obj; } 46 | 47 | public OBJECT_TYPE getType() { return mType; } 48 | private void setType(OBJECT_TYPE type) { mType = type; } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/Structure/ItemStructure.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics.Structure; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | import com.ibm.datapower.er.Analytics.Structure.ItemObject.OBJECT_TYPE; 23 | 24 | public class ItemStructure { 25 | 26 | public ItemStructure() 27 | { 28 | 29 | } 30 | 31 | public ItemObject getItem(String name) 32 | { 33 | ItemObject val = (ItemObject) mItems.get(name); 34 | return val; 35 | } 36 | 37 | public void addItem(String name, Object obj, OBJECT_TYPE type) 38 | { 39 | mItems.remove(name); // override previous entry, remove it if existed 40 | ItemObject itmObj = new ItemObject(name,obj,type); 41 | mItems.put(name, itmObj); 42 | } 43 | 44 | 45 | private Map mItems = new HashMap(); 46 | } 47 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/Structure/RunFormula.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics.Structure; 18 | 19 | import java.util.ArrayList; 20 | import java.util.concurrent.Callable; 21 | 22 | import org.w3c.dom.Element; 23 | 24 | import com.ibm.datapower.er.FirmwareInputStream; 25 | import com.ibm.datapower.er.Analytics.AnalyticsProcessor; 26 | import com.ibm.datapower.er.Analytics.ConditionField; 27 | import com.ibm.datapower.er.Analytics.ConditionsNode; 28 | import com.ibm.datapower.er.Analytics.DocumentSection; 29 | import com.ibm.datapower.er.Analytics.AnalyticsFunctions; 30 | 31 | public class RunFormula implements Callable { 32 | 33 | public DocumentSection documentSet = null; 34 | public ArrayList condNodes; 35 | public Formula formula; 36 | public int cidSectionID; 37 | public Element expElement; 38 | public boolean expressionsMatched = false; 39 | public boolean nextExpressionAnd = false; 40 | public int formulaPos; 41 | public AnalyticsProcessor mProc = null; 42 | public int docID = 0; 43 | public boolean anyExpressionsMatched = false; 44 | public ArrayList cFields = null; 45 | public String xPathQuery = ""; 46 | public String isSectionVariable = ""; 47 | public boolean bIsSectionVariable = true; 48 | public String regExp = ""; 49 | public String idxSearch = ""; // narrow down document by indexOf instead of regexp 50 | public String requiredFile = ""; // narrow down document by indexOf instead of regexp 51 | 52 | public RunFormula(AnalyticsProcessor proc, DocumentSection docSet, 53 | int docPos, ArrayList nodes, Formula formulaData, 54 | int sectionID, Element ele, boolean expressionAnd, ArrayList fields, String reqFile) { 55 | docID = docPos; 56 | mProc = proc; 57 | documentSet = docSet; 58 | condNodes = nodes; 59 | formula = formulaData; 60 | cidSectionID = sectionID; 61 | expElement = ele; 62 | nextExpressionAnd = expressionAnd; 63 | formulaPos = (int) formula.getItem("ID").getObject(); 64 | 65 | requiredFile = reqFile; 66 | 67 | loadVars(); 68 | 69 | cFields = fields; 70 | } 71 | 72 | public RunFormula(AnalyticsProcessor proc, DocumentSection docSet, 73 | int docPos, ArrayList nodes, Formula formulaData, 74 | int sectionID, Element ele, boolean expressionAnd, 75 | ArrayList fields, boolean multicore) { 76 | docID = docPos; 77 | mProc = proc; 78 | documentSet = docSet; 79 | condNodes = nodes; 80 | formula = formulaData; 81 | cidSectionID = sectionID; 82 | expElement = ele; 83 | nextExpressionAnd = expressionAnd; 84 | formulaPos = (int) formula.getItem("ID").getObject(); 85 | cFields = fields; 86 | 87 | loadVars(); 88 | 89 | if (!multicore) 90 | run(); 91 | 92 | } 93 | 94 | private void loadVars() 95 | { 96 | // this is the XPath expression of the value we are trying to extract to 97 | // compare against our condition 98 | xPathQuery = AnalyticsFunctions.getAttributeByTag("Section", "XPath", expElement, 99 | cidSectionID); 100 | 101 | // if set to false then we don't use it for the Condition:SectionName 102 | // variable in parsing the message 103 | isSectionVariable = AnalyticsFunctions.getAttributeByTag("Section", "SectionName", 104 | expElement, 0); 105 | 106 | // this is kind of a reverse operand, if its false then we don't want to 107 | // use it, otherwise we leave the old functionality/design of always 108 | // true 109 | if (isSectionVariable.toLowerCase().equals("false")) 110 | bIsSectionVariable = false; 111 | 112 | // This is the regular expression we use to break apart the value in 113 | // the error report (from xPath) 114 | regExp = FirmwareInputStream.getValueByTag("RegExp", 115 | expElement); 116 | 117 | // This is the regular expression we use to break apart the value in 118 | // the error report (from xPath) 119 | idxSearch = FirmwareInputStream.getValueByTag("IndexSearch", 120 | expElement); 121 | } 122 | 123 | public Object call() { 124 | run(); 125 | return (Object) this; 126 | } 127 | 128 | public void run() { 129 | anyExpressionsMatched = mProc.handleRunFormula(this); 130 | } 131 | 132 | public Formula getFormula() { 133 | return formula; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/TestAnalytics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2016 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import java.io.ByteArrayOutputStream; 20 | import java.io.File; 21 | import java.io.FileOutputStream; 22 | import java.io.FilenameFilter; 23 | import java.io.IOException; 24 | 25 | import org.xml.sax.SAXException; 26 | 27 | import com.ibm.datapower.er.ERFramework; 28 | 29 | import junit.framework.Assert; 30 | import junit.framework.TestCase; 31 | 32 | import java.lang.Runtime; 33 | import java.util.ArrayList; 34 | 35 | public class TestAnalytics extends TestCase { 36 | 37 | } 38 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/Analytics/XPathCache.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.Analytics; 18 | 19 | import org.w3c.dom.Document; 20 | import org.w3c.dom.NodeList; 21 | 22 | public class XPathCache { 23 | public XPathCache(NodeList xpathList, Document cidDoc, String xpath) 24 | { 25 | cacheXPathExpList = xpathList; 26 | cacheXPathDoc = cidDoc; 27 | cacheXPathQuery = xpath; 28 | } 29 | 30 | public NodeList getNodeList() { return cacheXPathExpList; } 31 | public Document getCidDoc() { return cacheXPathDoc; } 32 | public String getXPathQuery() { return cacheXPathQuery; } 33 | private NodeList cacheXPathExpList = null; 34 | private Document cacheXPathDoc = null; 35 | private String cacheXPathQuery = ""; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /* 20 | * Error Report Exception class 21 | * Thrown when ERFramework encounters an error and is unable to complete 22 | * the requested operation. 23 | * The exact nature of the problem (file read, MIME parse, etc.) 24 | * are included in the exception string. 25 | */ 26 | public class ERException extends Exception 27 | { 28 | private String detail; 29 | 30 | ERException (String a) 31 | { 32 | detail = a; 33 | } 34 | 35 | public String toString() 36 | { 37 | return "ERException[" + detail +"]"; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERFrameworkFileException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /* 20 | * Error Report Framework File exception class 21 | */ 22 | public class ERFrameworkFileException extends ERException 23 | { 24 | 25 | ERFrameworkFileException(String a) { 26 | super(a); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERFrameworkIOException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /* 20 | * Error Report Framework IO exception class 21 | */ 22 | public class ERFrameworkIOException extends ERException 23 | { 24 | 25 | ERFrameworkIOException(String a) { 26 | super(a); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERFrameworkMimeException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /* 20 | * Error Report Framework MIME exception class 21 | */ 22 | public class ERFrameworkMimeException extends ERException 23 | { 24 | 25 | ERFrameworkMimeException(String a) { 26 | super(a); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERFrameworkParseException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /* 20 | * Error Report Framework Parser exception class 21 | */ 22 | public class ERFrameworkParseException extends ERException 23 | { 24 | 25 | ERFrameworkParseException(String a) { 26 | super(a); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERFrameworkRun.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | 20 | import java.io.FileInputStream; 21 | import java.util.Enumeration; 22 | import java.util.Properties; 23 | 24 | import org.apache.logging.log4j.*; 25 | import org.apache.logging.log4j.core.config.Configurator; 26 | import org.apache.logging.log4j.core.config.DefaultConfiguration; 27 | 28 | import com.ibm.datapower.er.ERCommandLineArgs; 29 | 30 | public class ERFrameworkRun{ 31 | 32 | public static boolean mIsLoggerConfigured = false; 33 | 34 | public static void main(String[] args) throws Exception{ 35 | // log4j setup 36 | Configurator.initialize(new DefaultConfiguration()); 37 | Configurator.setRootLevel(Level.DEBUG); 38 | mIsLoggerConfigured = true; 39 | 40 | ERFrameworkRun erf = new ERFrameworkRun(args); 41 | erf.run(); 42 | } 43 | 44 | ERCommandLineArgs mParams; 45 | String mOutputReport; 46 | String mInputErrorReport; 47 | String mProcessorFile; 48 | Properties mProperties; 49 | 50 | ReportProcessor mReportProcessor; 51 | 52 | 53 | 54 | public ERFrameworkRun(String[] args){ 55 | mParams = new ERCommandLineArgs(args); 56 | mOutputReport = null; 57 | mInputErrorReport = null; 58 | mProcessorFile = null; 59 | mProperties = null; 60 | 61 | mReportProcessor = new ReportProcessor(); 62 | } 63 | public int run() throws Exception{ 64 | mProperties = new Properties(); 65 | mProperties.load(new FileInputStream(mProcessorFile)); 66 | 67 | 68 | String prepostprocessor = mProperties.getProperty("report.prepostprocessor"); 69 | Class toLoad = Class.forName(prepostprocessor); 70 | PrePostReportProcessor ip = (PrePostReportProcessor) toLoad.newInstance(); 71 | 72 | 73 | mReportProcessor.load(mInputErrorReport); 74 | mReportProcessor.setPrePostProcessor(ip); 75 | loadPartsProcessors(); 76 | mReportProcessor.setFilename(mOutputReport); 77 | mReportProcessor.run(); 78 | 79 | return 0; 80 | } 81 | 82 | public int loadCLA(){ 83 | String usage = "A tool for processing error reports using a given properties mProcessorFile\n" + 84 | "ertool [OPTIONS] -i ERROR REPORT FILE \n" + 85 | "OPTIONS\n" + 86 | " -p PROPERTIES_FILENAME\n" + 87 | " The special properties file indicating custom parts processor to use.\n" + 88 | " -i ERROR_REPORT_FILE\n" + 89 | " The location of the error report to be processed.\n" + 90 | " -o OUTPUT_FILE\n" + 91 | " The destination location of the zip file or html file for the processed error report\n" + 92 | " -v\n" + 93 | " Verbose output of program\n"; 94 | mParams.setUsageText(usage); 95 | mParams.parse(); 96 | 97 | 98 | if(!mParams.containsKey("-i")){ 99 | LogManager.getRootLogger().fatal("Error: you must specify an input file"); 100 | return -1; 101 | } else{ 102 | mInputErrorReport = mParams.getProperty("-i"); 103 | } 104 | if(mParams.containsKey("-o")){ 105 | mOutputReport = mParams.getProperty("-o"); 106 | } 107 | if(mParams.containsKey("-p")){ 108 | mProcessorFile = mParams.getProperty("-p"); 109 | } else { 110 | mProcessorFile = "properties/htmldefault.properties"; 111 | } 112 | if(!mParams.containsKey("-v")){ 113 | Configurator.setAllLevels(LogManager.getRootLogger().getName(), Level.OFF); 114 | } 115 | return 0; 116 | } 117 | 118 | @SuppressWarnings("unchecked") 119 | public void loadPartsProcessors() throws Exception { 120 | Enumeration keys = (Enumeration) mProperties.propertyNames(); 121 | //for every key 122 | while(keys.hasMoreElements()){ 123 | String key = keys.nextElement(); 124 | int start; 125 | 126 | String processorType = null; 127 | Class toLoad = null; 128 | 129 | if((start = key.indexOf("PartsProcessor.")) < 0){ 130 | key = null; 131 | } else { 132 | processorType = mProperties.getProperty(key); 133 | try { 134 | toLoad = Class.forName(processorType); 135 | } catch (ClassNotFoundException e){ 136 | LogManager.getRootLogger().debug(processorType + "not found, skipping..."); 137 | continue; 138 | } 139 | key = key.substring(start+15); 140 | } 141 | 142 | 143 | if(key == null){ 144 | continue; 145 | } 146 | else if(key.equals("default")){ 147 | mReportProcessor.addPartsProcessor((IPartsProcessor) toLoad.newInstance(), null); 148 | } else { 149 | mReportProcessor.addPartsProcessor((IPartsProcessor) toLoad.newInstance(), key); 150 | } 151 | } 152 | } 153 | 154 | 155 | 156 | 157 | } 158 | 159 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERFrameworkXMLException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /* 20 | * Error Report Framework XML exception class 21 | */ 22 | public class ERFrameworkXMLException extends ERException 23 | { 24 | 25 | ERFrameworkXMLException(String a) { 26 | super(a); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ERToolLogFormatter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | import java.text.SimpleDateFormat; 20 | import java.util.Date; 21 | import java.util.logging.LogRecord; 22 | 23 | public class ERToolLogFormatter extends java.util.logging.SimpleFormatter 24 | { 25 | static SimpleDateFormat DT = new SimpleDateFormat("yyyy/MM/DD hh:mm:ss.SSS "); 26 | 27 | public synchronized String format(LogRecord record) 28 | { 29 | String date = DT.format(new Date(record.getMillis())); 30 | return date + record.getThreadID() + " " + formatMessage(record) + "\n"; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/ErrorReportDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | /** 20 | * A class representing the Information from Firmware Version. 21 | * 22 | * @author Alex Teyssandier 23 | * 24 | */ 25 | public class ErrorReportDetails { 26 | String mSerial; 27 | String mVersion; 28 | String mBuild; 29 | String mBuildDate; 30 | String mWatchdogBuild; 31 | String mRunningDPOS; 32 | String mXMLAccelerator; 33 | String mMachineType; 34 | String mModelType; 35 | 36 | 37 | public void setSerial(String serial){ 38 | mSerial = serial; 39 | } 40 | public void setVersion(String version){ 41 | mVersion = version; 42 | } 43 | public void setBuild(String build){ 44 | mBuild = build; 45 | } 46 | public void setBuildDate(String buildDate){ 47 | mBuildDate = buildDate; 48 | } 49 | public void setWatchdogBuild(String watchdogBuild){ 50 | mWatchdogBuild = watchdogBuild; 51 | } 52 | public String setInstalledDPOS(String installedDPOS){ 53 | return mRunningDPOS; 54 | } 55 | public void setRunningDPOS(String runningDPOS){ 56 | mRunningDPOS = runningDPOS; 57 | } 58 | public void setXMLAccelerator(String xmlAccelerator){ 59 | mXMLAccelerator = xmlAccelerator; 60 | } 61 | public void setMachineType(String machineType){ 62 | mMachineType = machineType; 63 | } 64 | public void setModelType(String modelType){ 65 | mModelType = modelType; 66 | } 67 | public String getSerial(){ 68 | return mSerial; 69 | } 70 | public String getVersion(){ 71 | return mVersion; 72 | } 73 | public String getBuild(){ 74 | return mBuild; 75 | } 76 | public String getBuildDate(){ 77 | return mBuildDate; 78 | } 79 | public String getWatchdogBuild(){ 80 | return mWatchdogBuild; 81 | } 82 | public String getRunningDPOS(){ 83 | return mRunningDPOS; 84 | } 85 | public String getInstalledDPOS(){ 86 | return mRunningDPOS; 87 | } 88 | public String getXMLAccelerator(){ 89 | return mXMLAccelerator; 90 | } 91 | public String getMachineType(){ 92 | return mMachineType; 93 | } 94 | public String getModelType(){ 95 | return mModelType; 96 | } 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/FirmwareInputStream.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | import java.io.ByteArrayInputStream; 20 | import java.io.ByteArrayOutputStream; 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | 24 | import javax.xml.parsers.DocumentBuilder; 25 | import javax.xml.parsers.DocumentBuilderFactory; 26 | import javax.xml.parsers.ParserConfigurationException; 27 | 28 | import org.w3c.dom.Document; 29 | import org.w3c.dom.Element; 30 | import org.w3c.dom.Node; 31 | import org.w3c.dom.NodeList; 32 | import org.xml.sax.SAXException; 33 | 34 | 35 | /** 36 | * A special input stream to be used when processing the FirmwareVersion MIMEPart 37 | 38 | * A class representing the Information from Firmware Version. 39 | * 40 | * @author Alex Teyssandier 41 | * 42 | */ 43 | 44 | public class FirmwareInputStream extends InputStream { 45 | InputStream mInputStream; 46 | ErrorReportDetails mErrorReportDetails; 47 | ByteArrayOutputStream mByteArrayOut; 48 | ByteArrayInputStream mByteArrayIn; 49 | 50 | /** 51 | * Default constructor. called the InputStream constructor 52 | */ 53 | public FirmwareInputStream() { 54 | super(); 55 | } 56 | 57 | /** 58 | * Constructor that sets the InputStream and ErrorReportDetails 59 | * Will also load the ErrorReportDetails with the appropriate information 60 | * @param is the InputStream to set mInputStream to 61 | * @param erd the ErrorReportDetails to set the mErrorReportDetails to 62 | * @throws SAXException 63 | * @throws IOException 64 | * @throws ParserConfigurationException 65 | */ 66 | public FirmwareInputStream(InputStream is, ErrorReportDetails erd) throws SAXException, IOException, ParserConfigurationException { 67 | mInputStream = is; 68 | mErrorReportDetails = erd; 69 | mByteArrayOut = new ByteArrayOutputStream(); 70 | } 71 | /** 72 | * fills in the mByteArrayInputStream with the information from mInputStream 73 | * uses mByteArrayInputStream in a DOMParser to parse the XML and fill in the ErrorReportDetails 74 | * 75 | * @throws SAXException 76 | * @throws IOException 77 | * @throws ParserConfigurationException 78 | */ 79 | public void loadERD() { 80 | try { 81 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 82 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 83 | Document doc = dBuilder.parse(mByteArrayIn); 84 | doc.getDocumentElement().normalize(); 85 | 86 | 87 | Element eElement = (Element) doc.getElementsByTagName("FirmwareVersion").item(0); 88 | 89 | mErrorReportDetails.setSerial(getValueByTag("Serial", eElement)); 90 | mErrorReportDetails.setVersion(getValueByTag("Version", eElement)); 91 | mErrorReportDetails.setBuild(getValueByTag("Build", eElement)); 92 | mErrorReportDetails.setBuildDate(getValueByTag("BuildDate", eElement)); 93 | mErrorReportDetails.setWatchdogBuild(getValueByTag("WatchdogBuild", eElement)); 94 | mErrorReportDetails.setInstalledDPOS(getValueByTag("InstalledDPOS", eElement)); 95 | mErrorReportDetails.setRunningDPOS(getValueByTag("RunningDPOS", eElement)); 96 | mErrorReportDetails.setXMLAccelerator(getValueByTag("XMLAccelerator", eElement)); 97 | mErrorReportDetails.setMachineType(getValueByTag("MachineType", eElement)); 98 | mErrorReportDetails.setModelType(getValueByTag("ModelType", eElement)); 99 | } catch (SAXException e) { 100 | e.printStackTrace(); 101 | } catch (IOException ioe) { 102 | ioe.printStackTrace(); 103 | } catch (ParserConfigurationException pce){ 104 | pce.printStackTrace(); 105 | } 106 | } 107 | 108 | /** 109 | * Gets Value of an XML element by tag name 110 | * @param sTag the string value representation of the tag name 111 | * @param eElement the element in which to look for the tag nane 112 | * @return String value of the XML element 113 | */ 114 | public static String getValueByTag(String sTag, Element eElement){ 115 | try 116 | { 117 | NodeList nlList= eElement.getElementsByTagName(sTag).item(0).getChildNodes(); 118 | Node nValue = (Node) nlList.item(0); 119 | 120 | // null check added May 30th (DisplayMessage was an empty node) 121 | if ( nValue == null ) 122 | return ""; 123 | 124 | return nValue.getNodeValue(); 125 | }catch(Exception ex) 126 | { 127 | } 128 | 129 | return ""; 130 | } 131 | 132 | @Override 133 | public int read() throws IOException { 134 | int b = mInputStream.read(); 135 | //if b is not endoffile 136 | if(b != -1){ 137 | //add b to byte array outputstream; 138 | mByteArrayOut.write(b); 139 | } else { 140 | mByteArrayIn = new ByteArrayInputStream(mByteArrayOut.toByteArray()); 141 | loadERD(); 142 | } 143 | return b; 144 | } 145 | @Override 146 | public int read(byte[] byteArray) throws IOException { 147 | int bytesRead = mInputStream.read(byteArray); 148 | 149 | mByteArrayOut.write(byteArray, 0, bytesRead); 150 | mByteArrayIn = new ByteArrayInputStream(mByteArrayOut.toByteArray()); 151 | 152 | loadERD(); 153 | return bytesRead; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/IPartInfo.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | import java.io.InputStream; 20 | import java.util.Map; 21 | 22 | 23 | public interface IPartInfo 24 | { 25 | String H_CONTENT_ID = "Content-ID"; 26 | String H_CONTENT_TYPE = "Content-Type"; 27 | String H_CONTENT_DISPOSITION = "Content-Disposition"; 28 | String H_CONTENT_XFER_ENC = "Content-transfer-encoding"; 29 | 30 | /** 31 | * The Preamble of a MIME message is usually not used by any MIME 32 | * processors, but rather just informational text for non-MIME readers. 33 | * 34 | * The DataPower Error Report preamble information may contain headers and 35 | * an input stream to read its text. 36 | * 37 | * At the time of this writing, the DataPower Error Report preamble contains 38 | * the following text "DataPower Error Report for domain ..." 39 | */ 40 | final String MIME_PREAMBLE = "PREAMBLE"; 41 | 42 | /** 43 | * The Epilogue of a MIME message is usually not used by any MIME 44 | * processors. 45 | * 46 | * The DataPower Error Report currently has no epilogue information. 47 | */ 48 | final String MIME_BODYPART = "BODYPART"; 49 | 50 | /** 51 | * The Epilogue of a MIME message is usually not used by any MIME 52 | * processors. 53 | * 54 | * The DataPower Error Report currently has no epilogue information. 55 | */ 56 | final String MIME_EPILOGUE = "EPILOGUE"; 57 | 58 | /** 59 | * Indicates what MIME Part type this is. It returns a string for easier 60 | * printing, but it will always be one of the Constants defined in this 61 | * in interface 62 | * @return one of [MIME_PREAMBLE|MIME_EPILOGUE|MIME_BODYPART] 63 | */ 64 | String getType(); 65 | 66 | /** 67 | * Easy access to the Content-ID header. 68 | * @return 69 | */ 70 | String getContentID(); 71 | 72 | /** 73 | * Easy access to the Content-Type header. 74 | * @return 75 | */ 76 | String getContentType(); 77 | 78 | /** 79 | * Easy access to the Content-Transfer-Encoding header. 80 | * @return 81 | */ 82 | String getContentTransferEncoding(); 83 | 84 | /** 85 | * Easy access to the Content-Disposition header. 86 | * @return 87 | */ 88 | String getContentDisposition(); 89 | 90 | /** 91 | * Easy access to the attachment filename from the Content-Disposition header. 92 | * @return 93 | */ 94 | String getAttachmentFilename(); 95 | 96 | /** 97 | * Retrieves all headers associates with this part. 98 | * @return a Map containing the headers or null if no headers are available 99 | */ 100 | Map getHeaders(); 101 | 102 | /** 103 | * Retrieves the InputStream that access the body of this part. 104 | * @return an input stream to read the body 105 | */ 106 | InputStream getBodyStream(); 107 | 108 | /** 109 | * Retrieves the ErrorReportDetails about this part 110 | * @return an ErrorReportDetails with the information about the part 111 | */ 112 | ErrorReportDetails getErrorReportDetails(); 113 | 114 | /** 115 | * Resets the inputStream to a custom input stream 116 | * @param the input stream to replace the current InputStream 117 | */ 118 | void setInputStream(InputStream is); 119 | } 120 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/IPartsProcessor.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | import java.io.IOException; 20 | import java.io.PrintWriter; 21 | 22 | 23 | 24 | public interface IPartsProcessor 25 | { 26 | 27 | 28 | /** 29 | * Process each of the parts of a MIME document, including the Preamble, 30 | * the Epilogue and each Parts of the body. 31 | * 32 | * @param mimePart MIME document part information 33 | * @param writer Character-based output stream for writing post-processed 34 | * information about the part processed 35 | * 36 | * @throws IOException may be throws if there are problems reading the MIME 37 | * part or writing post processing information to the 38 | * output writer. 39 | */ 40 | void process( IPartInfo mimePart, PrintWriter writer ) throws IOException; 41 | } 42 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/PartsProcessorBacktraceHTML.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | import java.io.IOException; 20 | import java.io.PrintWriter; 21 | /** 22 | * A class to print out the Backtrace with surrounding html code. Will not print out start tags 23 | * @author alex 24 | * 25 | */ 26 | public class PartsProcessorBacktraceHTML extends PartsProcessorBacktrace { 27 | 28 | /** 29 | * Constructor for Parts Processor Backtrace 30 | */ 31 | public PartsProcessorBacktraceHTML() { 32 | super(); 33 | } 34 | 35 | /** 36 | * Inserts the target links and
 formatting tags on the output from partsProcessorBacktrace
37 |      * 
38 |      * @see PartsProcessorBacktrace
39 |      */
40 |     public void process(IPartInfo mimePart, PrintWriter writer) throws IOException{
41 |         String sectionName = mimePart.getContentID();        
42 |         int start = sectionName.indexOf('<')+1;
43 |         int end = sectionName.indexOf('@');
44 |         sectionName = sectionName.substring(start, end);
45 |         
46 |         writer.print("

"); 47 | writer.println(""); 48 | writer.println(""); 49 | writer.println(sectionName); 50 | writer.println(""); 51 | writer.println(""); 52 | writer.write("
");
53 |         super.process(mimePart, writer);
54 |         writer.write("
"); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/PartsProcessorBacktraceZIP.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er; 18 | 19 | import java.io.File; 20 | import java.io.FileOutputStream; 21 | import java.io.IOException; 22 | import java.io.PrintWriter; 23 | /** 24 | * A class to print out the Backtrace with surrounding html code. Will not print out start tags 25 | * @author alex 26 | * 27 | */ 28 | public class PartsProcessorBacktraceZIP extends PartsProcessorBacktrace { 29 | String mTempDir = ""; 30 | /** 31 | * Constructor for Parts Processor Backtrace 32 | */ 33 | public PartsProcessorBacktraceZIP() { 34 | super(); 35 | } 36 | 37 | public void setTempDir(String sTempDir){ 38 | mTempDir = sTempDir; 39 | } 40 | 41 | /** 42 | * Inserts the target links and
 formatting tags on the output from partsProcessorBacktrace
43 |      * 
44 |      * @see PartsProcessorBacktrace
45 |      */
46 |     public void process(IPartInfo mimePart, PrintWriter writer) throws IOException{
47 |         
48 |         String contentType = mimePart.getContentType();
49 |         String contentID = mimePart.getContentID();  
50 |         String extension = "";
51 |         String mFilename = "";
52 |         
53 |         
54 |               
55 |         int start = contentID.indexOf('<')+1;
56 |         int end = contentID.indexOf('@');
57 |         mFilename  = contentID.substring(start, end);
58 |         
59 |         if(contentType.indexOf("text/plain") >= 0){
60 |             extension = ".txt";
61 |         } else if(contentType.indexOf("text/xml") >= 0){
62 |             extension = ".xml";             
63 |         }
64 |         mFilename = mFilename.concat(extension);
65 |                
66 |         String fullfile = mTempDir.concat(File.separator).concat(mFilename); 
67 |         FileOutputStream fos = new FileOutputStream(fullfile);   
68 |         
69 |         PrintWriter tempWriter = new PrintWriter(fos);
70 |         
71 |         super.process(mimePart, tempWriter);
72 |         
73 |     }
74 | 
75 | }
76 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/PartsProcessorZIP.java:
--------------------------------------------------------------------------------
  1 | /**
  2 | * Copyright 2014-2020 IBM Corp.
  3 | *
  4 | * Licensed under the Apache License, Version 2.0 (the "License");
  5 | * you may not use this file except in compliance with the License.
  6 | * You may obtain a copy of the License at
  7 | *
  8 | * http://www.apache.org/licenses/LICENSE-2.0
  9 | *
 10 | * Unless required by applicable law or agreed to in writing, software
 11 | * distributed under the License is distributed on an "AS IS" BASIS,
 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 | * See the License for the specific language governing permissions and
 14 | * limitations under the License.
 15 | **/
 16 | 
 17 | package com.ibm.datapower.er;
 18 | 
 19 | import java.io.BufferedReader;
 20 | import java.io.File;
 21 | import java.io.FileOutputStream;
 22 | import java.io.IOException;
 23 | import java.io.InputStream;
 24 | import java.io.InputStreamReader;
 25 | import java.io.PrintWriter;
 26 | 
 27 | import com.ibm.datapower.er.mgmt.Base64;
 28 | 
 29 | /**
 30 |  * A parts processor that outputs the  contents of each file into filename in a temporary directory in
 31 |  * 
 32 |  * @author alex
 33 |  *
 34 |  */
 35 | 
 36 | public class PartsProcessorZIP implements IPartsProcessor{
 37 |     public static String mPath = null;
 38 |     IPartInfo mMimePart = null;   
 39 |     String mFilename = null;
 40 | 
 41 |     /**
 42 |      * Contructor that sets the temporary directory 
 43 |      * @param tempdir
 44 |      * @throws IOException
 45 |      */
 46 |     public PartsProcessorZIP() throws IOException {
 47 | 	}
 48 |     
 49 | 	/**
 50 | 	 * Process the mimepart and will output the information to the given PrintWriter.
 51 | 	 * 
 52 | 	 * 
 53 | 	 * @param mimePart the mimepart to be processed
 54 | 	 * @param writer the output printwriter to output the data. In this special zip processor case, the PrintWriter does not matter because all parts are written out to files and then consolidated by an external class
 55 | 	 * 
 56 | 	 */
 57 | 	public void process(IPartInfo mimePart, PrintWriter writer) throws IOException {
 58 | 	    mMimePart = mimePart;	    
 59 | 
 60 | 	    //check if mimeparts are null, if they are, no need to continue
 61 | 	    if(mimePart.getContentID() == null){
 62 | 	        return;
 63 | 	    }
 64 |         boolean decode = isBase64();
 65 | 	    InputStream in = mimePart.getBodyStream();
 66 | 	    createFile(in, decode);	    
 67 | 	}
 68 | 	/**
 69 | 	 * Creates a file inside the mPath directory of the mime part being processed
 70 | 	 * 
 71 | 	 * 
 72 | 	 * @param in the input stream containing the mime data
 73 | 	 * @param decode indicates whether data needs to be decoded from base64 or not
 74 | 	 * @throws IOException
 75 | 	 */
 76 | 	private void createFile(InputStream in, boolean decode) throws IOException{
 77 | 	    String filename = getFileName();	    
 78 | 	    
 79 | 	    String extension = getFileExtension();
 80 |             
 81 |             if (filename.startsWith("autopdzip")) {
 82 |                 int lastSeparator = filename.lastIndexOf('/');
 83 |                 filename = filename.substring(lastSeparator+1);
 84 |             } else {
 85 | 	        filename = filename.concat(extension);
 86 |             } 
 87 | 
 88 |             String fullfile = mPath.concat(File.separator).concat(filename);
 89 | 	    FileOutputStream fos = new FileOutputStream(fullfile);	      
 90 | 	    BufferedReader bis = new BufferedReader(new InputStreamReader(in)); 
 91 | 	    String nextLine = "";
 92 | 	        
 93 | 	    while((nextLine = bis.readLine()) != null){	        
 94 |             if(decode == true){
 95 |                 byte[] bytes = Base64.Decode(nextLine);
 96 |                 fos.write(bytes);
 97 |             }else {
 98 |                 fos.write(nextLine.getBytes());
 99 |                 fos.write('\n');
100 |             }
101 | 	    }
102 | 	        
103 | 	    fos.close();
104 | 	}
105 | 	/**
106 | 	 * gets either the attachment file name if the mime mimepart has one, or creates a filename based on the content ID
107 | 	 * 
108 | 	 * @return the filename for the temporary file
109 | 	 */
110 | 	private String getFileName(){
111 | 	    String attachmentFilename = mMimePart.getAttachmentFilename();
112 | 	    String  contentID = mMimePart.getContentID();
113 | 	    
114 | 	    String filename = null;
115 | 	        
116 | 	    if(attachmentFilename != null){
117 | 	        filename = attachmentFilename;
118 |         } else if (contentID != null && contentID.indexOf('<') != -1) {
119 |             //parse content ID
120 |             int start= contentID.indexOf('<')+1;
121 |             int end = contentID.indexOf('@');
122 |             filename = contentID.substring(start, end);     
123 |         } 
124 | 	    return filename;
125 | 	}
126 | 	/**
127 | 	 * determined the correct file extension for mime part based on either contentType or Content ID
128 | 	 * .pcap for background packet capture parts  
129 | 	 * .txt for plain text
130 | 	 * .xml for xml content type
131 | 	 * @return the file extension associated with the given mime part 
132 | 	 */
133 | 	private String getFileExtension(){
134 | 	    
135 | 	    String contentID = mMimePart.getContentID();
136 | 	    String contentType = mMimePart.getContentType();
137 | 	    
138 | 	    String extension = "";
139 | 	    if(contentID.indexOf("BackgroundPacketCapture") >= 0){
140 |             extension = ".pcap";
141 |         } else if(contentType.indexOf("text/plain") >= 0){
142 |             extension = ".txt";
143 |         } else if(contentType.indexOf("text/xml") >= 0){
144 |             extension = ".xml";             
145 |         }
146 | 	    return extension;
147 | 	}
148 | 	/**
149 | 	 * Determines wither the mimepart is in base64 encoding nand needs to be decoded
150 | 	 * 
151 | 	 * @return true if the mime part is in base 64 encoding and needs to be decoded, false otherwise
152 | 	 */
153 | 	private boolean isBase64(){
154 | 	    boolean base64 = false;
155 | 	    String encoding = mMimePart.getContentTransferEncoding();
156 | 	    if(encoding.equals("base64") ){
157 |             //decode it
158 |            base64 = true;
159 | 	    }    
160 |         return base64;    
161 |         
162 | 	}
163 | 
164 | }
165 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/PartsProcessorsXForm.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er;
18 | 
19 | import java.io.File;
20 | import java.io.IOException;
21 | import java.io.PrintWriter;
22 | 
23 | import javax.xml.transform.Result;
24 | import javax.xml.transform.Source;
25 | import javax.xml.transform.Transformer;
26 | import javax.xml.transform.TransformerConfigurationException;
27 | import javax.xml.transform.TransformerException;
28 | import javax.xml.transform.TransformerFactory;
29 | import javax.xml.transform.stream.StreamResult;
30 | import javax.xml.transform.stream.StreamSource;
31 | 
32 | 
33 | 
34 | public class PartsProcessorsXForm implements IPartsProcessor
35 | {
36 | 	public PartsProcessorsXForm(String xslPath)
37 | 	{
38 | 		try {
39 | 	        mXslPath = xslPath;
40 | 	        mXformFactory = TransformerFactory.newInstance();
41 |             mXformer = mXformFactory.newTransformer(new StreamSource(new File(mXslPath)));
42 |         } 
43 | 		catch (TransformerConfigurationException e) {
44 |             e.printStackTrace();
45 |         }
46 | 	}
47 | 	
48 | 	public void process(IPartInfo mimePart, PrintWriter writer) throws IOException {
49 | 		try {
50 | 	        Result result = new StreamResult(writer);
51 | 	        Source xmlSource = new StreamSource(mimePart.getBodyStream());
52 | 		    mXformer.transform(xmlSource, result);
53 | 		} 
54 | 		catch (TransformerException e) {
55 | 			throw new IOException(e);
56 | 		}
57 | 	}
58 | 	
59 | 	TransformerFactory mXformFactory;
60 | 	Transformer mXformer;
61 | 	String mXslPath;
62 | }
63 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/PrePostProcessorHTML.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er;
18 | 
19 | import java.io.FileNotFoundException;
20 | import java.io.FileOutputStream;
21 | import java.io.IOException;
22 | import java.io.OutputStream;
23 | 
24 | import org.apache.logging.log4j.*;
25 | 
26 | 
27 | public class PrePostProcessorHTML implements PrePostReportProcessor {
28 | 
29 |     OutputStream mOutputStream;
30 |     
31 | 
32 |     public PrePostProcessorHTML(){
33 |         mOutputStream = null;
34 |     }
35 |     
36 |     
37 |     @Override
38 |     public void postProcess() throws IOException {        
39 |         if(mOutputStream != null){
40 |             mOutputStream.close();           
41 |         }
42 |     }
43 | 
44 |     @Override
45 |     public void preProcess() throws Exception {
46 |         LogManager.getRootLogger().debug("Running HTML PreProcessor");        
47 |     }
48 | 
49 | 
50 |     @Override
51 |     public OutputStream getOutputStreamFromFilename(String filename) throws FileNotFoundException {        
52 |         if (filename == null){
53 |             mOutputStream = System.out;
54 |         } else {
55 |             mOutputStream = new FileOutputStream(filename);
56 |         }
57 |         return mOutputStream;               
58 |     }
59 |      
60 | 
61 | }
62 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/PrePostProcessorZip.java:
--------------------------------------------------------------------------------
  1 | /**
  2 | * Copyright 2014-2020 IBM Corp.
  3 | *
  4 | * Licensed under the Apache License, Version 2.0 (the "License");
  5 | * you may not use this file except in compliance with the License.
  6 | * You may obtain a copy of the License at
  7 | *
  8 | * http://www.apache.org/licenses/LICENSE-2.0
  9 | *
 10 | * Unless required by applicable law or agreed to in writing, software
 11 | * distributed under the License is distributed on an "AS IS" BASIS,
 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 | * See the License for the specific language governing permissions and
 14 | * limitations under the License.
 15 | **/
 16 | 
 17 | package com.ibm.datapower.er;
 18 | 
 19 | import java.io.File;
 20 | import java.io.FileInputStream;
 21 | import java.io.FileNotFoundException;
 22 | import java.io.FileOutputStream;
 23 | import java.io.IOException;
 24 | import java.io.OutputStream;
 25 | import java.util.zip.ZipEntry;
 26 | import java.util.zip.ZipOutputStream;
 27 | 
 28 | import org.apache.logging.log4j.*;
 29 | 
 30 | public class PrePostProcessorZip implements PrePostReportProcessor {
 31 |     //output stream for the zip report (the report processor will use system.out)
 32 |     ZipOutputStream mZipOutputStream;
 33 |     
 34 |     File[] filenames;
 35 |     File mTempDir;
 36 | 
 37 |     public PrePostProcessorZip(){
 38 |         mZipOutputStream = null;
 39 |     }
 40 |     
 41 |     
 42 |     @Override
 43 |     public void postProcess() throws IOException {        
 44 |         loadFileNames();
 45 |         createZip();
 46 |     }
 47 | 
 48 |     @Override
 49 |     public void preProcess() throws Exception {
 50 |         mTempDir = createTemporaryDirectory(); 
 51 |         PartsProcessorZIP.mPath = mTempDir.getAbsolutePath();;
 52 |     }
 53 |     @Override
 54 |     public OutputStream getOutputStreamFromFilename(String filename){
 55 |         //use the filename to create the output stream for the zip report, 
 56 |         //but return system.out as the output stream for the report processor        
 57 |         if(filename == null){
 58 |             mZipOutputStream = new ZipOutputStream(System.out);
 59 |         }else{
 60 |             String fullzipfile = filename;
 61 |             File zipfile = new File(fullzipfile);
 62 |             if(zipfile.isDirectory()){
 63 |                 fullzipfile = filename.concat(File.separator).concat("report"+Long.toString(System.nanoTime())+".zip");
 64 |                 zipfile = new File(fullzipfile);
 65 |             }
 66 |             try {                
 67 |                 mZipOutputStream = new ZipOutputStream(new FileOutputStream(zipfile));
 68 |             } catch (FileNotFoundException e) {
 69 |                 //if file is not found, just make it system.out
 70 |                 LogManager.getRootLogger().debug(zipfile.getAbsoluteFile() +  " not found, setting output to System.out");
 71 |                 System.out.println("file not found");
 72 |                 mZipOutputStream = new ZipOutputStream(System.out);
 73 |             }
 74 |         }
 75 |         return System.out;
 76 |     }
 77 |     
 78 |     /**
 79 |      * creates the temporary directory to hold all the processed files. 
 80 |      * @return the File representing the temporary directory
 81 |      * @throws IOException if the temporary directory cannot be creates
 82 |      */
 83 |     public File createTemporaryDirectory() throws IOException{
 84 |         File temp;      
 85 |         temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
 86 |         LogManager.getRootLogger().debug("Creating temp file: " + temp.getAbsolutePath());
 87 |         temp.delete();
 88 |         temp.mkdir();
 89 |         temp.deleteOnExit();
 90 |         return temp;    
 91 |     }  
 92 |     
 93 |     /**
 94 |      * obtain the list of all the filenames in the temporary directory to zip up into a zipfile
 95 |      */
 96 |     public void loadFileNames(){  
 97 |         filenames = mTempDir.listFiles();        
 98 |     }
 99 |     /**
100 |      * Creates a Zip with the output as either System.out, or a defined output file
101 |      * 
102 |      *  
103 |      * @throws IOException
104 |      */
105 |     public void createZip() throws IOException{
106 |         //Create a buffer for reading the files
107 |         byte[] buf = new byte[1024];
108 |         
109 | 
110 |         try {            
111 | 
112 |             for (int i=0; i 0) {
118 |                     mZipOutputStream.write(buf, 0, len);                    
119 |                 }
120 |                 mZipOutputStream.closeEntry();
121 |                 in.close();
122 |             }
123 | 
124 |         } catch (IOException e) {
125 |             throw e;
126 |         } finally{
127 |             if(mZipOutputStream != null){                
128 |                 mZipOutputStream.flush();
129 |                 mZipOutputStream.close();    
130 |             }
131 |                         
132 |         }
133 | 
134 |     }
135 | 
136 | 
137 | 
138 | 
139 | }
140 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/PrePostReportProcessor.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er;
18 | 
19 | import java.io.OutputStream;
20 | 
21 | public interface PrePostReportProcessor 
22 | {
23 | 	
24 | 	/**
25 | 	 * Will do preprocessing of the entire report for example, HTML headers, directory creation, etc
26 | 	 * @throws Exception 
27 | 	 *  
28 | 	 */
29 | 	void preProcess() throws Exception;
30 |    
31 | 	/**
32 |      * Will do postprocessing of the entire report, zip file creation for example
33 | 	 * @throws Exception 
34 |      *  
35 |      */
36 |     void postProcess() throws Exception;
37 |     
38 |     /**
39 |      * Will get the output stream from the filename to use as the output stream for the report
40 |      * @throws Exception 
41 |      *  
42 |      */
43 |     OutputStream getOutputStreamFromFilename(String filename) throws Exception;
44 | 	
45 | }
46 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/ReportProcessorPartInfo.java:
--------------------------------------------------------------------------------
  1 | /**
  2 | * Copyright 2014-2020 IBM Corp.
  3 | *
  4 | * Licensed under the Apache License, Version 2.0 (the "License");
  5 | * you may not use this file except in compliance with the License.
  6 | * You may obtain a copy of the License at
  7 | *
  8 | * http://www.apache.org/licenses/LICENSE-2.0
  9 | *
 10 | * Unless required by applicable law or agreed to in writing, software
 11 | * distributed under the License is distributed on an "AS IS" BASIS,
 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 | * See the License for the specific language governing permissions and
 14 | * limitations under the License.
 15 | **/
 16 | 
 17 | package com.ibm.datapower.er;
 18 | 
 19 | import java.io.InputStream;
 20 | import java.util.Map;
 21 | 
 22 | 
 23 | public class ReportProcessorPartInfo implements IPartInfo 
 24 | {
 25 | 	/**
 26 | 	 * @see IPartInfo#getType()
 27 | 	 */
 28 | 	public String getType() {
 29 | 		return mType;
 30 | 	}
 31 | 	
 32 | 	/**
 33 | 	 * @see IPartInfo#getContentID()
 34 | 	 */
 35 | 	public String getContentID() {
 36 | 		String cid = null;
 37 | 		if (mHeaders != null)
 38 | 		{
 39 | 			Object value = mHeaders.get(H_CONTENT_ID);
 40 | 			cid = value != null ? value.toString().trim() : null;
 41 | 		}
 42 | 		return cid;
 43 | 	}
 44 | 	
 45 | 	/**
 46 | 	 * @see IPartInfo#getContentType()
 47 | 	 */
 48 | 	public String getContentType() {
 49 | 		String ctype = null;
 50 | 		if (mHeaders != null)
 51 | 		{
 52 | 			Object value = mHeaders.get(H_CONTENT_TYPE);
 53 | 			
 54 | 			ctype = value != null ? value.toString().trim() : null;
 55 | 		}
 56 | 		return ctype;
 57 | 	}
 58 | 	
 59 | 	/**
 60 | 	 * @see IPartInfo#getContentTransferEncoding
 61 | 	 */
 62 | 	public String getContentTransferEncoding() {
 63 | 		String cte = null;
 64 | 		if (mHeaders != null)
 65 | 		{
 66 | 			Object value = mHeaders.get(H_CONTENT_XFER_ENC);
 67 | 			cte = value != null ? value.toString().trim() : null;
 68 | 		}
 69 | 		return cte;
 70 | 	}
 71 | 	
 72 | 	/**
 73 |      * @see IPartInfo#getContentTransferEncoding
 74 |      */
 75 |     public String getContentDisposition() {
 76 |         String cd = null;
 77 |         if (mHeaders != null)
 78 |         {
 79 |             Object value = mHeaders.get(H_CONTENT_DISPOSITION);
 80 |             cd = value != null ? value.toString().trim() : null;
 81 |         }
 82 |         return cd;
 83 |     }
 84 |     
 85 |     /**
 86 |      * @see IPartInfo#getContentTransferEncoding
 87 |      */
 88 |     public String getAttachmentFilename() {
 89 |         String cda = getContentDisposition();
 90 |         if(cda != null){
 91 |             int index = cda.indexOf("filename=")+9;
 92 |             cda = cda.substring(index);
 93 |         }
 94 | 
 95 |         return cda;
 96 |     }
 97 |     
 98 | 	
 99 | 
100 | 	/**
101 | 	 * @see IPartInfo#getHeaders()
102 | 	 */
103 | 	public Map getHeaders() {
104 | 		return mHeaders;
105 | 	}
106 | 
107 | 	/**
108 | 	 * @see IPartInfo#getBodyStream()
109 | 	 */
110 | 	public InputStream getBodyStream() {
111 | 	    return mBodyStream;
112 | 	}
113 | 	
114 | 	/**
115 |      * @see IPartInfo#setInputStream()
116 |      *  
117 |      */
118 |     public void setInputStream(InputStream is) {
119 |         mBodyStream = is;
120 |     }
121 |     
122 |     /**
123 |      * @see IPartInfo#getErrorReportDetails()
124 |      *  
125 |      */
126 |     public ErrorReportDetails getErrorReportDetails() {
127 |         return mERDetails;
128 |     }
129 | 	/**
130 | 	 * Package-protected Constructor
131 | 	 * @param type
132 | 	 * @param erInfo 
133 | 	 */
134 | 	public ReportProcessorPartInfo(String type, Map headers, InputStream stream, ErrorReportDetails erDetails)
135 | 	{
136 | 		mType = type;
137 | 		mHeaders = headers;
138 | 		mBodyStream = stream;
139 | 		mERDetails = erDetails;
140 | 	}
141 | 
142 | 	private String mType;
143 | 	private Map mHeaders;
144 | 	private InputStream mBodyStream;
145 | 	private ErrorReportDetails mERDetails;
146 | }
147 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/LogField.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | public class LogField {
20 | 	// name we set to this field, we will use this later for assignment and
21 | 	// comparison purposes
22 | 	public String mFieldName = "";
23 | 	// this is the regular expression group we use for this attribute
24 | 	public int mPosNum = 0;
25 | 
26 | 	public LogField(String fieldName, int posNum) {
27 | 		mFieldName = fieldName;
28 | 		mPosNum = posNum;
29 | 	}
30 | 
31 | 	public String getFieldName() {
32 | 		return mFieldName;
33 | 	}
34 | 
35 | 	public int getPosNum() {
36 | 		return mPosNum;
37 | 	}
38 | }
39 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/LogMessage.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | import java.util.HashMap;
20 | 
21 | public class LogMessage {
22 | 	// hash map of the attributes we pulled from this distinct log message
23 | 	public HashMap mLogMsg = null;
24 | 
25 | 	public LogMessage(HashMap map) {
26 | 		mLogMsg = map;
27 | 	}
28 | }
29 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/LogMessageSort.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | import java.util.Comparator;
20 | 
21 | public class LogMessageSort implements Comparator {
22 | 	@Override
23 | 	public int compare(LogMessage o1, LogMessage o2) {
24 | 		String condO1 = (String) o1.mLogMsg.get("timestamp");
25 | 		String condO2 = (String) o2.mLogMsg.get("timestamp");
26 | 
27 | 		if (condO1 != null && condO2 != null)
28 | 			return condO1.compareTo(condO2);
29 | 
30 | 		return 0;
31 | 	}
32 | }


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/LogType.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | import java.util.ArrayList;
20 | 
21 | public class LogType {
22 | 	protected String mRegEXP = "";
23 | 	protected ArrayList mFields = new ArrayList();
24 | 
25 | 	public LogType(String regEXP) {
26 | 		mRegEXP = regEXP;
27 | 	}
28 | 
29 | 	public void addField(int posNum, String fieldName) {
30 | 		mFields.add(new LogField(fieldName, posNum));
31 | 	}
32 | 
33 | 	public ArrayList getFields() {
34 | 		return mFields;
35 | 	}
36 | 
37 | 	public String getRegEXP() {
38 | 		return mRegEXP;
39 | 	}
40 | }
41 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/RunTransaction.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | import java.util.concurrent.Callable;
20 | 
21 | public class RunTransaction implements Callable {
22 | 
23 | 	public ParseTransx mTransactions = null;
24 | 	public String mLogName = "";
25 | 	
26 | 	public RunTransaction(ParseTransx transx, String logName)
27 | 	{
28 | 		mTransactions = transx;
29 | 		mLogName = logName;
30 | 	}
31 | 	@Override
32 | 	public Object call() throws Exception {
33 | 		run();
34 | 		return (Object) this;
35 | 	}
36 | 
37 | 	public void run() {
38 | 			mTransactions.runTransaction(mLogName);
39 | 	}
40 | 
41 | }
42 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/TestTransx.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | import junit.framework.TestCase;
20 | 
21 | public class TestTransx extends TestCase {
22 | 	String[] filesToTest = { "" };
23 | 
24 | 	public void testParseTransx() {
25 | 		ParseTransx transx = new ParseTransx();
26 | 		transx.SetTransactionRulesFile("c:\\dpgithub\\dptransx.xml");
27 | 		for (int f = 0; f < filesToTest.length; f++) {
28 | 			transx.setFileLocation(filesToTest[f]);
29 | 			transx.doParse("c:\\testout.txt", "EDT", false, "info");
30 | 		}
31 | 	}
32 | }
33 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/Transaction.java:
--------------------------------------------------------------------------------
  1 | /**
  2 |  * Copyright 2014-2020 IBM Corp.
  3 |  *
  4 |  * Licensed under the Apache License, Version 2.0 (the "License");
  5 |  * you may not use this file except in compliance with the License.
  6 |  * You may obtain a copy of the License at
  7 |  *
  8 |  * http://www.apache.org/licenses/LICENSE-2.0
  9 |  *
 10 |  * Unless required by applicable law or agreed to in writing, software
 11 |  * distributed under the License is distributed on an "AS IS" BASIS,
 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 |  * See the License for the specific language governing permissions and
 14 |  * limitations under the License.
 15 |  **/
 16 | 
 17 | package com.ibm.datapower.er.Transactions;
 18 | 
 19 | import java.text.SimpleDateFormat;
 20 | import java.util.ArrayList;
 21 | import java.util.Collections;
 22 | import java.util.Date;
 23 | import java.util.HashMap;
 24 | import java.util.TimeZone;
 25 | 
 26 | public class Transaction {
 27 | 
 28 | 	public enum LogLevel {
 29 | 		DEBUG, NOTICE, INFO, WARNING, ERROR, CRITICAL
 30 | 	}
 31 | 
 32 | 	private String mTransID = "";
 33 | 	protected String mStartTime = "";
 34 | 	protected String mEndTime = "";
 35 | 	protected String mTranslatedStartTime = "";
 36 | 	protected String mTranslatedEndTime = "";
 37 | 	protected String mLogType = "";
 38 | 	protected LogLevel mLogLevel = LogLevel.NOTICE;
 39 | 	protected String mLogLevelStr = "notice";
 40 | 	protected String mLogTimeFormat = "";
 41 | 
 42 | 	protected ArrayList mMessages = new ArrayList();
 43 | 	protected StringBuffer mTransactionLogs = new StringBuffer();
 44 | 
 45 | 	public Transaction(String transactionID) {
 46 | 		mTransID = transactionID;
 47 | 	}
 48 | 
 49 | 	public void setLogTimeFormat(String format) {
 50 | 		mLogTimeFormat = format;
 51 | 	}
 52 | 
 53 | 	public void setStartTime(String startTime) {
 54 | 		mStartTime = startTime;
 55 | 	}
 56 | 
 57 | 	public void setTranslatedStartTime(String startTime) {
 58 | 		mTranslatedStartTime = startTime;
 59 | 	}
 60 | 
 61 | 	public void setTranslatedEndTime(String endTime) {
 62 | 		mTranslatedEndTime = endTime;
 63 | 	}
 64 | 
 65 | 	public void setLogLevel(String loglevel) {
 66 | 		LogLevel newLevel = mLogLevel; // notice will drop to the bottom don't
 67 | 										// bother checking it
 68 | 		if (loglevel.equals("debug") && mLogLevel != LogLevel.WARNING
 69 | 				&& mLogLevel != LogLevel.ERROR
 70 | 				&& mLogLevel != LogLevel.CRITICAL)
 71 | 			newLevel = LogLevel.DEBUG;
 72 | 		if (loglevel.equals("info") && mLogLevel != LogLevel.WARNING
 73 | 				&& mLogLevel != LogLevel.ERROR
 74 | 				&& mLogLevel != LogLevel.CRITICAL)
 75 | 			newLevel = LogLevel.INFO;
 76 | 		else if (loglevel.equals("warn") && mLogLevel != LogLevel.ERROR
 77 | 				&& mLogLevel != LogLevel.CRITICAL)
 78 | 			newLevel = LogLevel.WARNING;
 79 | 		else if (loglevel.equals("error") && mLogLevel != LogLevel.CRITICAL)
 80 | 			newLevel = LogLevel.ERROR;
 81 | 		else if (loglevel.equals("critic"))
 82 | 			newLevel = LogLevel.CRITICAL;
 83 | 
 84 | 		if (mLogLevel != newLevel) {
 85 | 			mLogLevelStr = loglevel;
 86 | 			mLogLevel = newLevel;
 87 | 		}
 88 | 	}
 89 | 
 90 | 	protected String tryTimePattern(String pattern, String value,
 91 | 			String resultPattern) {
 92 | 		try {
 93 | 			SimpleDateFormat sdf = new SimpleDateFormat(pattern);
 94 | 			Date date = sdf.parse(value);
 95 | 			sdf.setTimeZone(TimeZone.getTimeZone(mLogTimeFormat));
 96 | 			sdf.applyPattern(resultPattern + " '" + mLogTimeFormat + "'");
 97 | 
 98 | 			return sdf.format(date).toString();
 99 | 		} catch (Exception ex) {
100 | 
101 | 		}
102 | 
103 | 		return value;
104 | 	}
105 | 
106 | 	public String translateTimeZone(String dateinfo) {
107 | 		if (dateinfo.length() < 1 || mLogTimeFormat.length() < 1
108 | 				|| mLogTimeFormat.equals(" ")
109 | 				|| (mLogTimeFormat.equals("Z") && dateinfo.endsWith("Z")))
110 | 			return dateinfo;
111 | 
112 | 		String outTime = tryTimePattern("yyyyMMdd'T'HHmmss'Z'", dateinfo,
113 | 				"dd MMM yyyy HH:mm:ss");
114 | 		if (outTime.equals(dateinfo))
115 | 			outTime = tryTimePattern("yyyyMMdd'T'HHmmss.SSS'Z'", dateinfo,
116 | 					"dd MMM yyyy HH:mm:ss.SSS");
117 | 		return outTime;
118 | 	}
119 | 
120 | 	public LogMessage addLogMessage(String line, HashMap strings) {
121 | 		LogMessage logMsg = new LogMessage(strings);
122 | 
123 | 		String timestamp = (String) strings.get("timestamp");
124 | 
125 | 		String translatedTime = translateTimeZone(timestamp);
126 | 		logMsg.mLogMsg.put("translatedtimestamp", translatedTime);
127 | 		if (timestamp != null && timestamp.length() > 1) {
128 | 			if (mStartTime.length() < 1
129 | 					|| (timestamp.endsWith("Z") && mStartTime
130 | 							.compareTo(timestamp) > 0)) {
131 | 				mStartTime = timestamp;
132 | 
133 | 				mTranslatedStartTime = translatedTime;
134 | 			}
135 | 			if (mEndTime.length() < 1
136 | 					|| (mEndTime.endsWith("Z") && timestamp.compareTo(mEndTime) > 0)) {
137 | 				mEndTime = timestamp;
138 | 
139 | 				mTranslatedEndTime = translatedTime;
140 | 			}
141 | 
142 | 			if (translatedTime.length() > 1
143 | 					&& !translatedTime.equals(timestamp)) {
144 | 				logMsg.mLogMsg.remove("message");
145 | 				logMsg.mLogMsg.put("message",
146 | 						line.replace(timestamp, translatedTime));
147 | 			}
148 | 		}
149 | 
150 | 		String loglevel = (String) strings.get("level");
151 | 		if (loglevel != null)
152 | 			setLogLevel(loglevel);
153 | 
154 | 		if (mLogType.length() < 1) {
155 | 			String logtype = (String) strings.get("type");
156 | 			if (logtype != null)
157 | 				mLogType = logtype;
158 | 		}
159 | 
160 | 		mMessages.add(logMsg);
161 | 
162 | 		return logMsg;
163 | 	}
164 | 
165 | 	public void OrderTransactions() {
166 | 		mTransactionLogs = new StringBuffer();
167 | 
168 | 		// order it by date
169 | 		Collections.sort(mMessages, new LogMessageSort());
170 | 		for (int i = 0; i < mMessages.size(); i++) {
171 | 			LogMessage msg = mMessages.get(i);
172 | 			String line = (String) msg.mLogMsg.get("message");
173 | 			if (line == null)
174 | 				continue;
175 | 
176 | 			mTransactionLogs
177 | 					.append(line + System.getProperty("line.separator"));
178 | 		}
179 | 	}
180 | 
181 | 	public String getTransID() {
182 | 		return mTransID;
183 | 	}
184 | 
185 | 	public String getStartTime() {
186 | 		return mStartTime;
187 | 	}
188 | 
189 | 	public String getTranslatedStartTime() {
190 | 		return mTranslatedStartTime;
191 | 	}
192 | 
193 | 	public String getTranslatedEndTime() {
194 | 		return mTranslatedEndTime;
195 | 	}
196 | 
197 | 	public String getEndTime() {
198 | 		return mEndTime;
199 | 	}
200 | 
201 | 	public String getLogType() {
202 | 		return mLogType;
203 | 	}
204 | 
205 | 	public String getLogLevel() {
206 | 		return mLogLevelStr;
207 | 	}
208 | 
209 | 	public StringBuffer getMessageBuffer() {
210 | 		return mTransactionLogs;
211 | 	}
212 | }
213 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/TransactionHistory.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | 
19 | import java.util.HashMap;
20 | 
21 | public class TransactionHistory {
22 | 
23 | 	protected HashMap mTransactions = new HashMap();
24 | 	protected String mLogTimeFormat = "";
25 | 
26 | 	public TransactionHistory() {
27 | 
28 | 	}
29 | 
30 | 	public void AppendTransaction(String transID, String line, HashMap strings) {
31 | 		String transIDToUse = transID;
32 | 
33 | 		// check if there was a global transaction ID defined
34 | 		String globalTID = (String) strings.get("gtid");
35 | 
36 | 		// if we have a global tid, replace our usage
37 | 		if (globalTID != null && globalTID.length() > 0)
38 | 			transIDToUse = globalTID;
39 | 
40 | 		Transaction transx = GetTransaction(transIDToUse);
41 | 		if (transx == null)
42 | 			transx = AddTransaction(transIDToUse);
43 | 
44 | 		transx.addLogMessage(line, strings);
45 | 	}
46 | 
47 | 	public Transaction GetTransaction(String tid) {
48 | 		Transaction transx = (Transaction) mTransactions.get(tid);
49 | 		return transx;
50 | 	}
51 | 
52 | 	private Transaction AddTransaction(String tid) {
53 | 		Transaction transx = new Transaction(tid);
54 | 		transx.setLogTimeFormat(mLogTimeFormat);
55 | 		mTransactions.put(tid, transx);
56 | 		return transx;
57 | 	}
58 | 
59 | 	public HashMap getTransactionMap() {
60 | 		return mTransactions;
61 | 	}
62 | 
63 | 	public void setLogFormat(String format) {
64 | 		mLogTimeFormat = format;
65 | 	}
66 | }
67 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/TransactionSort.java:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * Copyright 2014-2020 IBM Corp.
 3 |  *
 4 |  * Licensed under the Apache License, Version 2.0 (the "License");
 5 |  * you may not use this file except in compliance with the License.
 6 |  * You may obtain a copy of the License at
 7 |  *
 8 |  * http://www.apache.org/licenses/LICENSE-2.0
 9 |  *
10 |  * Unless required by applicable law or agreed to in writing, software
11 |  * distributed under the License is distributed on an "AS IS" BASIS,
12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 |  * See the License for the specific language governing permissions and
14 |  * limitations under the License.
15 |  **/
16 | 
17 | package com.ibm.datapower.er.Transactions;
18 | /**
19 |  *
20 |  * Licensed under the Apache License, Version 2.0 (the "License");
21 |  * you may not use this file except in compliance with the License.
22 |  * You may obtain a copy of the License at
23 |  *
24 |  * http://www.apache.org/licenses/LICENSE-2.0
25 |  *
26 |  * Unless required by applicable law or agreed to in writing, software
27 |  * distributed under the License is distributed on an "AS IS" BASIS,
28 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29 |  * See the License for the specific language governing permissions and
30 |  * limitations under the License.
31 |  **/
32 | 
33 | import java.util.Comparator;
34 | 
35 | public class TransactionSort implements Comparator {
36 | 	@Override
37 | 	public int compare(Transaction o1, Transaction o2) {
38 | 		String condO1 = o1.getStartTime();
39 | 		String condO2 = o2.getStartTime();
40 | 
41 | 		return condO1.compareTo(condO2);
42 | 	}
43 | }


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/Transactions/TransxXML.java:
--------------------------------------------------------------------------------
  1 | /**
  2 |  * Copyright 2014-2020 IBM Corp.
  3 |  *
  4 |  * Licensed under the Apache License, Version 2.0 (the "License");
  5 |  * you may not use this file except in compliance with the License.
  6 |  * You may obtain a copy of the License at
  7 |  *
  8 |  * http://www.apache.org/licenses/LICENSE-2.0
  9 |  *
 10 |  * Unless required by applicable law or agreed to in writing, software
 11 |  * distributed under the License is distributed on an "AS IS" BASIS,
 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 |  * See the License for the specific language governing permissions and
 14 |  * limitations under the License.
 15 |  **/
 16 | 
 17 | package com.ibm.datapower.er.Transactions;
 18 | 
 19 | import java.io.BufferedReader;
 20 | import java.io.File;
 21 | import java.io.IOException;
 22 | import java.io.InputStreamReader;
 23 | import java.io.PrintStream;
 24 | import java.util.ArrayList;
 25 | import java.util.Iterator;
 26 | import java.util.Map;
 27 | 
 28 | import javax.xml.parsers.DocumentBuilder;
 29 | import javax.xml.parsers.DocumentBuilderFactory;
 30 | import javax.xml.transform.Transformer;
 31 | import javax.xml.transform.TransformerFactory;
 32 | import javax.xml.transform.dom.DOMSource;
 33 | import javax.xml.transform.stream.StreamResult;
 34 | 
 35 | import org.w3c.dom.Attr;
 36 | import org.w3c.dom.Document;
 37 | import org.w3c.dom.Element;
 38 | 
 39 | public class TransxXML {
 40 | 
 41 | 	public static void writeTransactionsToXml(
 42 | 			ParseTransx parsex, ArrayList transactions, String dir) {
 43 | 		try {
 44 | 			DocumentBuilderFactory factory = DocumentBuilderFactory
 45 | 					.newInstance();
 46 | 			DocumentBuilder builder = factory.newDocumentBuilder();
 47 | 
 48 | 			Document doc = builder.newDocument();
 49 | 			
 50 | 			// base level 'Transactions'
 51 | 			Element root = doc.createElement("Transactions");
 52 | 			doc.appendChild(root);
 53 | 
 54 | 			for (int i = 0; i < transactions.size(); i++) {
 55 | 				Transaction transx = transactions.get(i);
 56 | 				// sub-element Transaction
 57 | 				Element transaction = doc.createElement("Transaction");
 58 | 
 59 | 				// Transaction attributes (hardcoded)
 60 | 				createAttribute(doc, transaction, "StartTime",
 61 | 						transx.getStartTime());
 62 | 				createAttribute(doc, transaction, "EndTime",
 63 | 						transx.getEndTime());
 64 | 				createAttribute(doc, transaction, "TransactionID",
 65 | 						transx.getTransID());
 66 | 				createAttribute(doc, transaction, "LogLevel",
 67 | 						transx.getLogLevel());
 68 | 				createAttribute(doc, transaction, "LogType",
 69 | 						transx.getLogType());
 70 | 
 71 | 				// Message level in Transactions
 72 | 				for (int m = 0; m < transx.mMessages.size(); m++) {
 73 | 					Element message = doc.createElement("Message");
 74 | 					LogMessage msg = transx.mMessages.get(m);
 75 | 					
 76 | 					// pull out the HashMap we created in the Transaction and parse it out as attributes
 77 | 					Iterator it = msg.mLogMsg.entrySet().iterator();
 78 | 					while (it.hasNext()) {
 79 | 						Map.Entry pair = (Map.Entry) it.next();
 80 | 
 81 | 						createAttribute(doc, message, pair);
 82 | 					}
 83 | 					// add each message to the transaction we are currently parsing
 84 | 					transaction.appendChild(message);
 85 | 				}
 86 | 				// add the transaction to the Transactions list
 87 | 				root.appendChild(transaction);
 88 | 			}
 89 | 
 90 | 			TransformerFactory xformFactory = TransformerFactory.newInstance();
 91 | 			Transformer xform = xformFactory.newTransformer();
 92 | 			DOMSource src = new DOMSource(doc);
 93 | 			StreamResult result = new StreamResult(new File(dir + "transactions.xml"));
 94 | 			xform.transform(src, result);
 95 | 			} catch (Exception ex) {
 96 | 
 97 | 		}
 98 | 	}
 99 | 
100 | 	private static void ReadFileToStream(ParseTransx parse,
101 | 			PrintStream stream, String filename) {
102 | 		BufferedReader input = null;
103 | 
104 | 		try {
105 | 			input = new BufferedReader(new InputStreamReader(parse
106 | 					.getClass().getClassLoader().getResourceAsStream(filename)));
107 | 		} catch (Exception ex) {
108 | 
109 | 		}
110 | 
111 | 		String s = "";
112 | 
113 | 		if (input == null)
114 | 			return;
115 | 
116 | 		try {
117 | 			while ((s = input.readLine()) != null) {
118 | 				stream.println(s);
119 | 			}
120 | 		} catch (IOException e) {
121 | 			e.printStackTrace();
122 | 		}
123 | 	}
124 | 	
125 | 	public static void createAttribute(Document doc, Element element,
126 | 			Map.Entry pair) {
127 | 		Attr keyattr = doc.createAttribute((String) pair.getKey());
128 | 		keyattr.setValue((String) pair.getValue());
129 | 		element.setAttributeNode(keyattr);
130 | 	}
131 | 
132 | 	public static void createAttribute(Document doc, Element element,
133 | 			String key, String value) {
134 | 		Attr keyattr = doc.createAttribute(key);
135 | 		keyattr.setValue(value);
136 | 		element.setAttributeNode(keyattr);
137 | 	}
138 | }
139 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/DeviceProfile.java:
--------------------------------------------------------------------------------
  1 | /**
  2 | * Copyright 2014-2020 IBM Corp.
  3 | *
  4 | * Licensed under the Apache License, Version 2.0 (the "License");
  5 | * you may not use this file except in compliance with the License.
  6 | * You may obtain a copy of the License at
  7 | *
  8 | * http://www.apache.org/licenses/LICENSE-2.0
  9 | *
 10 | * Unless required by applicable law or agreed to in writing, software
 11 | * distributed under the License is distributed on an "AS IS" BASIS,
 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 | * See the License for the specific language governing permissions and
 14 | * limitations under the License.
 15 | **/
 16 | 
 17 | package com.ibm.datapower.er.mgmt;
 18 | 
 19 | import java.util.Hashtable;
 20 | 
 21 | 
 22 | /**
 23 |  * This class provides a communications profile that is used to connect
 24 |  * the appliance.
 25 |  * 
 26 |  * @author DataPower Technology, Inc.
 27 |  * @author Dana Numkena
 28 |  *
 29 |  */
 30 | public class DeviceProfile {
 31 | 
 32 |     Hashtable mHashtable;
 33 |     
 34 |     // the '/' at the end of the URI is necessary.  Without it, certain requests
 35 |     // may not work.
 36 |     public static final String sDefaultManagmentURI = "/service/mgmt/current/";
 37 | 
 38 |     /**
 39 |      * Constructor
 40 |      */
 41 |     public DeviceProfile() {
 42 | 
 43 |         mHashtable = new Hashtable();
 44 |                 
 45 |     }
 46 | 
 47 |     /**
 48 |      * Gets hostname
 49 |      * 
 50 |      * @return hostname
 51 |      */
 52 |     public String getHostname() {
 53 |         if (mHashtable.containsKey("Host")) {
 54 |             return (String) mHashtable.get("Host");
 55 |         }
 56 |         return null;
 57 |     }
 58 | 
 59 |     /**
 60 |      * Sets hostname 
 61 |      * 
 62 |      * @param string hostname
 63 |      */
 64 |     public void setHostname(String string) {
 65 |         mHashtable.put("Host", string.trim());
 66 |     }
 67 | 
 68 |     /**
 69 |      * Gets XML management port
 70 |      * 
 71 |      * @return XML management port
 72 |      */
 73 |     public int getPort() {
 74 |         if (mHashtable.containsKey("Port")) {
 75 |             return Integer.parseInt((String) mHashtable.get("Port"));
 76 |         }
 77 |         return 0;
 78 |     }
 79 | 
 80 |     /**
 81 |      * Sets XML management port
 82 |      * 
 83 |      * @param i XML management port
 84 |      */
 85 |     public void setPort(int i) throws ERMgmtInvalidPortException {
 86 |         if(i < -1 || i > 0xffff)
 87 |         {
 88 |             throw new ERMgmtInvalidPortException("Port " + i + " is out of range");
 89 |         }
 90 |         mHashtable.put("Port", String.valueOf(i));
 91 |     }
 92 |     
 93 |     /**
 94 |      * Gets XML management URI
 95 |      * 
 96 |      * @return XML management URI
 97 |      */
 98 |     public String getManagementURI() {    
 99 |         return sDefaultManagmentURI;
100 |     }
101 | 
102 |     /**
103 |      * Gets password
104 |      * 
105 |      * @return password
106 |      */
107 |     public String getPassword() {
108 |         if (mHashtable.containsKey("Password")) {
109 |             return new String(
110 |                 Base64.Decode((String) mHashtable.get("Password")));
111 |         }
112 |         return null;
113 |     }
114 | 
115 |     /**
116 |      * Sets password
117 |      * 
118 |      * @param string password
119 |      */
120 |     public void setPassword(String string) {
121 |         mHashtable.put("Password", Base64.Encode(string.getBytes()));
122 |     }
123 | 
124 |     /**
125 |      * Gets user name
126 |      * 
127 |      * @return user name
128 |      */
129 |     public String getUser() {
130 |         if (mHashtable.containsKey("User")) {
131 |             return (String) mHashtable.get("User");
132 |         }
133 |         return null;
134 |     }
135 | 
136 |     /**
137 |      * Sets user name
138 |      * 
139 |      * @param string user name
140 |      */
141 |     public void setUser(String string) {
142 |         mHashtable.put("User", string.trim());
143 |     }
144 |     
145 |     /**
146 |      * Gets the certificate to use
147 |      * 
148 |      * @return certificate as a string
149 |      */
150 |     public String getCertificate() {
151 |         return (String) mHashtable.get("Certificate");
152 |     }
153 | 
154 |     /**
155 |      * Sets certificate to use
156 |      * 
157 |      * @param certficate the certificate as PEM string
158 |      */
159 |     public void setCertificate(String certificate) {
160 |     	if(certificate != null){
161 |     		mHashtable.put("Certificate", certificate);
162 |     	}
163 |     }
164 |     
165 | 
166 |     /**
167 |      * Gets allowing untrusted certificate
168 |      * 
169 |      * @return allow untrusted certificate
170 |      */
171 |     public boolean getAllowUntrustedCert() {
172 |         if (mHashtable.containsKey("AllowUntrustedCertificate")) {
173 |             return Boolean.parseBoolean((String) mHashtable.get("AllowUntrustedCertificate"));
174 |         }
175 |         return false;
176 |     }
177 | 
178 |     /**
179 |      * Sets allowing untrusted certificate
180 |      * 
181 |      * @param allowUntrustedCert allow untrusted certificate
182 |      */
183 |     public void setAllowUntrustedCert(boolean allowUntrustedCert) {
184 |         mHashtable.put("AllowUntrustedCertificate", Boolean.toString(allowUntrustedCert));
185 |     }
186 | 
187 | }
188 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/ERFilestore.java:
--------------------------------------------------------------------------------
  1 | /**
  2 | * Copyright 2014-2020 IBM Corp.
  3 | *
  4 | * Licensed under the Apache License, Version 2.0 (the "License");
  5 | * you may not use this file except in compliance with the License.
  6 | * You may obtain a copy of the License at
  7 | *
  8 | * http://www.apache.org/licenses/LICENSE-2.0
  9 | *
 10 | * Unless required by applicable law or agreed to in writing, software
 11 | * distributed under the License is distributed on an "AS IS" BASIS,
 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 | * See the License for the specific language governing permissions and
 14 | * limitations under the License.
 15 | **/
 16 | 
 17 | package com.ibm.datapower.er.mgmt;
 18 | 
 19 | import javax.xml.parsers.SAXParser;
 20 | import javax.xml.parsers.SAXParserFactory;
 21 | 
 22 | import org.xml.sax.Attributes;
 23 | import org.xml.sax.SAXException;
 24 | import org.xml.sax.helpers.DefaultHandler;
 25 | 
 26 | /**
 27 |  * This class handles get-filestore operations including sending requests
 28 |  * and parsing responses.
 29 |  * 
 30 |  * @author Dana Numkena
 31 |  *
 32 |  */
 33 | 
 34 | public class ERFilestore {
 35 |     
 36 |     DeviceProfile mSettings;
 37 |     String mModified;
 38 |     boolean mbIsErrorReportPresent;
 39 |     
 40 |     /**
 41 |      * Constructor 
 42 |      * 
 43 |      * @param communication settings of appliance
 44 |      */
 45 |     public ERFilestore(DeviceProfile settings) {
 46 |         mSettings = settings;
 47 |     }
 48 |     
 49 |     /**
 50 |      * determines if an error report is present on the appliance
 51 |      * 
 52 |      * returns true if an error report 
 53 |      */
 54 |     public boolean isErrorReportPresent() {
 55 |         return mbIsErrorReportPresent;
 56 |     }
 57 |     
 58 |     /**
 59 |      * Gets the modification date of the error report
 60 |      * 
 61 |      * returns modification date string
 62 |      */
 63 |     public String getModified() {
 64 |         return mModified;
 65 |     }
 66 |     
 67 |     /**
 68 |      * SAX parse handler to search for error report files in 
 69 |      * the get-filestore response and get informatoin on the 
 70 |      * error report files.
 71 |      * 
 72 |      * @author Dana Numkena
 73 |      */
 74 |     private static class GetFilestoreParseHandler extends DefaultHandler {
 75 | 
 76 |         private boolean mbFile = false;
 77 |         private boolean mbErrorReport = false;
 78 |         private boolean mbIsErrorReportPresent = false;
 79 |         private boolean mbModified = false;
 80 |         private String mModified = null;
 81 | 
 82 |         // constructor
 83 |         public GetFilestoreParseHandler() {
 84 |             
 85 |         }
 86 |         
 87 |         /**
 88 |          * Determines if appliance has an error report
 89 |          * 
 90 |          * @return true if an error report is present on the appliance
 91 |          */
 92 |         public boolean isErrorReportPresent() {
 93 |             return mbIsErrorReportPresent;
 94 |         }
 95 |         /**
 96 |          * Gets the modification date of the error report.
 97 |          * 
 98 |          * @return modification date
 99 |          */
100 |         public String getModified() {
101 |             return mModified;
102 |         }
103 | 
104 |         /* (non-Javadoc)
105 |         * @see org.xml.sax.ContentHandler#characters(char[], int, int)
106 |         */
107 |         public void characters(char[] arg0, int start, int length)
108 |             throws SAXException {
109 |             
110 |             if(mbModified == true) {
111 |                 mModified = new String(arg0, start, length);
112 |             } 
113 |         }
114 |         
115 |         /* (non-Javadoc)
116 |          * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
117 |          */
118 |         public void startElement(
119 |             String namespaceURI,
120 |             String localName,
121 |             String qualifiedName,
122 |             Attributes atts)
123 |             throws SAXException {
124 | 
125 |             if (qualifiedName.equalsIgnoreCase("file")) {
126 |                 
127 |                 //System.out.println("name: " + atts.getValue("name"));
128 |                 if((atts.getValue("name").compareTo("error-report.txt.gz") == 0) 
129 |                         || (atts.getValue("name").compareTo("error-report.txt") ==0 )) {
130 |                     mbErrorReport = true;
131 |                     mbIsErrorReportPresent = true;
132 |                 }
133 |                 
134 |                 mbFile = true;
135 |             }
136 |             else if(qualifiedName.equalsIgnoreCase("modified") && mbErrorReport == true) {
137 |                 mbModified = true;
138 |             }
139 |         }
140 | 
141 |         /* (non-Javadoc)
142 |          * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
143 |          */
144 |         public void endElement(
145 |             String namespaceURI,
146 |             String localName,
147 |             String qualifiedName)
148 |             throws SAXException {
149 | 
150 |             if(qualifiedName.equalsIgnoreCase("file") && mbFile == true) {
151 |                 mbFile = false;
152 |                 mbErrorReport = false;
153 |             }
154 |             else if(qualifiedName.equalsIgnoreCase("modified") && mbErrorReport == true) {
155 |                 mbModified = false;
156 |             }
157 |         }
158 | 
159 |         /* (non-Javadoc)
160 |          * @see org.xml.sax.ContentHandler#endDocument()
161 |          */
162 |         public void endDocument() throws SAXException {
163 |             
164 |         }
165 | 
166 |     }
167 |     
168 |     /**
169 |      * Refreshes directory information on temporary:///.
170 |      * 
171 |      * @throws ERMgmtException
172 |      */
173 |     public void refresh() throws ERMgmtException {
174 | 
175 |         SoapManagementRequest soma_request = null;
176 |         
177 |         
178 |         // setup for connection
179 |         ERConnection connection = new ERConnection(mSettings);
180 |         
181 |         // create a soap request
182 |         soma_request = new SoapManagementRequest();
183 |         
184 |         // create get-filestore request on temporary:///
185 |         soma_request.getFilestore("temporary:", false, false);
186 |         
187 |         // transmit the request
188 |         connection.send(soma_request);
189 |         
190 |         // issue the request
191 |         connection.send(soma_request);
192 |         
193 |         // process the get-filestore response
194 |         try { 
195 |             
196 |             SAXParserFactory factory = SAXParserFactory.newInstance();
197 |             SAXParser parser = factory.newSAXParser();
198 |         
199 |             GetFilestoreParseHandler get_filestore_parser = new GetFilestoreParseHandler();
200 |             parser.parse(
201 |                     soma_request.getResponse(),
202 |                     get_filestore_parser);
203 |             
204 |             // get information from the reponse
205 |             mbIsErrorReportPresent = get_filestore_parser.isErrorReportPresent();
206 |             mModified = get_filestore_parser.getModified();
207 |             
208 |         } catch (Throwable e) {
209 |             throw new ERMgmtSAXException("parsing get-filestore response failed. " + e);
210 |         }
211 |         
212 |     }
213 | 
214 | }
215 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/ERMgmtAuthenticationException.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er.mgmt;
18 | 
19 | /**
20 |  * This exception is thrown when either user or password is incorrect.
21 |  * 
22 |  * @author Dana Numkena
23 |  *
24 |  */
25 | 
26 | public class ERMgmtAuthenticationException extends ERMgmtException {
27 |     
28 |     ERMgmtAuthenticationException(String a) {
29 |         super(a);
30 |     }
31 |     ERMgmtAuthenticationException(String message, Throwable e) {
32 |         super(message, e);
33 |     }
34 |     
35 | }
36 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/ERMgmtBadResponseException.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er.mgmt;
18 | 
19 | /**
20 |  * This exception occurs when an unexpected response is received. 
21 |  * 
22 |  * @author Dana Numkena
23 |  */
24 | 
25 | public class ERMgmtBadResponseException extends ERMgmtException {
26 |     
27 |     ERMgmtBadResponseException(String a) {
28 |         super(a);
29 |     }
30 |     ERMgmtBadResponseException(String message, Throwable e) {
31 |         super(message, e);
32 |     }
33 |     
34 | }
35 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/ERMgmtCertificateException.java:
--------------------------------------------------------------------------------
  1 | /**
  2 | * Copyright 2014-2020 IBM Corp.
  3 | *
  4 | * Licensed under the Apache License, Version 2.0 (the "License");
  5 | * you may not use this file except in compliance with the License.
  6 | * You may obtain a copy of the License at
  7 | *
  8 | * http://www.apache.org/licenses/LICENSE-2.0
  9 | *
 10 | * Unless required by applicable law or agreed to in writing, software
 11 | * distributed under the License is distributed on an "AS IS" BASIS,
 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 | * See the License for the specific language governing permissions and
 14 | * limitations under the License.
 15 | **/
 16 | 
 17 | package com.ibm.datapower.er.mgmt;
 18 | 
 19 | import java.security.cert.CertificateEncodingException;
 20 | import java.security.cert.X509Certificate;
 21 | 
 22 | 
 23 | 
 24 | 
 25 | /**
 26 |  * This exception occurs when a connection to the appliance fails because of an untrusted Certificate.
 27 |  * Is a subclass of ERMgmtException and is used when catching generic ERMgmtExceptions
 28 |  * Contains the untrusted X509Certificate as well as a message indicating the issuers and the subject
 29 |  * 
 30 |  * @author Alex Teyssandier
 31 |  *
 32 |  */
 33 | 
 34 | 
 35 | public class ERMgmtCertificateException extends ERMgmtException {
 36 |     
 37 |     //the X509Certificate associated with the exception
 38 |     X509Certificate certificate = null;
 39 |     
 40 |     /**
 41 |      * Constructor for a Certificate Exception with a null certificate and a given message
 42 |      * @param message      the message of the exception. Should be the Issuer and Subject Information to present to the user
 43 |      * 
 44 |      */
 45 |     ERMgmtCertificateException(String message) {
 46 |         super(message);
 47 |     }
 48 |     /**
 49 |      * Construction for a Certificate Exceptionwith a null certificate and a given message and a given cause
 50 |      * @param message the message of the exception. 
 51 |      * @param e the Throwable cause of the exception
 52 |      */
 53 |     ERMgmtCertificateException(String message, Throwable e) {
 54 |         super(message, e);
 55 |     }
 56 |     
 57 |     /**
 58 |      * Constructor for a Certificate Exception with a given Certificate and Message
 59 |      * 
 60 |      * @param message The message to set the exception. Should be the Issuer and Subject Information to present to the user 
 61 |      * @param mycert   The X509Certificate that caused the exception.
 62 |      * 
 63 |      */
 64 |     ERMgmtCertificateException(String message, X509Certificate mycert) {
 65 |         this(message);
 66 |         certificate = mycert;
 67 |     }
 68 |     
 69 |     /**
 70 |      * Used to set the X509Certificate certificate that caused the exception to happen
 71 |      * 
 72 |      * @param mycert    The certificate that caused the exception
 73 |      */
 74 |     public void setCertificate(X509Certificate mycert){        
 75 |         certificate = mycert;
 76 |     }
 77 |     
 78 |     /**
 79 |      * Used to retrieve the certificate as an X509Certificate Object.
 80 |      * 
 81 |      * @return The X509Certificate
 82 |      */
 83 |     public X509Certificate getCertificate(){
 84 |         return certificate;
 85 |     }
 86 |     
 87 |     /**
 88 |      * Used to retrieve the certificate as a PEM formatted string as a PEM formatted string can be used to generate X509Certificates
 89 |      * 
 90 |      * @return the certificate in PEM format. 
 91 |      * @throws ERMgmtException when there was an error encoding the Certificate as a string 
 92 |      */
 93 |     public String getCertificateAsString() throws ERMgmtException{
 94 |         StringBuffer sb = new StringBuffer(2252);
 95 |         
 96 |         try{
 97 |             sb.append("-----BEGIN CERTIFICATE-----\n");
 98 |             sb.append(Base64.Encode(certificate.getEncoded()));
 99 |             sb.append("\n-----END CERTIFICATE-----\n");
100 |         } catch (CertificateEncodingException e){
101 |             throw new ERMgmtException("Error Encoding Certificate as String: "+e.toString());
102 |         }
103 |         
104 |         return sb.toString();
105 |     }   
106 | }
107 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/ERMgmtConnectException.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er.mgmt;
18 | 
19 | 
20 | /**
21 |  * This exception occurs when a connection to the appliance fails.
22 |  * 
23 |  * @author Dana Numkena
24 |  *
25 |  */
26 | 
27 | public class ERMgmtConnectException extends ERMgmtException {
28 | 
29 |     ERMgmtConnectException(String a) {
30 |         super(a);
31 |     }
32 |     ERMgmtConnectException(String message, Throwable e) {
33 |         super(message, e);
34 |     }
35 |     
36 | }
37 | 


--------------------------------------------------------------------------------
/framework/src/com/ibm/datapower/er/mgmt/ERMgmtException.java:
--------------------------------------------------------------------------------
 1 | /**
 2 | * Copyright 2014-2020 IBM Corp.
 3 | *
 4 | * Licensed under the Apache License, Version 2.0 (the "License");
 5 | * you may not use this file except in compliance with the License.
 6 | * You may obtain a copy of the License at
 7 | *
 8 | * http://www.apache.org/licenses/LICENSE-2.0
 9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | **/
16 | 
17 | package com.ibm.datapower.er.mgmt;
18 | 
19 | //import java.util.logging.Level;
20 | //import java.util.logging.Logger;
21 | 
22 | /**
23 |  * General exception from ERMgmt.
24 |  * 

25 | * This is a superclass to a number of ERMgmt exceptions. 26 | * 27 | * @author Dana Numkena 28 | */ 29 | 30 | public class ERMgmtException extends Exception { 31 | 32 | //private static Logger logger=Logger.getLogger("er.mgmt.exception.log"); 33 | 34 | ERMgmtException (String a) { 35 | super(a); 36 | //logger.log(Level.WARNING, a); 37 | //System.out.print(a); 38 | } 39 | /** 40 | * Constructs a new exception with the specified detail message and cause. 41 | * 42 | * @param message the detail message (which is saved for later retrieval by the Throwable.getMessage() method). 43 | * @param e the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) 44 | */ 45 | ERMgmtException (String message, Throwable e){ 46 | super(message, e); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtFileException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is thrown when file exceptions occurs. 21 | * 22 | * @author Dana Numkena 23 | * 24 | */ 25 | 26 | public class ERMgmtFileException extends ERMgmtException { 27 | 28 | ERMgmtFileException(String a) { 29 | super(a); 30 | } 31 | ERMgmtFileException(String message, Throwable e) { 32 | super(message, e); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtHttpNotOKException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is thrown when HTTP 200 Good is not received. 21 | *

22 | * Usually, this exception is thrown when HTTP 500 Internal Server Error 23 | * is received. 24 | * 25 | * @author Dana Numkena 26 | * 27 | */ 28 | 29 | public class ERMgmtHttpNotOKException extends ERMgmtException { 30 | 31 | ERMgmtHttpNotOKException(String a) { 32 | super(a); 33 | } 34 | ERMgmtHttpNotOKException(String message, Throwable e) { 35 | super(message, e); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtIOException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is a non-specific communication exception. 21 | * 22 | * @author Dana Numkena 23 | * 24 | */ 25 | 26 | public class ERMgmtIOException extends ERMgmtException { 27 | 28 | ERMgmtIOException(String a) { 29 | super(a); 30 | } 31 | ERMgmtIOException(String message, Throwable e) { 32 | super(message, e); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtInvalidPortException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is thrown when an invalid port is entered. 21 | *

22 | * In this case, an invalid port is either a port number out of range or 23 | * a port that is not a number. 24 | * 25 | * @author Dana Numkena 26 | * 27 | */ 28 | 29 | public class ERMgmtInvalidPortException extends ERMgmtException { 30 | 31 | ERMgmtInvalidPortException(String a) { 32 | super(a); 33 | } 34 | ERMgmtInvalidPortException(String message, Throwable e) { 35 | super(message, e); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtNoHttpResponseException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is thrown when the plug-in does not receive an HTTP response. 21 | * 22 | * @author Dana Numkena 23 | * 24 | */ 25 | 26 | public class ERMgmtNoHttpResponseException extends ERMgmtException { 27 | 28 | ERMgmtNoHttpResponseException(String a) { 29 | super(a); 30 | } 31 | ERMgmtNoHttpResponseException(String message, Throwable e) { 32 | super(message, e); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtNoRouteToHostException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is usually thrown when there is no thernet connection 21 | * to the host machine. 22 | * 23 | * @author Dana Numkena 24 | * 25 | */ 26 | 27 | public class ERMgmtNoRouteToHostException extends ERMgmtException { 28 | 29 | ERMgmtNoRouteToHostException(String a) { 30 | super(a); 31 | } 32 | ERMgmtNoRouteToHostException(String message, Throwable e) { 33 | super(message, e); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtSAXException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * The exception is thrown when there is a failure in parsing the response. 21 | * 22 | * @author Dana Numkena 23 | * 24 | */ 25 | 26 | public class ERMgmtSAXException extends ERMgmtException { 27 | 28 | ERMgmtSAXException(String a) { 29 | super(a); 30 | } 31 | ERMgmtSAXException(String message, Throwable e) { 32 | super(message, e); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERMgmtUnknownHostException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | /** 20 | * This exception is thrown when the destination hostname is unknown. 21 | * 22 | * @author Dana Numkena 23 | * 24 | */ 25 | 26 | public class ERMgmtUnknownHostException extends ERMgmtException { 27 | 28 | ERMgmtUnknownHostException(String a) { 29 | super(a); 30 | } 31 | ERMgmtUnknownHostException(String message, Throwable e) { 32 | super(message, e); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/ERTrustManagerCertificateException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | import java.security.cert.CertificateEncodingException; 20 | import java.security.cert.CertificateException; 21 | import java.security.cert.X509Certificate; 22 | 23 | /** 24 | * This exception occurs when a connection to the appliance fails because of a Certificate not trusted problem. 25 | * Thrown by ERTrustManager when an untrusted certificate is found. 26 | * Contains the untrusted X509Certificate as well as a message indicating the issuers and the subject 27 | * 28 | * @author Alex Teyssandier 29 | * 30 | */ 31 | 32 | public class ERTrustManagerCertificateException extends CertificateException { 33 | //the X509Certificate associated with the exception 34 | X509Certificate certificate = null; 35 | 36 | /** 37 | * Constructor for a Certificate Exception with a null certificate and a given message 38 | * @param message the message of the exception. Should be the Issuer and Subject Information to present to the user 39 | * 40 | */ 41 | ERTrustManagerCertificateException(String message) { 42 | super(message); 43 | } 44 | 45 | /** 46 | * Constructor for a Certificate Exception with a given Certificate and Message 47 | * 48 | * @param message The message to set the exception. Should be the Issuer and Subject Information to present to the user 49 | * @param mycert The X509Certificate that caused the exception. 50 | * 51 | */ 52 | ERTrustManagerCertificateException(String message, X509Certificate mycert) { 53 | this(message); 54 | certificate = mycert; 55 | } 56 | 57 | /** 58 | * Used to set the X509Certificate certificate that caused the exception to happen 59 | * 60 | * @param mycert The certificate that caused the exception 61 | */ 62 | public void setCertificate(X509Certificate mycert){ 63 | certificate = mycert; 64 | } 65 | 66 | /** 67 | * Used to retrieve the certificate as an X509Certificate Object. 68 | * 69 | * @return The X509Certificate 70 | */ 71 | public X509Certificate getCertificate(){ 72 | return certificate; 73 | } 74 | 75 | /** 76 | * Used to retrieve the certificate as a PEM formatted string as a PEM formatted string can be used to generate X509Certificates 77 | * 78 | * @return the certificate in PEM format. 79 | * @throws ERMgmtException when there was an error encoding the Certificate as a string 80 | */ 81 | public String getCertificateAsString() throws ERMgmtException{ 82 | StringBuffer sb = new StringBuffer(2252); 83 | 84 | try{ 85 | sb.append("-----BEGIN CERTIFICATE-----\n"); 86 | sb.append(Base64.Encode(certificate.getEncoded())); 87 | sb.append("\n-----END CERTIFICATE-----\n"); 88 | } catch (CertificateEncodingException e){ 89 | throw new ERMgmtException("Error Encoding Certificate as String: "+e.toString()); 90 | } 91 | 92 | return sb.toString(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/Message.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | import java.io.Reader; 20 | import java.io.Writer; 21 | 22 | /** 23 | * The Message interface provides methods to create SOMA requests. 24 | *

25 | * This interface is the glue between the SoapMessage and 26 | * SoapManagmentRequest classes. Most of the methods from this 27 | * interface refers to the SoapManagementRequest class. 28 | * 29 | * @author DataPower Technology, Inc. 30 | * @author Dana Numkena 31 | * 32 | */ 33 | public interface Message { 34 | 35 | /** 36 | * Write message to writer object 37 | * 38 | * @param Writer to write message out to 39 | * @throws ERMgmtIOException 40 | */ 41 | public void write(Writer writer) throws ERMgmtIOException; 42 | 43 | /** 44 | * Parse response message pointed by reader object 45 | * 46 | * @param Reader to read response from 47 | * @throws ERMgmtIOException 48 | */ 49 | public void parse(Reader reader) throws ERMgmtIOException; 50 | } 51 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/SoapEnvelope.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | import java.io.IOException; 20 | import java.io.Reader; 21 | import java.io.Writer; 22 | 23 | /** 24 | * This class provides an object as the SOAP message. 25 | *

26 | * Primarily, this class creates the SOAP envelope. Indirectly, this class 27 | * calls the SoapManagementRequest class to create the SOMA request. 28 | *

29 | * This class provides methods to write the SOAP message to streaming output 30 | * and parse responses. 31 | * 32 | * @author DataPower Technology, Inc. 33 | * @author Dana Numkena 34 | * 35 | */ 36 | public class SoapEnvelope implements Message { 37 | 38 | // name spaces 39 | private static final String NS_URI_SOAP_ENV = "http://schemas.xmlsoap.org/soap/envelope/"; 40 | 41 | // enveloped message 42 | private Message mMessage; 43 | 44 | /** 45 | * Constructor 46 | * 47 | * @param message content of the SOAP envelope element, 48 | * or the SOMA request. 49 | */ 50 | public SoapEnvelope(Message message) { 51 | mMessage = message; 52 | } 53 | 54 | /** 55 | * Write the SOMA request 56 | *

57 | * This method writes the SOAP envelope and indirectly writes 58 | * the SOMA request. 59 | * 60 | * @param wout Writer object pointing to the SOAP request. 61 | * 62 | * @throws ERMgmtIOException 63 | * 64 | * @see Message#write 65 | */ 66 | public void write(Writer wout) throws ERMgmtIOException { 67 | try { 68 | wout.write("\r\n"); 69 | wout.write("\r\n"); 71 | wout.write("\r\n"); 72 | mMessage.write(wout); 73 | wout.write("\r\n"); 74 | wout.write("\r\n"); 75 | } catch (IOException e) { 76 | throw new ERMgmtIOException("soap envelope write failure" + e.toString()); 77 | } 78 | } 79 | 80 | /** 81 | * Parse the SOAP response. 82 | * 83 | * @param reader a Reader object pointing to the SOAP response 84 | * 85 | * @throws ERMgmtIOException 86 | * 87 | * @see Message#parse 88 | */ 89 | public void parse(Reader reader) throws ERMgmtIOException { 90 | try { 91 | 92 | String soapBodyStartTag = ""; 93 | boolean bodyFound = false; 94 | 95 | // ********************* 96 | // search for 97 | // ********************* 98 | 99 | // search for the 100 | StringBuffer sb = new StringBuffer(); 101 | int c; 102 | while ((c = reader.read()) != -1) { 103 | sb.append((char) c); 104 | if (sb.indexOf(soapBodyStartTag) != -1) { 105 | bodyFound = true; 106 | break; 107 | } 108 | } 109 | 110 | // if body was not found 111 | if (!bodyFound) { 112 | throw new IOException("Malformed SOAP response - no body tag"); 113 | } 114 | 115 | // mark start 116 | reader.mark(0); 117 | sb.delete(0, sb.length()); // delete contents in buffer 118 | 119 | // *************** 120 | // Check for fault 121 | // *************** 122 | 123 | // read the next tag 124 | String soapFaultStartTag = ""; 125 | boolean tagClose = false; 126 | 127 | // read dp:response tag 128 | while ((c = reader.read()) != -1) { 129 | sb.append((char) c); 130 | if ((char) c == '>') { 131 | tagClose = true; 132 | break; 133 | } 134 | } 135 | 136 | // if tag has no end tag 137 | if (!tagClose) { 138 | throw new ERMgmtIOException("Malformed SOAP response - no end tag"); 139 | } 140 | 141 | // if dp:response have a SOAP fault element 142 | if (sb.toString().startsWith(soapFaultStartTag)) { 143 | 144 | // read remaining part of the response 145 | while ((c = reader.read()) != -1) { 146 | sb.append((char) c); 147 | } 148 | 149 | // parse fault string and throw exception 150 | String faultString = parseFaultString(sb.toString()); 151 | TraceHelper.trace("Received SOAP fault '" + faultString +"'"); 152 | throw new IOException(faultString); 153 | } 154 | 155 | // reset the element 156 | reader.reset(); 157 | 158 | // *************************** 159 | // no fault, parse the body element 160 | // *************************** 161 | 162 | // parse the body element, or parse the SOMA response 163 | mMessage.parse(reader); 164 | 165 | } catch (IOException e) { 166 | throw new ERMgmtIOException("soap envelope parse failure." + e.toString()); 167 | } 168 | } 169 | 170 | /** 171 | * Gets the content from the SOAP response. 172 | * 173 | * @param response the SOAP response message 174 | * 175 | * @return fault string content 176 | * 177 | * @throws IOException 178 | */ 179 | private String parseFaultString(String response) throws IOException { 180 | 181 | String startTag = ""; 182 | String endTag = ""; 183 | 184 | int start = response.indexOf(startTag) + startTag.length(); 185 | int end = response.indexOf(endTag); 186 | 187 | if ((start == -1) || (end == -1)) { 188 | throw new IOException("Malformed fault response"); 189 | } 190 | 191 | return response.substring(start, end); 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /framework/src/com/ibm/datapower/er/mgmt/TraceHelper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014-2020 IBM Corp. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | **/ 16 | 17 | package com.ibm.datapower.er.mgmt; 18 | 19 | import java.io.Writer; 20 | import java.util.logging.Logger; 21 | 22 | 23 | /** 24 | * This class provides an object to direct debugging info to an output. 25 | *

26 | * This is a subclass to the Writer class. Currently, output is disabled. 27 | * Uncomment to turn them on. 28 | * 29 | * @author DataPower Technology, Inc 30 | * @author Dana Numkena 31 | */ 32 | public class TraceHelper extends Writer { 33 | 34 | private String mBuffer = ""; 35 | private static Logger logger=Logger.getLogger("com.ibm.datapower.isa.er.mgmt"); 36 | 37 | /** 38 | * write debugging info to output 39 | */ 40 | protected static void trace(String traceString) { 41 | //System.out.println(": " + traceString); 42 | logger.info(traceString); 43 | } 44 | 45 | /** 46 | * write debugging info to buffer. 47 | */ 48 | public void write(String str) { 49 | 50 | //System.out.print(str); 51 | logger.info(str); 52 | mBuffer = mBuffer + str; 53 | } 54 | 55 | /** 56 | * Flush the buffer to output 57 | */ 58 | public void flush() { 59 | logger.info(mBuffer); 60 | //System.out.print(mBuffer); 61 | mBuffer = ""; 62 | }; 63 | 64 | public void close() {}; 65 | 66 | public void write(char[] cbuf, int off, int len) {}; 67 | } 68 | -------------------------------------------------------------------------------- /framework/src/erCSV.xsl: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 1 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | No status to report 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /framework/src/erTEXT.xsl: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 1 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 1 94 | 95 | 96 | No status to report 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /framework/syscall.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use CGI; 4 | 5 | my $var = `$WORKDIR/datapower/isa/framework/ertool -file error-report.txt.gz -format HTML -xsl HTML,*,./src/erHTML.xsl`; 6 | 7 | 8 | print $var; 9 | 10 | -------------------------------------------------------------------------------- /framework/tools/internal/ERBacktrace.java: -------------------------------------------------------------------------------- 1 | /* 2 | * IBM Confidential 3 | * OCO Source Materials 4 | * IBM WebSphere DataPower Appliances 5 | * Copyright IBM Corporation 2010 6 | * The source code for this program is not published or otherwise 7 | * divested of its trade secrets, irrespective of what has been 8 | * deposited with the U.S. Copyright Office. 9 | */ 10 | 11 | import java.net.URL; 12 | import java.net.URLConnection; 13 | import java.io.InputStream; 14 | import java.io.ByteArrayInputStream; 15 | import java.io.OutputStream; 16 | import java.io.IOException; 17 | 18 | /* 19 | * Invoke backtrace decoder via HTTP 20 | */ 21 | public class ERBacktrace { 22 | 23 | /* 24 | * Read a backtrace input stream and return a decoded input stream. 25 | */ 26 | public static InputStream decode(InputStream in) 27 | { 28 | return in; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /post-processing-error-reports/README.txt: -------------------------------------------------------------------------------- 1 | IBM WebSphere DataPower Appliances 2 | Copyright IBM Corporation 2012 3 | 4 | README 5 | 6 | Datapower Datapower Error Report Post-Processing Tool. 7 | 8 | errReportPostProcessing.pl 9 | ---------------- 10 | The errReportPostProcessing.pl is a Perl script that appends English text 11 | to each line of the error report in default-log section for a given non-English error report. 12 | 13 | Prerequisites 14 | ---------------- 15 | Before you can run this post-processing tool, perl model will need to be 16 | installed on your system. Perl can run on both Linux (Unix) systems and 17 | Windows (Win32). The latest version of Perl can be downloaded from perl.org. 18 | 19 | RUN 20 | --- 21 | Run the script as follows 22 | ./errReportPostProcessing.pl 23 | 24 | 25 | The path for the directory containing the English msgcat XML files 26 | 27 | The file path for the non-English error report file(.txt) 28 | 29 | The file path for the output error report file 30 | 31 | It will create a new error report file(Path:) with English text appended in default-log section. 32 | 33 | Example 34 | --- 35 | ./errReportPostProcessing.pl /datapower/msgcat/xml /dp/error-report.txt /dp/error-report-postprocessed.txt 36 | 37 | 38 | 39 | --------------------------------------------------------------------------------