Produced by Araxis Merge on 12/21/2016 2:21:12 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\OSCIF_VSS\Pri_un\ZIP\VSS_5_1_2438\VSS_5_1_2438\trunk\core\src\main\java\gov\va\shared\service\validation | ServiceValidationException.java | Wed Dec 7 02:28:48 2016 UTC |
2 | C:\OSCIF_VSS\Pri_re\ZIP\VSS_5_1_2438\VSS_5_1_2438\trunk\core\src\main\java\gov\va\shared\service\validation | ServiceValidationException.java | Mon Dec 12 20:49:52 2016 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 332 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | package go v.va.share d.service. validation ; | |
2 | ||
3 | import jav a.io.Seria lizable; | |
4 | import jav a.time.Zon eId; | |
5 | import jav a.time.Zon edDateTime ; | |
6 | ||
7 | import org .apache.co mmons.lang 3.StringUt ils; | |
8 | import org .apache.co mmons.lang 3.builder. EqualsBuil der; | |
9 | import org .springfra mework.con text.Messa geSourceRe solvable; | |
10 | ||
11 | import gov .va.shared .util.Date Util; | |
12 | ||
13 | /** | |
14 | * An exce ption whic h represen ts a valid ation erro r that occ urred in t he service | |
15 | * layer o f the appl ication. T his except ion also f unctions a s a | |
16 | * Message SourceReso lvable, wh ich used b y the Mess ageSource to retriev e the | |
17 | * appropr iate error message f or the use r. | |
18 | * | |
19 | * @author AI | |
20 | * | |
21 | */ | |
22 | public cla ss Service Validation Exception extends Ex ception im plements M essageSour ceResolvab le { | |
23 | pr ivate stat ic final l ong serial VersionUID = -357162 1035959917 290L; | |
24 | ||
25 | // --------- ---------- ---------- ---------- -------- S tatic Fiel ds | |
26 | ||
27 | pu blic stati c final St ring RULE_ SUFFIX = " .rule"; | |
28 | pu blic stati c final St ring RECOM MENDATION_ SUFFIX = " .recommend ation"; | |
29 | ||
30 | // --------- ---------- ---------- ---------- -------- F ields | |
31 | ||
32 | pr ivate Stri ng errorCo de; | |
33 | pr ivate Seri alizable[] arguments ; | |
34 | ||
35 | /* | |
36 | * Below are optional additional fields wh ich may he lp customi ze the mes sage | |
37 | * shown to the user: | |
38 | * / | |
39 | ||
40 | /* The param eter of th e service method hav ing the pr oblem */ | |
41 | pr ivate Stri ng paramet erName; | |
42 | ||
43 | /* | |
44 | * Allows th e creator to overrid e the Time Zones of a ll DateTim es stored in | |
45 | * the argum ents array , so that when they are used t o fill in placeholde rs | |
46 | * as a Mess ageSourceR esolvable, they are specific t o the user 's appropr iate | |
47 | * TimeZone. | |
48 | * / | |
49 | pr ivate Zone Id timeZon eOverride = null; | |
50 | ||
51 | // --------- ---------- ---------- ---------- -------- C onstructor s | |
52 | ||
53 | pu blic Servi ceValidati onExceptio n(String e rrorCode) { | |
54 | this (null, err orCode, nu ll); | |
55 | } | |
56 | ||
57 | pu blic Servi ceValidati onExceptio n(String e rrorCode, Serializab le... argu ments) { | |
58 | this (null, err orCode, ar guments); | |
59 | } | |
60 | ||
61 | pu blic Servi ceValidati onExceptio n(String p arameterNa me, String errorCode , Serializ able[] arg uments) { | |
62 | if ( errorCode == null) | |
63 | throw new Illega lArgumentE xception(" The errorC ode parame ter must b e non-null "); | |
64 | ||
65 | this .parameter Name = par ameterName ; | |
66 | this .errorCode = errorCo de; | |
67 | this .arguments = argumen ts; | |
68 | } | |
69 | ||
70 | // --------- ---------- ---------- ---------- -------- B usiness Me thods | |
71 | ||
72 | pu blic Seria lizable[] getArgumen ts() { | |
73 | if ( arguments == null) | |
74 | return arguments ; | |
75 | ||
76 | Seri alizable[] newArgs = new Seria lizable[ar guments.le ngth]; | |
77 | for (int i = 0 ; i < argu ments.leng th; i++) { | |
78 | if (ar guments[i] instanceo f ZonedDat eTime) { | |
79 | ZonedDat eTime dt = (ZonedDat eTime) arg uments[i]; | |
80 | if (time ZoneOverri de != null ) { | |
81 | newArgs[i] = DateUti l.localFor mat(timeZo neOverride , dt); | |
82 | } else { | |
83 | newArgs[i] = DateUti l.localFor mat(dt.get Zone(), dt ); | |
84 | } | |
85 | } else if (argum ents[i] in stanceof Z onedDateTi me[]) { | |
86 | ZonedDat eTime[] dt = (ZonedD ateTime[]) arguments [i]; | |
87 | if (dt.l ength != 2 ) | |
88 | throw new IllegalArg umentExcep tion("A " + ZonedDat eTime.clas s.getSimpl eName() | |
89 | + " range repr esented by an array was used a s an" + " argument b ut the len gth != 2") ; | |
90 | if (time ZoneOverri de != null ) { | |
91 | newArgs[i] = DateUti l.getDateR angeDescri ption(time ZoneOverri de, dt[0], dt[1]); | |
92 | } else { | |
93 | newArgs[i] = DateUti l.getDateR angeDescri ption(dt[0 ].getZone( ), dt[0], dt[1]); | |
94 | } | |
95 | } else { | |
96 | newArgs[ i] = argum ents[i]; | |
97 | } | |
98 | } | |
99 | ||
100 | retu rn newArgs ; | |
101 | } | |
102 | ||
103 | @O verride | |
104 | pu blic Strin g[] getCod es() { | |
105 | retu rn new Str ing[] { er rorCode }; | |
106 | } | |
107 | ||
108 | @O verride | |
109 | pu blic Strin g getDefau ltMessage( ) { | |
110 | retu rn "Messag e not foun d for any codes {" + StringUti ls.join(ge tCodes(), ",") + "}" ; | |
111 | } | |
112 | ||
113 | pu blic Strin g getRuleM essageKey( ) { | |
114 | retu rn errorCo de + RULE_ SUFFIX; | |
115 | } | |
116 | ||
117 | pu blic Strin g getRecom mendationM essageKey( ) { | |
118 | retu rn errorCo de + RECOM MENDATION_ SUFFIX; | |
119 | } | |
120 | ||
121 | /* * | |
122 | * Initializ es the cau se of this exception to the sp ecified Th rowable by | |
123 | * calling i nitCause() . This met hod follow s the cont ract of | |
124 | * Exception .initCause (), which means it c an only be called on ce. | |
125 | * / | |
126 | pu blic Servi ceValidati onExceptio n withCaus e(Throwabl e e) { | |
127 | init Cause(e); | |
128 | retu rn this; | |
129 | } | |
130 | ||
131 | // --------- ---------- ---------- ---------- -------- C ommon Meth ods | |
132 | ||
133 | @O verride | |
134 | pu blic boole an equals( Object o) { | |
135 | if ( o instance of Service Validation Exception == false) | |
136 | return false; | |
137 | ||
138 | Serv iceValidat ionExcepti on e = (Se rviceValid ationExcep tion) o; | |
139 | retu rn new Equ alsBuilder ().append( errorCode, e.errorCo de).append (arguments , e.argume nts) | |
140 | .append( parameterN ame, e.par ameterName ).append(t imeZoneOve rride, e.t imeZoneOve rride).isE quals(); | |
141 | } | |
142 | ||
143 | // --------- ---------- ---------- ---------- -------- A ccessor Me thods | |
144 | ||
145 | pu blic Strin g getParam eterName() { | |
146 | retu rn paramet erName; | |
147 | } | |
148 | ||
149 | pu blic Strin g getError Code() { | |
150 | retu rn errorCo de; | |
151 | } | |
152 | ||
153 | pu blic void setErrorCo de(String errorCode) { | |
154 | if ( errorCode == null) | |
155 | throw new Illega lArgumentE xception(" The errorC ode parame ter must b e non-null "); | |
156 | this .errorCode = errorCo de; | |
157 | } | |
158 | ||
159 | pu blic ZoneI d getTimeZ oneOverrid e() { | |
160 | retu rn timeZon eOverride; | |
161 | } | |
162 | ||
163 | pu blic void setTimeZon eOverride( ZoneId dtz ) { | |
164 | this .timeZoneO verride = dtz; | |
165 | } | |
166 | ||
167 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.