<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Madawa Soysa on Medium]]></title>
        <description><![CDATA[Stories by Madawa Soysa on Medium]]></description>
        <link>https://medium.com/@madawa?source=rss-9f10f0b369bf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RTaaZDgQN0g2Mpz-Tn-eIw.jpeg</url>
            <title>Stories by Madawa Soysa on Medium</title>
            <link>https://medium.com/@madawa?source=rss-9f10f0b369bf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:22:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madawa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a CI/CD Pipeline for WSO2 Enterprise Integrator using GitLab Tools]]></title>
            <link>https://medium.com/@madawa/building-a-ci-cd-pipeline-for-wso2-enterprise-integrator-using-gitlab-tools-431cbd00539d?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/431cbd00539d</guid>
            <category><![CDATA[gitlab-ci]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[wso2-ei]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 01:26:00 GMT</pubDate>
            <atom:updated>2019-08-15T07:27:03.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*5Es3PysUbC_T2NtJtecHUA.png" /></figure><p>WSO2 Enterprise Integrator is a comprehensive integration solution builder that comes with a handy set of development tools which provides a better developer experience to integration solution designers. If you have been working with WSO2 Enterprise Integrator (Formerly WSO2 Enterprise Service Bus) you would know that it comes with an Eclipse-based development studio which enables you to develop ESB Solution Projects as maven modules and package and deploy as a composite archive (CAR) file to the Enterprise Integrator.</p><p>Developer experience can be further improved and made efficient by implementing a CI/CD pipeline to deploy and test implemented integration solutions. Also, a CI/CD will hugely beneficial to manage multiple integration projects.</p><h3>Let’s Begin</h3><p>First set of tools to build this CI/CD pipeline comes with the WSO2 itself, which are developer studio and maven based project structure and maven-car-plugin which helps develop, build and package WSO2 EI Solutions.</p><p>For the next steps, I will be using the following tools,</p><ol><li>Source Code Management — <a href="https://gitlab.com/">GitLab</a></li><li>Automated Testing — <a href="https://www.getpostman.com/">Postman/Newman</a>. Alternatively, Apache JMeter or SoapUI can be used</li><li>Deploying — <a href="https://docs.ansible.com/">Ansible</a>. Alternatively, maven-car-deploy-plugin can be used.</li><li>Pipeline Definition and Execution —<a href="https://docs.gitlab.com/ee/ci/"> GitLab CI/CD tools</a></li></ol><p>I will be discussing how to build a basic pipeline assuming that WSO2 EI is deployed in multiple environments Test (QA), Staging and Production environments. Following flow chart describes the pipeline flow which will build, package and then deploy to Test, Staging and Production environments automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*ru10ZjCWdE92f9Flp81L6A.png" /><figcaption>CI/CD Pipeline Flow Chart</figcaption></figure><h3>Let’s Implement</h3><h4>Step 1</h4><p>First, we need to configure <a href="https://docs.gitlab.com/runner/">GitLab Runner</a> which will be acting as a coordinator for the build jobs and listen to the source code repository for commits. There are three types of runners which are <a href="https://docs.gitlab.com/ee/ci/runners/#shared-specific-and-group-runners">shared, specific and group runners</a>. You can install the Gitlab Runner by going through the following <a href="https://docs.gitlab.com/runner/install/">documentation</a>.</p><blockquote><strong>Note:</strong> If you decide to use shared runners, there is no need to install or register the runners. Therefore you can skip Step 1 and Step 2.</blockquote><h4>Step 2</h4><p>After you have properly installed GitLab Runner, register a single runner or multiple runners with your project if you need to run parallel builds by following <a href="https://docs.gitlab.com/runner/register/index.html">this documentation</a>. When registering runners, you will be asked to choose an executor. There are <a href="https://docs.gitlab.com/runner/executors/">multiple executor types</a> are supported in GitLab Runner. I recommend using the docker executor which will spawn a Docker container for every job within the pipeline.</p><h4>Step 3</h4><p>Let’s now get into pipeline configuration. GitLab CI/CD pipelines are configured using a <a href="https://docs.gitlab.com/ee/ci/yaml/">YAML file within each project</a>.</p><p>I have created the following project demonstrating the pipeline implementation using GitLab Runner docker executor.</p><p><a href="https://gitlab.com/madawa/wso2ei-cicd-demo">Madawa Soysa / wso2ei-cicd-demo</a></p><p>The above project contains a <a href="https://gitlab.com/madawa/wso2ei-cicd-demo/tree/master/WSO2EICICDDemo">WSO2 ESB Solution Project</a> which contains a simple REST API which echoes a message. The project also contains <a href="https://gitlab.com/madawa/wso2ei-cicd-demo/tree/master/tests/postman">tests written using Postman</a> as well as the <a href="https://gitlab.com/madawa/wso2ei-cicd-demo/tree/master/ansible">ansible playbook</a> which is used to deploy the CAR archive to WSO2 Servers.</p><blockquote>Note: Related ansible source can be maintained in a different repository and can be refered from each project instead of duplicating the playbooks in each project.</blockquote><p>Let’s have a closer look at the <a href="https://gitlab.com/madawa/wso2ei-cicd-demo/blob/master/.gitlab-ci.yml">CI/CD configuration</a> for the project.</p><p>The first line specifies the docker image to spawn the container and run the pipeline on.</p><pre>image: registry.gitlab.com/madawa/wso2ei-artifact-builder:ubuntu_latest</pre><p>In this configuration, I have used a custom image I created including all the packages (Java, Maven, Newman, Ansible) needed to build, test and deploy WSO2 EI artefacts. You can either use the same image or build a custom image as per the scenario. The image and the related docker files can be found in the below repository. The same image can be pulled from <a href="https://hub.docker.com/r/madawas/wso2ei-artifact-builder">DockerHub </a>as well.</p><p><a href="https://gitlab.com/madawa/wso2ei-artifact-builder">Madawa Soysa / wso2ei-artifact-builder</a></p><p>Next section of the configuration includes the stages of the pipeline and these will be executed in order.</p><pre>stages:<br>  - build<br>  - qa<br>  - test</pre><blockquote>Note: GitLab CI has default stages build, test and deploy<em> </em>and does not need to specify when default stages are used. However, in this case, we need to deploy the CAR to an existing environment before executing tests.</blockquote><p>Next, the jobs are configured. Jobs define the tasks to run in each stage. Jobs will run in the order of the stages. For example, jobs belong to build will run before jobs belong to qa. There can be multiple jobs that belong to a single-stage which will run in parallel given that there are multiple runners available.</p><h4><strong>Building</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb1d0759067ea1ccd9f455cfc00e139c/href">https://medium.com/media/fb1d0759067ea1ccd9f455cfc00e139c/href</a></iframe><p>This will build the project using maven and archives all the CAR files inside the project and share those with dependent jobs.</p><h4>Deploying to QA</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/56f5ae0b6789fad1bc24e79feece729d/href">https://medium.com/media/56f5ae0b6789fad1bc24e79feece729d/href</a></iframe><p>In the second job, we will be deploying the built CAR archives to the QA environment. This may seem different from a standard CI pipeline as here we do a deployment before testing. Since this is an integration solution, the actual systems should be available for testing. Hence we will first deploy the artefacts to one of the QA environments and run tests against that in the next stage.</p><h4>Testing</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/821ed65c4b45fcc7fe97109a9e75f4fd/href">https://medium.com/media/821ed65c4b45fcc7fe97109a9e75f4fd/href</a></iframe><p>This job will execute the tests against the deployed artifact on the QA environment. The idea here is to run tests belong to a single project which is equivalent to unit testing in the standard development lifecycle. This job will make sure that the solution is working as expected.</p><h3>Extending the Pipeline</h3><p>Up to now, we have built a CI/CD pipeline to build, deploy to QA and run unit tests against the QA environment. Depending on the requirements, we can extend the pipeline to manage the full development cycle until releasing to production. It is just a matter of adding a few more job definitions with some conditions to trigger only when a release is happening.</p><p>When specifying jobs in the GitLab CI configuration, we can use <a href="https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic">only/except</a> parameter to specify conditions to run jobs. Here we can use tags to identify releases.</p><pre>deploy_staging:<br>  stage: staging<br>  <strong>only:<br>    - tags</strong></pre><p>When configured as above, the job will only run when the commit is associated with a tag.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/132b71fbc36ed41fda4117cce9586562/href">https://medium.com/media/132b71fbc36ed41fda4117cce9586562/href</a></iframe><p>This is only a simple example of adding conditions. GitLab CI/CD offers <a href="https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-advanced">advanced configurations</a> to support advanced use cases.</p><h3>Conclusion</h3><p>This article discussed how to implement a CI/CD pipeline to use with WSO2 Enterprise Integrator artifacts using GitLab tools and implementation details of a basic pipeline. This pipeline can be easily customized according to different use cases and requirements.</p><p>There are multiple advantages of using GitLab tools for the CI/CD pipeline.</p><ol><li>Minimal configuration and easy to set up.</li><li>Everything is integrated with GitLab and everything can be managed via the source code repository.<br>e.g. <a href="https://gitlab.com/madawa/wso2ei-cicd-demo/pipelines">https://gitlab.com/madawa/wso2ei-cicd-demo/pipelines</a></li><li>Ability to customize pipelines in each project as the configuration is maintained within the project itself.</li></ol><h3>References</h3><ul><li><a href="https://docs.gitlab.com/ee/ci/">Get started with GitLab CI/CD | GitLab</a></li><li><a href="https://medium.com/wso2-learning/how-to-build-a-ci-cd-pipeline-for-wso2-esb-wso2-ei-1f7ba3cc833d">How to build a CI/CD pipeline for WSO2 ESB (WSO2 EI)</a></li><li><a href="https://medium.com/@mshazninazeer/practical-ci-cd-for-wso2-enterprise-integrator-with-jenkins-a25409009785">Practical CI/CD for WSO2 Enterprise Integrator with Jenkins</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=431cbd00539d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 API Manager Send Custom Authorization Header Based on Endpoint]]></title>
            <link>https://medium.com/@madawa/wso2-api-manager-send-custom-authorization-header-based-on-endpoint-6a8ceddb5151?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a8ceddb5151</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[mediation]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Wed, 06 Feb 2019 06:22:29 GMT</pubDate>
            <atom:updated>2019-02-06T06:22:29.687Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUbufM-5A5capEB4X9zwDA.jpeg" /></figure><p>WSO2 API Manager allows providing two endpoints when creating a managed API which lets you manage the sandbox and the production backends separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGjrnAAlQ7hzsdf11l-OsA.png" /><figcaption><em>Production and Sandbox Endpoints</em></figcaption></figure><p>Assume that the backend is secured and the production and sandbox environments expect different credentials or token via the Authorization header.</p><p>In order to implement this scenario, you can add a mediation policy to manipulate the request parameters before sending to the backend.</p><p>APIs created on API Manager is protected by OAuth2 therefore usually the incoming request which comes to API Manager has the Authorization Header with the OAuth2 access token. Before adding a custom Authorization Header we need to remove the existing header as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c155e2a289c57647b47da7efa9e3f33/href">https://medium.com/media/6c155e2a289c57647b47da7efa9e3f33/href</a></iframe><p>Then we can add our custom header value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/126f0317eff345dd50d65b0306fe4bc1/href">https://medium.com/media/126f0317eff345dd50d65b0306fe4bc1/href</a></iframe><p>To change the header value based on the endpoint, we can use the property AM_KEY_TYPE which is in the message context to identify the endpoint which is called and filter based on that as follows. The value AM_KEY_TYPE will be either PRODUCTION or SANDBOX depending on the endpoint which is going to be invoked.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d248f7191e333e46ed76d27fee5fcf78/href">https://medium.com/media/d248f7191e333e46ed76d27fee5fcf78/href</a></iframe><p>Once the sequence is completed, you can upload the sequence to the API from the Message Mediation Policies section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eh5aYyLYcYwZSOG5oHu8ng.png" /><figcaption>Add mediation policy</figcaption></figure><p>As explained in this article AM_KEY_TYPE property can be used to add different mediation policies based on the actual endpoint without modifying the client to send additional parameters to identify the environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a8ceddb5151" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git — Tips, Tricks & Practices]]></title>
            <link>https://medium.com/@madawa/git-tips-tricks-practices-3af20d162c6b?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3af20d162c6b</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[version-control]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Sat, 03 Feb 2018 14:17:46 GMT</pubDate>
            <atom:updated>2018-02-03T14:17:46.274Z</atom:updated>
            <content:encoded><![CDATA[<h3>Git — Tips, Tricks &amp; Practices</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2TMWFhw06VpZv8hrQUHMFg.jpeg" /></figure><p><a href="https://git-scm.com/">Git</a> is one of the most popular version controlling tool used among developers today. In this post, I’m going to talk about some useful tips, tricks and practices to follow when using git which I learnt while working with <a href="https://git-scm.com/">git</a> and <a href="https://github.com/">GitHub</a>.</p><h4>Managing Multiple Remote Repositories</h4><p>Git allows you to manage projects which have multiple remote repositories. You can verify the existing remote repositories by running the following command. This command lists all the existing remotes and respective URLs.</p><pre>git remote -v</pre><p>You can add a new remote by specifying an identifier and the URL of the repository as follows.</p><pre>git remote add &lt;identifier&gt; &lt;URL&gt;</pre><pre><strong><em>example:</em></strong><em> git remote add public git@github.com:madawas/sample-project.git</em></pre><p>A remote can be renamed or removed too from following commands.</p><pre><strong><em>rename:</em></strong> git remote rename &lt;old_identifier&gt; &lt;new_identifier&gt;</pre><pre><strong><em>remove:</em></strong> git remote rm &lt;identifier&gt;</pre><h4>Viewing &amp; Searching In Commit History</h4><p>Git log displays the commit history of the current branch. The commit history can be simply listed by the command git log . Other than simply viewing logs in the default view, the commit history can be filtered and formatted in different ways.</p><p>Logs can be viewed in a summarized mode by running one of the following command. shortlog command summarizes commit history and groups each commit by author and title. When oneline option is provided, each commit will be shown in one line.</p><pre>git shortlog<br>git log --oneline</pre><p>The --decorate flag makes git log display all of the references (e.g., branches, tags, etc) that relates to each commit.</p><pre>git log --decorate<br>git log --oneline --decorate</pre><p>Number of lines added and number of lines deleted for each file can be viewed with the logs by using the --stat flag and you will be able to see the full diff introduced from the commit by using -p</p><pre>git log --stat<br>git log -p</pre><p>If you want to view the branch structure with the log, you can use the --graph option. This will generate an ASCII graph with the commit description. Using the --graph flag with --oneline and --decorate improves the readability of the graph.</p><pre>git log --graph --oneline --decorate</pre><pre>* e086ecf correct formatting issues<br>| * 46d85a3 removing console logs<br>| * cdff923 validation improvements<br>* |   3bef943 Merge pull request #272 from alice/fix-261<br>|\ \  <br>| * | 6651dbb Fixed a typo<br>| * | b240957 Fixing #261<br>|/ /  <br>* | 4883a57 prepare for next development iteration<br>* | 4546e32 (tag: v1.0.20) prepare release v1.0.20<br>* |   a4d378f Merge pull request #266 from madawas/master<br>|\ \  <br>| * | 2ebd9e3 (origin/master, origin/HEAD) Adding build config<br>* | | [Release 1.0.19] prepare for next development iteration<br>* | | 6646a2f (tag: v1.0.19) prepare release v1.0.19<br>* | |   a49cdd9 Merge pull request #271 from bob/master<br>|</pre><p>Other than formatting the commit history view, you can also filter the commit history in order to find commits in the history. You can limit the number of commits shown in the log, filter by date, author, file and even search commits by message as follows.</p><pre><strong>Limiting number of commits</strong><br>git log -&lt;number&gt;<br><strong><em>example:</em></strong><em> git log -5</em></pre><pre><strong>Filter commits by date</strong><br>git log --after=&quot;25-01-2018&quot;<br>git log --after=&quot;01-01-2018&quot; --before=&quot;25-01-2018&quot;</pre><pre><strong>Filter commits by author</strong><br>git log --author=&quot;Madawa&quot;</pre><pre><strong>Filter commits by file<br></strong>git log -- Foo.java Bar.java</pre><pre><strong>Search for commits<br></strong>git log --grep=&quot;code formatting&quot;</pre><h4>Writing A Better Commit Message</h4><p>A diff of a commit would only tell you what lines were changed but not <em>why</em> those lines were changed. A well written commit message is the best way to communicate <em>why</em> a particular change has been made; to fellow developers. Also if you are using advanced git log filtering techniques to search commits, it is important to have a meaningful and well structured commit message.</p><p><strong>So how should you write a commit message?</strong></p><p>A commit message should contain a subject/heading which summarizes the change. The length of the commit subject should be 50 characters or less. Then a body explaining what, why and how regarding the change. Finally, include the reference to the issues which the change is related to.</p><p>Following are few samples of well-crafted commit messages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*nnv6kZ7N1OnWtQzMnIbRVg.png" /><figcaption>Sample Commit Message</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*d_2g1OBMDKqvmCT0cN6kaQ.png" /><figcaption>Sample Commit Message (Source: <a href="https://github.com/git/git/commits/master">https://github.com/git/git/commits/master</a>)</figcaption></figure><p>If you are writing the commit message from the command line, you can use multiple -m flags to organize the commit message in to different paragraphs. Git concatenates values of the each -m flag as a separate paragraph.</p><pre>git commit -m &quot;Subject&quot; -m &quot;Body&quot; -m &quot;Related issues&quot;</pre><p>However, if it is a detailed explanation, it is quite hard to format the commit message in the above method. Therefore it is recommended to use a proper text editor to write the commit message. Git will prompt the default text editor when you try to commit without providing the commit message.</p><h4>Keeping The History Clean</h4><p>Git is a collaboration tool for developers. Normally, multiple developers are working parallel in the same project and commits frequently. If you are writing a complex feature locally and pulling the latest changes from the upstream branch frequently, the branch you work will end up with multiple merge commits. This will mess up the commit history. It is important to maintain a clean and meaningful public history of commits. Git --rebase comes handy in this context.</p><p>When comes to re-basing commit history, it is a debatable topic because changing the base is treated as dangerous and a destructive process. However if you know what you are doing and when to use --rebase and when not to use it there will be no problem in changing the base to keep the project clean.</p><blockquote>Never use git rebase on a public branch</blockquote><p>Why? Well think what will happen if you rebase the master branch on to your local branch. Everyone who works on the master branch will get affected and their local history and the fork history will no longer be matched.</p><p><strong>When should you use rebase?</strong></p><p>Git rebasing can be used to clean up your local commit history. For example, assume that you are working on a feature or fix on your own and you want to sync up with the latest changes in the master branch regularly. If you use git pull every time you want to sync up your commit history will be polluted with merge commits. (Git pull will fetch the content and attempt a merge) Therefore instead of pulling you can rebase and pull by running the following command.</p><pre>git pull --rebase remote master</pre><p>This will first fetch the content of the master branch and replay your commits on top of the current HEAD of the master branch. In the commit history it will show as you have applied your changes as the most recent commits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uRNQbBbYPTVJ338iQvBB7w.png" /><figcaption>Merging vs Rebase Illustration</figcaption></figure><p>The rebase tool offers by git is very powerful. Other than for cleaning your commit history in the local branch, the interactive mode of the rebase tool can be used to modify your commits.</p><blockquote>Commit Often, Perfect Later, Publish Once</blockquote><p>Above is considered as the best practice of using git. You are not required to write the perfect commit message at the beginning or worry if a commit is really needed. When you do a significant change, just commit with a message that you can understand what that commit is for. When you are ready to publish, you can alter the commits and publish.</p><pre>git rebase -i HEAD~&lt;number_of_commits&gt;<br><strong><em>example: </em></strong><em>git rebase -i HEAD~5</em></pre><pre>git rebase -i &lt;branch_you_want_to_rebase_against&gt;<br><strong><em>example: </em></strong><em>git rebase -i origin/feature-1</em></pre><p>When you run either of the commands, the default editor will open up with following options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*h5SrDfkyX8ox8XvB8NYadg.png" /><figcaption>Git Interactive Rebase Example</figcaption></figure><p>As you can see from the above image, git has provided the documentation along with the available option for easiness of using them. So you can perfect your commits using interactive rebase before publishing. You can refer the git rebase <a href="https://git-scm.com/docs/git-rebase">documentation</a> for more explanation.</p><h4>Saving Your Work Temporarily</h4><p>Assume a scenario where you want to attend something else which is urgent. What are you going to do about the changes you have done so far? Two options are there. First one is just go ahead and commit the changes and switch to the urgent work. If you don’t feel like committing for any reason, you can simply use stash to temporarily save your work.</p><p>You can simply use the command git stash to temporarily store all the changes in to a stack and the git apply or git pop to pop the top most recent stashed change and apply when you are ready to work again but there are many other options supported by git to use in conjunction with stash.</p><pre>git stash list</pre><p>The above command will list all the stashes you have made so far. If you try out this command you will notice that every stash has an identifier in the format: stash@{&lt;id&gt;} You can refer to theses identifiers if you want to apply a specific stash as follows. By default, the apply command will apply the stash@{0}</p><pre>git stash apply stash@{2}</pre><p>When you use pop rather than apply to re-apply the changes you have temporarily saved, it will apply the change and delete the stash from the stash list. If you specifically want to delete a stash from the list you can use either of following commands.</p><pre>git stash drop <em>//drops the latest stash</em><br>git stash drop stash@{1} <em>//drops a specific stash</em></pre><p>You can delete the whole list of stash once by using the following command.</p><pre>git stash clear</pre><p>If you have many stashes on the stash list, how do you identify those? One trick is to use stash messages when creating the stash like follows.</p><pre>git stash save &quot;stash message&quot;</pre><p>Also you can view the changes done in each stash by using the command show The show command will show you the number of additions and deletions in each file and providing the flag -p the full diff can be viewed. Similar for the previous commands, you can specify the stash id to view the diff of a specific stash.</p><pre>git stash show<em><br></em>git stash show -p</pre><pre>git stash show stash@{1}<br>git stash show -p stash@{1}</pre><h4>Getting Only Specific Changes On To Another Branch</h4><p>Sometimes while working in a branch, you may want to pick only a commit or few commits and copy those changes to another branch. For example, let’s say there is an old release branch and you want to back port a specific bug fix to that release branch. Gitcherry-pick is the command you need to use in this situation. Use of this command is quite easy. First inspect the git log and copy the commit hash of the required commit to be copied. Then switch to the relevant branch and type the following command.</p><pre>git cherry-pick &lt;commit_hash&gt;<br><strong><em>example: </em></strong><em>git cherry-pick </em>ba5f6273e0a01d6b397b4efb0ffe490a93a2d342</pre><p>There you go! If you inspect the log of the current branch, you will see a new commit with the changes exactly same as the commit you picked.</p><h4>Finding A Bad Commit</h4><p>Let’s say you notice a build failure in your project suddenly which was not there yesterday. You have found that there are around 10 commits which have been pushed today and you want to find which commit caused the build failure. Git provides a tool for this too…!! That is git bisect</p><p>Before you run bisect, you need to find a commit in the history graph where the project build perfectly. Then you can start bisect and mark the good commit.</p><pre>git bisect start<br>git bisect good &lt;hash_of_the_good_commit&gt;</pre><p>Then you have to mark the bad commit as follows.</p><pre>git bisect bad &lt;hash_of_the_bad_commit&gt;</pre><p>Then the bisect will run and point you at a commit. You can test the project and mark if the commit is good or bad.</p><pre>git bisect good<br>or<br>git bisect bad</pre><p>You can keep marking the commits good or bad until git finds out the first bad commit.</p><pre>&lt;commit_hash&gt; is the first bad commit</pre><p>Once you found the commit, you can reset the working copy to its previous state like follows.</p><pre>git bisect reset</pre><p>These are only few tips and practices I learnt by using git for my software projects. Git is a very powerful tool when it comes to source code management and version control. Hope you all have learnt something and thanks for reading…!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3af20d162c6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Mobile Device Management Capabilities in WSO2 IoT Server]]></title>
            <link>https://medium.com/@madawa/ios-mobile-device-management-capabilities-in-wso2-iot-server-f0ebfb2d6266?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0ebfb2d6266</guid>
            <category><![CDATA[mobile-device-management]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Tue, 26 Sep 2017 05:40:48 GMT</pubDate>
            <atom:updated>2017-09-27T02:51:45.427Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://wso2.com/iot">WSO2 IoT Server</a> is an extensible open source platform which enables enterprises to manage mobile and IoT devices. In WSO2 IoT Server some common device types such as Android, Raspberry Pi, Windows etc. are supported out of the box and users are allowed to develop their own device types plug it in. More information about WSO2 IoT Server can be found in this documentation.</p><p>Among the many cool features offered in WSO2 IoT Server, one of the most attracted feature is iOS Mobile Device Management. WSO2 IoT Server offers many operations/policies to manage your iOS devices in enterprise level. This post will discuss these features as well as the configuration of iOS Mobile Device Management feature in the server which can be tricky. I will be using WSO2 IoT Server <a href="http://wso2.com/iot#download">3.1.0</a> which is the latest release as of today.</p><h4>Prerequisites</h4><p>Even though the <a href="http://wso2.com/iot">WSO2 IoT Server</a> is completely open source and released and distributed under <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>, iOS device management features are not pre-installed in the server due to licence incompatibility with the Apple MDM programme. So first you will have to obtain the iOS device management feature by contacting WSO2 via this <a href="http://wso2.com/products/iot-server/ios/">form</a>. Once the form is filled, WSO2 will email the relevant artifacts needed to install iOS features with End User License Agreement (EULA) and the README.txt.</p><p>Also in order to configure and test iOS device management features, You have to be enrolled in the <a href="https://developer.apple.com/programs/enterprise/">Apple Developer Enterprise Program</a> as an organization. Also you will be needed to download and install <a href="https://developer.apple.com/xcode/download/">Xcode</a>. If you don’t have a way to sign up for an Apple account, you can still try out the features by signing up to <a href="http://wso2.com/iot/cloud/">WSO2 Device Cloud</a> which offers 14 days trial account.</p><p>Following image summarizes the steps you have to follow in order to completely configure iOS device management capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*Uu7PECcAZmFU5anOk1_6pw.png" /><figcaption>Source: <a href="https://docs.wso2.com/display/IoTS300/WSO2+Iot+Server+Documentation">https://docs.wso2.com/display/IoTS300/WSO2+Iot+Server+Documentation</a></figcaption></figure><h4>Installing iOS Features</h4><p>First of all the WSO2 IoT Server should be downloaded from <a href="http://wso2.com/iot#download">here</a> and wso2iot-3.1.0.zip should be unzipped. The unzipped location will be called [IOT_HOME] hereafter. Once the iOS features were obtained through WSO2, the ios-feature-deployer.zip will be emailed. This file needs unzipped to the [IOT_HOME] . Then using a terminal go to [IOT_HOME]/ios-feature-deployer and run the following command.</p><p>mvn clean install -f ios-feature-deployer.xml</p><p>In this step, the End User Licence Agreement (EULA) should be accepted in order to continue the installation process.</p><h4>Configuring The Server with IP/Domain</h4><p>In order to enable secured HTTPS communication between the server and iOS devices a SSL certificate chain should be created. Before creating these certificates, the server has to be configured with a domain name or an IP address. To configure this, you can run the [IOT_HOME]/scripts/change-ip.sh script provided with the product.</p><p>Initially the script will ask for the IP address to replace. If the server hasn’t been configured before, the value for this will be localhost then you will have to enter the IP/domain you want to configure the server to.</p><pre>----------------------------------------                                                                                                                                                      <br>WSO2 IoT Server IP configuration tool                                                                                                                                                         <br>----------------------------------------                                                                                                                                                      <br>                                                                                                                                                                                              <br>&gt;&gt;&gt; Step 1: Change current IP address of the IoT server                                                                                                                                       <br>                                                                                                                                                                                              <br>Please enter the IoT Core IP that you need to replace (if you are trying out IoT server for the first time this will be localhost)                                                            <br>localhost                                                                                                                                                                                     <br>                                                                                                                                                                                              <br>Please enter your current IP                                                                                                                                                                  <br>&lt;Your IP or domain&gt;</pre><p>Then you will see a list of files that has been changed with the provided IP/domain. Then the script will generate SSL certificates to enable HTTPS communication. You will have to provide the values to be used for the SSL subject. Sample values are mentioned below.</p><pre>-----------------------------------------------<br>Generating SSL certificates for the IoT Server<br>-----------------------------------------------</pre><pre>=======Enter Values for IoT Core SSL Certificate=======<br>Please provide Country. Press Enter to skip.<br>SL<br>Please provide State. Press Enter to skip.<br>Western<br>Please provide Location. Press Enter to skip.<br>Colombo<br>Please provide Organization. Press Enter to skip.<br>Sample Inc.<br>Please provide Organizational Unit. Press Enter to skip.<br>IOT Test<br>Please provide Email Address. Press Enter to skip.<br><a href="/service/mailto:example@domain.com">example@domain.com</a><br>Please provide Common Name <br>10.10.10.123</pre><pre>Provided IoT Core SSL Subject :  /<a href="/service/mailto:C=SL/ST=Western/L=Colombo/emailAddress=example@domain.com">C=SL/ST=Western/L=Colombo/emailAddress=example@domain.com</a>/CN=10.10.10.123<br>If you have a different IoT Core Keystore password please enter it here. Press Enter to use the default password.</pre><h4>Generating iOS Related Certificates</h4><p>After configuring the server with IP/domain you have to generate SSL certificate chain to enable device-server communication. For that you can run the ios.sh in [IOT_HOME]/ios-configurator This script will again ask for a SSL subject. You can provide the same values provided before.</p><p>The next step is generating MDM APNS Certificate. The server communicates with the device via the <a href="https://docs.wso2.com/display/IoTS310/iOS+Notification+Method">Apple Push Notification Service (APNS)</a>. When doing so in order to establish a secure connection between WSO2 IoT Server and the APNS server, a client SSL certificate needs to be generated and downloaded from Apple Inc. This certificate is used to send a wake-up call to the device. In order to generate this certificate you need to follow the steps below.</p><ul><li>Generate a Base64 encoded Push Certificate Request by following <a href="https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/7-MDMVendorCSRSigningOverview/MDMVendorCSRSigningOverview.html">this guide</a>.</li><li>Once you obtained the certificate, log in to the <a href="https://identity.apple.com/pushcert/">Apple Push Certificate Portal</a> with your Apple ID and upload the encoded .plist Then download the generated MDM_Certificate.pem</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*7AWf6DJjN_LTXpNxV9BdhQ.png" /><figcaption>Generated Certificate through Apple Certificate Portal</figcaption></figure><ul><li>Then you have to run the following command and note down the UID from the generated MDM_Certificate</li></ul><pre>openssl x509 -in MDM_Certificate.pem -text -noout</pre><ul><li>You will create a private key while creating the CSR (Certificate Signing Request) in the step 1. You need to remove the password from the private key using following command.</li></ul><pre>openssl rsa -in &lt;private-key-file&gt; -out customerKey.pem</pre><ul><li>Merge the customer key file that was derived in the latter step, with the MDM signing certificate to generate the MDM Apple Push Notification Service (APNS) Certificate.</li></ul><pre>cat MDM_Certificate.pem customerKey.pem &gt; MDM_APNSCert.pem</pre><ul><li>Open the MDM Apple Push Notification service (APNs) Certificate (MDM_APNSCert.pem) and ensure that there is a line break between the contents of the two files.<br>Example: The content will look as follows:<br>-----END CERTIFICATE----------BEGIN RSA PRIVATE KEY-----<br>Therefore, add a line break to separate the 2 certificates <strong>after 5 </strong><strong>- (dashes)</strong> so that the content will look like what&#39;s shown below:</li></ul><pre>-----END CERTIFICATE-----</pre><pre>-----BEGIN RSA PRIVATE KEY-----</pre><ul><li>Convert the MDM_APNSCert.pem file to the MDM_APNSCert.pfx file. You will need to provide a password when converting the file.</li></ul><pre>openssl pkcs12 -export -out MDM_APNSCert.pfx -inkey &lt;private-key-file&gt; -in MDM_APNSCert.pem</pre><p>The next step would be to setup the Apple Push Notification Service (APNS) for WSO2 iOS Device Management Agent. WSO2 provides an open source <a href="https://github.com/wso2/cdmf-agent-ios">agent</a> (an iOS app) to enable few features such as location sharing, sending notifications to devices etc. Setting up this agent is optional, but in order to completely test the iOS management capabilities, the agent is needed. Following blog post explains in detail, how to setup the agent application.</p><p><a href="https://medium.com/wso2-iot/how-to-setup-apple-push-notification-apn-service-for-wso2-emm-ios-agent-cfd0595f5304">How to setup Apple Push Notification (APN) service for WSO2 EMM iOS Agent</a></p><h4>iOS Platform Related Configurations and Enrolling the Device</h4><p>Almost all the configurations are done now. So now the WSO2 IoT Server should be started by executing the [IOT_HOME]/bin/iot-server.sh After the server started completely you can go to the device management console by navigating to https://&lt;domain_or_public_ip&gt;:9443/devicemgt and by logging in using the default username and password which are admin and admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5GtR1j382j8j4mqWOMTAYg.png" /><figcaption>Device Management Console — Home Screen</figcaption></figure><p>Before enrolling a device, we have to do few more configurations related to iOS platform. For that click on the orange icon on the top left corner and navigate to Configuration Management &gt; Platform Configurations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*uTKKcWnCnLhAM2qCLcXBgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*JyfhRT0vQ1QsyAP-slXW0Q.png" /><figcaption>Navigating to platform configurations</figcaption></figure><p>In the platform configurations, when you click the “iOS Configurations” tab, you will see a series of configurations. The first part of the configurations should be filled with the values you have used as the SSL subject when creating the certificates and you can use any name as your organization display name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*7p27O3IJzpL0Xb57BZ5TtQ.png" /><figcaption>iOS SCEP Certificate Configurations</figcaption></figure><p>The next set of configurations are related to the generated certificates. You have to upload the generated MDM_Certificate.pfx file and provide the certificate password and provide the noted down UID as the Topic ID in the configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*HhpQjxM48UX_XYRY1YeYRQ.png" /></figure><p>The server is now completely ready to enroll a device and manage it. To enroll a device navigate to the device management console &gt; Device Management and go to enroll device. There you will see the supported device types. When you click the iOS icon you will be directed to a page with instructions on how to enroll the device as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-TYryIeWU9ALGChd3H3kA.png" /><figcaption>iOS Enrollment Page</figcaption></figure><p>From the device you can either scan the QR code and open the URL in safari browser or type the given URL in safari browser. Then you will go through a wizard of steps as described below.</p><ol><li>Install the server certificate<br>Since we have generated self signed set of certificates for the testing purposes, in order to the device to trust the server, we have to install the CA certificate of the server in to the trusted certificate list of the device. When you click install, a pop up will show with the certificate information and you can install it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*2YENXROHs-p63m3rFE5kEA.png" /><figcaption>Enrollment Wizard Step 1: Installing the certificate</figcaption></figure><p>2. Downloading the iOS agent<br>As explained before, iOS mobile agent application is needed to carryout some of the operations and you can skip this step if you don’t need an agent installed. once you click the install agent, the agent will be downloaded and installed in the background. In this point, you can exit from safari and open the new application. (Since the agent app is not registered in the App Store you will have to trust the developer from the settings in order to open the application)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*jLV9fuVWkfreYNa_kQcZCQ.png" /><figcaption>Enrollment Wizard Step 2: Installing the agent</figcaption></figure><p>3. Enrolling the device via agent<br>When you open the application for the first time, it will ask some permissions to fetch your locations and send notifications. Allow them so that the agent will work as expected. The next step is to enter the address of the server (https://&lt;host/ip&gt; ) to the agent and click ‘Enroll Device’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*X6nGlIBXCQ4TJoEy7ev09A.png" /><figcaption>Enrollment Wizard Step 3: Enroll form the agent</figcaption></figure><p>4. Logging in to the server<br>Then you will be directed to a login page where you have to log in with your credentials. The domain part can be left empty for now as it is related to multi tenancy and for testing purposes you can log in by providing the default credentials which is <strong>admin</strong> as<strong> </strong>both the username and password<strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*SZI1BkUuYlvY4IcxJ_ESXw.png" /><figcaption>Enrollment Wizard Step 4: Logging in to the server</figcaption></figure><p>5. Once you logged in to the server successfully, you will be directed to a EULA page and once you have read it and accepted you will be prompted to install Mobile Device Management profiles in to your device and after you installed them successfully the enrollment process is complete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*2bM0jhtg7wlwaNRjsbnF6w.png" /><figcaption>Enrollment Wizard Step 5: Licence agreement</figcaption></figure><h4>Managing Your Devices Through IoT server</h4><p>Now that we have successfully configured the server and enrolled a device to the server we can manage that device through the platform. You can view the enrolled device by navigating to devices in the device management console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*sDmr2GABfOAGP46fKHlnug.png" /><figcaption>Enrolled Device View</figcaption></figure><p>If you click on the device you will be redirected to a device detail and a management page. There you can see the information of the device such as the owner of the device (in this case it is the admin as I enrolled the device as the admin user), remaining battery and storage levels. Below that you will see a list of operations which can be performed on the device. In the right side of the window, you can see the log of the operations performed on the device and time stamps. Also in the location tab, you can monitor the location of the device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZkHLvQlhAPmQ6g9P8WAUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVLSQEL9IeRLGYaH1stZqw.png" /><figcaption>Device details page</figcaption></figure><p>Other than performing operations, you can enforce policies on the devices you manage. There are policies that you can apply to configure password related settings, Application and other restrictions, WIFI related settings etc. By navigating to the policy management in the device management console and apply them to your devices. These device policies are generated for device platforms and once you create a policy and apply, it will be applied on all the devices in the same platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-z-eOQgbIcLXZeIv2Xpkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DCjMko7fjZoThz9b-_hNiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*amCbLoIufU5eFnam4HOQnw.png" /><figcaption>Available policies for iOS device type</figcaption></figure><p>Once you enrolled devices in to the server you can try out the operations and policies. More information about applying policies can be found in <a href="https://docs.wso2.com/display/IoTS310/Policy+Management">this documentation</a>.</p><h4>Monitoring Devices Using Location Based Services</h4><p>One of the advanced and interesting features in WSO2 IoT server is the capability to track the devices using real time location information. To enable this feature, you will have to go through few more configurations as listed in <a href="https://docs.wso2.com/display/IoTS310/Monitoring+Devices+Using+Location+Based+Services">this documentation</a>. I will add an overview of the feature in this article. This feature enables you to track devices real time and generate alerts based on specific behaviors such as when the device exits from a specific region or enter to a specific region etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*DSwBAVjYTsidI2YwYK7CWw.png" /><figcaption>Creating Fences (Source: <a href="https://docs.wso2.com/display/IoTS310/Monitoring+Devices+Using+Location+Based+Services">https://docs.wso2.com/display/IoTS310/Monitoring+Devices+Using+Location+Based+Services</a>)</figcaption></figure><p>Once you enabled this feature, you will be able to create areas as shown in the above image and define alerts.</p><p>In conclusion WSO2 IoT Server is one of the most powerful completely open source IoT platform available. Being fully open source itself makes it even more powerful as anyone can do their own customization on top of what is available. In this post I discussed few of the capabilities that is available in the WSO2 IoT server which is very helpful for an organization who want to manage devices. This is only a one part of the WSO2 IoT Platform and anyone can download the product and play with its features.</p><h4>References</h4><ol><li><a href="https://docs.wso2.com/display/IoTS310">https://docs.wso2.com/display/IoTS310</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0ebfb2d6266" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indexing/Searching Documents Through SolrJ Client]]></title>
            <link>https://medium.com/@madawa/slor-solrj-client-sample-80acfd12c720?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/80acfd12c720</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[document-indexing]]></category>
            <category><![CDATA[solrj]]></category>
            <category><![CDATA[apache-solr]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Wed, 17 Aug 2016 07:28:43 GMT</pubDate>
            <atom:updated>2017-11-29T09:43:02.015Z</atom:updated>
            <content:encoded><![CDATA[<p>Apache Solr is an open source search platform built on top of <a href="https://lucene.apache.org/">Apache Lucene</a> project. Solr is a very popular enterprise search engine which supports full text search, hit highlighting, <a href="https://en.wikipedia.org/wiki/Faceted_search">faceted search</a>, real-time indexing, dynamic clustering, database integration, <a href="https://en.wikipedia.org/wiki/NoSQL">NoSQL</a> features and rich document handling. Solr exposes a REST-like HTTP/XML and JSON APIs that make it easy to use from virtually any programming language[1].</p><p><a href="http://lucene.apache.org/solr/6_1_0/solr-solrj/">SolrJ</a> is an API that makes it easy for Java applications to talk to Solr. SolrJ offers java interfaces to add, update, and query the solr index which allows the client application to interact with Solr with simple high-level methods.</p><p>In this article, I will discuss on setting up Apache Solr and writing a simple Java client using SolrJ to invoke basic operations in Solr such as indexing documents and querying for documents.</p><h4>Setting Up Apache Solr Server</h4><p>Latest Apache Solr Server version(v6.1.0) can be downloaded <a href="http://lucene.apache.org/solr/downloads.html">here</a>. And after you have downloaded, all you have to do is unzip the archive issue following command in the shell. You will get a success message as shown below with the port number and the pid of the solr process.</p><pre>$ ./[PRODUCT_HOME]/bin/solr start</pre><pre><em>Waiting up to 30 seconds to see Solr running on port 8983 [/]  <br>Started Solr server on port 8983 (pid=8703). Happy searching!</em></pre><p>Then we need to create a Solr Core which is a running instance of a Lucene index along with all the Solr configuration (<a href="https://wiki.apache.org/solr/SolrConfigXml">SolrConfigXml</a>, <a href="https://wiki.apache.org/solr/SchemaXml">SchemaXml</a>, etc…) required to use it. The easiest way to create a Solr Core is to issue following command in the shell.</p><pre>$ ./[PRODUCT_HOME]/bin/solr create -c &lt;name&gt;</pre><h4>Writing the SolrJ Client</h4><p>Set up a simple Java project and add solr-solrj-x.y.z.jar to the classpath or if you are using maven add the following dependency in the project’s <em>pom.xml</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00a778919139588024706f7357690e8d/href">https://medium.com/media/00a778919139588024706f7357690e8d/href</a></iframe><p>Then you need to initialize org.apache.solr.client.solrj.SolrClient which represents the Solr instance you want to use as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a0a9b75a4306382845973bc3bc726a5/href">https://medium.com/media/0a0a9b75a4306382845973bc3bc726a5/href</a></iframe><p>Once you have a SolrClient, you can use it to connect with the Solr server by invoking methods like query()<em>, </em>add(), and commit().</p><h4><strong>Indexing Documents</strong></h4><p>To index a document, you need to create a SolrInputDocument<em> </em>instance and invoke the add(document) method as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c3359c7c08476e2592e81e1395e1e2f/href">https://medium.com/media/0c3359c7c08476e2592e81e1395e1e2f/href</a></iframe><p>Invoking commit()<em> </em>will do a hard commit which means this document gets written into the index file in the disk. Otherwise it will remain in the in memory data structures which will be a soft commit.</p><h4>Performing Search Operations</h4><p>To perform search through SolrJ client, you need to pass a SolrQuery<em> </em>object to the query()<em> </em>method in SolrClient<em> </em>as follows. As the result, the query() method returns org.apache.solr.client.solrj.response.QueryResponse object. For the SolrQuery<em> </em>object you can set the search query as a string or as a set of fields. <em>(See [2] for view Solr search query syntax)</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed149f9233eae200921dd128fb80431e/href">https://medium.com/media/ed149f9233eae200921dd128fb80431e/href</a></iframe><p>Once you set the query, you can execute the query and access the results as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c321d983c33a5f397de3d6bbb1f151b9/href">https://medium.com/media/c321d983c33a5f397de3d6bbb1f151b9/href</a></iframe><h4>References</h4><p>[1] — <a href="http://lucene.apache.org/solr/6_1_0/index.html">http://lucene.apache.org/solr/6_1_0/index.html</a><br>[2] — <a href="https://wiki.apache.org/solr/SolrQuerySyntax">https://wiki.apache.org/solr/SolrQuerySyntax</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80acfd12c720" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 Governance Center — Advanced Asset Classification Using Multiple Taxonomy and Categorization…]]></title>
            <link>https://medium.com/@madawa/https-medium-com-madawa-wso2-governance-center-advanced-asset-classification-part2-889a312be1f1?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/889a312be1f1</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[soa-governance]]></category>
            <category><![CDATA[taxonomy]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Sun, 07 Aug 2016 14:03:04 GMT</pubDate>
            <atom:updated>2016-08-07T14:05:21.175Z</atom:updated>
            <content:encoded><![CDATA[<h3>WSO2 Governance Center — Advanced Asset Classification Using Multiple Taxonomy and Categorization Feature (Part 2)</h3><p>This article is focused on the usage of Taxonomy and Categorization feature in WSO2 Governance Center 5.3.0 which was introduced in the previous <a href="https://medium.com/@madawa/wso2-governance-center-advanced-asset-classification-using-multiple-taxonomy-and-categorization-65dc36abd646#.15p0ja5g2">article</a>.</p><p>WSO2 Governance Center has a built in getting started sample and anyone can follow <a href="https://docs.wso2.com/display/Governance530/Running+the+Product#RunningtheProduct-Populatingsampleartifacts">this guide</a> and run it. After running the sample and logging in to the publisher (https://localhost:9443/publisher) you can see a similar landing page as seen in the diagram 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*giOLJES_kiUDkon9." /><figcaption>Diagram 1 — Governance Center Publisher</figcaption></figure><p>Governance Center — Publisher application is used to create and manage artifacts. Classifying assets for taxonomies and adding there categorization attributes or changing them should be done via the Publisher. In the getting started sample sample taxonomies have been applied to REST Service and SOAP Service artifacts by default. If you browse either type of asset and navigate to an asset, you can see the taxonomies applied to the asset in the overview page as shown in diagram 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0-944DB2QpLVLSTbN8On-A.png" /><figcaption>Diagram 2 — Applied taxonomies for an asset</figcaption></figure><p>Following documentation describes how to classify assets using defined taxonomies.</p><p><a href="https://docs.wso2.com/display/Governance530/Adding+Filters+to+an+Asset">Adding Filters to an Asset</a></p><p>The categorization feature discussed in the previous <a href="https://medium.com/@madawa/wso2-governance-center-advanced-asset-classification-using-multiple-taxonomy-and-categorization-65dc36abd646">part</a> of the article can be managed as following documentation describes.</p><p><a href="https://docs.wso2.com/display/Governance530/Adding+Search+Refinements+to+an+Asset">Adding Search Refinements to an Asset - Governance Registry 5.3.0 - WSO2 Documentation</a></p><h4>Filtering Assets in Governance Center Store</h4><p>This section covers how to use the two features discussed before in the Governance Center — Store application which allows users to discover and use assets. The features discussed above which are Multiple Taxonomy and Categorization come in handy when discovering relevant assets from thousands of assets managed in the registry. When you navigate to the Governance Center — Store web user interface (http://localhost:9763/store), you will see a page similar to diagram 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xzrG5GhSTdgjAp7O1ME8SA.png" /><figcaption>Diagram 3 — Governance Center Store</figcaption></figure><p>Navigating to an asset type (which are shown in the left navigation bar) will show the available filtering options in the left navigation bar as shown in Diagram 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*4Qr7cromFmF8rqgkJVWxBg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*hLZc_eIh5WaIqQLuyCQuqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*9_azetugJvJ2r29stVp4Ag.png" /><figcaption>Diagram 4 — Filtering assets by taxonomy</figcaption></figure><p>In the diagram 4.1, you can see the available taxonomies under ‘Filter By’ section and the categorization options under ‘Refine By’ section. These options can be used simultaneously to filter and find the assets stored in the Governance Center very easily. To filter by a taxonomy, you can navigate through a taxonomy tree and apply a taxonomy as shown in diagram 4.2 or using the expanded view shown in Diagram 4.3 (You can expand the taxonomy view by clicking the icon next to ‘Filter By’ heading. A user can add multiple filters by following the same procedure. Diagram 5 shows how it is seen when multiple taxonomy filters are applied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*cj0taNpkFA12DL0tMMWnFQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*RSvmMsoYztlC2bA1Q9G7dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Ma-HbCPR-DYvDghllXXomA.png" /><figcaption>Diagram 5 — Applied filters</figcaption></figure><p>Once the filters are applied, these can be removed by clicking the red icon with the minus sign in the filter as shown in Diagram 5.3 and can be updated by clicking the white icon with the pencil sign.</p><p>Once these filters are applied, you may notice that the assets get filter out in the left side. Simultaneously the options in the ‘Refine By’ section and ‘Tags’ refreshes and will show only the relevant options to further refine the search.</p><h4>Further Refining the Filtered Assets</h4><p>Section above discussed filtering assets by applying multiple taxonomies. There is another feature which allows asset filtering which is Categorization feature. The available categorization options are listed under ‘Refine By’ section in the left navigation bar as a set of checkboxes as shown in Diagram 4.1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*rBeywtkC1qc0ZAF3rbquFQ.png" /><figcaption>Diagram 6 — Filtering assets by categorization options</figcaption></figure><p>Simply clicking these checkboxes as shown in Diagram 6 will filter the assets. The advantage of this feature is this can be used in combination with any other filter or search types. When any search or filter is applied, this section automatically refreshes and show only the relevant options that can be used to further filter the assets.</p><h4>Conclusion</h4><p>WSO2 Governance Center provides the capability of very advanced search and filter mechanisms with its latest release which is WSO2 Governance Center 5.3.0. These discussed features become unique because it is the first time that a SOA Governance product provides the capability to filter assets using multiple taxonomy simultaneously. More about WSO2 Governance Center can be found <a href="https://docs.wso2.com/display/Governance530/WSO2+Governance+Registry+Documentation">here</a> and you can find the latest release <a href="http://wso2.com/products/governance-registry/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=889a312be1f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 Governance Center — Advanced Asset Classification Using Multiple Taxonomy and Categorization…]]></title>
            <link>https://medium.com/@madawa/wso2-governance-center-advanced-asset-classification-using-multiple-taxonomy-and-categorization-65dc36abd646?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/65dc36abd646</guid>
            <category><![CDATA[taxonomy]]></category>
            <category><![CDATA[soa-governance]]></category>
            <category><![CDATA[wso2greg]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Sun, 24 Jul 2016 17:08:55 GMT</pubDate>
            <atom:updated>2016-08-11T05:38:18.813Z</atom:updated>
            <content:encoded><![CDATA[<h3>WSO2 Governance Center — Advanced Asset Classification Using Multiple Taxonomy and Categorization Feature (Part 1)</h3><p><a href="http://wso2.com/products/governance-registry/">WSO2 Governance Center</a> is a opensource tool which provides end-to-end SOA governance for enterprises. WSO2 Governance Center comes up with a enterprise store and publisher with a rich and enhanced user experience <a href="https://docs.wso2.com/display/Governance520/WSO2+Governance+Registry+Documentation">[1]</a>.</p><p>This article series is about the latest feature introduced with the Governance Center 5.3.0 which is asset classification by multiple taxonomy and further refine the filtering using asset categorization. This part of the article is focused on what is “Taxonomy” and the steps to configure taxonomies and refine options in Governance Center. The feature can be tested from the Governance Center 5.3.0 which can be found <a href="http://wso2.com/products/governance-registry/">here</a>.</p><h4>What is Taxonomy</h4><p>Taxonomy is simply a scheme of classification. Taxonomy enables and supports both internal processes such as content management and externally-facing features like navigation, search, and personalization.</p><p>Consider a real world scenario for further clarification. Assume an online retail store that sells almost anything. It is natural to classify each item in the retail store to be classified to different categories/departments based on the item type for the ease of management and to provide a better user experience. For example <a href="https://www.amazon.com/"><strong>Amazon</strong></a> has department structure that each item is classified based on the item type and similarly <a href="http://www.ebay.com/"><strong>ebay</strong></a> has a category structure. This hierarchical structure is a taxonomy. This structure can be visualized as a tree. Diagram 1 shows a sample taxonomy tree structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GECSkb6Ceyy4aJnF7s949Q.jpeg" /><figcaption>Diagram 1 — Sample taxonomy tree structure</figcaption></figure><p>Multiple taxonomy concept is a combination of several taxonomy structures which are independent of each other. Considering a real world scenario, assume that the retail store has different branches in different cities in different countries. So the items can be classified based on the location as well. classification is totally independent from the classification by type. In this kind of a scenario, multiple taxonomy comes in handy when managing and navigating items across locations.</p><h4>Taxonomy in Governance Center</h4><p>Taxonomy in Governance Center has the similar concept which is a hierarchical structure. In Governance Center, taxonomies can be defined as a simple XML structure. These defined taxonomies can be configured as global taxonomies which will be available for all the asset types or as an asset type specific taxonomy which will not inherit implicitly unless specified in the asset type configuration(<a href="https://docs.wso2.com/pages/viewpage.action?pageId=48284982">RXT</a>).</p><h4>Defining Taxonomy in Governance Center</h4><p>This sections explains how to define taxonomies and how to add them to specific asset types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*PXnuX1xFiyRSrOrzIP1v5w.png" /><figcaption>Diagram 2 — Add New Taxonomy page</figcaption></figure><p>Once the product is <a href="https://docs.wso2.com/display/Governance530/Running+the+Product">running</a> and logged in to the management console, there will be an icon to add new taxonomy as showed in the Diagram 2.</p><p>Clicking this icon will redirect to an embedded editor with a sample taxonomy. Same format can be followed when adding a new taxonomy. Rules to define taxonomies are discussed below.</p><p>All taxonomy documents should start with a<em> taxonomy</em> element which has attributes<em> id</em> which is a unique id to identify the taxonomy, <em>name</em> which is used as the display name and <em>global</em> which is an optional attribute which specifies whether the taxonomy is global. Then there will be a <em>root</em> element which acts as the root of the taxonomy tree. This element also has a unique <em>id</em> attribute and a <em>displayName</em> attribute.</p><pre>&lt;taxonomy id=&quot;categoryByType&quot; name=&quot;Item Type&quot; global=&quot;true&quot;&gt;<br>    &lt;root id=&quot;itemTypes&quot; displayName=&quot;Item Type&quot;&gt;<br>        .......<br>        .......<br>    &lt;/root&gt;<br>&lt;/taxonomy&gt;</pre><p>Then inside the <em>root</em> element, taxonomy hierarchy can be designed as node elements which again has a unique <em>id</em> attribute and a <em>displayName</em> attribute. Children of a node can be defined inside the node element as following code segment shows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0772bd71ca353b57598fad4d159f0b69/href">https://medium.com/media/0772bd71ca353b57598fad4d159f0b69/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*acOGFCHx9SjwwwEbRAf6qw.png" /><figcaption>Diagram 3 — Artifact Types list</figcaption></figure><p>Once the taxonomy is defined and successfully added to the system, an entry as shown in the following code block should be included in the RXT to bind the taxonomy with the asset type unless the taxonomy is global. Available RXTs are listed in <em>Extensions &gt; Artifact Types</em> tab. An RXT can be edited in the embedded editor by clicking View/Edit as shown in the Diagram 3.</p><pre>&lt;taxonomies&gt;<br>  &lt;taxonomy name=&quot;Item Type&quot;/&gt;<br>  ........<br>&lt;/taxonomies&gt;</pre><p>This <em>taxonomies </em>element has an optional attribute <em>excludeGlobal </em>and when this is <em>true </em>the asset type does not inherit global taxonomies.</p><pre>&lt;taxonomies excludeGlobal=&quot;true&quot;&gt;<br>  &lt;taxonomy name=&quot;Item Type&quot;/&gt;<br>  ........<br>&lt;/taxonomies&gt;</pre><h4>Categorization in Governance Center</h4><p>Considering the same retail store scenario, once a user navigates to a specific section using the taxonomy and searches for an item, the user may still wants to refine the search results by the item specific attributes such as color, brand etc. This is supported in the Governance Center through the categorization feature. In Governance Center, it is possible to define such attributes in the RXT itself as follows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1319aba53ed3cf332adf80be174ec7e/href">https://medium.com/media/d1319aba53ed3cf332adf80be174ec7e/href</a></iframe><p>Above sample is generated considering a vehicle asset type. Similar categorizations can be defined based on the specific attributes of an asset type.</p><h4>Conclusion</h4><p>This part of the article discussed on defining taxonomies and refine options for specific asset types in WSO2 Governance Center. The <a href="https://medium.com/@madawa/https-medium-com-madawa-wso2-governance-center-advanced-asset-classification-part2-889a312be1f1">next part</a> will be focusing on creating assets of different types and classifying them using taxonomies and searching/filtering and navigation capabilities of the Governance Center.</p><h4>References</h4><p>[1]<a href="https://docs.wso2.com/display/Governance520/WSO2+Governance+Registry+Documentation">https://docs.wso2.com/display/Governance520/WSO2+Governance+Registry+Documentation</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65dc36abd646" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extending WSO2 Registry Resource Handling Capabilities with Custom Handlers]]></title>
            <link>https://medium.com/@madawa/extending-wso2-registry-resource-handling-capabilities-with-custom-handlers-641f93251f53?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/641f93251f53</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[wso2-registry]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Sat, 23 Jul 2016 16:38:52 GMT</pubDate>
            <atom:updated>2016-07-24T09:06:26.214Z</atom:updated>
            <content:encoded><![CDATA[<p>WSO2 Registry is a repository where you can store your resources. A resource can be any document you or your organization wants to store and manage. For example, server configuration files, PDF documents, spreadsheets, JARs, API specifications. Any resource that will be added to the registry follows a standard processing scheme. However sometimes we need to customize the standard behavior for specific type of resources. For example, we may want to validate the resource content against a schema before storing the resource in the registry, or we may want to create another registry artifact using the content of the resource. In such a scenario, we can use the handler-based mechanism.</p><h4><strong>How a standard resource gets processed when adding to the registry?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*mmSneZil_fM6aSAO.png" /></figure><p>Above diagram shows the architecture of the WSO2 Registry where Web and App interfaces expose the registry functionality. Registry API implements all the resource related operations such as get(), put(), delete() and other operations such as versioning etc. Repository stores the actual resource and the version repository manages the versioning related operations. Data access layer implements the operations to persist the resources into the database. When a resource related registry API method is invoked, registry invokes the related methods in the repository which then performs its operations interacting with the data access layer. Then the registry invokes the version repository to handle version controlling operations of the resource. When a registry API method which is not directly related to resources is invoked, the registry implementation directly accesses the data access layer to carry out the related operations.</p><h4><strong>Handlers and Filters</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*7EZNnsXilDgQNDR5.png" /></figure><p>Handlers are pluggable components, that contains custom processing logic for handling resources. All the handlers should extend the abstract class Handler which has default implementations to handle resources.</p><p>Filters provide criteria for engaging handlers. Registry evaluates the associated filter and invokes the relevant handler if the filter evaluation is successful. All filters extends the abstract class Filter.</p><p>As shown in the above diagram, Handler Manager component is placed between the registry implementation and the rest of the back end. When a registry API method is invoked, the registry will invoke all the handler manager and it will invoke all the handlers specified in the <em>registry.xml</em> file until a handler indicates that the processing is complete.</p><h4><strong>Writing a Custom Handler</strong></h4><p>Following code segment shows a sample handler class written with basic functionality.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46043817ad6cacad2e5bed7cbfc94908/href">https://medium.com/media/46043817ad6cacad2e5bed7cbfc94908/href</a></iframe><p>Once the handler is implemented you need to register the new handler with the registry. To register the handler, you need to add the following entry in the <em>registry.xml</em> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1012ef53ddd30697a02564dbb5a966a/href">https://medium.com/media/f1012ef53ddd30697a02564dbb5a966a/href</a></iframe><p>The media type filter added here is a default implementation of the Filter class which matches the mediatype of the resource. This filter will return true if the mediatype of the resource is text/xml. Finally you have to bundle the implementation as a jar file and add it into the registry classpath. Now when a resource is added which has a mediatype of text/xml, this handler will get invoked.</p><p><em>Originally published at </em><a href="http://madawas.tumblr.com/post/112788401949/extending-wso2-registry-resource-handling"><em>madawas.tumblr.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=641f93251f53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Extension to Generate Machine Learning Models in R]]></title>
            <link>https://medium.com/@madawa/java-extension-to-generate-machine-learning-models-in-r-ef73642bb67c?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef73642bb67c</guid>
            <category><![CDATA[predictive-modeling]]></category>
            <category><![CDATA[jri]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Sat, 23 Jul 2016 16:27:50 GMT</pubDate>
            <atom:updated>2016-07-23T16:27:50.966Z</atom:updated>
            <content:encoded><![CDATA[<p>This article provides you with an overview of a project that is done using JRI and Java to generate Machine Learning models in <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwww.r-project.org%2F&amp;t=NDQzYTBiZTQxODljODI5MTMwYjIyYTJlMTRmZmZhNTNmNTQwM2M2OCx1U0JZWWJReQ%3D%3D">R</a>. This application can be used as an extension for existing Java Applications. In order to use this application, R and JRI environments have to be installed and configured as described later in this article.The project source code can be found at <a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fgithub.com%2Fdanula%2Fwso2-ml-r&amp;t=NTVkZWQ4MTNmOTVlN2U5ODVhMjM4Zjk3N2U1MGVkYTZlZDA4Zjc5OSx1U0JZWWJReQ%3D%3D">https://github.com/danula/wso2-ml-r</a></p><h4><strong>What is JRI?</strong></h4><p>JRI is a Java/R Interface providing a Java API to R functionality.The <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwww.rforge.net%2FJRI%2F&amp;t=OWM1YjIyYzRmNDVhN2NjNzNiYWU2NmU2ZjM0YWY5ODJmZjRjZDcxZSx1U0JZWWJReQ%3D%3D">project homepage</a> describes how to initially set up JRI in various environments. JRI uses Java Native Interface to access the JRI native library which calls the R library. To set up JRI, the user has to setup environment variables and configure the Java native library.</p><h4><strong>Setting up R and JRI in Debian/Ubuntu</strong></h4><p>Add the following line to /etc/apt/source.list where ${version_name} should be trusty, precise, utopic, lucid etc. according to your Ubuntu release.</p><p><em>deb </em><a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fcran.rstudio.com%2Fbin%2Flinux%2Fubuntu&amp;t=YjI2YmYwYWFlM2M2MDQ1ZDdiMDcwYWQ1NTVmY2IzMTFkNTkzY2FjZix1U0JZWWJReQ%3D%3D"><em>http://cran.rstudio.com/bin/linux/ubuntu</em></a><em> ${version_name}/</em></p><p><strong>Authenticate</strong></p><p><em>sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys E084DAB9</em></p><p><strong>Update</strong></p><p><em>sudo apt-get update</em></p><p><strong>Install R and rJava</strong></p><p><em>sudo apt-get install r-base-dev r-cran-rjava</em></p><h4><strong>Installing Required Packages to R Environment</strong></h4><p>Once R is installed successfully we need to install required packages to R. Following article provides instructions on how to install R packages. <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwww.r-bloggers.com%2Finstalling-r-packages%2F&amp;t=ODAzZDAxOWZkZTMyZWQ1NjQ1ZTgzMWRkNmE0NjAyZWRiMzI4ZDcwYSx1U0JZWWJReQ%3D%3D">http://www.r-bloggers.com/installing-r-packages/</a> The application described here requires caret and pmml packages as well as all the dependent packages of these.</p><h4><strong>Input and the Process</strong></h4><p>The input of the application is a simple JSON object which has the following structure. Features/attributes of the dataset can be specified as a JSON array as shown in the skeleton below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7c14f62d8ffdc0ac383d6844481de028/href">https://medium.com/media/7c14f62d8ffdc0ac383d6844481de028/href</a></iframe><p>Sample input can be viewed at <a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fgithub.com%2Fdanula%2Fwso2-ml-r%2Fblob%2Fmaster%2Fsrc%2Ftest%2Fresources%2Fworkflow-1.json&amp;t=YzdjOTMxZjRlZTE2MDYwZmJhNzJmOWFjODJhYjkyMDQ0Y2UyZWYxMCx1U0JZWWJReQ%3D%3D">https://github.com/danula/wso2-ml-r/blob/master/src/test/resources/workflow-1.json</a></p><p>Once the input is given, the application will generate the R-script by parsing the input extracting the information and passes the generated script to the underlying R engine through JRI. Following is an example script generated within the application to create a Decision Tree model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/744823636947d6a6e20d885f4f7cbbaf/href">https://medium.com/media/744823636947d6a6e20d885f4f7cbbaf/href</a></iframe><p>Once the model is generated, the application outputs description of the generated model in predictive model markup language (<a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPredictive_Model_Markup_Language&amp;t=NWVjNzY2N2ViZmU4MTVhZjdhYjRhZjlmMTRjYjNjNWM5NTdiMDgzYSx1U0JZWWJReQ%3D%3D">PMML</a>).</p><h4>Extending Current Functionality</h4><p>The current implementation supports Logistic Regression, Random Forest, Naive Bayes Classifier, K-Means clustering, and Support Vector Machine algorithms. If anyone needs a new algorithm, it can be simply added as follows.</p><p>First you need to create a new Java class which extends <a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fgithub.com%2Fdanula%2Fwso2-ml-r%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Forg%2Fwso2%2Fcarbon%2Fml%2Fextension%2Falgorithms%2FRAlgorithm.java&amp;t=YjZhMTc2Mjc4NWFmOTA0Mzc0MmRmODVkYjdhNTk5NmQ3MjQzNDA4Yix1U0JZWWJReQ%3D%3D">RAlgorithm</a> abstract class which contains the generic script generation algorithm using the ‘caret’ library. To create a custom script, you can simply override the methods in the RAlgorithm class and implement your own methods.</p><p>After creating the Algorithm class you need to register the new algorithm in the <a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fgithub.com%2Fdanula%2Fwso2-ml-r%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Falgorithms.properties&amp;t=YzJkZWM5NWZiMmMxZDdlZDllYzZjZjgzNmRlMjFlMDI3MjQ4NjI2MSx1U0JZWWJReQ%3D%3D">algorithms.properties</a> file in the following format.</p><pre>Algorithm Name=Algorithm Class</pre><p><em>Originally published at </em><a href="http://madawas.tumblr.com/post/132333044469/java-extension-to-generate-machine-learning-models"><em>madawas.tumblr.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef73642bb67c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSoC 2015 — Recommendation Solution for WSO2 Machine Learner]]></title>
            <link>https://medium.com/@madawa/gsoc-2015-recommendation-solution-for-wso2-machine-learner-1edd4017a39d?source=rss-9f10f0b369bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/1edd4017a39d</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Madawa Soysa]]></dc:creator>
            <pubDate>Sat, 23 Jul 2016 16:13:25 GMT</pubDate>
            <atom:updated>2016-07-23T16:22:13.919Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fwso2.com%2F&amp;t=NTg5YjFlM2JhNWYzOTljYTU0ZjU0NzJlZTk4NjBmZTc2MTU4NTcyMywwczB2T0hrdw%3D%3D">WSO2</a> is an open source organization which provides a wide range of service oriented architecture (SOA) solutions for professional developers<a href="http://wso2.com/">[1]</a>. Machine Learner is one the latest addition to WSO2’s product stack which helps you to manage and explore data, train models, compare and manage models and predict using the trained models<a href="http://nirmalfdo.blogspot.com/2015/07/sneak-peek-into-wso2-machine-learner-10.html">[2]</a>. My GSoC project was to add recommendation algorithm support to Machine Learner and expose the functionality through a REST API. The project was mentored by Dr. Srinath Perera and Nirmal Fernando.</p><h4><strong>Apache Spark MLlib &amp; Collaborative Filtering Implementation</strong></h4><p>WSO2 Machine Learner is built on top of <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fspark.apache.org%2F&amp;t=ODQ2N2U2ZDdhNjY3ODJjNjY4ZTc2OGRiM2EzZmIxMzI3MTkxODFjMiwwczB2T0hrdw%3D%3D">Apache Spark</a> cluster computing system to perform various operations on datasets in a scalable and efficient manner. Spark contains a machine learning library <a href="http://t.umblr.com/redirect?z=http%3A%2F%2Fspark.apache.org%2Fmllib%2F&amp;t=ZGIwMzNlOTg5YzNjYTQ0N2NjYTg1MjI5MWU5YWY3ZWJmNjIyZmYyMCwwczB2T0hrdw%3D%3D">MLlib</a> which consists of common learning algorithms and utilities. The latest released version of Machine Learner has supports many of MLlib’s machine learning algorithms. MLlib library has an implementation of a model based Collaborative Filtering algorithm which is a commonly used algorithm in recommender systems. My task was to integrate this algorithm to Machine Learner.</p><h4><strong>Explicit Data vs Implicit Feedback Data</strong></h4><p>Even though the standard approach to collaborative filtering requires explicit preference data of the users for items, in the real world case it is common to have access only to the implicit feedback data. In this project, the idea was to get user’s website interaction data such as page views, purchases, time spent on the page etc. These data cannot be directly send to the Spark since it requires a derived implicit preference score as the input. Therefore I given the users the opportunity to select relevant features and a weight for the each feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*WTpspoKnKvHXes3_.png" /></figure><h4><strong>Collecting Data</strong></h4><p>The required data is collected through a Javascript client which will send events to the <a href="http://t.umblr.com/redirect?z=https%3A%2F%2Fdocs.wso2.com%2Fdisplay%2FDAS300%2FWSO2+Data+Analytics+Server+Documentation&amp;t=MGZjNTk4ZDBmMzI5YzU5NTAyNDg5ZDgwZTc4OTJlMTNjYjFjNGRhMCwwczB2T0hrdw%3D%3D">WSO2 Data Analytics Server</a> which acts as the data source for the project. User has to generate the events in following structure and send it to the WSO2 DAS via the client.</p><pre>event:{ <br>  payloadData: { <br>    USER_ID: 818, <br>    PRODUCT_ID: 60, <br>    RATING: 1.34344 <br>  }<br>}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/74cb6b91706ae127db5b2f60910f3f2b/href">https://medium.com/media/74cb6b91706ae127db5b2f60910f3f2b/href</a></iframe><h4><strong>Generating Recommendations</strong></h4><p>Once the data is populated, users can follow the Machine Learner project wizard and create a collaborative filtering model and once the model is created, it will be available through the Machine Learner REST API. Following Image series contains steps to follow in Machine Learner in order to create a recommendation model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*N8VyPjL_o5zBdH3f.png" /><figcaption>Create Project</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*5Wdl3bPCUBDU_7jr.png" /><figcaption>Create Analysis</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*wASFrZw6XoQEtjYL.png" /><figcaption>Select Algorithm</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*YdvVSXE4a0fHsi3C.png" /><figcaption>Complete Model</figcaption></figure><h4>References</h4><p>[1]<a href="http://wso2.com/">http://wso2.com</a></p><p>[2]<a href="http://nirmalfdo.blogspot.com/2015/07/sneak-peek-into-wso2-machine-learner-10.html">http://nirmalfdo.blogspot.com/2015/07/sneak-peek-into-wso2-machine-learner-10.html</a></p><p><em>Originally published at </em><a href="http://madawas.tumblr.com/post/132579948719/gsoc-2015-recommendation-solution-for-wso2"><em>madawas.tumblr.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1edd4017a39d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>