Tuesday, December 25, 2012

Good Bye WSO2

It has been a really wonderful stay at WSO2. I can call it a fully featured internship. There was exposure, new connections, new learning, and fun. So thank you ALL (I really mean it) for ALL the help and support throughout the internship period and all the fun we had together. 

There are some people that I personally thank.


I like to summarize my internship.

Best Moment in my Internship period

Committing my changes to the branch (in Greg project) – I worked in several projects (around 5). Only in 2 projects I got chance to add them to the branch. It was in test automation and in Greg basic filter improvement. It feels great when we see our changes in the branch, knowing that it will be there in the future and thousands of people gonna use it. And I hope all other futuristic projects I did will be used in future. (https://svn.wso2.com/wso2/repo/intern/malinga/)

Worst moment in my Internship period

Missing the BB finals – BB final was one of the moment I wanted to be in, form the time we started the BB tournament (read a blog article by a past wild boar member and how they win the final match in the last minute). But I missed it due to the bad weather.

Best feeling in my Internship period

Non tech guy knowing WSO2 – in the last few months almost all the people met me, asked about my training place. So my answer was “A Place call WSO2”. Most of them are non-tech or in different fields and didn't know about WSO2. But 1% of them replied “Ahh.. WSO2”. It feels great and I was like “You know WSO2 :D”.

Worst feeling in my Internship period

Returning to the room after losing each and every TT match played– Luckily it happens extremely rarely because I don’t return till I win at least a single match.

Contact Me

Email –             malingaonfire@gmail.com
FB -                  https://www.facebook.com/romesh.perera.08
Linked in -         http://lk.linkedin.com/in/malingaperera
Twitter -             https://twitter.com/malingaperera
Blog on my Internship (Internship at WSO2) -
                         http://iwso2.blogspot.com/
Personal blogs - http://www.executioncycle.lkblog.com/
                         http://www.thinklikemalinga.lkblog.com/
OR you can simply Google “Romesh malinga perera”

Wish you a merry Christmas and a happy new year!

Thursday, December 20, 2012

Greg Basic Filter Improvement (Enhanced basic filter) – Final


All done and Committed. It was a good learning period for me. So let me give you a full summery of the full project. And I like to give this as two separate documents one for users and one for developers.
You can find the documentation from the below links.

Greg Basic Filter Documentation For Developers

Coming Soon....

Greg New Basic Filter Documentation For Users


Introduction

This new basic filter allows you to shape the basic filter as you need. Early greg basic filter allowed you to search the artifacts by name. With new basic filter you can decide with what you want to filter with. It might be the version, name space, or some minor attribute.

In new Greg all artifacts are defined with a RXT file you can easily access them form Extensions > Artifact Types as shown in the below screen capture.

You can view and Edit them from here. Below I have shown a part of a sample RXT file.

    /trunk/services/@{namespace}/@{name}
    overview_name
    overview_namespace
    
        
            
                
            
            
                
            
            
                
            
        
    
    
        
                Name
            
                Namespace
            
                Version
            
                Scopes
            
                Types
            
                Description
            
Contact Type Contact Name/Organization Name Contact None Technical Owner Business Owner
. . .
Below extracted part of it decide on the columns in the listing page.

            
                
            
            
                
            

According to above configuration we will have two columns (namely Service Name, Service Version, Service Endpoints) in Services listing page. User select them according to his priorities. New greg basic filter allows you to search by all the columns defined in the RXT. So in this case two attributes mentioned above will be there to select for before filtering. Other than that this will provide the capability of search by the Life-Cycle as a new feature.

Life cycle Filter (Use of negative filtering 'NOT')

Life cycle Filter

Other 'filter by' criteria will be followed by a text-box

Filter By Life-Cycle


This is something new that comes with the greg 4.5.3 with this new basic filter. Even the advance filter don't have the capability of search with Life-Cycle. This LC filter allows you to execute vast range of queries with the capability to do the Negative searchers too.

Example queries that can be executed by the LC filter.
1. Service that are not in the ABC life-cycle.
2. Services that are in the ABC life-cycle in the Development State
3. Services that are in the ABC life-cycle not in the Development State

Try it and you will easily understand how to use it. 

Limitations


1. All listing columns will be there to search with and you don't have option to omit few of them from the search only. Or in reverse you can't have a attribute to search with but not as a column in the searching page. Simply speaking items in the filter by drop down and the columns in the listing page will be same.
2. You can't filter with a Unbounded list.



Lunch from the Mentor @ The Mango Tree

It was nice lunch from our mentor Amila Maharachchi. Me and Lasindu with other Stratos members were part of this. Below are some nice captures from Lasindu's cam.
Stratos team @ The Mango Tree



Malinga Perera(Me) on left with Damitha Kumarage



Sanjaya Ratneweera (On left) With one of our metors Amila Maharachchi

Shariq Muhammed (Our other mentor) with Lasindu

Thursday, December 13, 2012

Axis 2 Handler for Custom Greg Email Notifications


What I needed to do.

We needed to use greg to help our support team. And we hosted all patch information in a greg instance. In greg we have subscription options any one who like to get updates on a specific artifact can subscribe to it. You can learn more on this subscription process in this article.

We needed to customize the emails sent via greg and we wanted to remove all unwanted details and give it a nice informative subject. I got to know it could be done with a  axis 2 handler.


Process:

I followed this sample found in the wso2 product wiki. And I needed to change the code there. You can go though that sample and try the basics first. And when you do it remember to insert relevant dependencies, like axis. They are not in the pom.xml and sample does not ask you to add them. You will lead to a compiler error of not finding axis bundle. You can overcome this by removing the below exclusion from the pom.xml

               <exclusion>
                    <groupId>org.wso2.carbon</groupId>
                    <artifactId>org.wso2.carbon.context</artifactId>
               </exclusion>


Removing above form the pom will get rid of following error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project org.wso2.carbon.registry.samples.handler: Compilation failure: Compilation failure: 
[ERROR] /home/malinga/work/Servers/wso2greg-4.5.1/samples/handler/src/src/main/java/org/wso2/carbon/registry/samples/notifications/EmailTransformHandler.java:[6,23] package org.apache.axis2 does not exist 
[ERROR] /home/malinga/work/Servers/wso2greg-4.5.1/samples/handler/src/src/main/java/org/wso2/carbon/registry/samples/notifications/EmailTransformHandler.java:[7,31] package org.apache.axis2.context does not exist 
[ERROR] /home/malinga/work/Servers/wso2greg-4.5.1/samples/handler/src/src/main/java/org/wso2/carbon/registry/samples/notifications/EmailTransformHandler.java:[8,30] package org.apache.axis2.engine does not exist 
[ERROR] /home/malinga/work/Servers/wso2greg-4.5.1/samples/handler/src/src/main/java/org/wso2/carbon/registry/samples/notifications/EmailTransformHandler.java:[9,32] package org.apache.axis2.handlers does not exist 
[ERROR] /home/malinga/work/Servers/wso2greg-4.5.1/samples/handler/src/src/main/java/org/wso2/carbon/registry/samples/notifications/EmailTransformHandler.java:[10,38] package org.apache.axis2.transport.mail does not exist 

After you are done with this you can look at my code. I change the EmailTransformHandler.java to suit my needs. We are subscribed to ChangeLCState event, and we got a mail for all state changes. 

Requirements:
We needed to Change the Subject to [QA] Patch <Artifact name>
We needed to Change the Massage Body
We needed to send the massage for some selected state changes only

How I did it:
We needed to Change the Subject to [QA] Patch <Artifact name>
You can get the transport headers like below and you can change the subject to what ever you need it to be, like below.


((Map<String, String>) msgContext.getOptions().getProperty(MessageContext.TRANSPORT_HEADERS)).put(MailConstants.MAIL_HEADER_SUBJECT, subject);


We needed to Change the Massage Body
It is same as how it is explained in the sample in the wso2 product wiki. Here the main problem is you only get the text body and you have to do lot of string manipulation to get what you need out of it. And if the original massage changes everything will go wrong. Below are some samples from my code

String sender = element.getText().substring(findStringInString(element.getText(), "This message"));


when you get the required information out you can create a string with the body you need and set it as the message body

if(element.getText().contains("'Development' to 'ReadyForQA'")){

                   element.setText(msgPromotedFromDev);

                }


We needed to send the massage for some selected state changes only

We can do a check on the message header, body and if it is not not needed massage you can use InvocationResponse.ABORT to stop the mail from sending, you can find the example from my code below.

if(element.getText().contains("'Development' to 'ReadyForQA'")){

                   element.setText(msgPromotedFromDev);

                }else if(element.getText().contains("'ReadyForQA' to 'Testing'")){

                    element.setText(msgPromotedFromQA);

                }else if(element.getText().contains("'Testing' to 'Released'")){

                    element.setText(msgPromotedFromTesting);

                }else{

                    return InvocationResponse.ABORT;

 }


Hope you got some understanding of Notification E-mail Customization and you can find more simple samples in http://docs.wso2.org/wiki/display/Governance451/Notification+E-mail+Customization+Sample

Sunday, December 9, 2012

The Most important grep (Some most useful commands/ways with grep)


I started my internship in wso2 6-7 months ago. By then I had no clue about the Linux command prompt. Even though I have worked with Ubuntu in when I was doing my A/Ls I didn’t use the bash to anything at all. But with the start of my internship I started Using the Command line for almost everything. It is a one way stop for everything and you feel really powerful and feel more control over things. With those I moved towards using the Command line more and more. When I do that ‘grep’ played a big part in my life. Simply you can’t survive in a command line environment without ‘grep’. Below are some nice little commands using grep that I think everyone should know.
basic usage of grep command is to search for a specific string within a specified set of files. In below commands you have to replace the <> and what is in there with what you need.

grep "<string you need to search>" filename

e.g. grep “submitFilterForm” index.jsp
Here we are searching for “submitFilterForm” in index.jsp. This will return the sentence that string can be found (if there is any).you can give a file pattern instead of the file name
e.g. grep “submitFilterForm” *.jsp
And if you need you can replace the search string with a regex. You can use some parameters to make the search more advances.
  • i - Ignore case(ignore capital, simple, “the”, “THE” and “The” all will be same)
  • w - Full strings only (if you don’t use this all the substring matches also will be there in the search)
  • v - Negative search. ( When you want to display the lines which does not matches the given string/pattern)
  • n - Line numbers (To show the line number of file with the line matched. It does 1-based line numbering for each file. Use -n option to utilize this feature.)
e.g. grep -iw "submitfilter" *.java
Above will search for "submitfilter" as a full word, ignoring case insensitively within all java files, try it and you will understand more.
e.g. grep -i "submitfilter" *.java
Above will search for "submitfilter", ignoring case insensitively within all java files.
e.g. grep -v "submitfilter" *.java
This will search for places which do NOT match "submitfilter”, within all java files.