tag:blogger.com,1999:blog-82032869773837289892024-03-05T15:40:09.641+11:00A cup of tea!Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.comBlogger48125tag:blogger.com,1999:blog-8203286977383728989.post-54735128855009200112017-05-26T12:51:00.001+10:002017-05-26T12:55:21.423+10:00Binary Support for API Integrations with Amazon API Gateway - multipart/form-data, application/octet-stream<br />
<h1 class="P3" style="clear: both; color: #1f3d5c; font-family: HelveticaNeueLight, Helvetica, Helvetica, Arial, sans-serif; font-size: 24pt; font-weight: normal; margin: 0.1665in 0px 0.0835in;">
Binary Support for API Integrations with Amazon API Gateway</h1>
<div>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
H2 { margin-bottom: 0.08in }
H2.ctl { font-family: "Arial Unicode MS" }
-->
</style>
<br />
<h2 align="LEFT" class="western" style="break-after: avoid;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
H2 { margin-bottom: 0.08in }
H2.ctl { font-family: "Arial Unicode MS" }
-->
</style>
</h2>
<h2 align="LEFT" class="western" style="break-after: avoid;">
<span style="font-size: small;"><span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-weight: normal;">Create
an API and POST method</span></span></span><b> </b><span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-weight: normal;">to
support binary</span></span></span>,
eg: multipart/form-data,
application/octet-stream</span></h2>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNin7UvTgQCGEgZmw-VYULr_r_ACzMSZI4ZOFXnIL_gbG8c8JCnk5Y3eClu9pnNLLwf3GqEPcR5D3Ri9GxgmdriMQJg_I7U5aQNcEnpqL3AN5mLxlaWv3LNVavxFjlghbFCNXCP8k4Snok/s1600/01.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="241" data-original-width="973" height="79" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNin7UvTgQCGEgZmw-VYULr_r_ACzMSZI4ZOFXnIL_gbG8c8JCnk5Y3eClu9pnNLLwf3GqEPcR5D3Ri9GxgmdriMQJg_I7U5aQNcEnpqL3AN5mLxlaWv3LNVavxFjlghbFCNXCP8k4Snok/s320/01.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<br />
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">For </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>API
name</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">,
enter ‘Thumbnail’, add a description, and choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Create
API</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyVykf1Ba7vaNLkBDIlsV8bqvFMO3x4pZslPfxojomHMUmnMSha8jIyM7On7J9J8XOskiS_F36tCwOeQhlHwWZHHO-2SxBTVg6bjpbZ3uYgdKsVpC1Olh-JLZ66LJLA7L2dqXbuuQ7eNhr/s1600/02.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="401" data-original-width="1207" height="106" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyVykf1Ba7vaNLkBDIlsV8bqvFMO3x4pZslPfxojomHMUmnMSha8jIyM7On7J9J8XOskiS_F36tCwOeQhlHwWZHHO-2SxBTVg6bjpbZ3uYgdKsVpC1Olh-JLZ66LJLA7L2dqXbuuQ7eNhr/s320/02.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div align="LEFT" style="margin-bottom: 0in;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">In
the created API, choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Resources</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">, </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Actions</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">,
and </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Create
Method</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiabfcA9LhPQSrwsPhMv6wJfVF1I-FCMbeagIWTosBJKeitGPp8ce1W6kYhVDuHI7Z71uZerD2DA64xCv-KtHGrCVPrXRX18ijEPoQpgb9O4GC6gZ4kdiKpTYag9d1ss2SDyHuZQWpR0eVy/s1600/01.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="241" data-original-width="973" height="79" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiabfcA9LhPQSrwsPhMv6wJfVF1I-FCMbeagIWTosBJKeitGPp8ce1W6kYhVDuHI7Z71uZerD2DA64xCv-KtHGrCVPrXRX18ijEPoQpgb9O4GC6gZ4kdiKpTYag9d1ss2SDyHuZQWpR0eVy/s320/01.jpg" width="320" /></a></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">To
create the method, choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>POST</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">and
select the checkmark.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLMhfOieWiK_5m0s20F38llhjL_7EX283dUxco1JZ2zCA0NZqQXvvIhqE99HBM5GB-ZPOTgq7ciIEz3Z9mkUL7onxRNjwV2PyotTIgwWpvS5CvklmLUeDW_jvBI532NmSRweZdxoSUm5wd/s1600/04.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="345" data-original-width="427" height="161" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLMhfOieWiK_5m0s20F38llhjL_7EX283dUxco1JZ2zCA0NZqQXvvIhqE99HBM5GB-ZPOTgq7ciIEz3Z9mkUL7onxRNjwV2PyotTIgwWpvS5CvklmLUeDW_jvBI532NmSRweZdxoSUm5wd/s200/04.jpg" width="200" /></a></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">To
set up the POST method, for </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Integration
type</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"> ,
select </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>HTTP</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"> ,
enter ‘https://${stageVariables.environmentUrl}’ for </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Endpoint
URL</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.
Choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Save</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-iNknW1u60-apGDCrTZlKcZ-GnUFDnls_U5zgHEl893HirtAKMgL2iiTlyb5GuTft0ZtupQWAh23MpJb2Q_aK1Ds38HpVWCm3k-g7iJYsbZMzhSCdjpDkaxuDkZdEbwKim5VcwDX2QRu1/s1600/05.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="457" data-original-width="1230" height="118" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-iNknW1u60-apGDCrTZlKcZ-GnUFDnls_U5zgHEl893HirtAKMgL2iiTlyb5GuTft0ZtupQWAh23MpJb2Q_aK1Ds38HpVWCm3k-g7iJYsbZMzhSCdjpDkaxuDkZdEbwKim5VcwDX2QRu1/s320/05.jpg" width="320" /></a></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;"><br /></span></span></span></h2>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;"><br /></span></span></span></h2>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;"><br /></span></span></span></h2>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;"><br /></span></span></span></h2>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;"><br /></span></span></span></h2>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;"><br /></span></span></span></h2>
<h2 align="LEFT" class="western" style="font-style: normal; font-weight: normal; orphans: 2; widows: 2;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneuelight" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: small;">Set
up the integration</span></span></span></h2>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Now,
you are ready to set up the integration. In the main page,
open </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Integration
Request</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span><br />
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ijmHEwzZVRfE1dw1JyNR1or0B4A4a4gxd94wHgmMqPP4KWPhEVuEEFZj0t3AtkW-da1c7VK0nO8g8TE_ahYHsplwhtbIgRyBCtJUf0pUzrrUho1mnXPlGc2UOs-zg8D9nYrB9_76phVx/s1600/06.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="533" data-original-width="1218" height="140" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_ijmHEwzZVRfE1dw1JyNR1or0B4A4a4gxd94wHgmMqPP4KWPhEVuEEFZj0t3AtkW-da1c7VK0nO8g8TE_ahYHsplwhtbIgRyBCtJUf0pUzrrUho1mnXPlGc2UOs-zg8D9nYrB9_76phVx/s320/06.jpg" width="320" /></a></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">On
the </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Integration
Request</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">page,
check </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Use
HTTP Proxy integration</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.For </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Content
Handling</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"> ,
choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Passthrough</span></span></span></strong><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>.</b></span></span></span></strong></div>
<div align="LEFT" style="margin-bottom: 0in;">
<br /></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3BRupGyI2RRQLBzpDnEFjqppDsf-VfNSlp1QJTeC6aZ-6BjbDT-XB4bkxWvZS23DzFxPONyH0uy_4Bmqvpcaml4T0WCzstRO30IOElUhwsWVw5e8YCXAkzQGoCjifW-Sr3_rWQA0y-P8X/s1600/07.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="576" data-original-width="1223" height="150" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3BRupGyI2RRQLBzpDnEFjqppDsf-VfNSlp1QJTeC6aZ-6BjbDT-XB4bkxWvZS23DzFxPONyH0uy_4Bmqvpcaml4T0WCzstRO30IOElUhwsWVw5e8YCXAkzQGoCjifW-Sr3_rWQA0y-P8X/s320/07.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<br />
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Specify
which media types need to be handled as binary. Choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>[API
name]</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">, </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Binary
Support</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgizl8pVl0rB1ORV3d-cYwsww5HLviqiCRKmxVERx28N67qKEdoi8EPfL8sSMcTDxPIsxyzIR585vgibX1b0Z0cB7uJqh2Lhi6KgRfTAjG3clFNCz6s9diA9YC9yy9Bb2unszRwsr16U3dK/s1600/08.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="348" data-original-width="973" height="114" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgizl8pVl0rB1ORV3d-cYwsww5HLviqiCRKmxVERx28N67qKEdoi8EPfL8sSMcTDxPIsxyzIR585vgibX1b0Z0cB7uJqh2Lhi6KgRfTAjG3clFNCz6s9diA9YC9yy9Bb2unszRwsr16U3dK/s320/08.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<br />
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Edit</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">,
specify the media type (such as “</span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">multipart/form-data</span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">”)
to be handled as binary, and then choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Save</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj8qaBrSV9EwtDlkZDkeWO6pfrkq_NF1vUs41fKi-zU11RZF4aMf17FT73sOjT5bjC1C8ilQYDfqfCfO-dUoY-kjmuM-knRttNVjPcAlhIRn7wBzWeuLcd3FBBKBPx3Pij2yAlQGcmnC4b/s1600/09.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="256" data-original-width="1420" height="57" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj8qaBrSV9EwtDlkZDkeWO6pfrkq_NF1vUs41fKi-zU11RZF4aMf17FT73sOjT5bjC1C8ilQYDfqfCfO-dUoY-kjmuM-knRttNVjPcAlhIRn7wBzWeuLcd3FBBKBPx3Pij2yAlQGcmnC4b/s320/09.jpg" width="320" /></a></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<h3 class="western" style="font-style: normal; font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><br /></span></span></h3>
<h3 class="western" style="font-style: normal; font-weight: normal;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span>
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Edit</b></span></span></span></strong><span style="color: #333333;"> </span><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">,
specify the media type (such as “</span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">application/octet-stream</span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">”)
to be handled as binary, and then choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Save</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzO0a77F96BuIyRwbveLC54aHUjupyCOHoCqJofEXcjyuY-ErfMq0-hdtGb31lMyjUmZt0RK4G4ptHQW2IuaR4FF_fWoGuTSBtJ9MHaFIRlzNR_9SQiAqJyY0f5bLFcqUeRbeLPrG6sOKC/s1600/10.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="285" data-original-width="1415" height="64" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzO0a77F96BuIyRwbveLC54aHUjupyCOHoCqJofEXcjyuY-ErfMq0-hdtGb31lMyjUmZt0RK4G4ptHQW2IuaR4FF_fWoGuTSBtJ9MHaFIRlzNR_9SQiAqJyY0f5bLFcqUeRbeLPrG6sOKC/s320/10.jpg" width="320" /></a></div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><br /></span></span></span></div>
</h3>
<h3 class="western" style="font-style: normal; font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><br /></span></span></h3>
<h3 class="western" style="font-style: normal; font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><br /></span></span></h3>
<h3 class="western" style="font-style: normal; font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;">Deployment</span></span></h3>
<div align="LEFT" style="margin-bottom: 0in;">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
H3 { margin-bottom: 0.08in }
H3.ctl { font-family: "Arial Unicode MS" }
-->
</style>
</div>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Now
that the API is configured, you need to deploy it. On the
thumbnail </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Resources</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"> page,
choose </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Action</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"> , </span></span></span><strong><span style="color: #333333;"><span style="font-family: "helveticaneuebold" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;"><b>Deploy
API</b></span></span></span></strong><span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">.</span></span></span></div>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzcCEJ5HbkaVH704qAJP8zwhcSI5_UqBbiWx0p1LewKPDSx4Aqt7tM5KxHWT-Teb640n8Fw5gpBUfxKx8EkLdAONKPBPbt1xfWccbj2hHNN9qFkcXxlDBSmD-mWXWkGOW4yIE2YL3wvDhM/s1600/11.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="350" data-original-width="1020" height="109" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzcCEJ5HbkaVH704qAJP8zwhcSI5_UqBbiWx0p1LewKPDSx4Aqt7tM5KxHWT-Teb640n8Fw5gpBUfxKx8EkLdAONKPBPbt1xfWccbj2hHNN9qFkcXxlDBSmD-mWXWkGOW4yIE2YL3wvDhM/s320/11.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
H3 { margin-bottom: 0.08in }
H3.ctl { font-family: "Arial Unicode MS" }
-->
</style>
<br />
<h3 class="western" style="font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 13pt;"><br /></span></span></span></h3>
<h3 class="western" style="font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 13pt;"><br /></span></span></span></h3>
<h3 class="western" style="font-weight: normal;">
<span style="color: #1f3d5c;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 13pt;">Testing</span></span></span></h3>
<div align="LEFT" style="margin-bottom: 0in;">
<span style="color: #333333;"><span style="font-family: "helveticaneue" , "helvetica" , "helvetica" , "arial" , sans-serif;"><span style="font-size: 9pt;">Now,
you are ready to test the newly created API. </span></span></span></div>
</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFYqXZestvJhNSfOKuUHsiDs74J5LDZ88Vy-KHeCAMzt6VfdhmyNDqbbNz3jqYWGvXW52IdO7vAkRWp7td4Fczx1kZJVTp_roSxNmctWRmnP98ypwooCvp0hAiIfeSwZoORuWBX7use19C/s1600/12.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="256" data-original-width="1051" height="77" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFYqXZestvJhNSfOKuUHsiDs74J5LDZ88Vy-KHeCAMzt6VfdhmyNDqbbNz3jqYWGvXW52IdO7vAkRWp7td4Fczx1kZJVTp_roSxNmctWRmnP98ypwooCvp0hAiIfeSwZoORuWBX7use19C/s320/12.jpg" width="320" /></a></div>
<div>
<br /></div>
<div>
<br />
<br />
<br />
<br />
<br />
Reference:<br />
<a href="https://aws.amazon.com/blogs/compute/binary-support-for-api-integrations-with-amazon-api-gateway/">https://aws.amazon.com/blogs/compute/binary-support-for-api-integrations-with-amazon-api-gateway/</a><br />
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<a href="https://www.blogger.com/null" name="toc_6" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; margin-top: 0px;"><br /></a><a href="https://www.blogger.com/null" name="toc_6" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; margin-top: 0px;"><br /></a></div>
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-54967156867609648672016-02-16T16:27:00.000+11:002016-02-17T09:33:20.285+11:00Install Eclipse-Che on Ubuntu server<li><b>Install jdk1.8+ & set </b><i>JAVA_HOME</i> </li><br />
<li><b>Install Docker</b> </li><br />
<pre class="brush:shell">$ which curl
$ sudo apt-get update
$ sudo apt-get install curl
$ curl -sSL https://get.docker.com/ | sh
</pre>If you would like to use Docker as a non-root user, you should now consider<br />
adding your user to the "docker" group with something like:<br />
<pre class="brush:shell">$ sudo usermod -aG docker serveradmin
</pre><i>Remember that you will have to log out and back in for this to take effect!</i><br />
<li><b>Verify docker is installed correctly</b></li><br />
<pre class="brush:shell">$ docker run hello-world
or
$ sudo docker run hello-world
</pre>This command downloads a test image and runs it in a container.<br />
<li> <b>Download eclipse-che installation jar</b> </li><br />
The reason why I download the installation jar (<a href="https://install.codenvycorp.com/che/eclipse-che-latest.jar">JAR Universal Extractor</a>) instead of directly use docker image with following command is that way isn't work for me. It's always showing some error.<br />
<pre class="brush:shell">$ docker run -it -p 1104:8080 codenvy/che
</pre><li> <b>Install eclipse-che</b> </li><br />
<pre class="brush:shell">$ sudo mkdir /usr/local/eclipse-che-4.0.0-RC3
$ sudo chown -R serveradmin:serveradmin /usr/local/eclipse-che-4.0.0-RC3
$ java -jar eclipse-che-latest.jar
</pre><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2smkIJACW21CJPrWz-Mq2gXpkhM-jSDydsOLrafWweVyIcYISBCOsgTQySrqxogzeJn5ZPUi1zlEv2fJ5QGuTlZ6Th2LEDWdjGi9c52YreUmbw5qNnlpEsGc1W34uzMPrWN6i4I6dRj3b/s1600/eclipse-che-01.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2smkIJACW21CJPrWz-Mq2gXpkhM-jSDydsOLrafWweVyIcYISBCOsgTQySrqxogzeJn5ZPUi1zlEv2fJ5QGuTlZ6Th2LEDWdjGi9c52YreUmbw5qNnlpEsGc1W34uzMPrWN6i4I6dRj3b/s320/eclipse-che-01.png" /></a><br />
You should select "/usr/local/eclipse-che-4.0.0-RC3" as target installation dir.<br />
<li><b>Add execute permisson to TOMCAT script</b></li><br />
<pre class="brush:shell">$ cd /usr/local/eclipse-che-4.0.0-RC3/tomcat/bin
$ chmod +x *.sh
</pre><li><b>Set </b><i>CHE_HOME</i></li><br />
<pre class="brush:shell">$ vi ~/.bashrc
</pre>Add the line to it<br />
<pre class="brush:shell">export CHE_HOME=/usr/local/eclipse-che-4.0.0-RC3
</pre>Reload<br />
<pre class="brush:shell">$ source ~/.bashrc
</pre>Create link to /usr/bin<br />
<pre class="brush:shell">$ sudo ln -s /usr/local/eclipse-che-4.0.0-RC3/bin/che.sh /usr/bin/che
</pre>Now,you can start Eclipse-Che by<br />
<pre class="brush:shell">$ che start
</pre><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7bAds9oUYzgB_mQxoTZ7d6iZczGqN48tdxjC9XsfLe4xxRpz2SuZ1By4u5hew1Yby6kItCkNxEujVSOn00yYxiU_jRyfdVnSKrziP1IenTdjS70rezPypC28GYKbhWl4YAh-TeME78YEM/s1600/eclipse-che-02.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7bAds9oUYzgB_mQxoTZ7d6iZczGqN48tdxjC9XsfLe4xxRpz2SuZ1By4u5hew1Yby6kItCkNxEujVSOn00yYxiU_jRyfdVnSKrziP1IenTdjS70rezPypC28GYKbhWl4YAh-TeME78YEM/s320/eclipse-che-02.png" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhlmBXmQgXBQHC3oKlraK5nDgXsQWNlFoke_IMtaQ2PTlOy100fZkq_FF6Yh4JTgBZd8cdKsJZi2v6WOHi65Y-C7lDyDmuRwBwLQYruAdJl7ELBKdg4uf1fzsgoMqdLFCYOk85D_QRkDvI/s1600/eclipse-che-03.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhlmBXmQgXBQHC3oKlraK5nDgXsQWNlFoke_IMtaQ2PTlOy100fZkq_FF6Yh4JTgBZd8cdKsJZi2v6WOHi65Y-C7lDyDmuRwBwLQYruAdJl7ELBKdg4uf1fzsgoMqdLFCYOk85D_QRkDvI/s320/eclipse-che-03.png" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiIPzbD-127EGXnU1HbVFNQszOWosRNOBnGaPttGqfi1YGipRT6svkzTHQUwLJWOsS_ZHct5rzk2nC_iE3xSwWBbT-YtMDjKloJVBV1kKm7kV3sdQcO0n1MInhaeL-frFXAQZglYcmuQRo/s1600/eclipse-che-04.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhiIPzbD-127EGXnU1HbVFNQszOWosRNOBnGaPttGqfi1YGipRT6svkzTHQUwLJWOsS_ZHct5rzk2nC_iE3xSwWBbT-YtMDjKloJVBV1kKm7kV3sdQcO0n1MInhaeL-frFXAQZglYcmuQRo/s320/eclipse-che-04.png" /></a><br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGJGBsYLlp0oG4BbMRVG542DMFuT9YB7Af026Cu_JwuSK6u8VI5HOPPHjN2H_SBqTh4p_05sqnfafLRmGuHzJS3BfDWbO4qoNxqobNrUfRkDxl99FNcxTJTjwoBxcPcIr-lolEHniZBz2D/s1600/eclipse-che-05.png" imageanchor="1" ><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGJGBsYLlp0oG4BbMRVG542DMFuT9YB7Af026Cu_JwuSK6u8VI5HOPPHjN2H_SBqTh4p_05sqnfafLRmGuHzJS3BfDWbO4qoNxqobNrUfRkDxl99FNcxTJTjwoBxcPcIr-lolEHniZBz2D/s320/eclipse-che-05.png" /></a><br />
<br />
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com1tag:blogger.com,1999:blog-8203286977383728989.post-28059737147818590952016-02-12T16:25:00.001+11:002016-02-12T16:25:38.822+11:00<ul><li>Get current running class dir path</li>
<pre class="brush:java">String jarOrBuildClassDir = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
</pre><p>It will return 'build/classes/main' if you run it on IDE</p><pre class="brush:shell">/Users/demo/workspace/MyDemo/build/classes/main/
</pre><p>It will return the location of 'jar' file which the class archived if you run it in a jar file</p><pre class="brush:shell">/Users/demo/workspace/MyDemo/install/MyDemo/lib/MyDemo.jar
</pre><li>Get special resources file path that copy from 'src/main/java/resources/com/demo/test.xsl'</li>
<pre class="brush:java">URL xslFileURL = getClass().getResource("/com/demo/test.xsl")
</pre><p>It will return 'build/resources/main' if you run it on IDE</p><pre class="brush:shell">/Users/demo/workspace/MyDemo/build/resources/main/com/demo/test.xsl
</pre><p>It will return the location of 'jar' file which the class archived if you run it in a jar file</p><pre class="brush:shell">file:/Users/demo/workspace/MyDemo/install/MyDemo/lib/MyDemo.jar!/com/demo/test.xsl
</pre>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-60608790233377305642014-11-12T11:56:00.001+11:002014-11-12T12:07:28.172+11:00BTrace trace ClassLoader LeakingIf you want to trace the common ClassLoader leaking, you just probe where to invoke "ClassLoader#defineClass". The BTrace script as follow:<br />
<pre class="brush:java;highlight:[8,9]">import com.sun.btrace.AnyType;
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class Trace {
@OnMethod(clazz = "+java.lang.ClassLoader",
method = "defineClass")
public static void traceClassLoaderLeak(@ProbeClassName String clazz, @ProbeMethodName String method, @TargetInstance Object instance) {
println("\n==== java.lang.ClassLoader#defineClass ====");
jstack();
}
}
</pre>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-76713295229981823602014-05-08T09:55:00.002+10:002014-05-14T16:59:02.783+10:00 Java client read content from URL with SSL<ul><li>Java client</li>
<pre class="brush:java;highlight:[17,18,20, 21, 22, 23,24,25,26,31]">import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class PDFTester {
private static final int FILE_BUFFER_SIZE = 2048;
public static final String CONTENT_TYPE_PDF = "application/pdf";
public static byte[] readPDFFromURL(URL url) throws IOException {
System.setProperty("javax.net.ssl.trustStore", "C:/temp/myCA.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
httpsURLConnection.connect();
byte[] buffer = new byte[FILE_BUFFER_SIZE];
int lengthOfByteToBeWrite;
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
InputStream inputStream = httpsURLConnection.getInputStream()) {
while ((lengthOfByteToBeWrite = inputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, lengthOfByteToBeWrite);
}
byteArrayOutputStream.flush();
return byteArrayOutputStream.toByteArray();
} catch (IOException e) {
throw e;
}
}
public static void main(String[] args) throws IOException, URISyntaxException {
URL url = new URL("https://www.sample.com/pdf");
byte[] bytes = readPDFFromURL(url);
Path path = Paths.get("c:/temp/test.pdf");
Files.write(path, bytes);
}
}
</pre><li>SSL base knowledge: <a href="https://sites.google.com/site/ssljavaguide/Home"><br />
Implementing SSL / TLS using Java</a></li>
</ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-58355051203798033262014-04-06T11:26:00.003+10:002014-04-06T11:26:44.406+10:00Hide unnecessary Horizontal Scrollbar on jqgriduse this css to remove it.<br />
<br />
<pre class="brush:css"><style type="text/css">
.ui-jqgrid-bdiv {
overflow-x: hidden !important;
}
</style>
</pre>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-46071845784992204712014-03-06T17:04:00.004+11:002014-03-06T17:04:51.701+11:00Share value between main report, multi sub reports<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves>false</w:TrackMoves>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-AU</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<div class="MsoNormal">
<b style="mso-bidi-font-weight: normal;">How to shared value
between multi crystal report sub report?</b></div>
<div class="MsoListParagraph" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">1.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Create two sub reports</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGoBDkoQKNHM6psL5LM6vEOGbPyNlDIN_D2LHS-QWlIaHDePMBattcuxHmxwLmns3lLEfg8KQlCHUmS8FqtFA2nY4ttKp5B1z-3hIn8zmfnF2RTVymGGVAcs_DhXGuzG2AcH12zErgE7A9/s1600/Snap1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGoBDkoQKNHM6psL5LM6vEOGbPyNlDIN_D2LHS-QWlIaHDePMBattcuxHmxwLmns3lLEfg8KQlCHUmS8FqtFA2nY4ttKp5B1z-3hIn8zmfnF2RTVymGGVAcs_DhXGuzG2AcH12zErgE7A9/s1600/Snap1.jpg" height="182" width="320" /></a></div>
<div class="MsoNormal">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"><br /></span></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">2.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Define Formula Field (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">defineGlobalPersonName</span></b>)
<span style="mso-spacerun: yes;"> </span>in <b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">subReport1</span></b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZe__NJjkZBEKr1xMiQL_UwDufPvEpAwcRSBrZnpd36RudwJNrnR8ntMJHkP5CRMf9XHI5SKZtvFj1vWvwDPM3-XXq7zU0ZZPL17_0eTa_X1zMhwGi6dOP4bQQ5JF2GzgRiVxXha-E6REv/s1600/Snap2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZe__NJjkZBEKr1xMiQL_UwDufPvEpAwcRSBrZnpd36RudwJNrnR8ntMJHkP5CRMf9XHI5SKZtvFj1vWvwDPM3-XXq7zU0ZZPL17_0eTa_X1zMhwGi6dOP4bQQ5JF2GzgRiVxXha-E6REv/s1600/Snap2.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tnQdCSTEkU2S9E6GDPgi8v-z01BxOPw7lXcn1gb1Jnw_LA5mCvli2ei2X-IPeAgN5xME5zueRuJMK4f_I5oxPQ55dQRXMTkE5mgbKDJ1Vmnu-GXI3asu3O9BaLQ_bRFt_F005I6kobep/s1600/Snap4.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1tnQdCSTEkU2S9E6GDPgi8v-z01BxOPw7lXcn1gb1Jnw_LA5mCvli2ei2X-IPeAgN5xME5zueRuJMK4f_I5oxPQ55dQRXMTkE5mgbKDJ1Vmnu-GXI3asu3O9BaLQ_bRFt_F005I6kobep/s1600/Snap4.jpg" height="100" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"><br /></span></div>
<div class="MsoListParagraph" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">3.<span style="font: 7.0pt "Times New Roman";">
</span></span></span><b style="mso-bidi-font-weight: normal;"><span style="color: #c00000;">Tricky</span></b>: This formula field (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">defineGlobalPersonName</span></b>) must use in somewhere in sub report (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">subReport1</span></b>) where inject value into the shared variable.
Otherwise, other sub report where reference the shared value (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">personName</span></b>) <span style="mso-spacerun: yes;"> </span>can’t get
the value when printing records.</div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsWXvQtUTXAtXA2Nsb5B58JGeGw-oeg4nufaxZIfjppGDDdUrD9ZLF3aZv__yDeV7mEVYHV3b4Vo7B1HQcbhAsNW-icRhulhpCNw2xPSmB3U57WMBZq0teroChqqr2lIAV5Zq4ZpaWKYzi/s1600/Snap5.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsWXvQtUTXAtXA2Nsb5B58JGeGw-oeg4nufaxZIfjppGDDdUrD9ZLF3aZv__yDeV7mEVYHV3b4Vo7B1HQcbhAsNW-icRhulhpCNw2xPSmB3U57WMBZq0teroChqqr2lIAV5Zq4ZpaWKYzi/s1600/Snap5.jpg" height="131" width="320" /></a></div>
<div class="MsoNormal">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"><br /></span></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">4.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Used shared variable in other sub report (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">subReport2</span></b>)</div>
<div class="MsoListParagraphCxSpLast" style="margin-left: 22.5pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">(a)<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Declare another “formula field (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">retreiveBackPersonName</span></b>)” to retrieve value from above shared
variable (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">personName</span></b>)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqsD9TVJQw3Knh8DmIpxptKnIM3HXol9Z5AYVji-MO3KrGEGrQ7Oq-b9p_JDR3ATQCVCUuWIANKbTF-fdOX8Ow6Q0Vx80eOvHMw6NPoqCF0peGUZJwleCqjvlu3dXZz4moNGI6N9M_Xsu6/s1600/Snap6.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqsD9TVJQw3Knh8DmIpxptKnIM3HXol9Z5AYVji-MO3KrGEGrQ7Oq-b9p_JDR3ATQCVCUuWIANKbTF-fdOX8Ow6Q0Vx80eOvHMw6NPoqCF0peGUZJwleCqjvlu3dXZz4moNGI6N9M_Xsu6/s1600/Snap6.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyKeTUr8TO4ja_q1wEQ5zKYc_DPoWaEO4UaJW2jjegA6y-k8FgKstcZB5ol_E1bmaVgZYBZ_ZG9K54aWLuGXQ1DYaIQ4LywFSjlJLEZ8DNRsyp4RAcT4JkmnamADhd2Dq921WNJlchpk5j/s1600/Snap7.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyKeTUr8TO4ja_q1wEQ5zKYc_DPoWaEO4UaJW2jjegA6y-k8FgKstcZB5ol_E1bmaVgZYBZ_ZG9K54aWLuGXQ1DYaIQ4LywFSjlJLEZ8DNRsyp4RAcT4JkmnamADhd2Dq921WNJlchpk5j/s1600/Snap7.jpg" /></a></div>
<div class="MsoNormal">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"><br /></span></div>
<div class="MsoNormal">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"><br /></span></div>
<div class="MsoListParagraph" style="margin-left: 22.5pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">(b)<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Use this formula field (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">retreiveBackPersonName</span></b>)
<span style="mso-spacerun: yes;"> </span>in your sub report (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">subReport2</span></b>)</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8j4inkAfkVJ9daUerZw3eznjA99W2Vh4jj1XwdyJ9E5BsspohusRFB180CsQyI4AiNJx2SWftylftkKvPnSZAuUoSN5VlccNPDS0nCyZMvGYzm7W9Ec8Qav2Ahv7Kq7ks0rpXvMOe__sr/s1600/Snap17.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8j4inkAfkVJ9daUerZw3eznjA99W2Vh4jj1XwdyJ9E5BsspohusRFB180CsQyI4AiNJx2SWftylftkKvPnSZAuUoSN5VlccNPDS0nCyZMvGYzm7W9Ec8Qav2Ahv7Kq7ks0rpXvMOe__sr/s1600/Snap17.jpg" height="235" width="320" /></a></div>
<div class="MsoListParagraphCxSpFirst" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">5.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>Preview final report</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglxVjRyRQ8PVWmoQWwD97jVQwboZ02-vlDBhxS8_yA56GX1D27BGqBIsCfST5_0cyYZ0B8ypKINU6752_DUdZ8IhZC_p9pYeLekgQwDSDK0iv3djDc9CkkcJf2PUZ47UgPz9awPxoNei7c/s1600/Snap17.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><br /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbkgAip0ryzo9LyyYDhjylgXIeK7k7bg-N-SB5hLdRuCLkDeIIc1PgTbE1w2GFgduqUZPBNlSWHBNTfIauru5sjq8Ur7dtJj7mYvoKVzpjc9lMa7_GywM8U2ZkwvLsmmSAydAUeelrhlc3/s1600/Snap11.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbkgAip0ryzo9LyyYDhjylgXIeK7k7bg-N-SB5hLdRuCLkDeIIc1PgTbE1w2GFgduqUZPBNlSWHBNTfIauru5sjq8Ur7dtJj7mYvoKVzpjc9lMa7_GywM8U2ZkwvLsmmSAydAUeelrhlc3/s1600/Snap11.jpg" height="100" width="320" /></a></div>
<div class="MsoListParagraphCxSpMiddle">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="mso-list: l1 level1 lfo1; text-indent: -18.0pt;">
<span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"><span style="mso-list: Ignore;">6.<span style="font: 7.0pt "Times New Roman";">
</span></span></span>If you want shared value to <b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">main report</span></b>
as well. <span style="mso-spacerun: yes;"> </span>You just only declare one “formula
field (<b style="mso-bidi-font-weight: normal;"><span style="color: #1f497d; mso-themecolor: text2;">sharedValue</span></b>)” <span style="mso-spacerun: yes;"> </span>in main report. Then you can use it</div>
<div class="MsoListParagraphCxSpMiddle">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC0Ms1rNXDMZLXjKveZkN3cmbxvg6IFvTPiwAUTLlmZzQ0MBlVSgAHgaT3U2ecCmSMLUpO-mVxqAY4h9iQ-XpUwMpEXJJu4H9XuH0PVThibAs_VrBZZyMvauYZmkkw_T64sYAU68ccLXaq/s1600/Snap18.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjC0Ms1rNXDMZLXjKveZkN3cmbxvg6IFvTPiwAUTLlmZzQ0MBlVSgAHgaT3U2ecCmSMLUpO-mVxqAY4h9iQ-XpUwMpEXJJu4H9XuH0PVThibAs_VrBZZyMvauYZmkkw_T64sYAU68ccLXaq/s1600/Snap18.jpg" height="253" width="320" /></a></div>
<div class="MsoListParagraphCxSpLast">
<span style="mso-fareast-language: EN-AU; mso-no-proof: yes;"></span>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVeuYXphMQTdZOeWPtX4g2pExWhMUHUThLrsQZ7S4Y4h7UQliFJSwFLZO9-oWVdII-BSkZ4e_LXvH8xpV6VaxNhpxwebw-83yHMhTf7Jojgbmj4UJiqh5GyfgoWbrhasIw8jquLxNACcS6/s1600/Snap14.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVeuYXphMQTdZOeWPtX4g2pExWhMUHUThLrsQZ7S4Y4h7UQliFJSwFLZO9-oWVdII-BSkZ4e_LXvH8xpV6VaxNhpxwebw-83yHMhTf7Jojgbmj4UJiqh5GyfgoWbrhasIw8jquLxNACcS6/s1600/Snap14.jpg" height="157" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbP5lhFH6jHtBtbDN_MaugqVI8K3ofgL_Jcebnkd3rliWm8F_2eGDBKA2XoCP-3Ad327xTCo8YozWiRwJ8j0UYvOJWtZbaL5M9AdD53fkTTZ6eeQGjSOZoMzhpsgk4sPs25YBSPNvMogKW/s1600/Snap14.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqxEVWC_gCglrPfzr0xWYrw1Ff2ERXE9jVx8GaJS5-PBKXf0y46KjHvc7a8u5-NBWXXhTFBden1Ja56sZSJSX4Wp5eJBUB61NG3_NdHtil8d4J8VFTkh_uNCK7qQGuPinu-d0wXlCzdkDH/s1600/Snap15.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqxEVWC_gCglrPfzr0xWYrw1Ff2ERXE9jVx8GaJS5-PBKXf0y46KjHvc7a8u5-NBWXXhTFBden1Ja56sZSJSX4Wp5eJBUB61NG3_NdHtil8d4J8VFTkh_uNCK7qQGuPinu-d0wXlCzdkDH/s1600/Snap15.jpg" height="191" width="320" /></a></div>
<br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves>false</w:TrackMoves>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-AU</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-fareast-language:EN-US;}
</style>
<![endif]-->
<br />
<br />Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-1886658001931679732014-02-06T16:29:00.002+11:002014-02-06T16:30:19.018+11:00use external icons in Bootstrap<ul><li>1. Define you own css </li>
<pre class="brush:css">.icon-pdf-file {
background-image: url(../img/document-pdf.png);
background-position: center center;
height: 16px;
width: 16px;
}
</pre><li>2. Use it in you page with &lgt;i></li>
<pre class="brush:html"><i class='icon-pdf-file'></i>
</pre></ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-29750109009013423382013-09-11T18:43:00.001+10:002013-09-12T09:26:30.429+10:00create own support Ctrl+v, Ctrl+c, Ctrl+X and 'Numeric only' jquery plugin <pre class="brush:javascript">(function ($) {
$.fn.forceNumeric = function () {
return this.each(function () {
// bind handler of 'paste' event
$(this).bind(
{
paste: function (e) {
var content = e.originalEvent.clipboardData.getData('text/plain');
var regExp = /^\d+$/;
if (!regExp.test($.trim(content))) {
e.preventDefault();
}
}
});
$(this).keydown(function (e) {
var key = e.which || e.keyCode;
if (!e.shiftKey && !e.altKey) {
if ((key >= 48 && key <= 57 ||
// Numeric keypad
key >= 96 && key <= 105 ||
// comma, period and minus, . on keypad
key == 190 || key == 188 || key == 109 || key == 110 ||
// Backspace and Tab and Enter
key == 8 || key == 9 || key == 13 ||
// Home and End
key == 35 || key == 36 ||
// left and right arrows
key == 37 || key == 39 ||
// Del and Ins
key == 46 || key == 45) && !e.ctrlKey) {
return true;
}
// Allow: Ctrl+C, Ctrl+V, Ctrl+X
if ((e.keyCode == 67 || e.keyCode == 86 || e.keyCode == 88) &&
(e.ctrlKey === true || e.metaKey === true)) {
return true;
}
}
return e.preventDefault();
});
});
};
}(jQuery));
</pre>
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-9519672772392453592013-08-26T14:04:00.002+10:002013-08-26T14:06:43.943+10:00tips of jqgrid<ul><li>Define own date formatter</li>
<pre class="brush:javascript">$.extend($.fn.fmatter , {
dateFormatter : function(cellvalue, options, rowObject) {
if (cellvalue) {
// parseExact just returns 'null' if the date you are trying to
// format is not in the exact format specified
var parsedDate = Date.parseExact(cellvalue, "yyyy-MM-ddTHH:mm:ss");
if(parsedDate == null )
parsedDate = new Date(cellvalue);
// if parsed date is null, just used the passed cell value; otherwise,
// transform the date to desired format
var formattedDate = parsedDate ? parsedDate.toString("yyyy-MM-dd HH:mm:ss") : cellvalue;
return formattedDate;
} else {
return '';
}
}
});
</pre><li>Add 'link' column to table</li>
<pre class="brush:javascript">$.extend($.fn.fmatter , {
dynamicLink : function (cellValue, options, rowObject) {
return "<a href='#' onclick=\"viewReport('" + rowObject.custodyRefNumber + "', '" + rowObject.docketNumber + "');return false;\">view report</a>";
}
});
</pre><li>dynamic setting width/height to match parent component</li>
<pre class="brush:javascript;hightlight:[2,5,6]">function resizeJqgridWidth() {
if (grid = $('.ui-jqgrid-btable:visible')) {
grid.each(function(index) {
gridId = $(this).attr('id');
gridParentWidth = $('#gbox_' + gridId).parent().width() - 5;
$('#' + gridId).setGridWidth(gridParentWidth);
});
}
}
</pre><li>convert string to javascript json object</li>
<pre class="brush:javascript">function convertDotNotationStringToNestJsonObject(data) {
var obj = {}, t, parts, part;
for (var k in data) {
t = obj;
parts = k.split('.');
var key = parts.pop();
while (parts.length) {
part = parts.shift();
t = t[part] = t[part] || {};
}
t[key] = data[k]
}
return obj;
}
</pre></ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-14433567275290243762013-04-11T21:23:00.000+10:002013-04-17T16:47:39.345+10:00Practice of customize JAXB Schema-2-JAVA use xjc<b>JAXB Marshalling with Custom Namespace Prefixes</b><br />
<ul><li>You have an XML schema with multiple XML namespaces.</li>
<li>You generate a JAXB model with xjc.</li>
<li>You build a JAXB document model and use the JAXB Marshaller to create XML from the model.</li>
<li>You want to override the default namespace prefixes <b>ns1, ns2</b>, ... created by the Marshaller.</li>
</ul><b>XJC bind Schema-2-java</b><br />
<ul><li>You want use customization java package</li>
<li>You want use more meanful java property name to replace xml element/attribute, default use element/attribute name</li>
<li>You want to override the default XmlAdapter <b>Adapter1.java, Adapter2.java</b>... created by xjc.</li>
</ul><br />
<b>Target xsd file</b><br />
<pre class="brush:xml;highlight:[5,34,35]"><?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ns1="http://seanshou.blogspot.com/XMLSchema"
targetNamespace="http://seanshou.blogspot.com/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="comment" type="xs:string"/>
<xs:element name="employee" type="ns1:EmployeeType">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="USAddress">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="state" type="xs:string"/>
<xs:element name="zip" type="xs:string"/>
</xs:sequence>
<xs:attribute name="country" type="xs:NMTOKEN" use="required" fixed="US"/>
</xs:complexType>
<xs:complexType name="EmployeeType">
<xs:sequence>
<xs:element name="address" type="ns1:USAddress"/>
<xs:element name="paySlip" type="ns1:payment"/>
<xs:element ref="ns1:comment"/>
</xs:sequence>
<xs:attribute name="userId" type="xs:int" use="required"/>
</xs:complexType>
<xs:complexType name="payment">
<xs:sequence>
<xs:element name="baseSalary" type="xs:int"/>
<xs:element name="supernation" type="xs:integer" nillable="true" minOccurs="0"/>
<xs:element name="bonus" type="xs:integer" nillable="true" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</pre><ul><li>line[5]: The generated classes by xjc will qualified by namespace: <b><i>http://seanshou.blogspot.com/XMLSchema</i></b></li>
<li>line[33,34]: The customization to use use-defined adapter <b>BigIntegerXmlAdapter</b> for <b>xs:integer</b></li>
</ul><b>Customized external bindings file</b><br />
<pre class="brush:xml;highlight:[17,18,21,24,,26,27,28,30,31,32]"><?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd
http://jaxb2-commons.dev.java.net/namespace-prefix http://java.net/projects/jaxb2-commons/sources/svn/content/namespace-prefix/trunk/src/main/resources/prefix-namespace-schema.xsd"
jxb:extensionBindingPrefixes="xjc"
version="2.1">
<jxb:bindings schemaLocation="Employee-Definiation.xsd" node="/xs:schema">
<jxb:globalBindings fixedAttributeAsConstantProperty="false" collectionType="java.util.ArrayList"
typesafeEnumBase="xs:NCName" choiceContentProperty="false"
typesafeEnumMemberName="generateError"
enableFailFastCheck="false" generateIsSetMethod="false" underscoreBinding="asCharInWord">
<xjc:javaType name="java.math.BigInteger" xmlType="xs:integer"
adapter="com.blogspot.seanshou.jaxb.adapter.BigIntegerXmlAdapter"/>
</jxb:globalBindings>
<jxb:schemaBindings>
<jxb:package name="com.blogspot.seanshou.jaxb.xml"/>
</jxb:schemaBindings>
<jxb:bindings>
<namespace:prefix name="NS1"/>
</jxb:bindings>
<jxb:bindings node="//xs:element[@name='employee']">
<jxb:class name="EmployeePojo"/>
</jxb:bindings>
<jxb:bindings node="//xs:complexType[@name='EmployeeType']">
<jxb:bindings node=".//xs:element[@name='address']">
<jxb:property name="mailAddress"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
</pre><ul><li>line[17,18]: customize to special java type use pre-defined 'XmlAdater'</li>
<li>line[21]: customize to java package name</li>
Note that this customization is <b>per namespace</b>. That is, even if your schema is split into multiple schema documents, you cannot put them into different packages if they are all in the same namespace
<li>line[24]: customize namespace prefix when XJC convert Schema-2-Java, the prefix <b>'NS1'</b> will be append package-info.java</li>
use <b>JAXB Namespace-prefix plugin</b>
<li>line[26,28]: binding root xml elemment <b>employee</b> to java class <b>EmployeeType</b></li>
<li>line[30,32]: binding child xml elemment <b>address</b> of <b>employee</b> to java property <b>mailAddress</b> of class <b>EmployeeType</b></li>
</ul><br />
<b>pom.xml</b><br />
<pre class="brush:xml"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blogspot.seanshou.jaxb</groupId>
<artifactId>JAXB-Schema-to-Java-showcase</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<!-- jaxb plugin -->
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<!--
<generatePackage>com.blogspot.seanshou.jaxb.xml</generatePackage>
<catalog>src/main/resources/catalog.xml</catalog>
-->
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>bindings.xml</include>
</bindingIncludes>
<args>
<arg>-extension</arg>
<arg>-Xnamespace-prefix</arg>
</args>
<removeOldOutput>true</removeOldOutput>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</pre><b>Pre-defined <i>BigIntegerXmlApater.java</i></b><br />
<pre class="brush:java">package com.blogspot.seanshou.jaxb.adapter;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.math.BigInteger;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.apache.commons.lang3.StringUtils.isBlank;
public class BigIntegerXmlAdapter extends XmlAdapter<String, BigInteger> {
@Override
public BigInteger unmarshal(String value) throws Exception {
if (isBlank(value)) {
return BigInteger.ZERO;
}
return DatatypeConverter.parseInteger(value);
}
@Override
public String marshal(BigInteger value) throws Exception {
if (value == null) {
return EMPTY;
}
return DatatypeConverter.printInteger(value);
}
}
</pre><br />
<b>Generated classes by xjc </b><br />
<ul><li>EmployeePojo.java</li>
<pre class="brush:java;highlight:[6]">package com.blogspot.seanshou.jaxb.xml;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
public class EmployeePojo extends JAXBElement<EmployeeType>
{
protected final static QName NAME = new QName("http://seanshou.blogspot.com/XMLSchema", "employee");
public EmployeePojo(EmployeeType value) {
super(NAME, ((Class) EmployeeType.class), null, value);
}
public EmployeePojo() {
super(NAME, ((Class) EmployeeType.class), null, null);
}
}
</pre><ul><li>line[6]: Customized by line[26-28] in <b>bindings.xml</b></li>
</ul><li>EmployeeType.java</li>
<pre class="brush:java;highlight:[18,19]">package com.blogspot.seanshou.jaxb.xml;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EmployeeType", propOrder = {
"mailAddress",
"paySlip",
"comment"
})
public class EmployeeType {
@XmlElement(name = "address", required = true)
protected USAddress mailAddress;
@XmlElement(required = true)
protected Payment paySlip;
@XmlElement(required = true)
protected String comment;
@XmlAttribute(name = "userId", required = true)
protected int userId;
public USAddress getMailAddress() {
return mailAddress;
}
public void setMailAddress(USAddress value) {
this.mailAddress = value;
}
public Payment getPaySlip() {
return paySlip;
}
public void setPaySlip(Payment value) {
this.paySlip = value;
}
public String getComment() {
return comment;
}
public void setComment(String value) {
this.comment = value;
}
public int getUserId() {
return userId;
}
public void setUserId(int value) {
this.userId = value;
}
}
</pre><ul><li>line[18,19]: Customized by line[30-32] in <b>bindings.xml</b></li>
</ul><li>Payment.java</li>
<pre class="brush:java">package com.blogspot.seanshou.jaxb.xml;
import java.math.BigInteger;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "payment", propOrder = {
"baseSalary",
"supernation",
"bonus"
})
public class Payment {
protected int baseSalary;
@XmlElementRef(name = "supernation", namespace = "http://seanshou.blogspot.com/XMLSchema", type = JAXBElement.class)
protected JAXBElement<BigInteger> supernation;
@XmlElementRef(name = "bonus", namespace = "http://seanshou.blogspot.com/XMLSchema", type = JAXBElement.class)
protected JAXBElement<BigInteger> bonus;
public int getBaseSalary() {
return baseSalary;
}
public void setBaseSalary(int value) {
this.baseSalary = value;
}
public JAXBElement<BigInteger> getSupernation() {
return supernation;
}
public void setSupernation(JAXBElement<BigInteger> value) {
this.supernation = value;
}
public JAXBElement<BigInteger> getBonus() {
return bonus;
}
public void setBonus(JAXBElement<BigInteger> value) {
this.bonus = value;
}
}
</pre><li>USAddress.java</li>
<pre class="brush:java">package com.blogspot.seanshou.jaxb.xml;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "USAddress", propOrder = {
"name",
"street",
"city",
"state",
"zip"
})
public class USAddress {
@XmlElement(required = true)
protected String name;
@XmlElement(required = true)
protected String street;
@XmlElement(required = true)
protected String city;
@XmlElement(required = true)
protected String state;
@XmlElement(required = true)
protected String zip;
@XmlAttribute(name = "country", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "NMTOKEN")
protected String country;
public String getName() {
return name;
}
public void setName(String value) {
this.name = value;
}
public String getStreet() {
return street;
}
public void setStreet(String value) {
this.street = value;
}
public String getCity() {
return city;
}
public void setCity(String value) {
this.city = value;
}
public String getState() {
return state;
}
public void setState(String value) {
this.state = value;
}
public String getZip() {
return zip;
}
public void setZip(String value) {
this.zip = value;
}
public String getCountry() {
if (country == null) {
return "US";
} else {
return country;
}
}
public void setCountry(String value) {
this.country = value;
}
}
</pre><li>ObjectFactory.java</li>
<pre class="brush:java;highlight:[44,50]">package com.blogspot.seanshou.jaxb.xml;
import java.math.BigInteger;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.namespace.QName;
import com.blogspot.seanshou.jaxb.adapter.BigIntegerXmlAdapter;
@XmlRegistry
public class ObjectFactory {
private final static QName _Comment_QNAME = new QName("http://seanshou.blogspot.com/XMLSchema", "comment");
private final static QName _PaymentSupernation_QNAME = new QName("http://seanshou.blogspot.com/XMLSchema", "supernation");
private final static QName _PaymentBonus_QNAME = new QName("http://seanshou.blogspot.com/XMLSchema", "bonus");
public ObjectFactory() {
}
public EmployeeType createEmployeeType() {
return new EmployeeType();
}
public Payment createPayment() {
return new Payment();
}
public USAddress createUSAddress() {
return new USAddress();
}
@XmlElementDecl(namespace = "http://seanshou.blogspot.com/XMLSchema", name = "comment")
public JAXBElement<String> createComment(String value) {
return new JAXBElement<String>(_Comment_QNAME, String.class, null, value);
}
@XmlElementDecl(namespace = "http://seanshou.blogspot.com/XMLSchema", name = "employee")
public EmployeePojo createEmployeePojo(EmployeeType value) {
return new EmployeePojo(value);
}
@XmlElementDecl(namespace = "http://seanshou.blogspot.com/XMLSchema", name = "supernation", scope = Payment.class)
@XmlJavaTypeAdapter(BigIntegerXmlAdapter.class)
public JAXBElement<BigInteger> createPaymentSupernation(BigInteger value) {
return new JAXBElement<BigInteger>(_PaymentSupernation_QNAME, BigInteger.class, Payment.class, value);
}
@XmlElementDecl(namespace = "http://seanshou.blogspot.com/XMLSchema", name = "bonus", scope = Payment.class)
@XmlJavaTypeAdapter(BigIntegerXmlAdapter.class)
public JAXBElement<BigInteger> createPaymentBonus(BigInteger value) {
return new JAXBElement<BigInteger>(_PaymentBonus_QNAME, BigInteger.class, Payment.class, value);
}
}
</pre><ul><li>line[44,50]: Customized by line[17-18] in <b>bindings.xml</b></li>
</ul><li>package-info.java</li>
<pre class="brush:java;highlight:[2]">@javax.xml.bind.annotation.XmlSchema(namespace = "http://seanshou.blogspot.com/XMLSchema", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://seanshou.blogspot.com/XMLSchema", prefix = "NS1")
})
package com.blogspot.seanshou.jaxb.xml;
</pre><ul><li>line[2]: Customized by line[24] in <b>bindings.xml</b></li>
</ul></ul><b>Reference</b><br />
<ul><li>JAXB plugins: <a href="http://java.net/projects/jaxb2-commons/pages/Home">http://java.net/projects/jaxb2-commons/pages/Home</a></li>
<li>JAXB Vendor Customizations <a href="http://jaxb.java.net/nonav/2.2.1/docs/vendorCustomizations.html#javaType">http://jaxb.java.net/nonav/2.2.1/docs/vendorCustomizations.html#javaType</a></li>
</ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-53865622769576863612013-03-14T13:28:00.001+11:002013-04-11T16:24:20.212+10:00How to make JAXB marshal/unmarshal show errorsJAXB by default silently ignores errors. Try adding this code to throw an exception if something goes wrong.<br />
<pre class="brush:java">unmarshaller.setEventHandler(
new ValidationEventHandler() {
public boolean handleEvent(ValidationEvent event ) {
ValidationEventLocator locator = event.getLocator();
String errorMessage = "Line:Column[" + locator.getLineNumber() + ":" + locator.getColumnNumber() + "]:" + event.getMessage();
throw new RuntimeException(errorMessage, event.getLinkedException());
}
});
</pre>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-65159248579747900872012-10-03T23:12:00.000+10:002012-10-03T23:21:53.951+10:00Java Swing PDF ViewerI'll use pdf-renderer to create an pdf viewer in java swing application.<br />
<ul><li> Dependencies </li>
<pre class="brush:xml"><dependency>
<groupid>org.swinglabs</groupId>
<artifactid>pdf-renderer</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupid>com.google.guava</groupId>
<artifactid>guava</artifactId>
<version>13.0.1</version>
</dependency>
</pre><li>PDF Viewer</li>
<pre class="brush:java;highlight:[58,59]">import com.google.common.base.CharMatcher;
import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPage;
import com.sun.pdfview.PagePanel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import static com.google.common.base.Strings.isNullOrEmpty;
public class PdfViewer extends JPanel {
private static enum Navigation {GO_FIRST_PAGE, FORWARD, BACKWARD, GO_LAST_PAGE, GO_N_PAGE}
private static final CharMatcher POSITIVE_DIGITAL = CharMatcher.anyOf("0123456789");
private static final String GO_PAGE_TEMPLATE = "%s of %s";
private static final int FIRST_PAGE = 1;
private int currentPage = FIRST_PAGE;
private JButton btnFirstPage;
private JButton btnPreviousPage;
private JTextField txtGoPage;
private JButton btnNextPage;
private JButton btnLastPage;
private PagePanel pagePanel;
private PDFFile pdfFile;
public PdfViewer() {
initial();
}
private void initial() {
setLayout(new BorderLayout(0, 0));
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
add(topPanel, BorderLayout.NORTH);
btnFirstPage = createButton("|<<");
topPanel.add(btnFirstPage);
btnPreviousPage = createButton("<<");
topPanel.add(btnPreviousPage);
txtGoPage = new JTextField(10);
txtGoPage.setHorizontalAlignment(JTextField.CENTER);
topPanel.add(txtGoPage);
btnNextPage = createButton(">>");
topPanel.add(btnNextPage);
btnLastPage = createButton(">>|");
topPanel.add(btnLastPage);
JScrollPane scrollPane = new JScrollPane();
add(scrollPane, BorderLayout.CENTER);
JPanel viewPanel = new JPanel(new BorderLayout(0, 0));
scrollPane.setViewportView(viewPanel);
pagePanel = new PagePanel();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
pagePanel.setPreferredSize(screenSize);
viewPanel.add(pagePanel, BorderLayout.CENTER);
disableAllNavigationButton();
btnFirstPage.addActionListener(new PageNavigationListener(Navigation.GO_FIRST_PAGE));
btnPreviousPage.addActionListener(new PageNavigationListener(Navigation.BACKWARD));
btnNextPage.addActionListener(new PageNavigationListener(Navigation.FORWARD));
btnLastPage.addActionListener(new PageNavigationListener(Navigation.GO_LAST_PAGE));
txtGoPage.addActionListener(new PageNavigationListener(Navigation.GO_N_PAGE));
}
private JButton createButton(String text) {
JButton button = new JButton(text);
button.setPreferredSize(new Dimension(55, 20));
return button;
}
private void disableAllNavigationButton() {
btnFirstPage.setEnabled(false);
btnPreviousPage.setEnabled(false);
btnNextPage.setEnabled(false);
btnLastPage.setEnabled(false);
}
private boolean isMoreThanOnePage(PDFFile pdfFile) {
return pdfFile.getNumPages() > 1;
}
private class PageNavigationListener implements ActionListener {
private final Navigation navigation;
private PageNavigationListener(Navigation navigation) {
this.navigation = navigation;
}
public void actionPerformed(ActionEvent e) {
if (pdfFile == null) {
return;
}
int numPages = pdfFile.getNumPages();
if (numPages <= 1) {
disableAllNavigationButton();
} else {
if (navigation == Navigation.FORWARD && hasNextPage(numPages)) {
goPage(currentPage, numPages);
}
if (navigation == Navigation.GO_LAST_PAGE) {
goPage(numPages, numPages);
}
if (navigation == Navigation.BACKWARD && hasPreviousPage()) {
goPage(currentPage, numPages);
}
if (navigation == Navigation.GO_FIRST_PAGE) {
goPage(FIRST_PAGE, numPages);
}
if (navigation == Navigation.GO_N_PAGE) {
String text = txtGoPage.getText();
boolean isValid = false;
if (!isNullOrEmpty(text)) {
boolean isNumber = POSITIVE_DIGITAL.matchesAllOf(text);
if (isNumber) {
int pageNumber = Integer.valueOf(text);
if (pageNumber >= 1 && pageNumber <= numPages) {
goPage(Integer.valueOf(text), numPages);
isValid = true;
}
}
}
if (!isValid) {
JOptionPane.showMessageDialog(PdfViewer.this, format("Invalid page number '%s' in this document", text));
txtGoPage.setText(format(GO_PAGE_TEMPLATE, currentPage, numPages));
}
}
}
}
private void goPage(int pageNumber, int numPages) {
currentPage = pageNumber;
PDFPage page = pdfFile.getPage(currentPage);
pagePanel.showPage(page);
boolean notFirstPage = isNotFirstPage();
btnFirstPage.setEnabled(notFirstPage);
btnPreviousPage.setEnabled(notFirstPage);
txtGoPage.setText(format(GO_PAGE_TEMPLATE, currentPage, numPages));
boolean notLastPage = isNotLastPage(numPages);
btnNextPage.setEnabled(notLastPage);
btnLastPage.setEnabled(notLastPage);
}
private boolean hasNextPage(int numPages) {
return (++currentPage) <= numPages;
}
private boolean hasPreviousPage() {
return (--currentPage) >= FIRST_PAGE;
}
private boolean isNotLastPage(int numPages) {
return currentPage != numPages;
}
private boolean isNotFirstPage() {
return currentPage != FIRST_PAGE;
}
}
public PagePanel getPagePanel() {
return pagePanel;
}
public void setPDFFile(PDFFile pdfFile) {
this.pdfFile = pdfFile;
currentPage = FIRST_PAGE;
disableAllNavigationButton();
txtGoPage.setText(format(GO_PAGE_TEMPLATE, FIRST_PAGE, pdfFile.getNumPages()));
boolean moreThanOnePage = isMoreThanOnePage(pdfFile);
btnNextPage.setEnabled(moreThanOnePage);
btnLastPage.setEnabled(moreThanOnePage);
}
}
</pre>Line:<i>58-59</i> automatically match the current screen resolution. The default is <i>800*600</i>. <p>The utility method "format" is here: <a href="http://seanshou.blogspot.com.au/2012/09/java-better-performance-string-formatter.html">format</a>
<li>Tester</li>
<pre class="brush:java">public static void main(String[] args) {
try {
long heapSize = Runtime.getRuntime().totalMemory();
System.out.println("Heap Size = " + heapSize);
JFrame frame = new JFrame("PDF Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//load a pdf from a byte buffer
File file = new File("/Users/Sean/Documents/test-pdf.pdf");
RandomAccessFile raf = new RandomAccessFile(file, "r");
FileChannel channel = raf.getChannel();
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
final PDFFile pdffile = new PDFFile(buf);
PdfViewer pdfViewer = new PdfViewer();
pdfViewer.setPDFFile(pdffile);
frame.add(pdfViewer);
frame.pack();
frame.setVisible(true);
PDFPage page = pdffile.getPage(0);
pdfViewer.getPagePanel().showPage(page);
} catch (IOException e) {
e.printStackTrace();
}
}
</pre><li>screen shots</li>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJjv5TnxxxqWzGA6H5q35ZlD0cCQbBrD7i5U_umc_Z4MWqbhOjWP8kwI25t_aW-a_6-KRMLWuZpLr7L8GQuGSEuGriZY_L7fYZepzHTvt1b-NxUW8MeTyZ0O14O15WEEuVKNZcW4Ux8tjt/s1600/pdf-viewer.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="310" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJjv5TnxxxqWzGA6H5q35ZlD0cCQbBrD7i5U_umc_Z4MWqbhOjWP8kwI25t_aW-a_6-KRMLWuZpLr7L8GQuGSEuGriZY_L7fYZepzHTvt1b-NxUW8MeTyZ0O14O15WEEuVKNZcW4Ux8tjt/s320/pdf-viewer.png" /></a></div></ul><br />
<br />
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com4tag:blogger.com,1999:blog-8203286977383728989.post-31241510853900385702012-09-19T11:52:00.002+10:002012-09-19T11:58:32.661+10:00How to create or initialize Generic Type Array<ui><br />
<li>solution 1</li><br />
<br />
<br />
<br />
<br />
<b>Limitation:</b> It's not work if input array is null. <br />
<br />
<pre class="brush:java;highlight:[13,16,20]">public static <T> T[] subarray(T[] array, int startIndexInclusive, int endIndexExclusive) {
if (array == null) {
return null;
}
if (startIndexInclusive < 0) {
startIndexInclusive = 0;
}
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
Class<?> type = array.getClass().getComponentType();
int newSize = endIndexExclusive - startIndexInclusive;
if (newSize < 0) {
final T[] emptyArray = (T[]) Array.newInstance(type, 0);
return emptyArray;
}
T[] subarray = (T[]) Array.newInstance(type, newSize);
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
</pre>
<li>solution 2</li>
It's work if input array is null. But it's more verbose for invoking.
<pre class="brush:java;highlight:[2,19]">public static <T> T[] subarray(T[] array, int startIndexInclusive, int endIndexExclusive, Class<T>> clazz) {
T[] emptyArray = (T[]) Array.newInstance(clazz, 0);
if (array == null) {
return emptyArray;
}
if (startIndexInclusive < 0) {
startIndexInclusive = 0;
}
if (endIndexExclusive > array.length) {
endIndexExclusive = array.length;
}
if (newSize < 0) {
return emptyArray;
}
T[] subarray = (T[]) Array.newInstance(clazz, newSize);
System.arraycopy(array, startIndexInclusive, subarray, 0, newSize);
return subarray;
}
</pre>
</ui>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-60566862121899057292012-09-18T13:42:00.003+10:002012-09-18T14:26:39.452+10:00Java Swing JTextField: Number only and give length<ui><br />
<li><br />
Solution 1<br />
</li><br />
Simple but It can't work for "CTRL + V" scenario <pre class="brush:java">private class NumberOnlyAdapter extends KeyAdapter {
private final int maxLength;
private NumberOnlyAdapter(int maxLength) {
this.maxLength = maxLength;
}
@Override
public void keyTyped(KeyEvent e) {
char typed = e.getKeyChar();
CharMatcher notDigit = noneOf("0123456789").and(isNot((char) VK_BACK_SPACE)).and(isNot((char) VK_DELETE));
JTextField textField = (JTextField) e.getComponent();
if (notDigit.apply(typed) || textField.getText().length() >= maxLength) {
e.consume();
}
}
}
...
int maxLength = 8;
JTextField textField = new JTextField();
textField.addKeyListener(new NumberOnlyAdapter(maxLength));
</pre><li>Solution 2</li><br />
It's work for all conditions <pre class="brush:java">import static org.apache.commons.lang3.StringUtils.*;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.DocumentFilter;
public class NumericOnlyAndMaxLengthFilter extends DocumentFilter {
private int maxLength = 0;
public NumericOnlyAndMaxLengthFilter() {
// allow any length of numeric
}
public NumericOnlyAndMaxLengthFilter(int maxLength) {
this.maxLength = maxLength;
}
@Override
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
if (isNumeric(string)) {
if (isExceedMaxLength(fb, string)) {
return;
}
super.insertString(fb, offset, string, attr);
}
}
@Override
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
if (isNumeric(text)) {
if (isExceedMaxLength(fb, text)) {
return;
}
super.insertString(fb, offset, text, attrs);
}
}
private boolean isExceedMaxLength(FilterBypass fb, String text) {
return maxLength > 0 && (fb.getDocument().getLength() + text.length()) > maxLength;
}
}
...
int maxLength = 8;
JTextField textField = new JTextField();
((AbstractDocument)textField .getDocument()).setDocumentFilter(new NumericOnlyAndMaxLengthFilter(maxLength));
</pre></ui><br />
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com2tag:blogger.com,1999:blog-8203286977383728989.post-86133292620268531622012-09-13T11:03:00.002+10:002012-09-13T11:23:09.873+10:00Maven generate HTML Junit report<ul><li>add to pom.xml</li>
<pre class="brush:xml,highlight:[5]"><plugin>
<groupid>org.apache.maven.plugins</groupId>
<artifactid>maven-surefire-plugin</artifactId>
<configuration>
<testfailureignore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupid>org.jvnet.maven-antrun-extended-plugin</groupId>
<artifactid>maven-antrun-extended-plugin</artifactId>
<executions>
<execution>
<id>test-reports</id>
<phase>test</phase>
<configuration>
<tasks>
<junitreport todir="target/surefire-reports">
<fileset dir="target/surefire-reports">
<include name="**/*.xml"/>
</fileset>
<report format="noframes" todir="target/surefire-reports"/>
</junitreport>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupid>org.apache.ant</groupId>
<artifactid>ant-junit</artifactId>
<version>1.8.4</version>
</dependency>
<dependency>
<groupid>org.apache.ant</groupId>
<artifactid>ant-trax</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>
</plugin>
</pre><li>Don't bind the AntRun plugin to the <b>test</b> phase, move the configuration outside the execution and call <b>mvn antrun:run</b> on the command line to generate the reports when wanted.</li>
<li> Or use the <b>testFailureIgnore</b> option of the test mojo and set it to <b>true</b> in the surefire plugin</li>
<li>Use maven command arguments</li>
<pre class="brush:bash">$mvn test -Dmaven.test.failure.ignore=true
</pre>
</ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-24491801944144107962012-09-05T11:13:00.001+10:002012-09-05T11:19:55.021+10:00Java - better performance String formatter<pre class="brush:java">/**
* Substitutes each {@code %s} in {@code template} with an argument. These
* are matched by position - the first {@code %s} gets {@code args[0]}, etc.
* If there are more arguments than placeholders, the unmatched arguments will
* be appended to the end of the formatted message in square braces.
*
* @param template a non-null string containing 0 or more {@code %s}
* placeholders.
* @param args the arguments to be substituted into the message
* template. Arguments are converted to strings using
* {@link String#valueOf(Object)}. Arguments can be null.
*/
public static String format(String template, Object... args) {
template = String.valueOf(template); // null -> "null"
// start substituting the arguments into the '%s' placeholders
StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
int templateStart = 0;
int i = 0;
while (i < args.length) {
int placeholderStart = template.indexOf("%s", templateStart);
if (placeholderStart == -1) {
break;
}
builder.append(template.substring(templateStart, placeholderStart));
builder.append(args[i++]);
templateStart = placeholderStart + 2;
}
builder.append(template.substring(templateStart));
// if we run out of placeholders, append the extra args in square braces
if (i < args.length) {
builder.append(" [");
builder.append(args[i++]);
while (i < args.length) {
builder.append(", ");
builder.append(args[i++]);
}
builder.append(']');
}
return builder.toString();
}
public static void main(String[] args) {
Stopwatch stopwatch = new Stopwatch();
stopwatch.start();
String result = Formatter.format("My name is: %s. I was start from: %s. ", "Sean", "25/05/2012", "another value here");
stopwatch.stop();
System.out.println(stopwatch.elapsedTime(TimeUnit.NANOSECONDS));
System.out.println(result);
stopwatch.reset();
stopwatch.start();
result = String.format("My name is: %s. I was start from: %s.", "Sean", "25/05/2012", "another value here");
stopwatch.stop();
System.out.println(stopwatch.elapsedTime(TimeUnit.NANOSECONDS));
System.out.println(result);
}
</pre>
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-22031333674588880772012-08-14T12:00:00.000+10:002012-08-14T12:17:07.488+10:00Read line (or get line count) from JTextArea with wrap enabled<pre class="brush:java;highlight:[16]">public class Demo {
JTextArea textArea = new JTextArea(text, 5, 50);
textArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
private static String[] readLinesFromTextArea(JTextArea textArea, int limitRows) {
String content = textArea.getText();
String[] lines = new String[limitRows];
Arrays.fill(lines, "");
try {
int count = 0;
int offs = 0;
while (offs < content.length() && count < limitRows ) {
int end = Utilities.getRowEnd(textArea, offs);
String line = StringUtils.substring(content, offs, end);
lines[count++] = line;
offs = end + 1;
}
} catch (BadLocationException e) {
log.error("Read line from 'Other' text area failed. Cause:\n", Throwables.getStackTraceAsString(e));
}
return lines;
}
}
</pre>
Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-56478380698608259582012-08-06T16:45:00.002+10:002012-08-08T09:17:58.550+10:00Use Apache PDFBox convert PDF to image (support BMP,bmp,jpeg,wbmp,gif,png,JPG,jpg,JPEG,WBMP)<ul><li>dependency</li>
<pre class="brush:xml"><dependency>
<groupid>org.apache.pdfbox</groupId>
<artifactid>pdfbox</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupid>org.bouncycastle</groupId>
<artifactid>bcprov-jdk15</artifactId>
<version>1.46</version>
</dependency>
<dependency>
<groupid>org.bouncycastle</groupId>
<artifactid>bcmail-jdk15</artifactId>
<version>1.46</version>
</dependency>
<dependency>
<groupid>org.apache.pdfbox</groupId>
<artifactid>fontbox</artifactId>
<version>1.7.0</version>
</dependency>
</pre><li>Code</li>
<pre class="brush:java;highlight:[35,48,49,50,73,86,87,88,100,101]">import au.gov.nsw.police.nodi.common.CustomProperties;
import org.apache.pdfbox.exceptions.CryptographyException;
import org.apache.pdfbox.exceptions.InvalidPasswordException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.util.PDFImageWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.imageio.*;
import javax.imageio.metadata.IIOInvalidTreeException;
import javax.imageio.metadata.IIOMetadata;
import javax.imageio.metadata.IIOMetadataNode;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import static com.google.common.base.Throwables.getStackTraceAsString;
public class PDFToImage {
private static final Logger log = LoggerFactory.getLogger(PDFToImage.class);
private static final String STANDARD_METADATA_FORMAT = "javax_imageio_1.0";
private static final String PDF_ENCRYPTED_PASSWORD = CustomProperties.getInstance().getProperty("pdf.from.esb.encrypted.password");
private static final String IMAGE_FORMAT = "png";
private static final int DEFAULT_IMAGE_RESOLUTION = 256;
public static RenderedImage convertPdfOfGivenPageNumberToRenderImage(PDDocument document, int pageNumber) throws IOException {
try {
decryptDocument(PDF_ENCRYPTED_PASSWORD, document);
int imageType = BufferedImage.TYPE_INT_RGB;
int resolution = DEFAULT_IMAGE_RESOLUTION;
try {
int screenResolution = Toolkit.getDefaultToolkit().getScreenResolution();
if (screenResolution > resolution) {
resolution = screenResolution;
}
} catch (HeadlessException e) {
log.debug("As it can't get the screen resolution. Use default resolution: {}", resolution);
}
List pages = document.getDocumentCatalog().getAllPages();
PDPage page = (PDPage) pages.get(pageNumber);
BufferedImage image = page.convertToImage(imageType, resolution);
return covertBufferedImageToRenderImage(image, IMAGE_FORMAT, resolution);
} finally {
if (document != null) {
document.close();
}
}
}
private static void decryptDocument(String password, PDDocument document) throws IOException {
if (document.isEncrypted()) {
try {
document.decrypt(password);
} catch (InvalidPasswordException e) {
log.error("Error: The document is encrypted. Please provide correct PDF_ENCRYPTED_PASSWORD. Cause:\n{}", getStackTraceAsString(e));
} catch (CryptographyException e) {
log.error(getStackTraceAsString(e));
}
}
}
private static RenderedImage covertBufferedImageToRenderImage(BufferedImage image, String imageFormat, int resolution) throws IOException {
ImageWriter imageWriter = null;
Iterator<imagewriter> imageWriterIterator = ImageIO.getImageWritersByFormatName(imageFormat);
if (imageWriterIterator.hasNext()) {
try {
imageWriter = imageWriterIterator.next();
ImageWriteParam writerParams = imageWriter.getDefaultWriteParam();
if (writerParams.canWriteCompressed()) {
writerParams.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
// reset the compression type if overwritten by setCompressionMode
if (writerParams.getCompressionType() == null) {
writerParams.setCompressionType(writerParams.getCompressionTypes()[0]);
}
writerParams.setCompressionQuality(1.0f);
}
IIOMetadata meta = createMetadata(image, imageWriter, writerParams, resolution);
IIOImage iioImage = new IIOImage(image, null, meta);
return iioImage.getRenderedImage();
} finally {
if (imageWriter != null) {
imageWriter.dispose();
}
}
}
return null;
}
private static PDDocument loadPdfDocumentFromBytes(byte[] imageOfPdf) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(imageOfPdf);
return PDDocument.load(byteArrayInputStream);
}
private static PDDocument loadPdfDocumentFromFile(String fileName) throws IOException {
return PDDocument.load(fileName);
}
//----------------------Copy from (start): org.apache.pdfbox.util.ImageIOUtil-----------------------------------
private static IIOMetadata createMetadata(RenderedImage image, ImageWriter imageWriter, ImageWriteParam writerParams, int resolution) {
ImageTypeSpecifier type;
if (writerParams.getDestinationType() != null) {
type = writerParams.getDestinationType();
} else {
type = ImageTypeSpecifier.createFromRenderedImage(image);
}
IIOMetadata meta = imageWriter.getDefaultImageMetadata(type, writerParams);
return (addResolution(meta, resolution) ? meta : null);
}
private static boolean addResolution(IIOMetadata meta, int resolution) {
if (!meta.isReadOnly() && meta.isStandardMetadataFormatSupported()) {
IIOMetadataNode root = (IIOMetadataNode) meta.getAsTree(STANDARD_METADATA_FORMAT);
IIOMetadataNode dimension = getChildNode(root, "Dimension");
IIOMetadataNode horizontalPixelSize = getChildNode(dimension, "HorizontalPixelSize");
String pixelSize = Double.toString(resolution / 25.4);
horizontalPixelSize.setAttribute("value", pixelSize);
IIOMetadataNode verticalPixelSize = getChildNode(dimension, "VerticalPixelSize");
verticalPixelSize.setAttribute("value", pixelSize);
try {
meta.mergeTree(STANDARD_METADATA_FORMAT, root);
} catch (IIOInvalidTreeException e) {
throw new RuntimeException("Cannot update image metadata: " + e.getMessage());
}
return true;
}
return false;
}
private static IIOMetadataNode getChildNode(IIOMetadataNode parentNode, String childNodeName) {
NodeList nodes = parentNode.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node child = nodes.item(i);
if (childNodeName.equals(child.getNodeName())) {
return (IIOMetadataNode) child;
}
}
return createChildNodeIfNotExist(parentNode, childNodeName);
}
private static IIOMetadataNode createChildNodeIfNotExist(IIOMetadataNode parentNode, String childNodeName) {
IIOMetadataNode childNode = new IIOMetadataNode(childNodeName);
parentNode.appendChild(childNode);
return childNode;
}
//----------------------Copy from (end): org.apache.pdfbox.util.ImageIOUtil-----------------------------------
public static void main(String[] args) throws IOException {
String pdfFile = "c:/temp/test_avo.pdf";
String outputPrefix = "c:/temp/";
PDDocument document = loadPdfDocumentFromFile(pdfFile);
int numberOfPages = document.getNumberOfPages();
for (int i = 0; i < numberOfPages; i++) {
int pageNumber = i + 1;
RenderedImage renderedImage = convertPdfOfGivenPageNumberToRenderImage(document, pageNumber);
// render image to ui or
}
// if you just want to covert pdf file to image file, it's much easier.
PDFImageWriter imageWriter = new PDFImageWriter();
boolean success = imageWriter.writeImage(document, IMAGE_FORMAT, password, startPage, endPage, outputPrefix, BufferedImage.TYPE_INT_RGB, resolution);
if (!success) {
System.err.println("Error: no writer found for image format '" + IMAGE_FORMAT + "'");
System.exit(1);
}
}
</pre>
<li>You can use following code to detected which image format is support</li>
<pre class="brush:java">public static String getImageFormats() {
StringBuffer retval = new StringBuffer();
String[] formats = ImageIO.getReaderFormatNames();
for (int i = 0; i < formats.length; i++) {
retval.append(formats[i]);
if (i + 1 < formats.length) {
retval.append(",");
}
}
return retval.toString();
}
</pre>
<li>Dependencies can be download <a href="https://docs.google.com/viewer?a=v&pid=sites&srcid=ZGVmYXVsdGRvbWFpbnxzZWFuc2hvdXxneDpkNzI1MjRkOThmZmUyYmM">here</a></li>
<li>Others</li>
Tiff image need native libary. You can find more information on java.net
</ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com3tag:blogger.com,1999:blog-8203286977383728989.post-15362713911154678112012-07-30T16:25:00.003+10:002012-10-15T09:32:52.877+11:00Soap Web Service with attachment Over JMS<ul><li><b>dependency</b></li>
<pre class="brush:xml"><dependency>
<groupid>com.sun.messaging.mq</groupid>
<artifactid>imqxm</artifactid>
<version>4.6-b01</version>
</dependency>
<dependency>
<groupid>javaee</groupid>
<artifactid>javaee-api</artifactid>
<version>5</version>
</dependency>
<dependency>
<groupid>xalan</groupid>
<artifactid>xalan</artifactid>
<version>2.7.0</version>
</dependency>
<dependency>
<groupid>com.sun.messaging.mq</groupid>
<artifactid>jaxm-api</artifactid>
<version>4.6-b01</version>
</dependency>
</pre><li><b>JMS message sender (Embedded SoapMessage with Attachment)</b></li>
<pre class="brush:java;highlight:[49, 68, 69]">import com.google.common.io.Files;
import com.sun.messaging.xml.MessageTransformer;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.xml.soap.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Hashtable;
public class MockWebServiceOverJMSSender {
private static final String CONNECTION_FACTORY_JNDI_NAME = "weblogic.jms.XAConnectionFactory";
private static final String QUEUE_JNDI_NAME = "jms/TestQueueJNDI";
public static void sendMessage() {
try {
QueueConnection connection = null;
QueueSession session = null;
QueueSender queueSender = null;
try {
Hashtable<String,String> properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
InitialContext context = new InitialContext(properties);
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(CONNECTION_FACTORY_JNDI_NAME);
connection = connectionFactory.createQueueConnection();
session = connection.createQueueSession(false, 0);
Queue queue = (Queue) context.lookup(QUEUE_JNDI_NAME);
queueSender = session.createSender(queue);
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
soapMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody soapBody = envelope.getBody();
soapBody.setTextContent(buildSoapBodyContent());
AttachmentPart attachment = buildSoapAttachment(soapMessage);
soapMessage.addAttachmentPart(attachment);
soapMessage.saveChanges();
Message message = MessageTransformer.SOAPMessageIntoJMSMessage(soapMessage, session);
queueSender.send(message);
} finally {
queueSender.close();
session.close();
connection.close();
}
} catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
private static String buildSoapBodyContent() throws IOException {
String responseFile = "c:/temp/PoliceAVOApplicationResponse-Non-provisional.xml";
return Files.toString(new File(responseFile), Charset.forName("UTF-8"));
}
private static AttachmentPart buildSoapAttachment(SOAPMessage soapMessage) {
DataHandler dh = new DataHandler(new FileDataSource("c:/temp/test_avo.pdf"));
return soapMessage.createAttachmentPart(dh);
}
public static void main(String args[]) {
sendMessage();
}
</pre><li><b>JMS consumer(parse message body & save attachment to disk)</b></li>
<pre class="brush:java;highlight:[50,122,123,124]">import au.gov.nsw.police.nodi.common.IOHelper;
import com.google.common.io.Files;
import com.sun.messaging.xml.MessageTransformer;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.soap.*;
import javax.xml.xpath.*;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
public class MockJMSMessageConsumer {
private static final String CONNECTION_FACTORY_JNDI_NAME = "weblogic.jms.XAConnectionFactory";
private static final String QUEUE_JNDI_NAME = "jms/TestQueueJNDI";
private static void consumeMessage() {
try {
QueueConnection connection = null;
QueueSession session = null;
QueueReceiver queueReceiver = null;
try {
Hashtable<String, String> properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
InitialContext context = new InitialContext(properties);
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(CONNECTION_FACTORY_JNDI_NAME);
connection = connectionFactory.createQueueConnection();
session = connection.createQueueSession(false, 0);
Queue queue = (Queue) context.lookup(QUEUE_JNDI_NAME);
queueReceiver = session.createReceiver(queue);
connection.start();
while (true) {
Message message = queueReceiver.receive(1);
MessageFactory messageFactory = MessageFactory.newInstance();
if (message != null) {
SOAPMessage soapMessage = MessageTransformer.SOAPMessageFromJMSMessage(message, messageFactory);
onMessage(soapMessage);
}
}
} finally {
queueReceiver.close();
session.close();
connection.close();
}
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(0);
}
}
private static void onMessage(SOAPMessage soapMessage) {
try {
System.out.println("Start to processing message from ESB...");
SOAPBody soapBody = soapMessage.getSOAPPart().getEnvelope().getBody();
Iterator iterator = soapMessage.getAttachments();
if (iterator.hasNext()) {
AttachmentPart attachmentPart = (AttachmentPart) iterator.next();
System.out.println("here");
parseMetadataFromSoapMessage(soapBody, attachmentPart);
}
System.out.println("Finish to processing message from ESB");
} catch (Throwable e) {
e.printStackTrace();
}
}
private static void parseMetadataFromSoapMessage(SOAPBody soapBody, AttachmentPart attachmentPart) throws IOException, SAXException, ParserConfigurationException, XPathExpressionException, SOAPException {
String content = soapBody.getTextContent();
Document doc = buildDocumentFromString(content);
XPath xPath = createXPath();
String courtReferenceNumber = getStringValueWithGiveXPath(xPath, doc, "/n1:PublishDocumentMessage/@ProceedingNumber");
String courtName = getStringValueWithGiveXPath(xPath, doc, "/n1:PublishDocumentMessage/n1:Listing/Court/@Name");
String eventNumber = getStringValueWithGiveXPath(xPath, doc, "/n1:PublishDocumentMessage/n1:QuestionsAndAnswers/n1:DataField[@Name='IDF POLAPPEVENTNO']/@Value");
String cni = getStringValueWithGiveXPath(xPath, doc, "/n1:PublishDocumentMessage/n1:Participant[n1:ParticipantID[@ParticipantRole='DEFENDANT']]/n1:CrimeIndividual/common:IndividualDetails/@CNI");
System.out.println("court reference number: " + courtReferenceNumber);
System.out.println("court name: " + courtName);
System.out.println("event number: " + eventNumber);
System.out.println("cni: " + cni);
saveAttachmentToDisk(attachmentPart);
}
private static Document buildDocumentFromString(String content) throws ParserConfigurationException, SAXException, IOException {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(content.getBytes());
return docBuilder.parse(inputStream);
}
private static XPath createXPath() {
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();
xpath.setNamespaceContext(new AVONamespaceContext());
return xpath;
}
private static String getStringValueWithGiveXPath(XPath xpath, Document document, String expression) throws XPathExpressionException {
XPathExpression xPathExpression = xpath.compile(expression);
return (String) xPathExpression.evaluate(document, XPathConstants.STRING);
}
private static void saveAttachmentToDisk(AttachmentPart attachmentPart) throws IOException, SOAPException {
byte[] pdfFile= IOHelper.readInputStream(attachmentPart.getDataHandler().getInputStream());
Date now = new Date();
Files.write(faxImages, new File("c:/temp/" + now.getTime() + ".pdf"));
}
public static void main(String args[]) {
consumeMessage();
}
</pre><li><b>help class</b></li>
<pre class="brush:java;">import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;
import java.util.Iterator;
public class AVONamespaceContext implements NamespaceContext {
public String getNamespaceURI(String prefix) {
if (prefix == null) throw new NullPointerException("Invalid Namespace Prefix");
else if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
return "http://www.w3.org/2001/XMLSchema-instance";
} else if ("n1".equals(prefix)) {
return "http://cats.agd.nsw.gov.au/PublishDocumentMessage/v1_0";
} else if ("common".equals(prefix)) {
return "http://cats.agd.nsw.gov.au/DocumentLodgementInterfaces/Common/v1_0";
} else if ("cim".equals(prefix)) {
return "http://cim.justicesector.nsw.gov.au/Common/1";
} else if ("as4590".equals(prefix)) {
return "http://cim.justicesector.nsw.gov.au/as459";
} else {
return XMLConstants.NULL_NS_URI;
}
}
public String getPrefix(String namespaceURI) {
return null;
}
public Iterator getPrefixes(String namespaceURI) {
return null;
}
}
</pre><li><b>Another Solution</b></li>
You don't need to dependent the above dependencies. You just implement your own transformer. My sample as follow: <pre class="brush:java">import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jms.BytesMessage;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.xml.messaging.JAXMException;
import javax.xml.soap.*;
import java.io.*;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import static com.google.common.base.Throwables.getStackTraceAsString;
/**
* The Rcode>Transformer</code> class encapsulates the functionality
* to transform SOAP and JMS messages.
*/
public class MessageTransformer {
private static final Logger log = LoggerFactory.getLogger(MessageTransformer.class);
private MessageTransformer() {
}
/**
* Transforms a <code>javax.xml.soap.SOAPMessage</code> message
* into a <code>javax.jms.Message</code> message.
*
* @param soapMessage the SOAPMessage to be converted to the JMS Message.
* @param session The JMS Session to be used to construct the JMS Message.
* @throws JAXMException If any error is encountered when transforming the message.
*/
public static Message SOAPMessageIntoJMSMessage(SOAPMessage soapMessage, Session session) throws JAXMException {
try {
/**
* Construct a bytes message object.
* This is to make sure the utility works across all vendors.
*/
BytesMessage bytesMessage = session.createBytesMessage();
/**
* This is here to make sure that RI's bad SOAP implementation
* will get updated for internal buffers.
*/
soapMessage.saveChanges();
writeMimeHeaders(soapMessage, bytesMessage);
writeSOAPBody(soapMessage, bytesMessage);
return bytesMessage;
} catch (JAXMException JAXMe) {
throw JAXMe;
} catch (Exception e) {
log.error(getStackTraceAsString(e));
throw new JAXMException(e);
}
}
private static void writeMimeHeaders(SOAPMessage soapMessage, BytesMessage bytesMessage) throws Exception {
MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
Hashtable hashtable = convertMimeHeadersToHashtable(mimeHeaders);
ByteArrayOutputStream mimeOut = writeHashtableToByteArrayOutputStream(hashtable);
byte[] mimeHeadersBytes = mimeOut.toByteArray();
int mimeHeadersLength = mimeHeadersBytes.length;
bytesMessage.writeInt(mimeHeadersLength);
bytesMessage.writeBytes(mimeHeadersBytes);
mimeOut.close();
log.debug("SOAP to JMS mime headers length: {}", mimeHeadersLength);
}
/**
* Convert MimeHeaders to Hashtable. The hashtable is then used to write
* to JMS BytesMessage.
*/
private static Hashtable convertMimeHeadersToHashtable(MimeHeaders mimeHeaders) {
Hashtable hashtable = new Hashtable();
Iterator it = mimeHeaders.getAllHeaders();
while (it.hasNext()) {
MimeHeader mimeHeader = (MimeHeader) it.next();
hashtable.put(mimeHeader.getName(), mimeHeader.getValue());
}
return hashtable;
}
private static ByteArrayOutputStream writeHashtableToByteArrayOutputStream(Hashtable hashtable) throws IOException {
ByteArrayOutputStream mimeOut = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(mimeOut);
objectOutputStream.writeObject(hashtable);
objectOutputStream.flush();
objectOutputStream.close();
return mimeOut;
}
private static void writeSOAPBody(SOAPMessage soapMessage, BytesMessage bytesMessage) throws Exception {
ByteArrayOutputStream bodyOutput = new ByteArrayOutputStream();
soapMessage.writeTo(bodyOutput);
byte[] bodyBytes = bodyOutput.toByteArray();
int bodyLength = bodyBytes.length;
bytesMessage.writeInt(bodyLength);
bytesMessage.writeBytes(bodyBytes);
bodyOutput.close();
log.debug("SOAP to JMS body length: {}", bodyLength);
}
/**
* Extracts a <code>javax.xml.soap.SOAPMessage</code> object from the
* <code>javax.jms.Message</code> object into which it was transformed
* using the <code>SOAPMessageIntoJMSMessage</code> method.
* <p/>* The <code>MessageFactory</code> parameter is used to construct the
* <code>javax.xml.soap.SOAPMessage</code> object.
* <p/>* If <code>MessageFactory</code> is <code>null</code> then the
* default SOAP MessageFactory will be used to construct the
* SOAP message.
*
* @param message The JMS message from which the SOAP message is to be extracted.
* @param messageFactory The SOAP MessageFactory to be used to contruct the SOAP message.
* @throws JAXMException If any error is encountered when extracting the message.
*/
public static SOAPMessage extractSOAPMessageFromJMSMessage(Message message, MessageFactory messageFactory) throws JAXMException {
BytesMessage bytesMessage = (BytesMessage) message;
try {
MimeHeaders mimeHeaders = readMimeHeaders(bytesMessage);
ByteArrayInputStream bodyByteArrayInputStream = readSoapBodyToByteArrayInputStream(bytesMessage);
return constructSoapMessage(messageFactory, mimeHeaders, bodyByteArrayInputStream);
} catch (Exception e) {
throw new JAXMException(e);
}
}
private static MimeHeaders readMimeHeaders(BytesMessage bytesMessage) throws JMSException, IOException, ClassNotFoundException {
int mimeHeadersLength = bytesMessage.readInt();
byte[] mimeHeadersBytes = new byte[mimeHeadersLength];
bytesMessage.readBytes(mimeHeadersBytes, mimeHeadersLength);
ByteArrayInputStream mimeHeadersByteArrayInputStream = new ByteArrayInputStream(mimeHeadersBytes);
ObjectInputStream objectInputStream = new ObjectInputStream(mimeHeadersByteArrayInputStream);
Hashtable hashtable = (Hashtable) objectInputStream.readObject();
return convertHashtableToMimeHeaders(hashtable);
}
private static MimeHeaders convertHashtableToMimeHeaders(Hashtable hashtable) {
MimeHeaders mimeHeaders = new MimeHeaders();
Enumeration enm = hashtable.keys();
while (enm.hasMoreElements()) {
Object key = enm.nextElement();
mimeHeaders.addHeader((String) key, (String) hashtable.get(key));
log.debug("mime-header: {} = {}", key, hashtable.get(key));
}
return mimeHeaders;
}
private static ByteArrayInputStream readSoapBodyToByteArrayInputStream(BytesMessage bytesMessage) throws JMSException {
int bodyLength = bytesMessage.readInt();
byte[] buf = new byte[bodyLength];
bytesMessage.readBytes(buf, bodyLength);
return new ByteArrayInputStream(buf);
}
private static SOAPMessage constructSoapMessage(MessageFactory messageFactory, MimeHeaders mimeHeaders,
ByteArrayInputStream bodyByteArrayInputStream) throws SOAPException, IOException {
if (messageFactory == null) {
messageFactory = getMessageFactory();
}
return messageFactory.createMessage(mimeHeaders, bodyByteArrayInputStream);
}
private static MessageFactory getMessageFactory() throws SOAPException {
return MessageFactory.newInstance();
}
}
</pre><li> reference</li>
<a href="http://www.w3.org/TR/soapjms/">SOAP over Java Message Service 1.0
</a>
</ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-4870602768179286812012-07-30T15:38:00.002+10:002012-07-30T16:27:16.235+10:00Create xml Document from File or String & convert Document to String<ul><li>Create xml Document from File or String</li>
<pre class="brush:java;">public Document buildDocumentFromExternalResource() throw Exception {
String content = "....";
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(content.getBytes());
Document doc = docBuilder.parse(inputStream);
// read from file
doc = docBuilder.parse(new File("c:/temp/myContent.xml"));
}
</pre><li>convert Document to String</li>
<pre class="brush:java;">public String convertDocumentToString(SOAPBody soapBody) throw Excepiton {
Document doc = soapBody.getOwnerDocument();
Source source = new DOMSource(doc);
StringWriter out = new StringWriter();
Result result = new StreamResult(out);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.transform(source, result);
String content = out.toString();
}
</pre></ul>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-71414007406632689232012-07-25T11:34:00.002+10:002012-07-25T11:35:23.007+10:00A simple JMSClient to test JMS queue/topic in Weblogic<pre class="brush:java">import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
public class TestJMS {
private static InitialContext context = null;
private static QueueConnectionFactory connectionFactory = null;
private static QueueConnection connection = null;
private static QueueSession session = null;
private static Queue queue = null;
private static QueueSender queueSender = null;
private static TextMessage message = null;
//Using the Default Connection Factories
//ref --> http://docs.oracle.com/cd/E15051_01/wls/docs103/jms/fund.html
private static final String CONNECTION_FACTORY_JNDI_NAME = "weblogic.jms.ConnectionFactory";
private static final String QUEUE_JNDI_NAME = "Police.Eno.CourtServiceQueue";
public TestJMS() {
super();
}
public static void sendMessage(String messageText) {
try {
try {
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://localhost:7001");
context = new InitialContext(properties);
connectionFactory = (QueueConnectionFactory) context.lookup(CONNECTION_FACTORY_JNDI_NAME);
connection = connectionFactory.createQueueConnection();
session = connection.createQueueSession(false, 0);
queue = (Queue) context.lookup(QUEUE_JNDI_NAME);
queueSender = session.createSender(queue);
message = session.createTextMessage();
message.setText(messageText);
queueSender.send(message);
} finally {
message = null;
queueSender.close();
queueSender = null;
queue = null;
session.close();
session = null;
connection.close();
connection = null;
connectionFactory = null;
context = null;
}
} catch (NamingException e) {
e.printStackTrace(System.err);
System.exit(0);
} catch (JMSException e) {
e.printStackTrace(System.err);
System.exit(0);
}
}
public static void main(String args[]) {
sendMessage("test message here!!!");
}
}
</pre>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-6556434787865607442012-07-09T12:35:00.000+10:002012-07-09T12:46:25.899+10:00Regular express validate date timereference:<br />
<a href="http://stackoverflow.com/questions/1315376/regular-expression-for-date-time-format-mm-dd-yy-hhmmss-am-pm-in-asp-net-reg">http://stackoverflow.com/questions/1315376/regular-expression-for-date-time-format-mm-dd-yy-hhmmss-am-pm-in-asp-net-reg</a><br />
<br />
<br />
RegEx for matching all dates, including leap years.<br />
<ol><li>For <b>DD-MM-YYYY</b> format</li>
<pre class="brush:java;">^(?:31#(?:(?:0[13578])|(?:1[02]))#)|(?:(?:29|30)#(?:(?:0[1,3-9])|(?:1[0-2]))#)(?:(?:1[6-9]|[2-9]\d)\d{2})$|^(?:29#02#(?:(?:(?:1[6-9]|[2-9]\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1\d)|(?:2[0-8]))#(?:(?:0[1-9])|(?:1[0-2]))#(?:(?:1[6-9]|[2-9]\d)\d{2})$
</pre><li>For <b>MM-DD-YYYY</b> format</li>
<pre class="brush:java;">^(?:(?:(?:0?[13578]|1[02])#31)\1|(?:(?:0?[1,3-9]|1[0-2])#(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2#29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))#(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
</pre><li>Java Code</li>
<pre class="brush:java; highlight:[3,4]">String inputDate;
String regex="^(?:31/(?:(?:0[13578])|(?:1[02]))/)|(?:(?:29|30)/(?:(?:0[1,3-9])|(?:1[0-2]))/)(?:(?:1[6-9]|[2-9]\\d)\\d{2})$|^(?:29/02/(?:(?:(?:1[6-9]|[2-9]\\d)(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0[1-9])|(?:1\\d)|(?:2[0-8]))/(?:(?:0[1-9])|(?:1[0-2]))/(?:(?:1[6-9]|[2-9]\\d)\\d{2})$";
Pattern pattern = Pattern.compile(inputDate);
Matcher matcher = pattern.matcher(inputDate);
boolean found = matcher.matches();
</pre><li>For <b>Time</b></li>
<pre class="brush:java;">^([0|1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$
</pre></ol>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com0tag:blogger.com,1999:blog-8203286977383728989.post-76302740456852042482012-04-19T16:04:00.002+10:002012-04-23T10:42:48.977+10:00How to unit test with @ResponseBody return Json in Spring MVC controller<ol><li><b>model</b></li>
<pre class="brush:java">public class Dealer {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
</pre><li><b>Controller</b></li>
<pre class="brush:java">import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;
@Controller
@RequestMapping("/dealer")
public class DealerController {
@Resource(name = "dealerService")
private DealerService dealerService;
@RequestMapping("json/all")
public @ResponseBody List<Dealer> getAllDealers() {
return dealerService.getAllDealers();
}
}
</pre><li><b>applicationContext.xml</b></li>
<pre class="brush:xml"><bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver" p:order="1">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</map>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView" p:marshaller-ref="unmarshaller" />
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" p:objectMapper-ref="jacksonJsonObjectMapper" />
</list>
</property>
</bean>
<oxm:jaxb2-marshaller id="unmarshaller">
<oxm:class-to-be-bound name="mypackge.Dealer"/>
</oxm:jaxb2-marshaller>
</pre><li><b>Unit test</b></li>
<pre class="brush:java; highlight:[39,40,41]">import com.google.common.collect.Lists;
import org.apache.http.HttpHeaders;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class TestDealerController {
private DealerController dealerController;
@Before
public void before() throws Exception {
DealerService dealerService = mock(DealerService.class);
when(dealerService.getAllDealers()).thenReturn(mockDealers());
dealerController = new DealerController();
ReflectionTestUtils.setField(dealerController, "dealerService", dealerService);
}
@Test
public void testGetAllDealers() throws Exception {
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setContentType(MediaType.APPLICATION_JSON.toString());
mockRequest.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
mockRequest.setMethod("GET");
mockRequest.setRequestURI("/dealer/json/all");
AnnotationMethodHandlerAdapter handlerAdapter = new AnnotationMethodHandlerAdapter();
HttpMessageConverter[] messageConverters = {new MappingJacksonHttpMessageConverter()};
handlerAdapter.setMessageConverters(messageConverters);
MockHttpServletResponse mockResponse = new MockHttpServletResponse();
handlerAdapter.handle(mockRequest, mockResponse, dealerController);
String expected="[{\"id\":\"01\",\"name\":\"dealer-01\"}, {\"id\":\"02\",\"name\":\"dealer-02\"}]";
assertEquals(expected, mockResponse.getContentAsString());
}
private List<Dealer> mockDealers() {
Dealer dealer01 = new Dealer();
dealer01.setId("01");
dealer01.setName("dealer-01");
Dealer dealer02 = new Dealer();
dealer02.setId("02");
dealer02.setName("dealer-02");
return Lists.newArrayList(dealer01, dealer02);
}
</pre><li><b>reference</b></li>
<a href="http://stackoverflow.com/questions/9138555/spring-framework-test-restful-web-service-controller-offline-i-e-no-server-n">Spring Framework TEST RESTful Web Service (Controller) Offline i.e. No Server, No Database</a> </ol>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com6tag:blogger.com,1999:blog-8203286977383728989.post-11664545669277270712012-03-21T14:27:00.013+11:002012-04-13T09:30:49.493+10:00Spring support multiple @Transactional datasource1. Define tx-manager<br />
<pre class="brush:xml" name="code"><beans>
<tx:annotation-driven/>
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="jpaTxManager">
<property name="dataSource" ref="dataSource1"/>
</bean>
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="jdbcTxManager2">
<property name="dataSource" ref="dataSource2"/>
</bean>
</beans>
</pre><br />
2. In you service layer code<br />
<pre class="brush:java" name="code">
@Transactional(value = "jdbcTxManager")
public List<String> getNames() {
return userDao.getNames();
}
@Transactional(value = "jpaTxManager")
public void persitentUser(User user) {
return user.persist();
}
</pre>Seanhttp://www.blogger.com/profile/11407289389468631342noreply@blogger.com1