Class PolyspaceHelpersUtils
- java.lang.Object
-
- com.mathworks.polyspace.jenkins.utils.PolyspaceHelpersUtils
-
public class PolyspaceHelpersUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PolyspaceHelpersUtils.AccessUploadResult
Small utility class to hold a results runId and projectId
-
Constructor Summary
Constructors Constructor Description PolyspaceHelpersUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
appendLineInFile(Path file, String line)
Appendline
with a new line infile
static String
getAccessResultProjectId(Path output)
static String
getAccessResultRunId(Path output)
static String
getAccessResultUrl(Path output, String accessURL)
static long
getCountFindings(Path report)
static Path
getReportOwner(Path report, String owner)
Build the report-owner filename: Owner is empty: "report
" unmodified Report without extension: "report
_owner
" Report with extension: "report
_owner
.ext"static Path
getReportOwnerList(Path report)
Build the report-owner-list filename:report
.owners.liststatic String
getReportStatus(Path report, long max)
static Boolean
isOwnerInFile(Path ownerList, String owner)
static void
reportFilter(Path originalReport, Path filteredReport, String owner, String[] filters)
FilteroriginalReport
againstfilters
intofilteredReport
associated withowner
static int
reportGetColId(String line, String token)
Get the column ID oftoken
inline
Note that tokens inline
are separated by tabs
-
-
-
Method Detail
-
isOwnerInFile
public static Boolean isOwnerInFile(Path ownerList, String owner) throws IOException
- Parameters:
ownerList
- - The owner list fileowner
- - An owner- Returns:
true
ifowner
is inownerList
-false
otherwise- Throws:
IOException
- Error while accessingownerList
-
appendLineInFile
public static void appendLineInFile(Path file, String line) throws IOException
Appendline
with a new line infile
- Parameters:
file
- - Path to a fileline
- - Line string to add- Throws:
IOException
- Error while accessingfile
-
getReportOwner
public static Path getReportOwner(Path report, String owner)
Build the report-owner filename:- Owner is empty: "
report
" unmodified - Report without extension: "
report
_owner
" - Report with extension: "
report
_owner
.ext"
- Parameters:
report
- - Path to the reportowner
- - An owner- Returns:
- The report-owner filename
- Owner is empty: "
-
getReportOwnerList
public static Path getReportOwnerList(Path report)
Build the report-owner-list filename:report
.owners.list- Parameters:
report
- - Path to the report- Returns:
- The report-owner-list filename
-
reportGetColId
public static int reportGetColId(String line, String token)
Get the column ID oftoken
inline
Note that tokens inline
are separated by tabs- Parameters:
line
- - Line string containing the report column namestoken
- - Searched token- Returns:
- The column ID
-
reportFilter
public static void reportFilter(Path originalReport, Path filteredReport, String owner, String[] filters) throws IOException
FilteroriginalReport
againstfilters
intofilteredReport
associated withowner
- Parameters:
originalReport
- - Path to original reportfilteredReport
- - Path to the new filtered report - it may already exist to allow to append multiple filtered reportsowner
- - The owner for the filtered report - must be a username matching an email as it will also be used to send the email notificationfilters
- - An array of strings containing one or more "key" "value" pairs- Throws:
IOException
- Error while accessingoriginalReport
orfilteredReport
-
getCountFindings
public static long getCountFindings(Path report) throws IOException
- Parameters:
report
- - Path to the report- Returns:
- - Number of findings in
report
: number of lines - 1 (title line) - Throws:
IOException
- Error while accessingreport
-
getReportStatus
public static String getReportStatus(Path report, long max) throws IOException
- Parameters:
report
- - Path to the reportmax
- - Thereshold for status- Returns:
- - Job status string: SUCCESS if num findings smaller than
max
, UNSTABLE otherwise - Throws:
IOException
- Error while accessingreport
-
getAccessResultRunId
public static String getAccessResultRunId(Path output) throws IOException
- Parameters:
output
- - Path to the report- Returns:
- Result runId
- Throws:
IOException
- Error while accessingoutput
-
getAccessResultProjectId
public static String getAccessResultProjectId(Path output) throws IOException
- Parameters:
output
- - Path to the report- Returns:
- Result projectId
- Throws:
IOException
- Error while accessingoutput
-
getAccessResultUrl
public static String getAccessResultUrl(Path output, String accessURL) throws IOException
- Parameters:
output
- - Path to the reportaccessURL
- - Root Access server URL- Returns:
- Results URL
- Throws:
IOException
- Error while accessingoutput
-
-