tag:blogger.com,1999:blog-66176416846910466422024-02-19T08:43:51.414+05:30Tan's Techy and SketchyTanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.comBlogger19125tag:blogger.com,1999:blog-6617641684691046642.post-51247958680216222452017-03-12T22:12:00.001+05:302017-03-12T22:12:41.593+05:30Receiving HL7 Messages with WSO2 EIBefore getting EI involved in this story,let's get to know what are these HL7 messages? Why do we need such messages ? From where does these messages come?
<br/><br/>
<b>What is HL7 ?</b><br /><br/>
HL7 refers to a set of international standards defined for exchanging, integrating, sharing, and retrieval of clinical and administrative data between software applications used by various healthcare providers. In simple words HL7 is the common language that is used by different types of health care instruments to talk to each other.<br/><br/>
<b>Use case</b><br /><br/>
Now let's see how these HL7 messages can be received from WSO2 EI using a simple use case.
<br/><br/>
In order to simulate emitting messages from Health instruments, we will be using Hapi Test Panel. If you are not familiar with the Hapi Test Panel you can go thorough this <a href="http://tanyamadurapperuma.blogspot.com/2017/03/sending-hl7-messages-using-hapi-test.html">previous</a> blog post about Hapi Test Panel.
<br/><br/>
Messages sent from the Hapi Test Panel will be captured by WSO2 EI's <a href="https://docs.wso2.com/display/EI600/HL7+Inbound+Protocol">HL7 inbound endpoint</a> and the mediated messages will be saved in a MYSQL database as shown in the below architecture diagram.<br/><br/><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN1HIhvyTg4oiTiBd_Qgdg3QHJ2Zdt1rdp4X2prdGzQcIk6lXbnJnuB-B4yfzav5nW7K8v7IyHFZ09uFNpyZlboyfmL_GfmyyWmUqDhYzshsvdUx4-aG6TAEFeavNESPFndfw0UkWG4Fg/s1600/sa_diagram.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN1HIhvyTg4oiTiBd_Qgdg3QHJ2Zdt1rdp4X2prdGzQcIk6lXbnJnuB-B4yfzav5nW7K8v7IyHFZ09uFNpyZlboyfmL_GfmyyWmUqDhYzshsvdUx4-aG6TAEFeavNESPFndfw0UkWG4Fg/s640/sa_diagram.png" width="640" height="272" /></a></div>
<br/><br/>
<b>Approach</b><br /><br/>
Note that we are building the above use case starting from the right side of the above diagram.<br/><br/>
<div style="text-align: justify;">
1. Create MySQL table and data service for storing messages</div>
<div style="text-align: justify;">
2. Writing Mediation logic for extracting data from HL7 messages and calling data service</div>
<div style="text-align: justify;">
3. Writing HL7 inbound to receive HL7 messages</div>
<div style="text-align: justify;">
3. Sending HL7 messages to WSO2 EI from Hapi Test Panel</div>
<br/>
<div color:="" d="" style="border: 1.5px solid #000;">
<br/><span style="color: red;"> Note : As the purpose of this blog post is to demonstrate the HL7 capabilities of EI and not to deploy in any production environment as is, we will be creating synapse configurations using management console of EI.</span><br/>
<br/></div><br/>
<br/>
<b>Creating data service in WSO2 EI</b><br /><br/>
Let's first create the MySQL table for storing mediated messages. Below given is the sample table that we created in MySQL database.<br/><br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-PWY_Alkkq2aI2HiheXjiLGQt0HZepDZmWarQIBRknAO2tJf7OlOgxwgYkqHgVjrFh26i_gBsCXs7DP8o796BkPiFZnQKJU1dXR6P49u8yYXLqI5dOj7eJNwdZ6twO-GWEln8FzVkLw0/s1600/mysql.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-PWY_Alkkq2aI2HiheXjiLGQt0HZepDZmWarQIBRknAO2tJf7OlOgxwgYkqHgVjrFh26i_gBsCXs7DP8o796BkPiFZnQKJU1dXR6P49u8yYXLqI5dOj7eJNwdZ6twO-GWEln8FzVkLw0/s1600/mysql.png" /></a></div><br/><br/>
<div style="text-align: justify;">
1. Copy the MySQL driver in to EI_HOME/lib folder and start EI by running integrator.sh script at EI_HOME/bin</div>
<div style="text-align: justify;">
2. Log into the EI management console and Go to <b>Configure</b> --> <b>Datasources</b> and click <b>Add Datasource</b></div>
<div style="text-align: justify;">
3. Fill in the details as per your created table in MySQL and <b>Save</b></div>
</br><br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip6sN6749FX1Zo4Dxbo9lI8lhP9WK187R8aD3LG_q3h-yATnB1fZ7Anu7z_mBbMrCeJBIoRlGfxjeRxlkMfkzHADqUAF_vSFOZ3B3eZoASUIV3xxzeRbEcPEqlKMl8k4ZpK_M-oFPUjBs/s1600/datasource.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip6sN6749FX1Zo4Dxbo9lI8lhP9WK187R8aD3LG_q3h-yATnB1fZ7Anu7z_mBbMrCeJBIoRlGfxjeRxlkMfkzHADqUAF_vSFOZ3B3eZoASUIV3xxzeRbEcPEqlKMl8k4ZpK_M-oFPUjBs/s1600/datasource.png" /></a></div>
<br/>
<div style="text-align: justify;">
4. Then go to <b>Main</b> --> <b>Generate</b> under <b>Data Source</b></div>
<div style="text-align: justify;">
5. Go through the wizard and generate the data service.</div><br/><i>Note the data service name that we have used in this use case is "patient_data_DataService"</i><br/><br/>
<div style="text-align: justify;">
6. Go to <b>Main</b> --> <b>Endpoints</b> and click on <b>Add endpoint</b></div>
<div style="text-align: justify;">
7. Choose <b>Address Endpoint</b> from the list of endpoints and fill in the data as given below</div><br/><i>Since our data service name is "patient_data_DataService", our endpoint address is "http://localhost:8280/services/patient_data_DataService"</i><br/><br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjVzrD45RQ87_RKKjNYkTyGtxgoev2EyhcSTZ8yMekP602kzdVd0u6EzhRKr2rVWAWCv3140tneLmS4GyB4asWANN4hThR3HXgyKiF8LhsbnfaPCHW28fiywQJKnQwPJZUQEvQ0GS_loA/s1600/address_ep.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjVzrD45RQ87_RKKjNYkTyGtxgoev2EyhcSTZ8yMekP602kzdVd0u6EzhRKr2rVWAWCv3140tneLmS4GyB4asWANN4hThR3HXgyKiF8LhsbnfaPCHW28fiywQJKnQwPJZUQEvQ0GS_loA/s640/address_ep.png" width="640" height="253" /></a></div>
<br/><br/>
<b>Writing mediation for the HL7 messages in WSO2 EI</b><br /><br/>
<div style="text-align: justify;">
1. Select <b>Main</b> --> <b>Sequences</b> and click on <b>Add Sequence</b></div>
<div style="text-align: justify;">
2. Switch to the source view and paste the below given sequence</div>
<br/><br/>
<script src="https://gist.github.com/TanyaM/36cf251d57947cc0adab71f226adba83.js"></script><br/><i>Note that we have used a payload factory mediator to extract data from HL7 message and at the end of the sequence we are calling the data service with the newly built payload.</i><br/><br/>
<b>Creating HL7 Inbound endpoint in WSO2 EI</b><br /><br/>
<div style="text-align: justify;">
1. Go to <b>Main</b> --> <b>Inbound Endpoints</b></div>
<div style="text-align: justify;">
2. Then click on <b>Add Inbound Endpoint</b></div>
<div style="text-align: justify;">
3. Give an endpoint name and select Type as <b>HL7</b></div>
<div style="text-align: justify;">
4. Fill in the details as shown in the below image</div>
<br/>
<br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim0J7Wr5vqg2Ojku7aLgBIKLXXdDIW_m-slFMeuEK4RKnZkZlaXUm4NzAsHWK15RSs4DfXcOT1irMZ8fZCCfMOgyPL627kRwn69G-vdR6cCR8pgCjjsFrPQ8cVU97Ry4SmTyRXGfFDyfQ/s1600/ep.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim0J7Wr5vqg2Ojku7aLgBIKLXXdDIW_m-slFMeuEK4RKnZkZlaXUm4NzAsHWK15RSs4DfXcOT1irMZ8fZCCfMOgyPL627kRwn69G-vdR6cCR8pgCjjsFrPQ8cVU97Ry4SmTyRXGfFDyfQ/s1600/ep.png" /></a></div><i>Note that the inbound HL7 port is 20000</i>
<br/><br/>
<b>Sending HL7 messages from Hapi Test Panel</b><br /><br/>
Send below HL7 message of type ORU^R01 and version 2.4<br/><br/>
<script src="https://gist.github.com/TanyaM/aa0ea582c84eb292ec984f2ee2f3e61a.js"></script>
<br/>
Now go to your MySQL table and verify whether the following entry is inserted.
<br/><br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMkBHvGPcuYNZapYdjJuG277efyiq_u0YNH-bIbOOLsqdi7lrwGEG4XE4lH1sgJlDX1yFBGEXNi27sHAi_fev6mrUZvQ2nMHDL33UttMM9lTHW3m4melLd-JkBd4JcfnwKtuLJpN9Ybmg/s1600/mysql_insert.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMkBHvGPcuYNZapYdjJuG277efyiq_u0YNH-bIbOOLsqdi7lrwGEG4XE4lH1sgJlDX1yFBGEXNi27sHAi_fev6mrUZvQ2nMHDL33UttMM9lTHW3m4melLd-JkBd4JcfnwKtuLJpN9Ybmg/s1600/mysql_insert.png" /></a></div>
</br>Note that the payload factory mediator is written only to accept messages of type ORU^R01 and version 2.4 and in a real use case we can write the mediation logic in a more generic way to accept differnt type of HL7 messages.Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-40165670406974459812017-03-12T17:13:00.001+05:302017-03-12T17:25:32.024+05:30Sending HL7 messages using Hapi Test PanelThe purpose of this blog post is to describe how to install the Hapi Test Panel in an ubuntu environment and send HL7 messages using that.
<br/><br/>
<b>What is Hapi Test Panel ?</b><br /><br/>
The HAPI Test Panel is a tool that can be used to send, receive and edit HL7 messages.
<br /><br/>
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggek0mGbvP269YhtWoac1B7C1EptLx_7sn8PR7-pPx3vpHS1fZhsXx28Z6eam64sJsIF2fSs1Tq3S80Lh89BON955DkyDm1MbyHMMpPJbSga26e_SGHSmoAU1F-P5gzR6GWDekBI-OMr0/s1600/Hl7_testpanel.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggek0mGbvP269YhtWoac1B7C1EptLx_7sn8PR7-pPx3vpHS1fZhsXx28Z6eam64sJsIF2fSs1Tq3S80Lh89BON955DkyDm1MbyHMMpPJbSga26e_SGHSmoAU1F-P5gzR6GWDekBI-OMr0/s640/Hl7_testpanel.png" width="640" height="345" /></a></div>
<br/><br/>
<b>How to install in Ubuntu ?</b><br /><br/>
There are multiple ways to install Hapi Test panel and you can find more information <a href="http://http://hl7api.sourceforge.net/hapi-testpanel/install.html">here</a>.
The approach that I followed was
<div style="text-align: justify;">
1. Download hapi-testpanel-2.0.1-linux.tar.bz2 from <a href="https://sourceforge.net/projects/hl7api/files/hapi-testpanel/2.0.1/">download page</a></div>
<div style="text-align: justify;">
2. Extract the download to your preferred location</div>
<div style="text-align: justify;">
3. Run the <b>testpanel.sh</b> file which is at the Home of the Hapi Test Panel extraction</div>
<br/>
<b>How to send HL7 messages using Test Panel ?</b><br /><br/>
<div style="text-align: justify;">
1. Click on <b>Test</b> Menu and then select <b>Populate Test Panel with Sample Message and Connections</b></div>
<div style="text-align: justify;">
2. You can send the created new message by clicking <b>Send</b> button which is in the top of the middle panel</div><br/>
If you need any specific version or type of message, you can click on <b>File</b> Menu and then select <b>New Message</b>. You can choose your preferred message version and type from the pop up window.<br/>
<br/><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirsF2wCkwGA1un2c5R5GQWljfjC1INCS2Bl9t776AgXWgagbwcWmnRmStT3neohllirsfQ6MMyjIEX-nr4iRP4_EkK19oktViT9sB24stJj_vDmJ7FdtLakLNBNniJtx-q2mbWXm9WWV8/s1600/Screenshot+from+2017-03-12+16-59-21.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirsF2wCkwGA1un2c5R5GQWljfjC1INCS2Bl9t776AgXWgagbwcWmnRmStT3neohllirsfQ6MMyjIEX-nr4iRP4_EkK19oktViT9sB24stJj_vDmJ7FdtLakLNBNniJtx-q2mbWXm9WWV8/s400/Screenshot+from+2017-03-12+16-59-21.png" width="400" height="356" /></a></div>
<br/>
Enjoy sending HL7 messages with Hapi Test Panel !!!Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-70043193099250118322017-01-27T11:55:00.000+05:302017-01-27T11:55:04.207+05:30Loading JsPlumb with RequireJSHave you hit with an error like below ?
<div style="text-align: justify;">
<br /></div>
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: #800000;">Uncaught TypeError: Cannot read property 'Defaults' of undefined</span><br />
<br /></div>
<div style="text-align: justify;">
</div>
Or something similar which says jsPlumb is not loaded with requireJs ?
<br/><br/>
<b>Solution</b><br /><br/>
Add jsPlumb to your shim configuration using the export setting as shown below.<br/><br/>
<script src="https://gist.github.com/TanyaM/634573277cef23c83c3b2d6a84c5c2e5.js"></script>
And then you can use the library in the usual manner.<br/><br/>
<script src="https://gist.github.com/TanyaM/abdad4a693c9d99adc50abd92374f931.js"></script>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-32562015978206397452016-10-29T02:02:00.000+05:302016-10-29T02:06:48.236+05:30Aggregate multiple responses using WSO2 ESBThis blog post explains how we can aggregate multiple responses from different endpoints.
<br/>In my <a href="http://tanyamadurapperuma.blogspot.com/2016/10/call-multiple-endpoints-in-parallel.html">previous</a> post, I explained how we can call multiple endpoints in parallel using WSO2 ESB. So in this post we are aggregating the responses we got from those service calls.
<br/><br/>
<b>Synapse Configuration</b><br /><br/>
<script src="https://gist.github.com/TanyaM/68af165fc06d91fc35f6c2e85f05279c.js"></script>
<br/>
<b>Explanation</b><br /><br/>
In this example, we have aggregated the two responses coming from our two service calls and have wrap them using My_Response tag. So your final message after the aggregation will look like below.<br/><br/>
<script src="https://gist.github.com/TanyaM/4e4b09c2e064fe8bfd0562fb797776cc.js"></script>
Note the following.<br/>
<ul><li>When aggregating we have used the same id (which is "BOOKING_RESPONSE") that we set when we are calling the two services</li>
<li>Inside "onComplete" element you can write the logic you want to perform after the aggregation. It can contain sequences or another call to an endpoint.</li>
<li>In this example we have aggregated the bodies of the two responses without any condition</li>
<li>"Aggregated_Responses" property defined before the aggregate mediator is used to accumulate the aggregated messages inside a single property. Note we have given the name of the property in the "enclosingElementProperty" tag</li>
</ul>
<br/>Apart from aggregating the responses of the service calls sent from clone mediator, we can use the aggregate mediator to aggregate responses of the service calls from iterate mediator as well.<br/>Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-41122477488208704582016-10-29T01:36:00.001+05:302016-10-29T01:36:53.747+05:30Call multiple endpoints in parallel using WSO2 ESBIn this blog post I'm going to explain how to call multiple endpoints in parallel using the Clone Mediator.
<br/><br/>
<b>Synapse Configuration</b><br /><br/>
<script src="https://gist.github.com/TanyaM/1cf01891dc0628e28eb69ee947f3fc4a.js"></script>
<br/>
<b>Explanation</b><br /><br/>
In the above example configuration, we are calling the two endpoints defined in the two call templates in parallel. Similarly by adding multiple "target" elements to the same configuration you can call multiple endpoints in parallel. When using the above configuration same message is cloned and two identical copies of the message is send to the two endpoints.<br/>
<br/>Note the following.<br/>
<ul><li>"sequential" attribute is set to false. Hence the two calls are happening in parallel</li>
<li>A value is set to "id" so that later we can use this id to aggregate the responses from two services</li>
<li>By default "continueParent" is set to false</li>
<li>Instead of the call template you can also use a sequence inside the "target"</li>
</ul>
<br/>In a future post I will explain how we can aggregate the response from the two services when the clone mediator is used to call endpoints.Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com1tag:blogger.com,1999:blog-6617641684691046642.post-71171112580359459772016-10-23T10:30:00.000+05:302016-10-23T10:33:05.705+05:30Adding a new xml element to the payload - WSO2 ESBIn this blog post I'm going to explain how we can insert a single new xml element in to the payload in WSO2 ESB.
<br /><br />
<b>Why not payloadFactory Mediator ?</b><br />
If you are familiar with WSO2 ESB you may know that if we want to change the entire payload into a different payload or build a new payload by extracting properties using the existing payload, we can use payloadFactory mediator. But for this requirement that I'm going to describe, payload factory mediator will not be the ideal mediator due to different reasons. One major reason is, if the current payload is bit lengthy one, you will have to build the other parts of the payload even though you don't need to change them at all.
<br /><br />
<b>If not payloadFactory then what?</b><br />
It will be very convenient to get this requirement done using Enrich Mediator. Enrich Mediator will take your desired OMElement (xml element) using the configuration that you state in the source section and then will insert it to the target location you state.
<br /><br />
<b>Usecase</b><br />
I will explain the configuration using a sample usecase. Say I receive some request into ESB and depending on some properties in the payload I want to set some element in the payload. For an example assume I need to insert a new element into the payload if the received payload is not a valid payload.
<br /><br />
<b>Configuration</b><br />
<script src="https://gist.github.com/TanyaM/bd7bdd4047ffa4e1470ced09640d5062.js"></script>
In the above example I have set the incoming request to ESB in to a property (INCOMING_REQUEST) during a previous mediation. And hence using the first enrich mediator I am replacing the body of the current payload using that property.<br />
So the second mediator is the one actually does the job.<br />
It will take the OMElement given under source which is <br /><script src="https://gist.github.com/TanyaM/23ce94b99ccedae329636d72c2b9a1bd.js"></script> and will insert as a child element of /BookingRequest/Booking xpath location in the INCOMING_REQUEST xml.
<br /><br />
<b>Incoming Request</b><br />
<script src="https://gist.github.com/TanyaM/a692a7052aa2a907f0cc4c799f720001.js"></script>
<br /><br />
<b>After enrich mediator</b><br />
<script src="https://gist.github.com/TanyaM/65089699e6756c801533280f74fd11cc.js"></script>
In this example I have modified the payload by adding only one xml element. Even if you need to add more elements also you can follow the same approach.
<div style="font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="font-family: 'Times New Roman'; font-size: small; text-align: justify;">
<br/>
</span>
</div>
<div>
<u>
<span style="font-family: inherit;">Acknowledgement</span>
</u>
</div>
<div style="text-align: justify;">
Many thanks to Rajith from WSO2 for the tip.
</div>
<div style="font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<br/>
<br/>
</div>Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com2tag:blogger.com,1999:blog-6617641684691046642.post-69309312459795711272014-02-20T11:03:00.000+05:302014-02-20T17:30:44.712+05:30Crowning of WSO2 ESB as "Usain Bolt" in the ESB space !!!<div style="text-align: justify;">
With the latest round of performance testing results published for WSO2 ESB 4.8.1, it is unveiled that the fastest ESB in the ESB space is WSO2 ESB. You can find the complete article <a href="http://wso2.com/library/articles/2014/02/esb-performance-round-7.5/" target="_blank">here</a>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The tests has been conducted against number of leading open source ESB's and it is proven that WSO2 ESB surpasses rest in almost all the scenarios and crowned as the No 1.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Observations</b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div style="text-align: justify;">
The table and the graph below shows the summarized results.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcbvX2dCGtQzgrG_6ZPT8QuXJiWIQGI1CBhiYUqLZ5qU3vFTgnmqmJFgEQy1S5EfCFMwBLsFxCz6cxpkEDJuEKvdunmBjFHPaWQemM6aBJJbyDsSWeXoDfWoUAQM5ewLaE_UuCI3U11qE/s1600/esb_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcbvX2dCGtQzgrG_6ZPT8QuXJiWIQGI1CBhiYUqLZ5qU3vFTgnmqmJFgEQy1S5EfCFMwBLsFxCz6cxpkEDJuEKvdunmBjFHPaWQemM6aBJJbyDsSWeXoDfWoUAQM5ewLaE_UuCI3U11qE/s1600/esb_1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZDP0kTgr5ncZxXnw-RpZvkzlSq0yHUepUdpJdrr0nx5mnLN37Ki5JpVE2B8f1r_ml5TCWgDXdNw1DNtnF1Rb3Ehs2Tbl5wcB4AwfrMNs-LmvsR4IFFISCiQr-hAH3bihde8EKr_qAFVM/s1600/esb_2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZDP0kTgr5ncZxXnw-RpZvkzlSq0yHUepUdpJdrr0nx5mnLN37Ki5JpVE2B8f1r_ml5TCWgDXdNw1DNtnF1Rb3Ehs2Tbl5wcB4AwfrMNs-LmvsR4IFFISCiQr-hAH3bihde8EKr_qAFVM/s1600/esb_2.png" /></a></div>
<div style="text-align: justify;">
<b>Conclusion</b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div style="text-align: justify;">
<b><span style="color: #660000;">WSO2 ESB 4.8.1 has continued to outperform all other compared ESBs in almost all scenarios !!!</span></b></div>
<div style="text-align: justify;">
<b><span style="color: #660000;"><br /></span></b></div>
<div style="text-align: justify;">
<b><span style="color: #660000;"><br /></span></b></div>
<div style="text-align: justify;">
<b><u>References</u></b></div>
<div style="text-align: justify;">
[1]<b> </b><a href="http://wso2.com/library/articles/2014/02/esb-performance-round-7.5/">http://wso2.com/library/articles/2014/02/esb-performance-round-7.5/</a></div>
<div style="text-align: justify;">
<br /></div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-500855279826730702014-02-11T20:21:00.001+05:302014-02-11T21:06:15.639+05:30WSO2 User Engagement Server 1.5.0 -Milestone-1 Released !<div style="text-align: justify;">
Let me start this post with a saying.</div>
<div style="text-align: left;">
<b> "Data is worthless if you don't communicate It correctly"</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I'm sure everybody reading this post will agree on the above saying. WSO2 User Engagement Server or simply known as WSO2 UES was released with the aim of providing a set of tools that will ease your data visualization.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
If it is the first time that you are hearing about WSO2 UES, I would suggest you to peep a bit into WSO2 documentation about UES 1.0.0 <a href="http://docs.wso2.org/display/UES100/WSO2+User+Engagement+Server+Documentation" target="_blank">here</a>. Also if you are a developer who is interested in how the things have been done, UES <a href="https://github.com/wso2/ues" target="_blank">git repo</a> is the place for you.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
UES 1.0.0 release was done sometime back and recently we released the milestone one of version 1.5.0 of the product. Milestone 1 mainly contains the initial implementation of Gadget generation tool which will simply take user through a wizard and will draw a graphing gadget visualizing his data.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Are you interested ? Let me walk you through the lanes of UES. First of all download the WSO2 UES 1.5.0 Milestone 1 pack from <a href="http://dist.wso2.org/milestone/ues/1.5.0-M1/wso2ues-1.5.0.zip" target="_blank">here</a>.<br />
<br />
<span style="color: #38761d;">NOTE:</span><br />
<span style="color: #38761d;"> PRODUCT_HOME that I will be referring from here on-wards is the directory where you unzipped the downloaded pack. </span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
OK. Now we are ready to make our hands dirty with our data :)<br />
<br />
<b>Place your RDBMS driver at <PRODUCT_HOME>/repository/components/lib/</b><br />
For an example if your data resides in a mysql database, place the mysql driver at the above location.<br />
<span style="color: #660000;">(IMPORTANT : If you have started the server already, you have to restart after placing the driver.)</span><br />
<br />
<b>Start the downloaded pack as you start any of the WSO2 products.</b></div>
<ul><span style="text-align: justify;">
<li>On Windows: <PRODUCT_HOME>\bin\wso2server.bat</li>
<li>On Linux/Solaris: sh <PRODUCT_HOME>/bin/wso2server.sh</li>
</span></ul>
<span style="text-align: justify;">
</span>
<br />
<div>
<span style="text-align: justify;">You can find more information on how to start the product <a href="http://docs.wso2.org/display/UES100/Running+the+Product" target="_blank">here</a>.</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><b>Go to the browser and open the link</b> </span><a href="http://localhost:9763/portal">http://localhost:9763/portal</a> <b>and login.</b><br />
You will see a page similar to following.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW-jsPZLDllWJiHxj2NmGqa9Jv1ol0ikCUF2pkQwuzj8HCa6yPgAvmjXSkmt7d0IzcmaMfE1mPu48Wz5qFniP10rLt2XzJVVKQzFNlkWJ3ahPokrGmYCLThKcKcGVWmx_iSJkVwU1PyWs/s1600/Screenshot+from+2014-02-11+17:18:44.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW-jsPZLDllWJiHxj2NmGqa9Jv1ol0ikCUF2pkQwuzj8HCa6yPgAvmjXSkmt7d0IzcmaMfE1mPu48Wz5qFniP10rLt2XzJVVKQzFNlkWJ3ahPokrGmYCLThKcKcGVWmx_iSJkVwU1PyWs/s1600/Screenshot+from+2014-02-11+17:18:44.png" height="344" width="640" /></a></div>
<br />
<br />
Find the sign in button on the top right corner of the page. For the moment let's login with following credentials.<br />
Username : admin<br />
Password: admin<br />
Please note that if you need to create a new user and login with that user, you can do so.<br />
<br />
Once you logged in, you will be redirected to the dashboard creation page.<br />
<br />
<b>Click Create on top left corner and select Dashboard.</b><br />
<b><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6pP52FCgFgsHtUMon8tSeQ5IVMTfls-KomR-FeAP-_Z90-G5pbcu6-rxPOq_6mYYkeQyY1qQsauXSzc8CpyXu4HApSz3W70HHPS0VGltokeISjTIB_tcVhT8x2L6CjZSdnaOSiF3s1QY/s1600/das_1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6pP52FCgFgsHtUMon8tSeQ5IVMTfls-KomR-FeAP-_Z90-G5pbcu6-rxPOq_6mYYkeQyY1qQsauXSzc8CpyXu4HApSz3W70HHPS0VGltokeISjTIB_tcVhT8x2L6CjZSdnaOSiF3s1QY/s1600/das_1.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<b>Give a preferred name to the dashboard and select a layout. Then click on Create new app.</b><br />
Layout defines the arrangement of gadgets in your dashboard.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_YdkKfbCLsUsBbXrMe1-9dpd_G8OmOZ3o8tYZmEdNS8Coa2gPE90O_1RewTb0uHpdbnVN46K21TX-4qN_nA4iwqy9Mllc0oQVU2tGJlJFRo9XKckwOOUTFvrHbeFa5FJdDvnWvgUkmOY/s1600/das2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_YdkKfbCLsUsBbXrMe1-9dpd_G8OmOZ3o8tYZmEdNS8Coa2gPE90O_1RewTb0uHpdbnVN46K21TX-4qN_nA4iwqy9Mllc0oQVU2tGJlJFRo9XKckwOOUTFvrHbeFa5FJdDvnWvgUkmOY/s1600/das2.png" /></a></div>
<br />
<div style="text-align: justify;">
Then you will be redirected to the dashboard designer window where you can add gadgets to the created dashboard.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Click on "Add Gadget" button on any of the blocks visible and follow the wizard.</b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzlMqGwCjCcYhln7Lieec2EPaHm4y_DreV3f1e3FnS1g5IUJcWtKpfhQCmi0n29M-Y0laVLCjfoXb4c23TxsfrGOfC9GjYwfxlRyRp0etMT8xa8I3D6wr-Vj-46TaOVXkWzvPLkQJJsRY/s1600/das3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzlMqGwCjCcYhln7Lieec2EPaHm4y_DreV3f1e3FnS1g5IUJcWtKpfhQCmi0n29M-Y0laVLCjfoXb4c23TxsfrGOfC9GjYwfxlRyRp0etMT8xa8I3D6wr-Vj-46TaOVXkWzvPLkQJJsRY/s1600/das3.png" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<span style="text-align: justify;"><b>Select your preferred data-source and click Next.</b></span><br />
<span style="color: #38761d; text-align: justify;">NOTE :</span><br />
<span style="color: #38761d; text-align: justify;"> Since this is milestone 1 of the tool, we have completed the implementation only for RDBMS. So please bear with us, we will support rest of the data-source types in coming releases.</span><br />
<span style="text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigobFiD66oIdfh1Y5LVFWClraHuGW-BqSRSTl7ewr2NhyphenhyphenAF_lvT59rmJqtpcoXH2m7mAZKRTwIchFZQEYRr8I4Cv3CDCWYod1MBCByF4iH35q45hrtP-mFs0CYQMr0VOvEAksSYk0NDlE/s1600/das4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigobFiD66oIdfh1Y5LVFWClraHuGW-BqSRSTl7ewr2NhyphenhyphenAF_lvT59rmJqtpcoXH2m7mAZKRTwIchFZQEYRr8I4Cv3CDCWYod1MBCByF4iH35q45hrtP-mFs0CYQMr0VOvEAksSYk0NDlE/s1600/das4.png" /></a></div>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><b>Enter the connection details of your data-source and click Next. </b></span><br />
<span style="text-align: justify;">See the image below where I have entered mysql connection details of the database where I want to visualize my data. My database is "std" and both the username and password for the database is "test". </span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Also note that the information of the data-source needs to be of the driver that you placed in the lib folder as stated in first step.</span><br />
<span style="text-align: justify;">Ex: If you place mysql driver in lib folder then connection URL, username and password fields should be of a mysql database.</span><br />
<span style="text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijTfeZ9gPrF-zZss85JifGJ6KdF25hmOHzwG83faiL7z95ZmGc9OGD2LbfwRQtJD7uukn6T5HfIefx35_Hj0l_P15oraLwHssliirhqa3X2D1evjeZv9xpuhckM_prYWl5r2n1pGND4zE/s1600/das4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijTfeZ9gPrF-zZss85JifGJ6KdF25hmOHzwG83faiL7z95ZmGc9OGD2LbfwRQtJD7uukn6T5HfIefx35_Hj0l_P15oraLwHssliirhqa3X2D1evjeZv9xpuhckM_prYWl5r2n1pGND4zE/s1600/das4.png" /></a></div>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><b>Enter your SQL query to get the data from the respective table of the database and Click Next.</b></span><br />
<span style="text-align: justify;">This SQL query can be any complex query which return the columns that you want to visualize in your gadget. </span><br />
<span style="color: #660000; text-align: justify;">NOTE : Do not add the semi-colon at the end of the query.</span><br />
<span style="text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFIYRQHMDLwPpUZ_deIUkdghuAqPznxAhUUAiva4WHALrFIakFZD9XyVTAKjJbPbc-El8ryQHU-2tkjzcmEwJZ-7IibLcg1yU_FXjlAtNu1uGmWIto1RLy0E9yiQeVFftBz8XOYiGcEEE/s1600/das5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFIYRQHMDLwPpUZ_deIUkdghuAqPznxAhUUAiva4WHALrFIakFZD9XyVTAKjJbPbc-El8ryQHU-2tkjzcmEwJZ-7IibLcg1yU_FXjlAtNu1uGmWIto1RLy0E9yiQeVFftBz8XOYiGcEEE/s1600/das5.png" /></a></div>
<span style="text-align: justify;"><br /></span></div>
<span style="text-align: justify;">
</span>
<br />
<div>
<span style="text-align: justify;"><b>Go to "Store Items" and click on your preferred graph type.</b></span><br />
<span style="text-align: justify;"><span style="color: #38761d;">NOTE:</span></span><br />
<span style="text-align: justify;"><span style="color: #38761d;"> As I mentioned above, at the moment we only support the chart types that I have caged with a rectangle (Line chart and Bar chart). Await for more chart types in future.</span></span><br />
<span style="text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: justify;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzdIvUFhasprIWT0PWX_AhsYYA2GLtnU1-30J1rxpRMeUH4ShO06UBDHlGBVuQj4LI0EP8sZvP1j5sl2vK068nBZRLRBVqgnC1iw8VmVZfMJgcL-Y5MYhWPh4doBYE14W7QQmFWc2joWQ/s1600/das6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgzdIvUFhasprIWT0PWX_AhsYYA2GLtnU1-30J1rxpRMeUH4ShO06UBDHlGBVuQj4LI0EP8sZvP1j5sl2vK068nBZRLRBVqgnC1iw8VmVZfMJgcL-Y5MYhWPh4doBYE14W7QQmFWc2joWQ/s1600/das6.png" height="312" width="640" /></a></span></div>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Let's say I select the chart type as "Bar Chart".</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><b>Do the data mapping of the columns as needed and click Next.</b></span><br />
<span style="text-align: justify;"><br /></span>
<br />
<ul><span style="text-align: justify;">
<li>Depending on the SQL query that you submitted in the previous step, the columns retrieved from that particular query will be visible as drop down for each axis. Select the column names from them.</li>
<li>Give the axis label names that you want in your chart.</li>
<li>You can set your chart to be updated at a given interval by setting the Update interval value. Note that update interval is in seconds.</li>
<li>Click on the + mark (shown in the cage), if you want to add more series to the same graph.</li>
</span></ul>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: justify;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk9iUGQBGl41wuhWIgD0iVwmy4y0OkO84T9CoEsZa2Gx_0UQnhhSJOqkx4rcd9BwRrt3CO1Wvn_nWwN9MM1WKv0QpK9b20wjum3q2xHiJl87t_af3PEx2m3GjGTQeovjB80IWTHSuPy98/s1600/das7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk9iUGQBGl41wuhWIgD0iVwmy4y0OkO84T9CoEsZa2Gx_0UQnhhSJOqkx4rcd9BwRrt3CO1Wvn_nWwN9MM1WKv0QpK9b20wjum3q2xHiJl87t_af3PEx2m3GjGTQeovjB80IWTHSuPy98/s1600/das7.png" /></a></span></div>
<div>
<span style="text-align: justify;"><br /></span></div>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Once you click on the + button, you can add multiple series as follows.</span><br />
<span style="text-align: justify;">Let's say I want to show both Maths marks and Science marks of the students in the same graph. For the first series I have selected Maths marks. Now let's add Science marks for the second series.</span><br />
<span style="text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: justify;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQPiXoxLaDwDQoRKZ0X1afbM4uLTK6vnFWmYb4gxWmly4IVNGjlk9CW0hXiFs_Xt5CqzFaeDcivM66NB9PRMVWu3tHM3WhlIL3CKxDeANYsUIMjQYCU1x2IEnN_lXOaooCSp1QE-E1v5U/s1600/das8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQPiXoxLaDwDQoRKZ0X1afbM4uLTK6vnFWmYb4gxWmly4IVNGjlk9CW0hXiFs_Xt5CqzFaeDcivM66NB9PRMVWu3tHM3WhlIL3CKxDeANYsUIMjQYCU1x2IEnN_lXOaooCSp1QE-E1v5U/s1600/das8.png" /></a></span></div>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Like wise you can add any number of series in the same graph.</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Once you have finish adding the required series click on Next button and you will see your data been visualized into a bar chart as follows.</span><br />
<span style="text-align: justify;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: justify;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6GYjbZ0zGGmcF1n8_X_yAf9W0vPd7CYAb0rfC-rTNe8IWjLMgANV3YLumNPjUIFuoq2ROFDvWQ1W5fJ9qXtJKrXMUT9-sH4S0ltOC8WIw2UDf_Ut0cnADZMqdALoqaXrWdZuwMfKH1ck/s1600/das9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6GYjbZ0zGGmcF1n8_X_yAf9W0vPd7CYAb0rfC-rTNe8IWjLMgANV3YLumNPjUIFuoq2ROFDvWQ1W5fJ9qXtJKrXMUT9-sH4S0ltOC8WIw2UDf_Ut0cnADZMqdALoqaXrWdZuwMfKH1ck/s1600/das9.png" /></a></span></div>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Note that you can customize your chart (change colors, bar width etc) using a simple configuration file to meet your desire.</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><b>Click on the title "Bar Chart" on the top of the added gadget and change the title of your chart.</b></span><br />
<span style="text-align: justify;"><b><br /></b>
Enjoy adding as many as gadgets you need in to your dashboard.</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">Once you have completed adding gadgets click on <b>Save</b> on top right corner to save your dashboard.</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"><span style="color: #660000;"><u>IMPORTANT</u></span></span><br />
<span style="text-align: justify;">Gadget gen tool feature is in its very early stages, you will encounter number of bugs and feature limitations, we are working on improving these in future milestones.</span><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;"> <u>Limitations</u></span><br />
<ul><span style="text-align: justify;">
<li>Only supports connecting to RDBMS data source at the moment.</li>
<li>Line chart and Bar chart templates have been re-factored and rest of the charts will be done in future milestones.</li>
<li>Wizard UI will to be styled and polished in coming releases.</li>
<li>Error handling and validations are yet to be done.</li>
<li>Supporting text based x-axis ticks has been done and other special data types (ex : date/time) has not been done yet. Because by default flot (graphing library used for gadgets) supports only integer based x-axis ticks)</li>
</span></ul>
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">More good things are yet to come !!!</span><br />
<span style="text-align: justify;">Be with us, tool will be improved more and more in future releases to cater all your data visualization needs.</span><br />
<span style="text-align: justify;"><br /></span></div>
<span style="text-align: justify;">
</span>Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com5tag:blogger.com,1999:blog-6617641684691046642.post-47907175767418318162014-01-07T17:35:00.002+05:302014-01-08T09:47:17.783+05:30Struggling with NoSuchProviderException: smtp or UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed ?<div style="text-align: justify;">
If you have faced with any of the above exceptions this blog post may be a little help for you to clear out some dark areas as I will list out some helpful posts/forums/articles that I ran through to chase away above two nasty fellows. But the main reason for writing this blog post is as a note to myself how I got through the above scary exceptions. </div>
<br />
<div style="text-align: justify;">
I came across the above two exceptions when I was asked to go through <a href="https://wso2.org/jira/browse/UES-466">this</a> issue. The jaggery pom file that this jira is referring was <a href="https://github.com/wso2/jaggery/blob/6eeab8002b7559a11191c896d85e06f4f392d33d/components/hostobjects/org.jaggeryjs.hostobjects.email/pom.xml">this</a>. As said in the jira when the jaggery level email feature is enabled, Axis2 email transport is not working and throwing the above said exception of </div>
<br />
<span style="color: #660000; font-family: Arial, sans-serif;"><span style="font-size: 14px; line-height: 16px;">ERROR {org.apache.axis2.transport.mail.MailTransportSender} - Error creating mail message or sending it to the configured serverjavax.mail.<b>NoSuchProviderException</b>: smtpat javax.mail.Session.getService(Session.java:782)at javax.mail.Session.getTransport(Session.java:708)at javax.mail.Session.getTransport(Session.java:651)</span></span><br />
<span style="color: #660000; font-family: Arial, sans-serif;"><span style="font-size: 14px; line-height: 16px;">..............................</span></span><br />
<span style="color: #660000; font-family: Arial, sans-serif;"><span style="font-size: 14px; line-height: 16px;"><br /></span></span>
As commented in the jira when I remove the below three lines in jaggery pom file under the export package header, Axis2 email transport started to function without any issue.<br />
<br />
<span style="color: blue;">com.sun.mail.imap;version="2.0.0.wso2v1", </span><br />
<span style="color: blue;">com.sun.mail.pop3;version="2.0.0.wso2v1", </span><br />
<span style="color: blue;">com.sun.mail.smtp;version="2.0.0.wso2v1", </span><br />
<br />
<div style="text-align: justify;">
But after removing those lines I tested the jaggery level email feature with a sample application and it had break the jaggery email feature with the same exception as NoSuchProvider found in jaggery Rhino Engine as follows.</div>
<br />
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;">ERROR {org.jaggeryjs.scriptengine.<wbr></wbr>engine.RhinoEngine} - org.mozilla.javascript.<wbr></wbr>WrappedException: Wrapped org.jaggeryjs.scriptengine.<wbr></wbr>exceptions.ScriptException: javax.mail.<wbr></wbr><b>NoSuchProviderException</b>: smtp (/Test//Test.jag#13)</span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;">[2013-12-23 10:09:21,600] ERROR {org.jaggeryjs.jaggery.core.<wbr></wbr>manager.WebAppManager} - org.mozilla.javascript.<wbr></wbr>WrappedException: Wrapped org.jaggeryjs.scriptengine.<wbr></wbr>exceptions.ScriptException: javax.mail.<wbr></wbr>NoSuchProviderException: smtp (/Test//Test.jag#13)</span></div>
<div style="background-color: white; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;">..........................................</span></div>
<br />
<div style="text-align: justify;">
So that made sense when these exports are there, Axis2 email transport picks the wrong bundle at the class loading which is exported from jaggery. ( Where axis2 needs those bundles of version 1.4.0 it picks that of version 2.0.0.wso2v1) </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Then I thought of going ahead with fixing jaggery level email feature to work without the above three exports. Because even though those bundles were exported, they were used no where in jaggery. So there must be some misery why we have exported these in jaggery pom file.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
To explore what is going behind the scene I played a bit with the pom file by removing all mail related imports/exports and etc as all those are coming from axis2 email transport. And ended up with the following exception.</div>
<div style="text-align: justify;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;">ERROR {org.jaggeryjs.scriptengine.<wbr></wbr>engine.RhinoEngine} - org.mozilla.javascript.<wbr></wbr>WrappedException: Wrapped org.jaggeryjs.scriptengine.<wbr></wbr>exceptions.ScriptException: javax.mail.MessagingException: IOException while sending message;</span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;"> nested exception is:</span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;"><span style="white-space: pre-wrap;"> </span>javax.activation.<wbr></wbr><b>UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed</b>; </span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;"><span style="white-space: pre-wrap;"> </span>boundary="----=_Part_0_<wbr></wbr>1755306561.1387772655287" (/Test//Test.jag#13)</span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;"><br /></span></div>
<div style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="color: #660000;"><br /></span></div>
<div style="background-color: white;">
<div style="text-align: justify;">
<span style="font-family: inherit;">So then my journey started to chase after this exception and came across <a href="http://forum.spring.io/forum/osgi-related/dm-server-general/61205-problems-sending-mime-multipart-mails">this</a> forum post. Go through the below comment by Oleg which shed some light in to the problem.</span></div>
</div>
<div style="background-color: white;">
<div style="text-align: justify;">
<span style="font-family: inherit;">(I will add a screen shot of part of the reply for you to identify which one I'm talking about as there are many replies by Oleg ) </span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSh37OMR_YTSaQNqNIaEEGeKWrZGASE6CNIKvQkxCIWNpmDdfizBgp_9n8XOOz3CwOagfWRq_QN2EUFQ2nJjYQ9GhrZ7jmTfTNPNftomgenac2Y5N0hjvLdhMGIwcQAUKg3XY0Ri_sQg8/s1600/Screenshot+from+2014-01-07+15:05:08.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSh37OMR_YTSaQNqNIaEEGeKWrZGASE6CNIKvQkxCIWNpmDdfizBgp_9n8XOOz3CwOagfWRq_QN2EUFQ2nJjYQ9GhrZ7jmTfTNPNftomgenac2Y5N0hjvLdhMGIwcQAUKg3XY0Ri_sQg8/s1600/Screenshot+from+2014-01-07+15:05:08.png" /></a></div>
<span style="font-family: inherit;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Go ahead reading the complete answer by Oleg. Although that answer ensured that this is some problem with class loading in OSGI level and also why we have exported those in jaggery level, still it didn't provide a solution to the problem.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Then <a href="http://www.spagoworld.org/jira/browse/SPAGIC-581?attachmentOrder=desc">this</a> post came in to play.</span><br />
<span style="font-family: inherit;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmyfq7jVCwfjQh2uq1884L41ecUeUEfpf-LUgLg7DxXcR6VYdTgWdDaMMDmkqmRYFlZpPtAb4MlpKRJLNZ6ORsFDAtiVQXS2z25FDeZTvC3fBV8_dmAWk7dI_IA8IsmmCDekfwS2QcsOU/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmyfq7jVCwfjQh2uq1884L41ecUeUEfpf-LUgLg7DxXcR6VYdTgWdDaMMDmkqmRYFlZpPtAb4MlpKRJLNZ6ORsFDAtiVQXS2z25FDeZTvC3fBV8_dmAWk7dI_IA8IsmmCDekfwS2QcsOU/s1600/2.png" /></a></div>
<span style="font-family: inherit;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Now the problem is more clear that this is due to buggy behavior of javax.activation and javax.mail in osgi level, due to issues in dynamic class loading. I could not go with the suggested approach due to some platform specific reasons of our code.<br />
<br />
Finally the comments in <a href="http://nostacktrace.com/dev/2010/6/24/sending-multipart-mail-in-an-osgi-container.html">this</a> post became savior of mine.<br />
<br />
So the send code is changed as given below.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<div style="text-align: left;">
<span style="color: blue;">public void</span> jsFunction_send() <span style="color: blue;">throws</span> ScriptException { </div>
<div style="text-align: left;">
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( javax.mail.Session.<span style="color: blue;">class</span>.getClassLoader() );</div>
<div style="text-align: left;">
<span style="color: blue;">try</span> {</div>
<div style="text-align: left;">
<span style="color: purple;">message</span>.setContent(<span style="color: purple;">multipart</span>); </div>
<div style="text-align: left;">
Transport.send(<span style="color: purple;">message</span>); </div>
<div style="text-align: left;">
} <span style="color: blue;">catch</span> (MessagingException e) {</div>
<div style="text-align: left;">
<span style="color: blue;">throw new</span> ScriptException(e); </div>
<div style="text-align: left;">
}<span style="color: blue;"> finally</span> { </div>
<div style="text-align: left;">
Thread.currentThread().setContextClassLoader(classLoader);</div>
<div style="text-align: left;">
} </div>
<div style="text-align: left;">
}</div>
<br /></div>
</div>
<div style="background-color: white;">
<span style="font-family: 'Times New Roman'; font-size: small; text-align: justify;"><br /></span></div>
<div style="background-color: white; font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="font-family: 'Times New Roman'; font-size: small; text-align: justify;"><br /></span></div>
<div style="background-color: white;">
<div>
<span style="font-family: inherit;">Done with the self note :) In-case you need to go through the current code, my pom file is <a href="https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.email/pom.xml">here</a> and java class is <a href="https://github.com/wso2/jaggery/blob/master/components/hostobjects/org.jaggeryjs.hostobjects.email/src/main/java/org/jaggeryjs/hostobjects/email/SenderHostObject.java">here</a>.</span></div>
<div style="font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<span style="font-family: 'Times New Roman'; font-size: small; text-align: justify;"><br /></span></div>
<div>
<u><span style="font-family: inherit;">Acknowledgement</span></u></div>
<div style="text-align: justify;">
Many thanks to Pradeep, Kishanthan and Rajith from WSO2 for their help.</div>
<div style="font-family: arial, sans-serif; font-size: 12.800000190734863px;">
<br />
<br /></div>
</div>
</div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-63791332544391083632014-01-07T10:25:00.001+05:302014-01-07T10:37:09.997+05:30Run Your Tests With GreenMail - A simple Mail Server <div style="text-align: justify;">
Let me start this post with some background information why I had to use a simple mail server like GreenMail.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Background story</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
I came across the need of an email or some mechanism that can be used in email related testcases. For an example if I need to send an email within my test case what is the mail account that I can use .</div>
<br />
<div style="text-align: justify;">
Simplest way is create some mail account with <a href="http://mail.google.com/">G-mail</a><span id="goog_407407687"></span><span id="goog_407407688"></span><a href="https://www.blogger.com/"></a>, <a href="http://mail.yahoo.com/%E2%80%8E">Yahoo</a>, <a href="http://www.gmx.com/">Gmx</a> or what ever your preferred free email provider and use credentials of that account and provider's smtp severs.</div>
<div style="text-align: justify;">
<br /></div>
See the example below which is written in <a href="http://jaggeryjs.org/">Jaggery</a>. You can find a detailed sample code <a href="http://jaggeryjs.org/apidocs/sender.jag">here</a>.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span class="kwd" style="background-color: #fefbf3; color: #195f91; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; font-size: 12px; line-height: 20px; white-space: pre-wrap;"> </span><br />
<span class="kwd" style="background-color: #fefbf3; color: #195f91; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> var</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> sender </span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">=</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> </span><span class="kwd" style="background-color: #fefbf3; color: #195f91; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">new</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> email</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">.</span><span class="typ" style="background-color: #fefbf3; color: #cb4b16; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">Sender</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">(</span><span class="str" style="background-color: #fefbf3; color: #268bd2; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">"smtp.gmail.com"</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">,</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> </span><span class="str" style="background-color: #fefbf3; color: #268bd2; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">"25"</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">,</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> </span><span class="str" style="background-color: #fefbf3; color: #268bd2; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">"mytestmail@gmail.com"</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">,</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> </span><span class="str" style="background-color: #fefbf3; color: #268bd2; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">"pw"</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">,</span><span class="pln" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;"> </span><span class="str" style="background-color: #fefbf3; color: #268bd2; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">"tls"</span><span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; line-height: 20px; white-space: pre-wrap;">);</span><br />
<span class="pun" style="background-color: #fefbf3; color: #93a1a1; font-family: Monaco, 'Andale Mono', 'Courier New', monospace; font-size: 12px; line-height: 20px; white-space: pre-wrap;"><br /></span>
</div>
<br />
<div style="text-align: justify;">
In the above example we have used the smtp mail server of google (smtp.gmail.com) and a some dummy account that we have created with G-mail. Similarly you can do the same with your preferred free email provider.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
But the problem with this approach is when you run your test repeatedly for sometime (may be a year or so) test case starts failing. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Recently I had to go through the same issue and I was amazed when I found out that it is a problem with the credentials that I used in the code which used to be pass the test without any issue earlier. (In the above example "<span style="color: #274e13;">mytestmail@gmail.com</span>" and password "<span style="color: #274e13;">pw</span>") So I tried login to that gmail account and Google complained with the following message.</div>
<div style="text-align: justify;">
<br /></div>
<div style="background-color: white; font-family: arial, sans-serif;">
<i><span style="color: #660000;">"Please change your password</span></i></div>
<div style="background-color: white; font-family: arial, sans-serif;">
<i><span style="color: #660000;">We've detected suspicious activity on your Google Account. Please choose a new password to finish signing in. "</span></i></div>
<div style="background-color: white; font-family: arial, sans-serif;">
<br /></div>
<div style="background-color: white;">
<div style="text-align: justify;">
Google is suspicious with the account due to reasons listed <a href="https://support.google.com/accounts/answer/140921?hl=en">here</a> and the reason for this particular account may be "<i>Messages that you didn't send appear in Sent Mail </i>".I could have got this issue fixed by resetting the password of this account as instructed in the above message. But someday I might face the same issue as this is a temporary solution.<br />
<br />
So this solution of simple mail servers popped up with this background. Apart from <a href="http://www.icegreen.com/greenmail/">GreenMail</a>, there are many other simple mail servers available such as <a href="http://james.apache.org/">Apache James</a>, <a href="http://sourceforge.net/projects/dumbster/">Dumbster</a> and so on. But GreenMail was the one that fitted most in to my requirement and I decided to move on with GreenMail.<br />
<br />
<b>How to get GreenMail mail server in your testcase</b><br />
<b><br /></b>
Add the relevant maven dependency in your pom file. You can find GreenMail dependencies for Maven projects <a href="http://www.icegreen.com/greenmail/maven.html">here</a>.<br />
<br />
I added following snippet in my pom file.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: blue;"><dependency></span><br />
<span style="color: #38761d;"> </span><span style="color: blue;"> <groupId></span>com.icegreen<span style="color: blue;"></groupId></span><br />
<span style="color: #38761d;"> </span><span style="color: blue;"><artifactId></span>greenmail<span style="color: blue;"></artifactId></span><br />
<span style="color: #38761d;"> </span><span style="color: blue;"><version></span>1.3.1b<span style="color: blue;"></version></span><br />
<span style="color: #38761d;"> </span><span style="color: blue;"></dependency></span><br />
<br /></div>
<br />
And then added the following imports in my test java class file.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: #38761d;"> </span><span style="color: blue;">import</span><span style="color: #38761d;"> </span>com.icegreen.greenmail.util.GreenMail;<br />
<span style="color: #38761d;"> </span><span style="color: blue;"> import</span><span style="color: #38761d;"> </span>com.icegreen.greenmail.util.ServerSetupTest;<br />
<br /></div>
<br />
Afterwards you have to initialize and start the GreenMail server as stated below in the same test class.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
GreenMail <span style="color: purple;">greenMai</span>l = <span style="color: blue;">new</span> GreenMail ( ServerSetupTest<span style="color: purple;">.SMTP </span>);<br />
<span style="color: purple;">greenMail</span>.start ();<br />
<br /></div>
<br />
Then include what ever your sender code. In my case my sender code is written in Jaggery as below in a separate jaggery (.jag) file. (My test class is pointing to the jaggery file after the Green Mail initialization and start above. )<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: blue;">var</span> <span style="color: purple;">from</span> = <span style="color: #38761d;">"from@localhost.com"</span>;<br />
<span style="color: blue;">var</span> <span style="color: purple;">to</span> = <span style="color: #38761d;">"to@localhost.com"</span>;<br />
<span style="color: blue;">var</span> <span style="color: purple;">subject</span> = <span style="color: #38761d;">"Test Subject"</span>;<br />
<span style="color: blue;">var</span> <span style="color: purple;">content</span> = <span style="color: #38761d;">"Test Content"</span>;<br />
<br />
<span style="color: blue;">var</span> <span style="color: purple;">msg</span> = require(<span style="color: #38761d;">'email'</span>);<br />
<span style="color: blue;">var</span> <span style="color: purple;">email</span> = <span style="color: blue;">new</span> <span style="color: purple;">msg</span>.Sender(<span style="color: #38761d;">"localhost"</span>, <span style="color: #38761d;">"3025"</span>, <span style="color: #38761d;">"from@localhost.com"</span>, <span style="color: #38761d;">"frompw"</span>, <span style="color: #38761d;">"tls"</span>);
<br />
<br />
<span style="color: purple;">email.from </span>=<span style="color: purple;"> from</span>;<br />
<span style="color: purple;">email.to </span>=<span style="color: purple;"> to</span>;<br />
<span style="color: purple;">email.subject </span>=<span style="color: purple;"> subject</span>;<br />
<span style="color: purple;">email.text </span>=<span style="color: purple;"> content</span>;<br />
<br />
<span style="color: purple;">email</span>.send();<br />
print(<span style="color: #38761d;">"email successfully sent"</span>);<br />
<br /></div>
<b><br /></b>You may note in the above code that you don't need any free email provider credentials, but simply xxx@localhost.com and some random password. So your test case will not fail due to credential issues.<br />
<br />
Also note that without specifying the sender information as in the above code you can also embed that information in your configuration files as described in the answer <a href="http://stackoverflow.com/questions/9661907/testing-greenmail-without-installing-a-smtp-server">here</a>.<br />
<br />
Your next step is upon message delivery and you need to check whether the message received is as same as the message sent.<br />
<br />
Given below is how you test whether the sent message subject is as same as the received message subject. You can do the same for mail content as well.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
String subject = greenMail.getReceivedMessages()[<span style="color: blue;">0</span>].getSubject();<br />
assertEquals ( subject , <span style="color: #38761d;">"Test Subject"</span>);<br />
<br /></div>
<br /></div>
</div>
<div style="background-color: white; text-align: justify;">
<span style="background-color: transparent;">Donot forget to stop the GreenMail server at the end.</span><br />
<span style="background-color: transparent;"><br /></span>
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: purple;">greenMail</span>.stop();<br />
<br /></div>
<span style="background-color: transparent;"><br /></span><span style="background-color: transparent;">We are done :) Run your test and see whether your test get passed. </span><br />
<span style="background-color: transparent;"><br /></span>
<span style="background-color: transparent;">If you need any reference you can find my pom file <a href="https://github.com/wso2/jaggery/blob/master/server/integration/pom.xml">here</a> , test class <a href="https://github.com/wso2/jaggery/blob/master/server/integration/src/test/java/org/wso2/jaggery/integration/tests/hostObjects/EmailHostObjectTestCase.java">here</a> and my jaggery file <a href="https://github.com/wso2/jaggery/blob/master/server/integration/src/test/resources/email.jag">here</a>.</span><br />
<span style="background-color: transparent;"><br /></span>
Try out more complex test cases with GreenMail !!!</div>
<div style="background-color: white; text-align: justify;">
<span style="background-color: transparent;"><br /></span></div>
<div style="background-color: white; font-family: arial, sans-serif; text-align: justify;">
<i><span style="color: #660000;"><br /></span></i></div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com1tag:blogger.com,1999:blog-6617641684691046642.post-68347976511218181452013-12-12T11:38:00.002+05:302013-12-12T11:38:29.965+05:30Flot - Get Your Ticks Rotated With Flot-Tickrotor<div style="text-align: justify;">
Once again this blog post is some simple but useful feature that I came across while playing out with <a href="http://flotcharts.org/">Flot</a>.<br />
<br />
<b>Problem</b><br />
Have you ever got into trouble by your x-axis ticks overlapping on each other as you have many to be occupied within a small place-holder or because ticks are too long? It will make your chart look like a mess. </div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWje_grqveq9NJn1RfjTLvHwZ1pb9pP_8FxCgHJ8Ln_ZOhIhPMqXs_Un9uoEQBL1AyifGmGyJm_LnYyRk92gALU8SXMVU5SmA2dl6hIvEjHQVzNjpOZ7tuuYtnXdUwnigCxi713Bp4MlA/s1600/Screenshot+from+2013-12-12+10:45:51.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWje_grqveq9NJn1RfjTLvHwZ1pb9pP_8FxCgHJ8Ln_ZOhIhPMqXs_Un9uoEQBL1AyifGmGyJm_LnYyRk92gALU8SXMVU5SmA2dl6hIvEjHQVzNjpOZ7tuuYtnXdUwnigCxi713Bp4MlA/s1600/Screenshot+from+2013-12-12+10:45:51.png" /></a></div>
<div style="text-align: justify;">
<b>Solution</b></div>
<div style="text-align: justify;">
As a workaround you can increase the width of your place-holder. But you will face into trouble if your place-holder has already occupied the full length of your page or your place-holder size is fixed and you don't have control over it.</div>
<div style="text-align: justify;">
<br />
<b>Best possible solution</b></div>
<div style="text-align: justify;">
Probably you might have thought of rotating them in some angle to get this solved so that the visibility of the ticks get improved. Yes, that is the best possible solution that one can think of. Rotate the x-axis ticks !!!</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So in this blog post I will explain how you can rotate your ticks or in other words display your ticks in some preferred angle.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
It is just simple three step process.<br />
<br /></div>
<div style="text-align: justify;">
<b>1. Clone Flot-Tickrotor from <a href="https://github.com/markrcote/flot-tickrotor">here</a> and place the <a href="https://github.com/markrcote/flot-tickrotor/blob/master/jquery.flot.tickrotor.js">jquery.flot.tickrotor.js</a> along with other flot plugins.</b></div>
<div style="text-align: justify;">
<b>2. Import the script file in your chart file as follows. </b></div>
<div style="text-align: justify;">
<br /></div>
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: #38761d;"><script language="javascript" src="lib/jquery.flot.tickrotor.js" type="text/javascript"></script></span><br />
<br /></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
<b><span style="color: #990000;">IMPORTANT</span> :</b><br />
If you are using jquery.flot.axislabels.js then make sure that you place your jquery.flot.tickrotor.js before the jquery.flot.axislabels.js. Because jquery.flot.tickrotor.js completely redefines X-axis label height and then jquery.flot.axislabels.js modifies it.<br />
<br />
<b>3. In the options section of the xaxis specify the angle that you need to get your ticks rotated as <span style="color: #0b5394;">rotateTicks</span>.</b><br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: #38761d;"> xaxis: {</span><br />
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span> axisLabel: 'Application',</span><br />
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> </span><span style="color: #38761d;">ticks: ticks,</span><br />
<span style="color: #38761d;"> -------------------------</span><br />
<span style="color: #38761d;"> < your other x-axis options goes here ></span><br />
<span style="color: #38761d;"> -------------------------</span><br />
<span class="Apple-tab-span" style="color: #38761d; white-space: pre;"> </span> <span style="color: #0b5394;">rotateTicks: 135</span><br />
<span style="color: #38761d;"> }</span><br />
<br /></div>
<br />
<br />
We are ready to go !!! Now our x-axis ticks have rotated with an angle of 135 degrees.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-sm7IopEbFCbAm82m2evaImw0F4KGKKb3vT7Z6HNOsQuAvtZxs1cS6xVM82PIreP5Mhp9y0rQYvhi5sMhen1gfYvBUd80e1F7J_NuyPoHRvagzDzUZ5EEBMMhR5VnumNioDbGvBq0nbg/s1600/Screenshot+from+2013-12-12+11:01:51.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-sm7IopEbFCbAm82m2evaImw0F4KGKKb3vT7Z6HNOsQuAvtZxs1cS6xVM82PIreP5Mhp9y0rQYvhi5sMhen1gfYvBUd80e1F7J_NuyPoHRvagzDzUZ5EEBMMhR5VnumNioDbGvBq0nbg/s1600/Screenshot+from+2013-12-12+11:01:51.png" /></a></div>
<b><u><br /></u></b>
<span style="color: #990000;"><b>IMPORTANT :</b></span><br />
You need to use the jquery.flot.js file from the <a href="https://github.com/flot/flot/blob/master/jquery.flot.js">flot-branch master</a> as there is some bug fixed done in the master, related to ticks rotation.<br />
<br />
If not, you will end up with your ticks getting repeated as shown in the below image.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh10AGaceSheWQ4C9ba1cmVREicjZFImq8tOyqUNEmcR_xZsZAqZhw0CHcn_nubktfj2pMOYhNmy-YE5IBksAfObTC5w58mwi62aoO7WodJvJZgoKmsJ9ACd6wvj1JQQXZXmy35WwZEu8/s1600/Screenshot+from+2013-12-12+11:17:13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh10AGaceSheWQ4C9ba1cmVREicjZFImq8tOyqUNEmcR_xZsZAqZhw0CHcn_nubktfj2pMOYhNmy-YE5IBksAfObTC5w58mwi62aoO7WodJvJZgoKmsJ9ACd6wvj1JQQXZXmy35WwZEu8/s1600/Screenshot+from+2013-12-12+11:17:13.png" /></a></div>
<br />
You can find the full sample code of the above graph <a href="https://svn.wso2.org/repos/wso2/people/tanya/flot_label_rotate.zip">here</a> .<br />
<br />
<b><u>Acknowledgement</u></b><br />
- Thanks <a href="https://github.com/markrcote">Mark Cote</a> for the flot plugin to get the ticks rotated.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br /></div>
<div style="text-align: justify;">
<br /></div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com1tag:blogger.com,1999:blog-6617641684691046642.post-74808949327693186742013-12-12T00:17:00.003+05:302013-12-12T09:12:47.039+05:30Inter Gadget Communication with WSO2 UES<div style="text-align: justify;">
The main objective of this blog post is to explain how to implement inter-gadget communication with WSO2 User Engagement Server (UES). </div>
<b><br /></b>
<br />
<div style="text-align: justify;">
<b><b>Inter - Gadget Communication</b></b></div>
<div style="text-align: justify;">
Inter-gadget communication that we are talking here is the capability of one gadget to talk with some other gadget. In simple words "is Gadget A capable of sending some data to Gadget B" and "is Gadget B capable of updating itself with the received data". The message paradigm that is used underneath is the publisher - subscriber model.
</div>
<br />
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Publisher - Subscriber Model</b></div>
<div style="text-align: justify;">
As shown in the image given below, publisher publishes the message to a channel and subscribers listen to that channel. Upon a new message in the channel by the publisher, subscribers fetch the message and update their selves accordingly.</div>
<div style="text-align: justify;">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl4wXZjTOvbVURoCkHpRD1Uz53-Cw8J5NRVjBgz0BmNrOBaCh7R_oVtSOUVi1lGRqWd0o_kkqggYsHyhANSCFOko8gXjJt6FIC3ALijw1qg-y3HyV0J2XSny8Pch1LeSVz31lQw_-nKtg/s1600/pub_sub+(2).jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl4wXZjTOvbVURoCkHpRD1Uz53-Cw8J5NRVjBgz0BmNrOBaCh7R_oVtSOUVi1lGRqWd0o_kkqggYsHyhANSCFOko8gXjJt6FIC3ALijw1qg-y3HyV0J2XSny8Pch1LeSVz31lQw_-nKtg/s1600/pub_sub+(2).jpg" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br /></div>
<div style="text-align: justify;">
In a complex scenario, there can be one publisher publishing to multiple channels and also number of subscribers listening to multiple channels. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The role of WSO2 User Engagement Server is to act as the Message Broker in this paradigm.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Implementation</b></div>
<div style="text-align: justify;">
I will explain the implementation of this publisher - subscriber (pub-sub) model with a simple example scenario.</div>
<div style="text-align: justify;">
<br />
Let's say publisher-gadget publishes a random number to a channel and that random number will be shown up in the subscriber-gadget each time that publisher-gadget will publish.<br />
<br />
Gadgets usually communicate with the gadget-container via features and those features are declared in the the <b>ModulPrefs</b> section of gadget.xml file.<br />
<br />
Gadgets convey their interest to either publish or subscribe to a channel via the <b>gadgets.Hub.*</b> API. Therefore the feature titled "<b>pubsub-2</b>" needs to be imported in-order to load the necessary API fragments . As I mentioned earlier this feature can be declared in the ModulePrefs section of our gadget.<br />
<br />
OK. Now let's make our hands dirty with the sample that I described earlier.<br />
<br />
Hint : Once we are done with the implementation we will have two gadgets with the following folder/file structure.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLIr6M6NAYa6lgVYlrB1ziCeSTioylO5hMm4RHl4O4TARIwbURiWGSPfz2S1LdF4HOQnhGXuNVHjkoGjcxwyvfPg5hTDkhT7YgMPlZ8yEPz5bMb93CMFibW0U2q-HzjvFbsv1_9qHerPU/s1600/Screenshot+from+2013-12-11+22:59:10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLIr6M6NAYa6lgVYlrB1ziCeSTioylO5hMm4RHl4O4TARIwbURiWGSPfz2S1LdF4HOQnhGXuNVHjkoGjcxwyvfPg5hTDkhT7YgMPlZ8yEPz5bMb93CMFibW0U2q-HzjvFbsv1_9qHerPU/s1600/Screenshot+from+2013-12-11+22:59:10.png" /></a></div>
<br />
<br />
<b><span style="color: purple;">Publisher Gadget</span></b><br />
Let's see how we can declare this in the publisher - gadget.xml file.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span> <span style="color: #38761d;"><Require feature="</span><span style="color: #990000;">pubsub-2</span><span style="color: #38761d;">"></span><br />
<span style="color: #38761d;"> <Param name="topics"></span><br />
<span style="color: #38761d;"> <![CDATA[</span><br />
<span style="color: #38761d;"> <Topic title="randomNumber </span><span style="color: #990000;">name="my-channel" publish="true"</span><span style="color: #38761d;">/></span><br />
<span style="color: #38761d;"> ]]></span><br />
<span style="color: #38761d;"> </Param></span><br />
<span style="color: #38761d;"> </Require></span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
Pay attention to the sections I have marked in red in the above code snippet. Feature that we have to import is <span style="color: #990000;">pubsub-2</span>. And <span style="color: #990000;">my-channel</span> is the channel that the publisher wishes to publish into. To indicate that this is the publisher gadget we have set <span style="color: #990000;">publish="true"</span>.<br />
<br />
In the sample that I'm going to describe in this post, when somebody clicks the button named "Publish a random number" in the publisher gadget, a random number will be published to my-channel. So let's have a button declared in our gadget.xml file.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;"> <div></span><br />
<span style="color: #38761d;"> <input type="button" value="Publish a random number" onclick="publish()"/></span><br />
<span style="color: #38761d;"> </div></span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
The function call that will be triggered by this button click is publish() and we define it in the js file of our publisher - gadget. (in publisher-gadget.js)<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;"> function publish() {</span><br />
<span style="color: #38761d;"> var message = Math.random();</span><br />
<span style="color: #38761d;"> </span><span style="color: #990000;">gadgets.Hub.publish("my-channel", message);</span><br />
<span style="color: #38761d;"> document.getElementById("output").innerHTML = "Number that is published to the channel : " + message;</span><br />
<span style="color: #38761d;"> }</span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
Once again pay your attention to the red line which says publish the random number to my-channel which we declared in the ModulePrefs section.<br />
<br />
<b><span style="color: purple;">Subscriber Gadget</span></b><br />
As we did in the publisher gadget, we need to import the pubsub-2 feature and declare this gadget as a subscriber gadget in the subscriber-gadget.xml file.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;"> <Require feature="</span><span style="color: #990000;">pubsub-2</span><span style="color: #38761d;">"></span><br />
<span style="color: #38761d;"> <Param name="topics"></span><br />
<span style="color: #38761d;"> <![CDATA[</span><br />
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span><Topic title="randomNumber" </span><span style="color: #990000;">name="my-channel"</span><br />
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span>description="Subscribes to random number channel" type="object"</span><br />
<span class="Apple-tab-span" style="color: #38761d; white-space: pre;"> </span><span style="color: #990000;">subscribe="true"</span><span style="color: #38761d;">/></span><br />
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span>]]></span><br />
<span style="color: #38761d;"> </Param></span><br />
<span style="color: #38761d;"> </Require></span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
And then let's have a simple div in the subscriber-gadget.xml file which we can use to set the fetched value from the publisher's channel.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;"> <div id="output"> </div></span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
After that we need to add the following snippet in the subscriber-gadget.js to activate the subscription to "my-channel" channel.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;"> gadgets.HubSettings.onConnect = function () {</span><br />
<span style="color: #38761d;"> gadgets.Hub.subscribe("my-channel", callback);</span><br />
<span style="color: #38761d;"> };</span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
The function that we want to invoke in the subscriber end, upon a message publishing by the publisher is written in the javascript callback function as follows which is also in the subscriber-gadget.js file.<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;"> function callback(topic, obj, subscriberData) {</span><br />
<span style="color: #38761d;"> document.getElementById("output").innerHTML = "Number that is fetched from the channel : " + obj;</span><br />
<span style="color: #38761d;"> }</span><br />
<span style="color: #38761d;"><br /></span>
</div>
<br />
OK. We are done with the pub-sub implementation.<br />
<br />
Finally what we need to do is add these two gadgets to a WSO2 UES dashboard and check out the functionality.<br />
<br />
For that you can follow WSO2 UES documentation on <a href="http://docs.wso2.org/display/UES100/Creating+a+Gadget">how to create a gadget</a> and <a href="http://docs.wso2.org/display/UES100/Creating+a+Dashboard">how to add gadgets to dashboards</a>.<br />
<br />
Or else there is a bit hacky way also ;) (Not recommended. But if you want to check whether your two gadgets working fine, you can try this out.)<br />
<br />
<span style="text-align: left;">1. Copy your two gadgets in </span><b style="text-align: left;">UES_HOME/repository/deployment/server/jaggeryapps/portal/gadgets/</b><br />
<span style="text-align: left;">2. Then create a dashboard (let's say our dashboard is pub-sub) using any two of the existing gadgets (NOT our two gadgets) in UES dashboard.</span><br />
<span style="text-align: left;">3. Open up </span><b style="text-align: left;">UES_HOME/repository/deployment/server/jaggeryapps/pub-sub</b><span style="text-align: left;"> and open up the <b>index.jag</b></span><br />
<span style="text-align: left;">4. Search for word <b>.xml</b> and you will find two of them.</span><br />
<span style="text-align: left;">5. Replace those two urls with the following and save the index.jag file.</span><br />
<span style="text-align: left;"><b> http://localhost:9763/portal/gadgets/publisher/publisher-gadget.xml</b></span><br />
<span style="text-align: left;"><b> http://localhost:9763/portal/gadgets/subscriber/subscriber-gadget.xml</b></span><br />
<span style="text-align: left;"><b><br /></b></span>
<span style="text-align: left;">So your index.jag will have two snippets as follows.</span><br />
<span style="text-align: left;"><br /></span>
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: #38761d;"> <li class="layout_block " data-sizey="2" data-sizex="2" data-col="1" data-row="2" </span><br />
<span style="color: #38761d;"> data-url="</span><span style="color: #990000;">http://localhost:9763/portal/gadgets/publisher/publisher-gadget.xml</span><span style="color: #38761d;">" </span><br />
<span style="color: #38761d;"> data-wid="5" data-prefs="{}" data-title=""></span><br />
<span style="color: #38761d;"><br /></span></div>
</div>
<br />
<br />
<div color:="" d="" style="border: 1.5px solid #000;">
<br />
<span style="color: #38761d;"> <li class="layout_block " data-sizey="2" data-sizex="2" data-col="3" data-row="2"</span><br />
<span style="color: #38761d;"> data-url="</span><span style="color: #990000;">http://localhost:9763/portal/gadgets/subscriber/subscriber-gadget.xml</span><span style="color: #38761d;">" </span><br />
<span style="color: #38761d;"> data-wid="6" data-prefs="{}" data-title=""></span><br />
<span style="color: #38761d;"><br /></span></div>
<br />
6. And then access the dashboard as <a href="https://localhost:9443/pub-sub/">https://localhost:9443/pub-sub/</a><br />
7. You'll see a dashboard as given in the below image.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkGeMEfwV8dTUNOf8Zucn2rDmo-HJOJR7Y74tQexXfcWXsw0RrxQjglxVfW_IV1OZG31UxpSjkqT4mWDXgejB0dCKG6gNUb3CsA5uFgnCJX15CKSD_ApcZujuvcjF9BGDsYGaIu07YDfw/s1600/Screenshot+from+2013-12-12+00:00:19.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="174" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkGeMEfwV8dTUNOf8Zucn2rDmo-HJOJR7Y74tQexXfcWXsw0RrxQjglxVfW_IV1OZG31UxpSjkqT4mWDXgejB0dCKG6gNUb3CsA5uFgnCJX15CKSD_ApcZujuvcjF9BGDsYGaIu07YDfw/s640/Screenshot+from+2013-12-12+00:00:19.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
8. Click on "Publish a random number" button in the publisher gadget and observe that the same number getting printed in the subscriber gadget as well.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv5xuP3oMgnykbwGsHySummxYdWaCwvnMaXkti8LOndGGs0TmsLzcgAEXJRqamu2bBmywUFe9CjKvfpuJP92za-pISM0zzARwHoCT6_P7xdv4TjVhc87kw6xZQSpwVyHgkGNNkZDoHliY/s1600/Screenshot+from+2013-12-12+00:05:50.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgv5xuP3oMgnykbwGsHySummxYdWaCwvnMaXkti8LOndGGs0TmsLzcgAEXJRqamu2bBmywUFe9CjKvfpuJP92za-pISM0zzARwHoCT6_P7xdv4TjVhc87kw6xZQSpwVyHgkGNNkZDoHliY/s640/Screenshot+from+2013-12-12+00:05:50.png" width="640" /></a></div>
<br />
<br />
9. Try clicking on the same button several times and observe the subscriber gadget updating its content accordingly.<br />
<br />
You can download the complete code of the above two gadget from <a href="https://svn.wso2.org/repos/wso2/people/tanya/pub-sub/">here</a>.<br />
<br />
<b>Real World Scenario</b><br />
Let's say we have a time slider as the publsiher gadget. Upon a time period selection on the slider, we need to display the number of builds per apps within that period in a seperate gadget. So the later gadget acts as the subscriber by listening to the time slider gadget's channel.<br />
<br />
You can do whole lot of things with WSO2 UES pub-sub model :)<br />
Enjoy !!!<br />
<br />
<b><u>Acknowledgement</u></b><br />
- Thanks to the WSO2 Gadget Server ( currently deprecated ) <a href="http://docs.wso2.org/pages/viewpage.action?pageId=9372671">documentation</a> on pub-sub model.<br />
<br />
<br />Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com3tag:blogger.com,1999:blog-6617641684691046642.post-14305388039749273032013-12-09T22:04:00.001+05:302013-12-10T10:19:53.006+05:30How to Get Axis Labels in Flot ChartsHave you tried adding axis labels in to any type of Flot chart ? By default Flot does not support axis labels. But it is very easy to get the axis labels with the aid of a simple plugin. So let's see how we can get it done in 3 steps !!!<br />
<br />
<ol>
<li>Git clone <a href="https://github.com/xuanluo/flot-axislabels">this</a> repository and place the <a href="https://github.com/xuanluo/flot-axislabels/blob/master/jquery.flot.axislabels.js">jquery.flot.axislabels.js</a> inside the folder where you have other Flot related libraries or plugins.</li>
</ol>
<div>
<span style="background-color: black;"><span style="color: white;"> git clone https://github.com/xuanluo/flot-axislabels.git</span></span></div>
<div>
<span style="color: #38761d;"><br /></span></div>
<div>
2. Import the script file in the Flot chart file as follows.</div>
<div>
<br /></div>
<div>
<span style="color: #38761d;"> <script language="javascript" type="text/javascript" src="../../jquery.flot.axislabels.js"></script></span></div>
<div>
<span style="color: #38761d;"><br /></span></div>
<div>
3. Pass the axis names and their formatting in the options section along with the other options of X-axis and Y-axis as in the below snippet.</div>
<div>
<br /></div>
<br />
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>xaxis: {</span></div>
<div>
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span> axisLabel: 'X',</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> axisLabelUseCanvas: true,</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span> axisLabelFontSizePixels: 12,</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabelPadding: 5</span></div>
<div>
<span style="color: #38761d;"><br /></span></div>
<div>
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span> },</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>yaxis: {</span></div>
<div>
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabel: 'Sin(X)',</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabelUseCanvas: true,</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabelFontSizePixels: 12,</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',</span></div>
<div>
<span style="color: #38761d;"> <span class="Apple-tab-span" style="white-space: pre;"> </span>axisLabelPadding: 5</span></div>
<div>
<span style="color: #38761d;"><br /></span></div>
<div>
<span style="color: #38761d;"><span class="Apple-tab-span" style="white-space: pre;"> </span> },</span></div>
<div>
<span style="color: #38761d;"><br /></span></div>
<div>
Now you can see the axis labels appearing in your chart as shown in the below image. </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuPJFAtNmFfc1n1WsE2qVPP0STx6AcM4MyqpUW55Mg8T3wY4aiUIYWDlVEDkif-EWR2i3P8K2IgNMuM0VD4-jDmGtTltQyYvleD8Yid8EiUa0xNR_zbSZCwJulQwiPqCy7f8J1vv4SQ78/s1600/Screenshot+from+2013-12-09+21:48:42.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="340" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuPJFAtNmFfc1n1WsE2qVPP0STx6AcM4MyqpUW55Mg8T3wY4aiUIYWDlVEDkif-EWR2i3P8K2IgNMuM0VD4-jDmGtTltQyYvleD8Yid8EiUa0xNR_zbSZCwJulQwiPqCy7f8J1vv4SQ78/s640/Screenshot+from+2013-12-09+21:48:42.png" width="640" /></a></div>
<div>
<br /></div>
<div>
We are done :) It is simple as that.<br />
<br />
Have a look at the <a href="https://github.com/xuanluo/flot-axislabels/blob/master/README">README</a> section of the cloned repository for more details. (Although I said a repository, it is just a single file )</div>
<div>
<br /></div>
<div>
You can refer the full sample code given below in-case if anything was unclear.</div>
<div>
<br /></div>
<pre class="brush: xml"><html>
<head>
<title>Flot Axis Labels</title>
<link href="../examples.css" rel="stylesheet" type="text/css"></link>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../../excanvas.min.js"></script><![endif]-->
<script language="javascript" src="../../jquery.js" type="text/javascript"></script>
<script language="javascript" src="../../jquery.flot.js" type="text/javascript"></script>
<script language="javascript" src="../../jquery.flot.axislabels.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var d1 = [];
for (var i = 0; i < Math.PI * 2; i += 0.25) {
d1.push([i, Math.sin(i)]);
}
$.plot("#placeholder",
[
{ data: d1 }
],
{
series: {
lines: { show: true },
points: { show: true }
},
xaxis: {
ticks: [
0, [ Math.PI/2, "\u03c0/2" ], [ Math.PI, "\u03c0" ],
[ Math.PI * 3/2, "3\u03c0/2" ], [ Math.PI * 2, "2\u03c0" ]
],
axisLabel: 'X',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5,
},
yaxis: {
ticks: 10,
min: -2,
max: 2,
tickDecimals: 3,
axisLabel: 'Sin(X)',
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
axisLabelPadding: 5,
},
grid: {
backgroundColor: { colors: [ "#fff", "#eee" ] },
borderWidth: {
top: 1,
right: 1,
bottom: 2,
left: 2
}
}
});
});
</script>
</head>
<body>
<div id="header">
<h2>
Axis Labels</h2>
</div>
<div id="content">
<div class="demo-container">
<div class="demo-placeholder" id="placeholder">
</div>
</div>
</div>
</body>
</html>
</pre>
<b><u>Acknowledgement
</u></b><br />
[1] <a href="https://github.com/xuanluo/flot-axislabels">https://github.com/xuanluo/flot-axislabels</a><br />
<br />
<br />Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com2tag:blogger.com,1999:blog-6617641684691046642.post-84443883997184841682013-12-04T11:47:00.000+05:302013-12-06T17:58:32.046+05:30WSO2 ESB - Get-rid of Scientific Representation of Large Numbers When Message Transformed Through a XSLT Mediator<div style="text-align: justify;">
In this blog post I'm going to explain how to get-rid of the scientific representation ( ex: 2.2908408306<b>E44 </b>) and get the non-scientific representation of the number when large numbers are mediated through the XSLT mediator. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>Problem</b></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Following diagram explains the problem that I'm going to explain. Note that the large number that is sent across the mediator is derived from defined xpath and do some mediation logic to that particular number. (in this example multiplied by 55 ) The non-scientific number that we sent across the mediator has been converted in to a scientific number.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWwrSi070DDI30zxq4GGH2KB5JOhViR8goL6DezkD-joL_j9KjzgB51pJrswukxWk0Z6b-YHxw-_mzc8eSbq5mJ_rKrGfn7CiYd5B0kTKSQOsVPmwhMf6azh4rhZZQsrfthqdvjRZHFgg/s1600/Screenshot+from+2013-12-04+05:36:18.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWwrSi070DDI30zxq4GGH2KB5JOhViR8goL6DezkD-joL_j9KjzgB51pJrswukxWk0Z6b-YHxw-_mzc8eSbq5mJ_rKrGfn7CiYd5B0kTKSQOsVPmwhMf6azh4rhZZQsrfthqdvjRZHFgg/s1600/Screenshot+from+2013-12-04+05:36:18.png" /></a></div>
<br />
<b>When is this problematic ?</b><br />
<b><br /></b>
Assume that the number that is sent across the mediator is a customer ID. And the mediated customer ID will be sent through some other mediation logic or will be sent to a login portal. But that end will be expecting a non-scientific representation of the customer ID and this will result in a failure in that end.<br />
<br />
<b>Why is the large number represented in a scientific format ?</b><br />
<span style="text-align: justify;"><br /></span>
<span style="text-align: justify;">If you have used WSO2 ESB versions earlier to ESB 4.5.0, you might have noticed that this conversion does not happen. Reason behind this representation is from ESB 4.5.0 on-wards the XSLT engine that does the XSLT mediation has been replaced from xalan 2.7.0 to saxon. So saxon converts large numbers in to scientific representation.</span><br />
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<b>How to reproduce the above scenario ?</b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div style="text-align: justify;">
I will explain how you can reproduce the above scenario using a sample proxy configuration with a sample XSLT style-sheet.<br />
<br />
1. Start WSO2 ESB (tested in ESB 4.7.0) and create a proxy service using the following synapse configuration.</div>
<br />
<pre class="brush: xml"><proxy name="testXSLT" startonload="true" statistics="disable" trace="disable" transports="https,http" xmlns="http://ws.apache.org/ns/synapse">
<target><insequence>
<log level="full">
<xslt key="conf:/users/transform.xslt">
<log level="full">
</log></xslt></log></insequence>
<outsequence>
<send>
</send></outsequence>
</target>
<description>
</description></proxy></pre>
<div style="text-align: justify;">
2. Go to <b>Browse</b> under <b>Registry</b> in the left pane and navigate to <b>/_system/config/users/</b> and Click on <b>Add Resource</b> to add the given XSLT style-sheet (Add it as<b> transform.xslt</b>) and Save.</div>
<br />
<pre class="brush: xml">
<xsl:stylesheet version="1.0" xmlns:cus="http://test.com" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes">
<xsl:template match="/">
<xsl:variable name="customerId"><xsl:value-of select="customerDetail/id"></xsl:value-of></xsl:variable>
<id><xsl:attribute name="CUSTOMER_ID"> <xsl:value-of select="$customerId * 55"></xsl:value-of></xsl:attribute></id>
</xsl:template>
</xsl:output></xsl:stylesheet>
</pre>
<br />
3. Go to back to <b>Services list</b> under <b>Manage</b> in the left pane and click on <b>Try this service</b> under <b>testXSLT</b>. (Our transoformation proxy service is testXSLT)<br />
<br />
4. Use the following sample request to test out the behavior. And then click on <b>Send</b>.<br />
<br />
<span style="color: #a64d79;"><body></span><br />
<span style="color: #a64d79;"> <customerDetail></span><br />
<span style="color: #a64d79;"> <name>Tanya Madurapperuma</name></span><br />
<span style="color: #a64d79;"> <id>416516514654651634984</id></span><br />
<span style="color: #a64d79;"> </customerDetail></span><br />
<span style="color: #a64d79;"></body></span><br />
<br />
5. Go and observe the logs that get printed on the ESB console. (Please note that in the given sample proxy configuration I have paid attention only to the <b>message that is sent through the XSLT mediator and the message that is returned from the mediator</b> but not about what is sent out from the out-sequence as this is just for reproducing the issue. )<br />
<br />
In the sample proxy configuration I have set to log the message before it is sent through the mediator and the message after it is mediated by XSLT mediator.<br />
<br />
Following are the logs that got printed in my console. Note I have marked the important parts of the log in red.<br />
<br />
<span style="color: #38761d;">[2013-12-04 06:24:00,252] INFO - LogMediator To: /services/testXSLT.testXSLTHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:61a7932a-1852-421b-b6f2-fbea95117e95, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><customerDetail><name>Tanya Madurapperuma</name></span><b><span style="color: #cc0000;"><id>416516514654651634984</id></span></b><span style="color: #38761d;"></customerDetail></soapenv:Body></soapenv:Envelope></span><br />
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;">[2013-12-04 06:24:00,383] INFO - LogMediator To: /services/testXSLT.testXSLTHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:61a7932a-1852-421b-b6f2-fbea95117e95, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body></span><b><span style="color: #cc0000;"><id xmlns:cus="http://test.com" CUSTOMER_ID="2.2908408306005837E22"/></span></b><span style="color: #38761d;"></soapenv:Body></soapenv:Envelope></span><br />
<span style="color: #38761d;"><br /></span>
Observe that id which was originally in non-scientific format is converted in to the scientific format once it is sent through the XSLT mediator.<br />
<br />
<b>How to get-rid of the scientific representation ?</b><br />
<b><br /></b>
Now let's look at how we can avoid our number getting converted to a scientific representation. There are two approaches that we can take in order to get this done.<br />
<br />
<u>Approach No 1</u><br />
Change your XSLT style-sheet to get the number formatted back to non-scientific representation as in the following manner.<br />
<br />
format-number($customerId * 55, "#")<br />
<br />
You can edit your style-sheet as follows. Go to <b>Browse</b> under <b>Registry</b> and navigate to <b>/_system/config/users/transform.xslt </b>and click on <b>Edit as text </b>and modify your XSLT style-sheet.<br />
<br />
So at the end of the day your complete style-sheet will look as below.<br />
<br />
<br />
<pre class="brush: xml">
<xsl:stylesheet version="1.0" xmlns:cus="http://test.com" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes">
<xsl:template match="/">
<xsl:variable name="customerId"><xsl:value-of select="customerDetail/id"></xsl:value-of></xsl:variable>
<id><xsl:attribute name="CUSTOMER_ID"> <xsl:value-of select="format-number($customerId * 55, "#")"></xsl:value-of></xsl:attribute></id>
</xsl:template>
</xsl:output></xsl:stylesheet>
</pre>
<br />
<u>Approach No 2</u><br />
Replace the XSLT engine saxon with xalan.<br />
<br />
Although this is not a recommended approach, you can get back the non-scientific representation by replacing the XSLT engine in WSO2 ESB with xalan.<br />
<br />
For that download a WSO2 ESB version prior to 4.5.0. Then follow the below steps.<br />
<br />
1. Go to ESB_HOME_4.7.0/lib/endorsed/ and back up saxon9he.jar and delete it.<br />
2. Go to ESB_HOME_Prior_to_4.5.0/lib/endorsed/ and copy xalan-2.7.0.wso2v1.jar and paste in ESB_HOME_4.7.0/lib/endorsed/<br />
<br />
And then try the transformation proxy with the same sample request.<br />
<br />
So you logs will look like as follows once you have taken any of the above suggested approaches.<br />
<br />
<span style="color: #38761d;">[2013-12-04 11:15:37,167] INFO - LogMediator To: /services/testXSLT.testXSLTHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:5a9fbd26-b905-4e4e-894d-325e5881c50d, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><customerDetail><name>Megan Aguilar</name></span><span style="color: #cc0000;"><b><id>416516514654651634984</id></b></span><span style="color: #38761d;"></customerDetail></soapenv:Body></soapenv:Envelope></span><br />
<span style="color: #38761d;"><br /></span>
<span style="color: #38761d;">[2013-12-04 11:15:37,171] INFO - LogMediator To: /services/testXSLT.testXSLTHttpSoap12Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:5a9fbd26-b905-4e4e-894d-325e5881c50d, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body></span><span style="color: #cc0000;"><b><id xmlns:cus="http://test.com" CUSTOMER_ID="22908408306005836824576"/></b></span><span style="color: #38761d;"></soapenv:Body></soapenv:Envelope></span><br />
<span style="color: #38761d;"><br /></span>
Observe that the number is back in non-scientific format !!!<br />
<br />
<br />Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com0tag:blogger.com,1999:blog-6617641684691046642.post-48428396894896584452013-10-26T08:18:00.000+05:302013-10-27T13:39:36.138+05:30Flot Multi Bar Chart with Text based X-axis Ticks<div style="text-align: justify;">
<a href="http://www.flotcharts.org/">Flot</a> is a javascript plotting library for jquery which has some nice, interactive and easy to use features. Also unlike some other plotting libraries, almost all browsers supports flot graphs.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In this blog post I'm going to explain how to create a multi-bar chart using flot which has text based tick values in X axis. If you have ever played with Flot, you may know why I emphasize the phrase "text based tick values". Because flot normally supports only number based tick values in X-axis. As you read ahead the post, I'll show up the way how to get your texty ticks in X-axis.</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGy6nsdOUCEfZSAwPPR3LjNARmarRloXHlIBmzhiE1u4mnXLyE97pXglDqkfWyI52Lv40BffV6_qoa3XzABNpMVLHMFbpUC9jjwY7v_k8kqgZUyzLM3lL35Qh-npwwIJSo4Zliv7I-MlA/s1600/flot_multi_bar_chart.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGy6nsdOUCEfZSAwPPR3LjNARmarRloXHlIBmzhiE1u4mnXLyE97pXglDqkfWyI52Lv40BffV6_qoa3XzABNpMVLHMFbpUC9jjwY7v_k8kqgZUyzLM3lL35Qh-npwwIJSo4Zliv7I-MlA/s1600/flot_multi_bar_chart.png" /></a></div>
<div style="text-align: justify;">
As you can see in the above graph, I'm going to explain a multi bar chart drawn in order to display the number of successful and failed builds per each application. I will explain the code step by step in drawing the chart.<br />
<br />
<pre class="brush: xml"><!--[if lte IE 8]>
<script type="text/javascript" language="javascript" src="mulit-bar/excanvas.min.js"></script><![endif]-->
<script language="javascript" src="mulit-bar/jquery.js" type="text/javascript"></script>
<script language="javascript" src="mulit-bar/jquery.flot.js" type="text/javascript"></script>
<script language="javascript" src="mulit-bar/jquery.flot.axislabels.js" type="text/javascript"></script>
<script language="javascript" src="mulit-bar/jquery.flot.orderBars.js" type="text/javascript"></script></pre>
<br />
The first script tag contains the excanvas which is needed for support Internet Explorer versions below 9.<br />
<br />
Flot placeholder is a jquery object and therefore you need to add the <b>jquery.js</b>. And then comes the file that is responsible for drawing all these flot charts which is <b>jquery.flot.js</b>. All the flot related library files can be checked out from the <a href="https://github.com/flot/flot">flot github</a> location. (Note: To draw this graph we do not need all those files, but you might need them when trying with other types of graphs or other flot features.)<br />
<br />
By default Flot doesn't come with the support for axis labels. The file <b>jquery.flot.axislabels.js</b> is included to make it possible to mark the axis names of the graph. In the above graph X-axis is named as App and Y-axis is named as No of builds. You can download that flot plugin from <a href="https://github.com/xuanluo/flot-axislabels">here</a>.<br />
<br />
In order to get the multi bar chart to work, we will have to include a plugin called <b>jquery.flot.orderBars.js</b> underneath the above files. You can download the jquery.flot.orderBars.js from <a href="http://www.benjaminbuffet.com/public/js/jquery.flot.orderBars.js">here</a>.<br />
<br />
Below given is the initial data set which I need to get a flot multi bar chart.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgePlXs73qevFcaVxJqINcdUqsmI6EjzTQOWcuNd3lvNCxYxSSt0cmxRowO4FTucfwpwjjQWk4OXuw_Hpr6tggw0nV1Uki_qijchjlomUs-TPRgosIBC7PHJ0oDXz0QwD3aseVc_j2xsP4/s1600/intial_data_set.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgePlXs73qevFcaVxJqINcdUqsmI6EjzTQOWcuNd3lvNCxYxSSt0cmxRowO4FTucfwpwjjQWk4OXuw_Hpr6tggw0nV1Uki_qijchjlomUs-TPRgosIBC7PHJ0oDXz0QwD3aseVc_j2xsP4/s1600/intial_data_set.png" /></a></div>
<br />
<br />
Now let's look at the format of the data that needs to be passed in to the flot graph.<br />
<br />
The format of our initial data will be different from the data that is passed to the flot graph. As I have mentioned above, one reason for that is X-axis of the graph contains text based tick values such as "app4", "app5" and etc. But flot accepts only integer type ticks for the X-axis. So what we do is we come up with some integer mapping to represent each X-axis tick which is text based.<br />
<br />
<pre class="brush: xml">[1, "app4"],
[2, "app5"],
[3, "app6"],
[4, "app7"],
[5, "app8"]
</pre>
<br />
So we map "app4", "app5" and etc with the integer we selected according to the above mapping.(instead of "app4" we put 1, for "app5" we put 2 and so on ) Hence the data that we will be passing to flot will take the following format.<br />
<br />
<pre class="brush: xml">var build_pass_data = [
[1, 4],
[2, 1],
[3, 1],
[4, 4],
[5, 3]
];
var build_fail_data = [
[1, 2],
[2, 3],
[3, 3],
[4, 3],
[5, 6]
];
var data = [
{label: "PASS", data: build_pass_data, bars: {fillColor: "#336600"}, color: "#336600"},
{label: "FAIL", data: build_fail_data, bars: {fillColor: "#E41B17"}, color: "#E41B17"}
]
</pre>
<br />
Along with the data we will pass the fill color and the border color of the bars as well.<br />
<br />
Then we have to tell the flot about the above mapping we used. That information is passed to the flot options. So our options section is as follows.
<br />
<br />
<pre class="brush: xml">var options = {
xaxis: {
min: 0,
max: 7,
mode: null,
ticks: [
[1, "app4"],
[2, "app5"],
[3, "app6"],
[4, "app7"],
[5, "app8"]
],
tickLength: 0,
axisLabel: "App",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: "Verdana, Arial, Helvetica, Tahoma, sans-serif",
axisLabelPadding: 5
}, yaxis: {
axisLabel: "No of builds",
tickDecimals: 0,
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: "Verdana, Arial, Helvetica, Tahoma, sans-serif",
axisLabelPadding: 5
}, grid: {
hoverable: true,
clickable: false,
borderWidth: 1
}, legend: {
labelBoxBorderColor: "none",
position: "right"
}, series: {
shadowSize: 1,
bars: {
show: true,
barWidth: 0.13,
order: 1
}
}
};
</pre>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br />
You might notice that under the "ticks" of xaxis we have placed our mapping. Also note how we have mentioned the X-axis name and the Y-axis name and their formatting.<br />
<br />
Finally we need to pass the data and the options to the flot placeholder.<br />
<br />
<pre class="brush: xml">$.plot($("#placeholder"), data, options);
</pre>
<br />
Additionally we have to specify the css of the placeholder,legend and etc for the better look and feels of the graph.
<br />
<br />
Now we are done with the Flot Multi-bar chart !!!<br />
<br />
I have given the complete code below in-case you need any reference. (enclosed the following code within two html tags.)<br />
<br />
Enjoy plotting with flot :)<br />
<br />
<pre class="brush: xml"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Flot Multi Bar Chart</title>
<style type="text/css">
#placeholder {
width: 1000px;
height: 500px;
position: relative;
margin: 0 auto;
}
.legend table, .legend > div {
height: 82px !important;
opacity: 1 !important;
top: 10px;
right: 10px;
width: 116px !important;
}
.legend table {
border-spacing: 5px;
border: 1px solid #555;
padding: 2px;
}
</style>
<!--[if lte IE 8]>
<script type="text/javascript" language="javascript" src="mulit-bar/excanvas.min.js"></script><![endif]-->
<script language="javascript" src="mulit-bar/jquery.js" type="text/javascript"></script>
<script language="javascript" src="mulit-bar/jquery.flot.js" type="text/javascript"></script>
<script language="javascript" src="mulit-bar/jquery.flot.axislabels.js" type="text/javascript"></script>
<script language="javascript" src="mulit-bar/jquery.flot.orderBars.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
var build_pass_data = [
[1, 4],
[2, 1],
[3, 1],
[4, 4],
[5, 3]
];
var build_fail_data = [
[1, 2],
[2, 3],
[3, 3],
[4, 3],
[5, 6]
];
var data = [
{label: "PASS", data: build_pass_data, bars: {fillColor: "#336600"}, color: "#336600"},
{label: "FAIL", data: build_fail_data, bars: {fillColor: "#E41B17"}, color: "#E41B17"}
];
var options = {
xaxis: {
min: 0,
max: 7,
mode: null,
ticks: [
[1, "app4"],
[2, "app5"],
[3, "app6"],
[4, "app7"],
[5, "app8"]
],
tickLength: 0,
axisLabel: "App",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: "Verdana, Arial, Helvetica, Tahoma, sans-serif",
axisLabelPadding: 5
}, yaxis: {
axisLabel: "No of builds",
tickDecimals: 0,
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: "Verdana, Arial, Helvetica, Tahoma, sans-serif",
axisLabelPadding: 5
}, grid: {
hoverable: true,
clickable: false,
borderWidth: 1
}, legend: {
labelBoxBorderColor: "none",
position: "right"
}, series: {
shadowSize: 1,
bars: {
show: true,
barWidth: 0.13,
order: 1
}
}
};
$.plot($("#placeholder"), data, options);
});
</script>
</head>
<body>
<div id="placeholder">
</div>
</body>
</html>
</pre>
<br /></div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com16tag:blogger.com,1999:blog-6617641684691046642.post-42398517241165853692013-10-20T21:56:00.001+05:302013-11-06T14:20:55.190+05:30Tricky way to modify the userName SCIM claim in WSO2 Identity Server ( IS )<div style="text-align: justify;">
<a href="http://www.simplecloud.info/">SCIM</a> is an open standard for Identity Provisioning. In simple words SCIM is designed to create, maintain (read,update) and deactivate (delete) user accounts and related identities which reside in one or more systems/applications.<br />
<div>
<br /></div>
</div>
<div style="text-align: justify;">
In this blog post, I'm going to explain a tricky way to modify the userName claim. Why I said a tricky way is because you will not be able to simply update it via a curl command as userName claim in carbon user stores is immutable. If you have ever tried updating the userName claim, you might have ended up with an error like this.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
{"Errors":[{"description":"User name is immutable in carbon user store.","code":"500"}]}</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In order to test this, start a WSO2 IS (tested with IS 4.5.0) connected to Active Directory as back-end data store. (You can do it by modifying the user-mgt.xml to connect to a AD instance.)</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
And then go to<b> Configure --> Claim Management</b> and select <b>urn:scim:schemas:core:1.0</b></div>
<div style="text-align: justify;">
<b><br /></b></div>
<div style="text-align: justify;">
Now we have to map the SCIM claims to the existing attributes of the Active Directory. Because when we add a user via SCIM, apart from the userName SCIM claim there are four other SCIM attributes that is being added behind the scene. <br />
( Make sure that you map String type attributes from the AD with the SCIM claims. You can find the AD attributes <a href="http://www.kouti.com/tables/userattributes.htm">here</a>. )</div>
<div style="text-align: justify;">
<br />
<table border="1">
<tbody>
<tr><td><b>CLAIM URI</b></td><td><b>AD Attribute</b></td></tr>
<tr><td>urn:scim:schemas:core:1.0:userName </td><td>mail</td></tr>
<tr><td>urn:scim:schemas:core:1.0:meta.location </td><td>streetAddress</td></tr>
<tr><td>urn:scim:schemas:core:1.0:meta.created </td><td>homePhone</td></tr>
<tr><td>urn:scim:schemas:core:1.0:meta.lastModified </td><td>pager</td></tr>
<tr><td>urn:scim:schemas:core:1.0:id </td><td>homePostalAddress</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br />
Apart from the above mapping add the following mappings as well. (This is for better explanation of this post.)<br />
<br />
<table border="1">
<tbody>
<tr><td><b>CLAIM URI</b></td><td><b>AD Attribute</b></td></tr>
<tr><td>urn:scim:schemas:core:1.0:name.givenName </td><td>givenName</td></tr>
<tr><td>urn:scim:schemas:core:1.0:name.familyName </td><td>company</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br />
First of all let's Create a user via SCIM. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<div style="text-align: left;">
<b>curl -v -k --user username:password --data "{"schemas":[],"name":{"familyName":"Madurapperuma", "givenName":"Tani"},"userName":"tanya@wso2.com","password":"testing123@"}" --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users</b></div>
</div>
<div style="text-align: justify;">
<br />
<span style="font-family: inherit;">You will get a response payload as follows.</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
{"id":"5c05a64c-4f9b-44c7-9092-27cd4dc15640","schemas":["urn:scim:schemas:core:1.0"],"name":{"familyName":"Madurapperuma","givenName":"Tani"},"userName":"tanya@wso2.com","meta":{"lastModified":"2013-10-20T09:47:35","location":"https://localhost:9443/wso2/scim/Users/5c05a64c-4f9b-44c7-9092-27cd4dc15640","created":"2013-10-20T09:47:35"}}<br />
<br />
As I have mentioned above, you will not be able to update the userName SCIM claim after the creation of the user since the userName claim is immutable in carbon user store.<br />
<br />
So with this tricky method you will be able to modify it.<br />
<span style="color: blue;"><b>Map the AD attribute that you have mapped to the userName claim to another SCIM claim and try modifying the newly mapped claim</b>. </span><br />
<br />
In our case we have mapped AD attribute "mail" to SCIM claim "userName". So we will map it to SCIM claim "Emails" as well.<br />
<br />
Now we have the following additional mapping as well.<br />
<br />
<table border="1">
<tbody>
<tr><td><b>CLAIM URI</b></td><td><div style="text-align: right;">
<b>AD Attribute</b></div>
</td></tr>
<tr><td>urn:scim:schemas:core:1.0:emails </td><td><div style="text-align: right;">
mail</div>
</td></tr>
</tbody></table>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now let's try updating SCIM claim "emails".</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: left;">
<b>curl -v -k --user username:password -X PUT -d "{"schemas":[],"userName":"tanya@wso2.com", "emails":"tani@wso2.com"}" --header "Content-Type:application/json" https://localhost:9443/wso2/scim/Users/5c05a64c-4f9b-44c7-9092-27cd4dc15640</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
At this point, you might be worrying that it did not work seeing the response payload. Wait !!! The response payload that I got is as follows. </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
{"id":"5c05a64c-4f9b-44c7-9092-27cd4dc15640","schemas":["urn:scim:schemas:core:1.0"],"userName":"tanya@wso2.com","emails":"tani@wso2.com","meta":{"lastModified":"2013-10-20T09:54:20","location":"https://localhost:9443/wso2/scim/Users/5c05a64c-4f9b-44c7-9092-27cd4dc15640","created":"2013-10-20T09:47:35"}} </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
So hasn't the trick worked ? </div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
Let's get the updated user and see what has happenned.</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>curl -v -k --user username:password https://localhost:9443/wso2/scim/Users/5c05a64c-4f9b-44c7-9092-27cd4dc15640</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: justify;">
Response payload is as follows. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: left;">
{"id":"5c05a64c-4f9b-44c7-9092-27cd4dc15640","schemas":["urn:scim:schemas:core:1.0"],"name":{"familyName":"Madurapperuma","givenName":"Tani"},"userName":"tani@wso2.com","emails":["tani@wso2.com"],"phoneNumbers":[{"value":"2013-10-01T09:54:20","type":"pager"},{"value":"2013-10-01T09:47:35","type":"home"}],"addresses":[{"value":"https://localhost:9443/wso2/scim/Users/5c05a64c-4f9b-44c7-9092-27cd4dc15640","type":"streetAddress"}],"meta":{"lastModified":"2013-10-20T09:54:20","created":"2013-10-20T09:47:35","location":"https://localhost:9443/wso2/scim/Users/5c05a64c-4f9b-44c7-9092-27cd4dc15640"}}</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="text-align: justify;">No more worries :) It has worked. You may notice that it is the same user that we created a while ago. See the familyName and the giveName values if you are not sure. </span></div>
<div style="text-align: left;">
<span style="text-align: justify;"><br /></span></div>
<div style="text-align: left;">
<span style="text-align: justify;">So in summing up, all you have to do is just map the AD attribute that you mapped to SCIM claim userName to another AD attribute that is mutable.</span></div>
<div style="text-align: left;">
<span style="text-align: justify;"><br /></span></div>
<div style="text-align: left;">
<span style="text-align: justify;"><br /></span></div>
<div style="text-align: left;">
<span style="text-align: justify;"><u><b><span style="font-family: inherit;">Acknlowlegement</span></b></u></span></div>
<div style="text-align: left;">
<ul>
<li><span style="text-align: justify;">Venura and Ishara at WSO2 </span></li>
<li><span style="text-align: justify;">Two blog posts by <a href="http://hasini-gunasinghe.blogspot.com/2012/02/scim-to-overcome-identity-provisioning.html">Hasini</a> and <a href="http://sureshatt.blogspot.com/2013/06/scim-user-provisioning-with-wso2.html">Suresh</a></span></li>
</ul>
<div>
<br /></div>
</div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com3tag:blogger.com,1999:blog-6617641684691046642.post-2725822817052651442013-10-05T01:33:00.000+05:302013-12-13T14:36:33.741+05:30Localizing WSO2 Carbon Products - Part 2<h3>
How to generate language fragment bundles to localize Carbon products</h3>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
In <a href="http://tanyamadurapperuma.blogspot.com/2013/10/localizing-wso2-carbon-products-part-1.html">this last</a> blog post, I explained what is localizing, why we need to localize and also why we go ahead with the fragment bundle approach when it comes to localizing WSO2 carbon products.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So as I promised in the last post, will explain how to generate language fragment bundles. </div>
<div style="text-align: justify;">
<ol>
<li>First find out the ui bundles in CARBON_HOME/repository/components/plugins/ that contain Resources.properties files which you need to localize.</li>
<li>And then pack resource files in the folder structure with the proper naming conventions. See the example below.</li>
</ol>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJEtTBlBxdgPV6l8PeRWEUJ1j9MdPAKlp8DT3Ph257Ebq5LjXkiR-l2Aqgqx6aWmcoU_guLQ9lWY1lUVwHvCIaRTBbVIfdeRjxCX8jvNN61Chh4jKmlN1FXZvS1_Y8C25oN_Qs-jxz5iU/s1600/Screenshot+from+2013-10-04+23:16:40.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJEtTBlBxdgPV6l8PeRWEUJ1j9MdPAKlp8DT3Ph257Ebq5LjXkiR-l2Aqgqx6aWmcoU_guLQ9lWY1lUVwHvCIaRTBbVIfdeRjxCX8jvNN61Chh4jKmlN1FXZvS1_Y8C25oN_Qs-jxz5iU/s1600/Screenshot+from+2013-10-04+23:16:40.png" /></a></div>
<div>
<br /></div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: red;">IMPORTANT: Note that folder names (such as org.wso2.carbon.claim.mgt.ui_4.2.0 ) should be named with the original bundle name and the version. ( I will explain later why you need to do so. )</span></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
3. Once you have created the resource files packed in the correct folder structure, place them in the CARBON_HOME/resources folder. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
4. And navigate to the CARBON_HOME/bin and run the following command.</div>
<div style="text-align: justify;">
<pre class="brush: xml">ant localize</pre>
</div>
<div style="text-align: left;">
5. Now go to the CARBON_HOME/repository/components/dropins/. You will see the generated language bundles that you can use to localize.
</div>
<div style="text-align: justify;">
<br />
NOTE: In case if you want to change the location of your resource files or stored location you can change it by passing those as parameters to the ant command.<br />
<pre class="brush: xml">ant localize -Dresources.directory=/data/blog/wso2is-4.5.0/myResources/ -Ddropins.directory=/data/blog/wso2is-4.5.0/myDrpoins/</pre>
But regardless your resource file location, after the generation of fragment bundles, you need to place them in the CARBON_HOME/repository/components/dropins/ directory.<br />
<br />
6. Now you change the locale through browser setting or pass as a query param to the url. And you will observe your page is being localized. Switch between locales and observe that the product getting changed with the new language.<br />
<br />
<h4>
Story behind ant task</h4>
</div>
<div style="text-align: justify;">
In what ever the product you choose to localize, open the<b> build.xml</b> file at <b>CARBON_HOME/bin</b>. Bit down there in that file, there is an ant task called localize.<br />
<br />
If you go through this ant task closely, you may note that the folder name of the resources files are spitted and assigned as fragment host and version.<br />
<br />
<pre class="brush: xml"><ac:for param="file">
<path>
<dirset dir="${resources.directory}" includes="*">
</dirset></path>
<sequential>
<ac:var name="basename" unset="true">
<basename file="@{file}" property="basename">
<echo message="step1 = ${basename}">
<ac:var name="fragmentHost.name" unset="true">
<ac:var name="fragmentHost.version" unset="true">
<ac:propertyregex input="${basename}" property="fragmentHost.name" regexp="(.*)_(.*)" select="\1">
<ac:propertyregex input="${basename}" property="fragmentHost.version" regexp="(.*)_(.*)" select="\2">
</ac:propertyregex></ac:propertyregex></ac:var></ac:var></echo></basename></ac:var></sequential></ac:for></pre>
</div>
Also note that default locations of resources directory is set to CARBON_HOME/resources while dropins directory is set to CARBON_HOME/repository/components/dropins/
<br />
<pre class="brush: xml"><property name="resources.directory" value="${carbon.home}/resources">
<property name="dropins.directory" value="${carbon.home}/repository/components/dropins">
</property></property></pre>
<b><u><br /></u></b>
<b><u>Acknowledgement
</u></b><br />
My thanks goes to Sumedha at WSO2 for his tremendous support given during this task.<br />
<br />
<br />Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com2tag:blogger.com,1999:blog-6617641684691046642.post-31677022711811039072013-10-04T21:35:00.000+05:302013-11-13T10:55:42.705+05:30Localizing WSO2 Carbon Products - Part 1<div style="text-align: justify;">
<h3>
Introduction to Localization of Carbon products </h3>
<br />
WSO2 products are used all over the world and it's users may need to translate a product into different languages when adapting that particular product into their country or region. This process of translating the product into different languages is known as <b>Localization</b>.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
If you open up any WSO2 product and go inside CARBON_HOME/repository/components/plugins, you will see number of jar files. Among those jars the ones that have their names end with <b>ui_<version>.jar</b> are usually the bundles that contains the resources files that needs to localization.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
For an example, let's take WSO2 Identity Server 4.5.0 and go to repository/components/plugins. From that let's select org.wso2.carbon.claim.mgt.ui_4.2.0.jar. Open up the jar using an archive manager or in any preferred way. You may observe folder structure similar to this.<br />
<br /></div>
<div style="text-align: justify;">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqnN0mtXw-ByCE5QiZL-kACaWS7FEeRI8Y1brS2Ou90anhxWHcyZFPlk8v_YmY3gbX8fTpqctY0o6s9Fb8BeLwpsW5oDQfjdwSzhlRZMshVRC0ymtSg_DDdZ-iULGhQTnPyWY0BLTMViI/s1600/Screenshot+from+2013-10-04+21:03:53.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqnN0mtXw-ByCE5QiZL-kACaWS7FEeRI8Y1brS2Ou90anhxWHcyZFPlk8v_YmY3gbX8fTpqctY0o6s9Fb8BeLwpsW5oDQfjdwSzhlRZMshVRC0ymtSg_DDdZ-iULGhQTnPyWY0BLTMViI/s1600/Screenshot+from+2013-10-04+21:03:53.png" /></a></div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The file you see at the very end; <b>Resources.properties</b> file is the one which the page in the UI used to read string values from. If you open the Resources.properties file you'll observe that it contains some name value pairs as below.</div>
<br />
<pre class="brush: xml">claim.mgt=Claim Management
claim.add=Add
add=Add
cancel=Cancel
claim.management=Claim Management
new.claim.details=New Claim Details
</pre>
<div style="text-align: justify;">
First make a copy of this file and name it with the code of the locale of your preferred language. For an example if you want to localize to French, name of your file should look like <b>Resources_fr.properties</b>. And then you need to change the value of the name value pairs to go with your language. For an example you might change the first pair as follows.
</div>
<div style="text-align: justify;">
<br /></div>
<pre class="brush: xml" style="text-align: justify;">claim.mgt=Gestion des réclamations</pre>
<div style="text-align: justify;">
In order to localize the whole product, you need to add a resource file for each ui bundle with your desired language.<br />
<br />
NOTE:<br />
You can have any number of resource files inside one jar as follows. ( So that you can switch between different languages very easily.)<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoA9D79hdRV1eqSVxly_m3CZDC5jMC7C7VohI-16o5D4b8b8-mncuIQnkRrpmfaLp6MT08Acsq7qL-qup6LBOQcB_ubvMKF7jjQL7RxXiSUA2FV6C_1vK2nfTyGPJY5keEPh6Iycp4b3Q/s1600/Screenshot+from+2013-10-04+22%253A48%253A12.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoA9D79hdRV1eqSVxly_m3CZDC5jMC7C7VohI-16o5D4b8b8-mncuIQnkRrpmfaLp6MT08Acsq7qL-qup6LBOQcB_ubvMKF7jjQL7RxXiSUA2FV6C_1vK2nfTyGPJY5keEPh6Iycp4b3Q/s1600/Screenshot+from+2013-10-04+22%253A48%253A12.png" /></a></div>
<br />
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
After that go ahead and change the locale either through browser settings or passing the locale through a url parameter ( as locale=fr ). Now if you refresh the page you will see the page being localized in your preferred language.<br />
<span style="color: red;"><br /></span>
<span style="color: red;">But the problem with this approach is that if you happen to patch any of these jars, you will have to update the Resources.properties file of your preferred language every time that you do so.</span><br />
<span style="color: red;"><br /></span>
So the recommended approach is to localize through fragment bundles which gets attached to the specified host. In my <a href="http://tanyamadurapperuma.blogspot.com/2013/10/localizing-wso2-carbon-products-part-2.html">next post</a> I will be explaining how to generate the fragment bundles to localize WSO2 carbon products.</div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com1tag:blogger.com,1999:blog-6617641684691046642.post-55429125892071728752013-09-30T03:35:00.000+05:302014-01-18T11:59:29.734+05:30Configure WSO2 Identity Server SAML2 IDP with Oracle Weblogic as Service ProviderThis blog post explains How to configure WSO2 Identity Server as SAML2 IDP and Oracle Weblogic as Service Provider.<br />
<br />
You might already know that there are two parties engaged in a single sign on system.<br />
<ol>
<li>Identity Providers (IDP)</li>
<li>Service Providers (SP)</li>
</ol>
<span style="text-align: justify;">So there should be a mechanism for the identity provider to know that this is an authentic service provider and at the same time service provider needs to know that authentication response came from a trusted identity provider. This secure transaction between IDP and SP is ensured by sharing metadata files of the two parties.</span><br />
<div>
<br /></div>
<div>
First let's see <b>How can we configure Weblogic as a Service Provider</b>.</div>
<div>
<br /></div>
<div>
First you need to download and install Weblogic server. You can download it from <a href="http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html">here</a> and follow the README.txt for the installation. </div>
<div>
<br /></div>
<div>
NOTE: Make sure you configure a new domain if you do not have one already.</div>
<div>
<br /></div>
<div>
Start a browser and log in to Oracle weblogic server administration console at <a href="http://localhost:7001/console">http://localhost:7001/console</a></div>
<div>
<br /></div>
<div>
We will be using appB as the sample test application which you can download from <a href="http://www.oracle.com/technetwork/articles/entarch/sso-with-saml-134555.zip">here</a>. </div>
<div>
<br /></div>
<div>
Deploy appB in the Weblogic server. </div>
<div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<ol>
<li>Go to <b>Deployments</b> under <mydomain> and click <b>install</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_GhI8UTLKtfBh6gXeddsAlC0arDe4wHG-YS_36K3LC0ECVTXUaAEUjfiU4HHeeXyQw3OpXHdgklDky9h2cG_asgA3_26quVJ8gmjyAG6_VSOx1Qh85IHQhi2AhcoJHNLiLX8aYgJjnbY/s1600/1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_GhI8UTLKtfBh6gXeddsAlC0arDe4wHG-YS_36K3LC0ECVTXUaAEUjfiU4HHeeXyQw3OpXHdgklDky9h2cG_asgA3_26quVJ8gmjyAG6_VSOx1Qh85IHQhi2AhcoJHNLiLX8aYgJjnbY/s1600/1.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Click <b>upload your file(s)</b> and browse appB.<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Keep all the default options and <b>finish</b> deployment.</li>
</ol>
<div>
Create a user in security realms.</div>
</div>
<div>
<ol>
<li>Go to <b>Security Realms</b> --> <b>myrealm<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9aFfZkx4ZL456wStkag8tZd_WF6yZc6tBCyAN5oQs3kD2g5hQs_HbdyQAQi3PS3TlN7SmYoq6eCuku8mXx_n7xZx-jx198iKdD47oDVsVMAa83CTH7z8WMPaHoQ7XOqWkwXU9BCwFjpU/s1600/2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9aFfZkx4ZL456wStkag8tZd_WF6yZc6tBCyAN5oQs3kD2g5hQs_HbdyQAQi3PS3TlN7SmYoq6eCuku8mXx_n7xZx-jx198iKdD47oDVsVMAa83CTH7z8WMPaHoQ7XOqWkwXU9BCwFjpU/s1600/2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</b></li>
<li>Select <b>Users and Groups</b> tab and Add a <b>New</b> user. (If you are using above appB, create your user as ssouser, because in weblogic.xml file of appB <principal-name> is defined as ssouser.)<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiTQbzqQiDfvF_kIJgJzsDemhQ9t1WDFfOl-uMOa2RlFG71-geY8cc9qal1d-vKgyCI4chXipCB5zUP8oNEmY_5X7pQPQLKFPLtj2qtmxcw7bFSAy2VIvTvnovqFn_JHx-Yy-u3hvSSd8/s1600/3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiTQbzqQiDfvF_kIJgJzsDemhQ9t1WDFfOl-uMOa2RlFG71-geY8cc9qal1d-vKgyCI4chXipCB5zUP8oNEmY_5X7pQPQLKFPLtj2qtmxcw7bFSAy2VIvTvnovqFn_JHx-Yy-u3hvSSd8/s1600/3.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
</ol>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
Create SAML2 Identity Asserter.</div>
</div>
<div>
<ol>
<li>Go to <b>Security Realms</b> --> <b>myrealm</b></li>
<li><b>Providers</b> tab --> <b>Authentication</b> tab and select <b>New</b>.<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwd0TN54QhSTPMqWXjLum3_itMgsecjKNQnWo0CLqRxDJ1opyG4mKr8gL_TJcARZVnMQaucs5gpM-kuOMTPvggNXOZkNgA6d23K4uyWf7_kKKnyX2bnQJHhJrCGmB80tHkmZQt8-kqeEc/s1600/4.png" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwd0TN54QhSTPMqWXjLum3_itMgsecjKNQnWo0CLqRxDJ1opyG4mKr8gL_TJcARZVnMQaucs5gpM-kuOMTPvggNXOZkNgA6d23K4uyWf7_kKKnyX2bnQJHhJrCGmB80tHkmZQt8-kqeEc/s1600/4.png" /></a>
</li>
<li>Create an Identity Asserter choosing the type as <b>SAML2IdentityAsserter</b><br /><div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjL3PSsFNSgF7HHwJ1y1fWwYq2ms9XCkJegGuyololuKQ7l0t6UEkaTSeN6ZZdmlYiL1mmdmAl3aYYjU425dNmMqFGbsimZIIuw38w5qkADGcgWKQyLJXeCKyQoT5U6iQsPXGs5DjIPPQ/s1600/5.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjL3PSsFNSgF7HHwJ1y1fWwYq2ms9XCkJegGuyololuKQ7l0t6UEkaTSeN6ZZdmlYiL1mmdmAl3aYYjU425dNmMqFGbsimZIIuw38w5qkADGcgWKQyLJXeCKyQoT5U6iQsPXGs5DjIPPQ/s1600/5.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Click on the just created SAML2IdentityAsserter and select <b>Management</b> tab. (You need to restart the admin server before this step to get the changes affected.)<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Click on <b>New</b> and select <b>New Web Single Sign-On Identity Provider Partner</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9XbU6NbyqL1h6TcmCw1XJOcNeDC-qJx0yVJgfeC2CvdI9tugyEZ4TkaMh1jnhR_pcjy6fMxs4-RbYQI4cXunGQqDtZEdE6mPkOFTaiM9t93rNYlyV6IRRlRPE7lbAPgZfAdg-BRr5L_w/s1600/6.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9XbU6NbyqL1h6TcmCw1XJOcNeDC-qJx0yVJgfeC2CvdI9tugyEZ4TkaMh1jnhR_pcjy6fMxs4-RbYQI4cXunGQqDtZEdE6mPkOFTaiM9t93rNYlyV6IRRlRPE7lbAPgZfAdg-BRr5L_w/s1600/6.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Browse and give the metadata file of WSO2 Identity Server. (NOTE : At the moment with IS 4.5.0 , it is not possible to auto generate the metadata file. The below given metadata file is one I created manually following the spec. )<pre class="brush: xml"><md:entitydescriptor entityid="https://localhost:9443/samlsso" validuntil="2023-09-23T06:57:15.396Z" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
<md:idpssodescriptor protocolsupportenumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:keydescriptor use="signing">
<ds:keyinfo>
<ds:x509data>
<ds:x509certificate>MIICNTCCAZ6gAwIBAgIES343gjANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJVUzELMAkGA1UE
CAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDTALBgNVBAoMBFdTTzIxEjAQBgNVBAMMCWxv
Y2FsaG9zdDAeFw0xMDAyMTkwNzAyMjZaFw0zNTAyMTMwNzAyMjZaMFUxCzAJBgNVBAYTAlVTMQsw
CQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzENMAsGA1UECgwEV1NPMjESMBAGA1UE
AwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCUp/oV1vWc8/TkQSiAvTou
sMzOM4asB2iltr2QKozni5aVFu818MpOLZIr8LMnTzWllJvvaA5RAAdpbECb+48FjbBe0hseUdN5
HpwvnH/DW8ZccGvk53I6Orq7hLCv1ZHtuOCokghz/ATrhyPq+QktMfXnRS4HrKGJTzxaCcU7OQID
AQABoxIwEDAOBgNVHQ8BAf8EBAMCBPAwDQYJKoZIhvcNAQEFBQADgYEAW5wPR7cr1LAdq+IrR44i
QlRG5ITCZXY9hI0PygLP2rHANh+PYfTmxbuOnykNGyhM6FjFLbW2uZHQTY1jMrPprjOrmyK5sjJR
O4d1DeGHT/YnIjs9JogRKv4XHECwLtIVdAbIdWHEtVZJyMSktcyysFcvuhPQK8Qc/E/Wq8uHSCo=</ds:x509certificate>
</ds:x509data>
</ds:keyinfo>
</md:keydescriptor>
<md:singlelogoutservice binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" location="https://localhost:9443/samlsso" responselocation="https://localhost:9443/samlsso">
<md:singlesignonservice binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" location="https://localhost:9443/samlsso">
<md:singlesignonservice binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" location="https://localhost:9443/samlsso">
</md:singlesignonservice></md:singlesignonservice></md:singlelogoutservice></md:idpssodescriptor>
</md:entitydescriptor>
</pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsCl4IgYe5mPC5GkpmRqQqm_oHpROVLRg-xItcc3WIaKQwgAGU82OvQ1PKZekkHqD2okYgiASv4Q1PAuoaFL_b-ICTT1jnJ1luMOEazyVDl5KRWzBAumj-sq0qVpMuK5pjJ7YXqG-EzGU/s1600/7.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsCl4IgYe5mPC5GkpmRqQqm_oHpROVLRg-xItcc3WIaKQwgAGU82OvQ1PKZekkHqD2okYgiASv4Q1PAuoaFL_b-ICTT1jnJ1luMOEazyVDl5KRWzBAumj-sq0qVpMuK5pjJ7YXqG-EzGU/s1600/7.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Click on the just created Identity Provider Partner and fill the details, tick the options as below and Click <b>Save</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBvllm97NCkixD9X_Bma9yavFqozN8FocCqDLDa2Hc_9lGlMr6wWdM9HM7MqcvE_fe3bhFr8Uh9kj1f19sCctR3Mn8qwchmswSQQNtgUKFg2mo5n1BSF7CXO6p-K0TM4SCjD66hY5VgAI/s1600/8.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBvllm97NCkixD9X_Bma9yavFqozN8FocCqDLDa2Hc_9lGlMr6wWdM9HM7MqcvE_fe3bhFr8Uh9kj1f19sCctR3Mn8qwchmswSQQNtgUKFg2mo5n1BSF7CXO6p-K0TM4SCjD66hY5VgAI/s1600/8.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Verify whether your metadata file has parsed correctly by navigating to <b>Single Sign-On Signing Certificate </b>tab and <b>Single Sign-On Service Endpoints</b> tab.</li>
</ol>
<div>
Configure at server level.</div>
<div>
<ol>
<li>Go to <b>Environment</b> --> <b>Servers </b>and Click on <b>myserver(admin)</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbpyz9LxmC9mWGyjKszNpMtHcbwpewNKhSSZgRHJimSWJVuTfB0krn3b5pIelva0Pz-q7eTMNBHQrjLV60pwkvU24Ai_DII-uQ0DnYdjjviIX3h0QA6JSj5qwcmYdLewNZGBdM13VyeR4/s1600/9.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbpyz9LxmC9mWGyjKszNpMtHcbwpewNKhSSZgRHJimSWJVuTfB0krn3b5pIelva0Pz-q7eTMNBHQrjLV60pwkvU24Ai_DII-uQ0DnYdjjviIX3h0QA6JSj5qwcmYdLewNZGBdM13VyeR4/s1600/9.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Tick the <b>SSL Listen Port Enabled</b> option and <b>Save</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo6QpeH9MFkm3MBiGssI_JGtLkYuOfaLOIhCv17_fCEmzM5_OlUjLCAyo7BxVn5y5xKC0aE7eIj77vztMaBPd1qyegpMfFy5-EDuHyPJcZuGO4v8GHo7ZgSJ0yTQ19QEBtb6v9hde8lpk/s1600/10.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo6QpeH9MFkm3MBiGssI_JGtLkYuOfaLOIhCv17_fCEmzM5_OlUjLCAyo7BxVn5y5xKC0aE7eIj77vztMaBPd1qyegpMfFy5-EDuHyPJcZuGO4v8GHo7ZgSJ0yTQ19QEBtb6v9hde8lpk/s1600/10.png" /></a></div>
</li>
</ol>
<div>
NOTE: We will be using the demo Keystore and if you need you can have your own custom keystore.</div>
<div>
<br /></div>
<div>
SAML2 General Tab configurations.</div>
<div>
<ol>
<li>Go to <b>Federation Services</b> tab --> <b>SAML 2.0 General</b> tab. <div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Fill the fields with relevant information as shown below and <b>Save</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMUtnrvB35ZiTZ8moAZp6HYJ4wd5jD5E54an-dzpbqBQF6jOZIVY4XldFF8OLSct1TmxC5ILnLY1ydr6TLRRfin-psJWk1Cm1IxDU_vuEzs6GIMMy9Jx58Pp6jOret-Hd0ETpMCMjoxWw/s1600/11.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMUtnrvB35ZiTZ8moAZp6HYJ4wd5jD5E54an-dzpbqBQF6jOZIVY4XldFF8OLSct1TmxC5ILnLY1ydr6TLRRfin-psJWk1Cm1IxDU_vuEzs6GIMMy9Jx58Pp6jOret-Hd0ETpMCMjoxWw/s1600/11.png" /></a></div>
</li>
</ol>
<div>
SAML2 Service Provider Tab configurations.</div>
</div>
<div>
<ol>
<li>Go to <b>Federation Services</b> tab --> <b>SAML 2.0 Service Provider</b> tab.<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li><b>Enable</b> it and <b>Save</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR24-DgkyTURBCpru1Zu08F3cGo3yr9jAaSjfNpSFJHMnyUwrkD_LGsYkWoVbKH2SX4mtRGNgnD2tuxbO7pKFJMW5G3jMy1pPW8jq11-Pmiws-3xlwH37XJPLVtv0MYz1sCHJSyHUWyTw/s1600/12.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR24-DgkyTURBCpru1Zu08F3cGo3yr9jAaSjfNpSFJHMnyUwrkD_LGsYkWoVbKH2SX4mtRGNgnD2tuxbO7pKFJMW5G3jMy1pPW8jq11-Pmiws-3xlwH37XJPLVtv0MYz1sCHJSyHUWyTw/s1600/12.png" /></a></div>
</li>
</ol>
<div>
Publish Metadata. (Incase your IDP requires a metadata file from Weblogic server.)</div>
<div>
<ol>
<li>Go back to <b>SAML2 General</b> tab and Click on <b>Publish Meta Data.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC5WcPTHVRDcJQl8cGJNB_gGr4eOyRLB0ZsJHyOMkw_YoEXlWcooDvAeo0ePRmsjTs6Wz_hbVIATuiuRtkNGgY4jWlKVgDgcj14fiQuRxvbQ6CRi7kgCRtwnLrEnap4wt63wtd_9hfY6Y/s1600/13.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC5WcPTHVRDcJQl8cGJNB_gGr4eOyRLB0ZsJHyOMkw_YoEXlWcooDvAeo0ePRmsjTs6Wz_hbVIATuiuRtkNGgY4jWlKVgDgcj14fiQuRxvbQ6CRi7kgCRtwnLrEnap4wt63wtd_9hfY6Y/s1600/13.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</b></li>
<li>Provide a location to save the Weblogic metadata file.</li>
</ol>
<div>
Create SAML Authentication Provider.</div>
</div>
</div>
<div>
<ol>
<li>Go to <b>Security Realms</b> --> <b>myrealm</b></li>
<li><b>Providers</b> tab --> <b>Authentication</b> tab and select <b>New</b>.</li>
<li>Create SAML Authenticator choosing the type as <b>SAMLAuthenticator</b>. <div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzQPuiBK0HZLl_PDKrJDPrKJPyEz9AdAXJxp8rXRO50TaYS4ZI9woL6eM9xjTiWH_d185zac5QLst65w6Lylf-tAVMq9Fgo07OBvFRO4yEYnoIhi39P8N77UuuNdU_KMFAcZTzfBHU4hY/s1600/15.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzQPuiBK0HZLl_PDKrJDPrKJPyEz9AdAXJxp8rXRO50TaYS4ZI9woL6eM9xjTiWH_d185zac5QLst65w6Lylf-tAVMq9Fgo07OBvFRO4yEYnoIhi39P8N77UuuNdU_KMFAcZTzfBHU4hY/s1600/15.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
<li>Click on the just created SAMLAuthenticator.</li>
<li>Go to <b>Configuration</b> tab --> <b>Common</b> tab and select <b>Control Flag</b> as <b>Sufficient</b>.<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGJSEYi9dEwbZVxXuj_3soJFCPblauPw2o4wb_3MrpXF1AnmpaWigNL43ruxehfq_koE1ZkJxJH9a414q-PboviyxQWGgGoNUVLVBq3fq8AFm7tC3NWmOFKRJeoaXe15OwDcHNf3Kx9_A/s1600/16.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGJSEYi9dEwbZVxXuj_3soJFCPblauPw2o4wb_3MrpXF1AnmpaWigNL43ruxehfq_koE1ZkJxJH9a414q-PboviyxQWGgGoNUVLVBq3fq8AFm7tC3NWmOFKRJeoaXe15OwDcHNf3Kx9_A/s1600/16.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
</ol>
<div>
Go to DefaultAuthenticator and select <b>Control Flag</b> as <b>Sufficient </b>as well.</div>
</div>
<div>
<br /></div>
<div>
Now we have done with configuring Weblogic server as the service provider.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Let's have a look <b>how can we configure WSO2 IS to serve as the Identity provider</b>.</div>
<div>
<br /></div>
</div>
<div>
Start WSO2 Identity server (tested in IS 4.5.0) and login as admin.</div>
<div>
<br /></div>
<div>
Create the same user you created in Weblogic server in Identity Server.</div>
<div>
<ol>
<li>Go to <b>Configure</b> tab and click on <b>Users</b>.</li>
<li>Click on Add New User and add the same user.</li>
<li>Give Login permission to that user.</li>
</ol>
</div>
<div>
<br /></div>
<div>
Register new Service Provider.</div>
<div>
<ol>
<li>Go to <b>Main</b> tab and select SAML SSO under <b>Manage</b>.</li>
<li>Click on <b>Register New Service Provider.<div class="separator" style="clear: both; text-align: center;">
</div>
</b></li>
<li>Fill the data as below and click <b>Register</b>.<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4yhsaLHRMLQDbsbBsZMlNTmPvcovlcqBU_nnKxY7xaJVtclphm8FAgjWPcg11jXfsFrVljgwN-pTNbXUup2v5AgE8gWHZNkEmQcDjjSLXSoRxytA9FLcCSCyn1qAPbZqRLK7WXPFErWM/s1600/is_2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4yhsaLHRMLQDbsbBsZMlNTmPvcovlcqBU_nnKxY7xaJVtclphm8FAgjWPcg11jXfsFrVljgwN-pTNbXUup2v5AgE8gWHZNkEmQcDjjSLXSoRxytA9FLcCSCyn1qAPbZqRLK7WXPFErWM/s1600/is_2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</li>
</ol>
Now we have done with configuring both IDP and SP and it's the time to test the SAML2 Application.</div>
<div>
<br /></div>
<div>
Restart the weblogic server + WSO2 IS and go to <a href="localhost:7001/appB/admin/services.jsp">http://localhost:7001/appB/admin/services.jsp </a> and you will be redirected to WSO2 Identity server SAML sso page.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRhLVIYNsZ40bgNtWDEx4OoYQDOcSokVG625x4n6UoHh8MK5zc8XaZ7xu0JFEVhdDHgMDDPjVzSlP36JnHcTr70-5YWyrdb3LyWPaToxm_QUbicYz0pBxqTZYdiLJUXF6tqQeG8s10C7Q/s1600/IS_sso_login_page.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRhLVIYNsZ40bgNtWDEx4OoYQDOcSokVG625x4n6UoHh8MK5zc8XaZ7xu0JFEVhdDHgMDDPjVzSlP36JnHcTr70-5YWyrdb3LyWPaToxm_QUbicYz0pBxqTZYdiLJUXF6tqQeG8s10C7Q/s1600/IS_sso_login_page.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
</div>
<div>
<br /></div>
<div>
Log in with the created user ( in our case ssouser )</div>
<div>
<br /></div>
<div>
If you see the below page, Congratulations !!! You have configured WSO2 IS as SAML2 IDP and Weblogic as SP.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizu1i3cuWSxyMxXWalH2Wbia8vh-rTHse25x4lB9HbQeqgBo66RTaLbxkByznukDw5KgY0nW0CdHJX1REYk29exFu81o5O5cNmUdT8e9AfJGItqRA3L47mt3W0kOnAsG6GQkNnJ8tVi1k/s1600/success.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizu1i3cuWSxyMxXWalH2Wbia8vh-rTHse25x4lB9HbQeqgBo66RTaLbxkByznukDw5KgY0nW0CdHJX1REYk29exFu81o5O5cNmUdT8e9AfJGItqRA3L47mt3W0kOnAsG6GQkNnJ8tVi1k/s1600/success.png" /></a></div>
</div>
<div>
<br /></div>
<div>
<u>Acknowledgement</u></div>
<div>
<ul>
<li>My thanks goes to Prabath and Dulanja at WSO2.</li>
<li>Gilles for <a href="http://morieux.blogspot.com/2012/02/first-issue-authenticate-weblogic-11g.html">this</a> excellent blog post.</li>
</ul>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
Tanyahttp://www.blogger.com/profile/04741778277224514122noreply@blogger.com12