Produced by Araxis Merge on 8/31/2017 11:16:51 AM Central Daylight 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 | JLV_2.6.zip\JLV_2.6\JLV_2.6\Joint Legacy Viewer\BHIERelayService\src\main\java\gov\va\med\bhie\dataservice | BHIECacheClient.java | Thu Aug 31 12:13:46 2017 UTC |
2 | JLV_2.6.zip\JLV_2.6\JLV_2.6\Joint Legacy Viewer\BHIERelayService\src\main\java\gov\va\med\bhie\dataservice | BHIECacheClient.java | Thu Aug 31 13:16:33 2017 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 398 |
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.med.b hie.datase rvice; | |
2 | ||
3 | import org .apache.lo g4j.Logger ; | |
4 | ||
5 | import jav a.io.Input Stream; | |
6 | import jav a.io.Outpu tStream; | |
7 | import jav a.io.Outpu tStreamWri ter; | |
8 | import jav a.io.Write r; | |
9 | import jav a.net.Http URLConnect ion; | |
10 | import jav a.net.URL; | |
11 | import jav a.net.URLC onnection; | |
12 | import jav a.nio.char set.Charse t; | |
13 | import jav a.util.Loc ale; | |
14 | ||
15 | public cla ss BHIECac heClient e xtends Thr ead { | |
16 | /** | |
17 | * Log ger. | |
18 | */ | |
19 | privat e static f inal Logge r LOGGER = | |
20 | Logger.g etLogger(B HIECacheCl ient.class .getName() ); | |
21 | ||
22 | private st atic final String RE QUESTBEGIN = "<soape nv:Envelop e xmlns:so apenv=\"ht tp://schem as.xmlsoap .org/soap/ envelope/\ " xmlns:we b=\"http:/ /webservic e.bhie. URL /\">\n" | |
23 | + " <soape nv:Header/ >\n" | |
24 | + " <soape nv:Body>\n " | |
25 | + " <we b:addCache >\n"; | |
26 | privat e static f inal Strin g REQUESTE ND = " </web:ad dCache>\n" | |
27 | + " </soap env:Body>\ n" | |
28 | + "</soapenv :Envelope> "; | |
29 | ||
30 | privat e String u rl = ""; | |
31 | privat e String a uth = ""; | |
32 | privat e String t ype = ""; | |
33 | privat e String k ey = ""; | |
34 | privat e String v alue = ""; | |
35 | privat e String t imestamp = ""; | |
36 | ||
37 | public BHIECache Client() { | |
38 | su per(); | |
39 | } | |
40 | ||
41 | public BHIECache Client(Str ing url, S tring auth , String t ype, Strin g key, Str ing value, String ti mestamp) { | |
42 | su per(); | |
43 | th is.url = u rl; | |
44 | th is.auth = auth; | |
45 | th is.type = type; | |
46 | th is.key = k ey; | |
47 | th is.value = value; | |
48 | th is.timesta mp = times tamp; | |
49 | } | |
50 | ||
51 | /** | |
52 | * Run the servi ce. | |
53 | */ | |
54 | public void run( ) { | |
55 | tr y { | |
56 | if (url != null && url.toLow erCase(Loc ale.getDef ault()).st artsWith(" http")) { | |
57 | Stri ngBuilder request = new String Builder(10 24); | |
58 | requ est.append (REQUESTBE GIN); | |
59 | requ est.append (" <type><![ CDATA[" + type + "]] ></type>\n "); | |
60 | requ est.append (" <key><![C DATA[" + k ey + "]]>< /key>\n"); | |
61 | requ est.append (" <value><! [CDATA[" + value + " ]]></value >\n"); | |
62 | requ est.append (" <timestam p><![CDATA [" + times tamp + "]] ></timesta mp>\n"); | |
63 | requ est.append (REQUESTEN D); | |
64 | Stri ng soapreq = request .toString( ); | |
65 | URL cacheurl = new URL(u rl); | |
66 | URLC onnection uconn = ca cheurl.ope nConnectio n(); | |
67 | Http URLConnect ion connec tion = (Ht tpURLConne ction) uco nn; | |
68 | conn ection.set ReadTimeou t(60000); | |
69 | conn ection.set DoOutput(t rue); | |
70 | conn ection.set DoInput(tr ue); | |
71 | conn ection.set RequestPro perty("Con tent-Type" , "text/xm l"); | |
72 | conn ection.set RequestPro perty("Acc ept", "tex t/xml"); | |
73 | conn ection.set RequestPro perty("Con tent-lengt h", Intege r.toString (soapreq.l ength())); | |
74 | if ( auth != nu ll && auth .length() > 0) { | |
75 | // auth sh ould be an encoded s tring like : Base64En coder.enco de ("test1 :test1") | |
76 | connection .setReques tProperty( "Authoriza tion", "Ba sic " + au th); | |
77 | } | |
78 | conn ection.set RequestMet hod("POST" ); | |
79 | ||
80 | Outp utStream o ut = conne ction.getO utputStrea m(); | |
81 | Writ er wout = null; | |
82 | try { | |
83 | wout = new OutputStr eamWriter( out, Chars et.forName ("UTF-8"). newEncoder ()); | |
84 | wout.write (soapreq); | |
85 | wout.flush (); | |
86 | } fi nally { | |
87 | if (wout ! = null) { | |
88 | try { | |
89 | wo ut.close() ; | |
90 | } catc h (Excepti on ex) { | |
91 | LO GGER.error (ex.getLoc alizedMess age(), ex) ; | |
92 | } | |
93 | } | |
94 | } | |
95 | Inpu tStream in put = null ; | |
96 | // St ringBuilde r resp = n ew StringB uilder(102 4); | |
97 | try { | |
98 | input = co nnection.g etInputStr eam(); | |
99 | int chr = input.read (); | |
100 | while (chr != -1) { | |
101 | // resp .append((c har) chr); | |
102 | chr = input.read (); | |
103 | } | |
104 | } fi nally { | |
105 | if (input != null) { | |
106 | input. close(); | |
107 | } | |
108 | } | |
109 | } | |
110 | // LOGGER .debug("Re ceived: \n " + resp.t oString(). replaceAll ("><", ">\ n<")); | |
111 | // LOGGER .debug("Re sponse cod e = " + co nnection.g etResponse Code()); | |
112 | } catch (Exc eption ex) { | |
113 | LOGGER.e rror(ex.ge tLocalized Message(), ex); | |
114 | } | |
115 | } | |
116 | ||
117 | /** | |
118 | * @re turn the u rl | |
119 | */ | |
120 | public String ge tUrl() { | |
121 | re turn url; | |
122 | } | |
123 | ||
124 | /** | |
125 | * @pa ram url th e url to s et | |
126 | */ | |
127 | public void setU rl(String url) { | |
128 | th is.url = u rl; | |
129 | } | |
130 | ||
131 | /** | |
132 | * @re turn the a uth | |
133 | */ | |
134 | public String ge tAuth() { | |
135 | re turn auth; | |
136 | } | |
137 | ||
138 | /** | |
139 | * @pa ram auth t he auth to set | |
140 | */ | |
141 | public void setA uth(String auth) { | |
142 | th is.auth = auth; | |
143 | } | |
144 | ||
145 | /** | |
146 | * @re turn the t ype | |
147 | */ | |
148 | public String ge tType() { | |
149 | re turn type; | |
150 | } | |
151 | ||
152 | /** | |
153 | * @pa ram type t he type to set | |
154 | */ | |
155 | public void setT ype(String type) { | |
156 | th is.type = type; | |
157 | } | |
158 | ||
159 | /** | |
160 | * @re turn the k ey | |
161 | */ | |
162 | public String ge tKey() { | |
163 | re turn key; | |
164 | } | |
165 | ||
166 | /** | |
167 | * @pa ram key th e key to s et | |
168 | */ | |
169 | public void setK ey(String key) { | |
170 | th is.key = k ey; | |
171 | } | |
172 | ||
173 | /** | |
174 | * @re turn the v alue | |
175 | */ | |
176 | public String ge tValue() { | |
177 | re turn value ; | |
178 | } | |
179 | ||
180 | /** | |
181 | * @pa ram value the value to set | |
182 | */ | |
183 | public void setV alue(Strin g value) { | |
184 | th is.value = value; | |
185 | } | |
186 | ||
187 | /** | |
188 | * @re turn the t imestamp | |
189 | */ | |
190 | public String ge tTimestamp () { | |
191 | re turn times tamp; | |
192 | } | |
193 | ||
194 | /** | |
195 | * @pa ram timest amp the ti mestamp to set | |
196 | */ | |
197 | public void setT imestamp(S tring time stamp) { | |
198 | th is.timesta mp = times tamp; | |
199 | } | |
200 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.