1
2
3
4
5
6
7
8
9
10
11
12
13 package gov.nasa.pds.vtool.status;
14
15 import gov.nasa.pds.vtool.validate.ValidationRecord;
16
17 /***
18 * Exit Status values
19 * <ul>
20 * <li>0 = Success</li>
21 * <li>1 = Application error</li>
22 * <li>2 = System error</li>
23 * <li>32 = One or more files skipped the validation run</li>
24 * <li>64 = One or more validation warnings encountered during the
25 * validation run</li>
26 * <li>96 = One or more files skipped and validation warnings encountered
27 * during the validation run</li>
28 * <li>128 = One or more validation errors encountered during the validation
29 * run</li>
30 * <li>160 = One or more files skipped and validation errors encountered
31 * during the validation run</li>
32 * <li>192 = One or more validation warnings and errors encountered during
33 * the validation run</li>
34 * <li>224 = One or more files skipped, validation warnings and errors
35 * encountered during the validation run</li>
36 * </ul>
37 *
38 * @author mcayanan
39 *
40 */
41 public class ExitStatus implements ExitStatusType {
42 private int status;
43 private String ERROR = "ERROR";
44
45 /***
46 * Constructor
47 *
48 * @throws IllegalArgumentException If the verbose level
49 */
50 public ExitStatus() throws IllegalArgumentException {
51 status = 0;
52 }
53
54 /***
55 * Get the status
56 *
57 * @param severity The severity level and above to include when
58 * determining the exit status.
59 *
60 * @return The exit status value.
61 */
62 public int getStatus(String severity) {
63
64
65 if(ERROR.equalsIgnoreCase(severity)) {
66 status = (status & 191);
67 }
68 return status;
69 }
70
71 /***
72 * Set the status
73 * @param value integer value that would represent the status.
74 * @throws IndexOutOfBoundsException
75 */
76 public void setStatus(int value) throws IndexOutOfBoundsException {
77 status = (status | value);
78 }
79
80 /***
81 * Set the status
82 *
83 * @param record A ValidationRecord containing the results of a validaiton run.
84 */
85 public void setStatus(ValidationRecord record) {
86 if(record.getFilesSkipped() != 0)
87 status = (status | SKIPPED_FILES);
88 if(record.hasWarnings())
89 status = (status | WARNINGS_FOUND);
90 if(record.hasErrors())
91 status = (status | ERRORS_FOUND);
92 }
93 }