Writing custom queries to retrieve data from WSO2 Governance Registry

WSO2 Governance Registry is a big part of wso2 governance product stack. Even though it is primarily aimed at managing, versioning, rating, and commenting on SOA artifacts it can also be used as a simple data store. with the 3.0 version the G-Reg gave support to custom query execution from the client side. This feature helps immensely when you use the registry for non-standard tasks. For me I had to do some pagination work for the comments that belongs to a particular resource, hence my approach was to write few custom quires to get the job done. The code is as follows.

	/**
	 * Returns a chunk of comments
	 * 
	 * @param resPath	Path to the comment
	 * @param start		The beginning index
	 * @param size		Size of the chunk
	 * @return			an array of comments
	 */
 public Comment[] getCommentSet(String resPath, int start, int size) {
		Registry registry = null;
		try {
			registry = ; // get an instance of the registry 

			Resource comQuery = registry.newResource();

                        // The Sql Statement
			String sql = "SELECT REG_COMMENT_ID FROM REG_RESOURCE_COMMENT RC, REG_RESOURCE R, REG_PATH P WHERE "
					+ "RC.REG_VERSION=R.REG_VERSION AND "
					+ "R.REG_NAME=? AND "
					+ "P.REG_PATH_VALUE=? AND "
					+ "P.REG_PATH_ID=R.REG_PATH_ID LIMIT ?, ?";

			// Set SQL statement as the resource content
                        comQuery.setContent(sql);

                       // Setting the media type and properties
			comQuery.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
			comQuery.addProperty(RegistryConstants.RESULT_TYPE_PROPERTY_NAME, RegistryConstants.COMMENTS_RESULT_TYPE);

			registry.put("system/myQueries/query", comQuery);
                 String resourceName = "testResource";
                 String pathToResource = "/system/myResources"

			Map params = new HashMap();

                        //Setting the parameters
			params.put("1", resourceName);
			params.put("2", pathToResource);
			params.put("3", start);
			params.put("4", size);

                       // Executing the SQL statement
			Collection qResults = registry.executeQuery("system/myQueries/query", params);

			String[] qPaths = (String[]) qResults.getContent();

			Comment[] comments = new Comment[qPaths.length];
                        // Loading the comment data to comment object array 
			for (int i = 0; i < qPaths.length; i++) {
				if (registry.resourceExists(qPaths[i])) {
					comments[i] = (Comment) registry.get(qPaths[i]);
				}
			}

			return comments;

		} catch (Exception e) {
			String errorMsg = "Backend server error - could not get comment set";
			log.error(new MyTestException(errorMsg, e));
			return null;
		}

	}

Yeah simple as that you get your resources set without much effort. A big thank goes to Dimuthu

Best of SOA Summer School

During this entire summer, WSO2 conducted a series of trainings on SOA best practices, How-Tos and trends, titled “SOA Summer School“. With the dawn of the autumn the series of online summer classes came to an end. With the popular demand, a 3 hour session is going to be held tomorrow the 13th August summarizing the 8 weeks of lessons and highlighting their key areas.

Untitled
for a better insight I have attached tomorrow’s agenda, and it is conducted by Samisa Abeysinghe, Ruwan Linton, Prabath Siriwardena, Keith Chapman and Nandika Jayawardena. The online trainings are totally free and any one who is interested in SOA and EA can gain a good knowledge of its dynamics.

JSF, Spring together with apache CXF

Good tutorials and resources on Apache CXF How Tos are not easy to digg. I had to spend hours searching and reading to make my small application up and running, Integrating Spring with JSF was pretty straightforward, but when it comes to integrating those two with JSF i got stuck.

So this post is about exposing a web service as a web project using JSF front end / Spring backed and CXF for service invocation

before starting I should mention few valuable resource around the net.

The web service u used was the publicly available spelling checker which is used in the netbeans tutorial.

The Step by step guide as follows >>

Step 1 :

Create the classes from the WSDL you can use netbeans for this task or WSDL2JAVA command (wsdl2java [URL]) in the shell.

Continue reading JSF, Spring together with apache CXF

Few productive days in a dreamy vacation

Well, not hoping to write about my dreamy vacation, so will just tip off the few productive days. 🙂 Yeah so i was doing some work for Archmage last few days, gave life to a dead project, played with joomla, wordpress and osCommerce.

After much research and hacking me and few of my friends at Archmage thought of using Joomla and WordPress as core CMSes for our web development tasks, to make the work more rapid and easy. So yeah am hacking and looking for plugins and modules that i can use on joomla. Since last two weeks i was working on a real estate project and an e-commerce one. i was looking for resources on them. so yeah if you are looking for something similar try Estate Agent Improved for real estate and Virtuemart for E-Commerce. both are nicely made, Joomla plugins. With a little bit of customization they can be used like a charm.

OH and yeah today i gave a new look to my blog. 🙂 last night i updated to WordPress 2.5.1 ( yeah I know FINALLY!! 🙂 ) Edit: I updated it again today (16th June) to WP 2.6 🙂 .  Many thanks goes to Andrayogi for a pretty neat template. Added some plugins, had some problems with the DIGG IT icon. My firebug started giving a javascript error “unterminated string literal” and finally found a fix.. well its simple just edit the plugin and add

digg_bodytext = '<?php echo trim(preg_replace('/s/', ' ', get_the_excerpt())); ?>';

instead of

digg_bodytext = '<?php get_the_excerpt(); ?>';

That will fix the error. yeah so the site looks pretty neat. am sure many over the net uses this theme. even tried some different colors and combinations but thought this is the best combination so kept it in original.

Soo yeah will write some thing with more value soon.

cheers !

Single Sign-On between Joomla (PHP) and a custom JSF / JSP login (JAVA)

Single sign-on (SSO) is a method of access control, that enables a user to authenticate once, and gain access to the resources of multiple software systems. Well in my case, the task i have given is to authenticate a user in a PHP and a JAVA (Web) system simultaneously.

My PHP web application is the well known Joomla CMS, and my JAVA web application is based on JSF and custom built. After some thinking and research I found several resources which are worth reading (JOSSO, OneSign ), but i couldn’t take any help from them, mostly those SSO frameworks are complex ( yeah 🙂 I couldn’t understand ) and aimed on a general pourpose and most of them are not for free.

So yeah I thought of doing some Hack to joomla and also make some changes in my Java web app’s authentication method. After talking with some of my geeky Friends (Sandaruwan and Anjana). I came up with two approaches. both are involved in handling the cookies manually up to certain extent.

The 1st approach is (Which i didn’t try and had to give up due to the reason that I am using JSF as the web application framework) to log-in to the Joomla site and after loged in to Joomla create a random named temp file in the server (possibly in /home/secrets with 777) with the user-name (if a valid log in) and set a cookie using set_cookie(“name”,$filename) and direct to a jsp page to do the java side authentication.

in this JSP, page read the secret file name from the cookie and read the file from the http server in-order to take the username of the loged-in user. By passing this to the authentication method of the java web app, the java side also can be authenticated.

yup it is pretty simple, but i had to give it up mainly because I use JSF. if I do the user authentication in the above way in the java side. I cannot add the user object to the FacesContext which will be used by my other java side components. so even though i log in. later on in other jsf pages my loged user cannot be found. (Shortly my java login process is not happening according to the JSF implementation procedures.) and secondly i had to give up this method because my Project manger didn’t like the idea of saving temp files in the server. 🙂

So the Second and the method which i have implemented is, automating the Joomla log-in process by making an http request to the http server from my JSF backing bean. and set the PHP cookie manually via Http Servlet response.

before i explain this method more broadly i have to mention about two nice tools which helped me to monitor the http requests and response.
Apache TCP Monitor
Live Http headers (FireFox ad-on)

Architecture

Implementation

There are two different scenarios.
1. User can visit teh home page of the joomla site 1st and the PHP Cookie is already set.
2. User visit the Java site PHP Cookie is not available.

Continue reading Single Sign-On between Joomla (PHP) and a custom JSF / JSP login (JAVA)

UDDI Tutorial : JUDDI / UDDI4J ( publish & inquiry using juddi console and uddi4j client API )

Last two weeks i was busy with my office work trying to figure out some tasks related to an EU project called sensoria. I had to integrate the Events plugin of Joomla (CMS) with Google calender (which i am hoping to write about in future) and I had to compose a case study documentation for service discovery using UDDI (Universal Description, Discovery and Integration). It took me few days to setup a test environment to get things actually working.pict_uddi_1.gif

As I saw, that in this area there aren’t many help or online tutorials.. you have to collect tits and bits from every where and put some effort to make things work..

SO yeah thats why i thought to publish a small tutorial on setting up a UDDI server and handling the UDDI4J java client API..

 

Continue reading UDDI Tutorial : JUDDI / UDDI4J ( publish & inquiry using juddi console and uddi4j client API )

Vuze (Azureus 3.0) – Next Gen P2P Application

azureus.png“Next generation P2P Application”, Thats what they say about Azureus 3.0 Well I know this is not so news, But I happened to discover this very recently due to few reasons.. I was not a major Azureus Fan after all.. I was using utorrent for all my p2p downloads.. for many reasons I loved uTorrent.. for its light lightnes, the fancy progress charts, Statistic GUIs and the user friendliness.

When I was back there home.. I ran utorrent in my WinXp Pro Desktop and it was working really fine..but later i came to Germany I install uTorrent to my notebook but I encountered a browsing problem while utorrent running.. I could not even go to Google home page even when no torrent is downloading.. so when i browse the torrent client had to be stopped.

After googling for some time i found some fixes..(by Lowering net.max_halfopen to 4) ..yet I was not happy so i thought of trying something new.. I tried BitCommet..since its developed useing C++ and also light weighted, But I disliked its appearances.. So finally I thought of trying Azureus.. I have used Azureus for a short while in my Linux box when it was in its 2.x ages.. and it was looking good although it eats up alot of system memory.. well yeah Its a Java application I have to accept that fact..

So i downloaded and it said Vuze (Azureus 3.0)…. I installed it…And Now what the heck is this.. Its looking so colorful so bright having a Cristal bluish UI..and it was truly amazing.. What i did first is to go back to its download site and double check whether its the official Azureus Version.. and yeah no mistake there.. The new Azureus version is bundled with the Vuze Skin making the whole application very much eye catching.. While keeping all its old 2.x features the application is being more aimed on entertainment which is very nice and interesting. It almost forgets or makes its memory usage a minor problem.

h.png

So this post is not for the Loyal Azureus Users.. I know they already use this.. this post is for the people who are using other torrent clients.. I think its worthy to check the new Azureus.. !! and to decide whether it is the next generation P2P Application is all up to you…

Accessrunner-based USB ADSL modems – Get it to work on Ubuntu Dapper/Edgy

This is one wide area that no clear online article is available as a help document. I my self had a huge problem in searching and making my modem to work with Edgy. When you google for the Conexant AccessRunner driver you get the driver file as sources from the sourceforge,
http://accessrunner.sourceforge.net/index.shtml
where you have to add those files to the kernel source tree and recompile the kernel creating a great deal of work. But yet luckily the new kernels (after 2.6.10) have this driver inbuilt (Ubuntu Dapper/edgy) so you don’t have to mess up recompiling the kernel.

Any how you have to manually add the firmware, otherwise the modem will not work. (The LEDs wont Blink) for this you have to do few things, things I gathered from many online forums/blogs and help guides.

you have to extract the CnxEtU.sys file from the CD which you got from the vendor of your modem, and have to place it in /lib/firmware directory to make the firmware working. The step by step guide as follows.

for this purpose since we do not have the extract command, we have to download the package that Nicholas Wheeler created. from http://revu.tauware.de/details.py?upid=2426 there are several files but what you have to take is cxacrufw_1.2.orig.tar.gz and cxacrufw_1.2-1.diff .

After downloading these two files unzip the .gz and copy the .diff file in to that folder, and being inside that folder through the terminal patch it using
patch < cxacrufw_1.2-1.diff

then type make and make install. now you mush be havening a command called cxacru-fw. now your ready to extract the firmware.

insert the CD you got from the modem vendor and using the terminal type the following commands.

cp /media/cdrom/driver/ADSL/Wan/CnxEtU.sys ~/

(the above path can be different according to your settings so adjust the folder path)

then

cxacru-fw ~/CnxEtU.sys ~/cxacru-fw.bin
sudo cp ~/cxacru-fw.bin /lib/firmware

Make sure that the firmware is installed as /lib/firmware/cxacru-fw.bin or else the LED wont light up.

restart your computer and thats it you must be seeing the modem is working fine with the LED lighten up. anyhow though you have attached the modem to the computer and if your ISP is providing you a PPPoE protocol you will still have problems connecting your modem to Internet

there are few sites I saw some details which i think will be useful so just visit till I post a topic on HOW TO configure PPPoE

http://www.tldp.org/HOWTO/DSL-HOWTO/configure.html#BRIDGEVSPPP

and if any one who knows on PPPoE please leave a comment….

Installing Gnome(cairo)-Dock

Today while i was surfing the net (digging new gadgets for my Gnome desktop) i saw some interesting screenshots of a universal dock something which is similar to the OSX making me hunt down this new feature to my desktop. i googled for “Gnome dock” and found a post in ubuntu forums where i followed the installation process and at last.. yes !! I got the DOCK but there were no application images seen in the DOCK. i solved this problem by editing the .svg files and the cairo-dock.c file. but the biggest problem i encountered was that when i added this to the sesion and restarted my X-server. I crashed or rather I didn’t see my desktop at all. (well for some wired reason it crashes only the desktop.) I think this happens when the Gnome session loads Beryl-manager, Beryl, Gdesklets and the cairo-dock at the same time it might get overloded and crashes the desktop.

Anyhow as a solution i delayed the loading process of each of these applications through a shell script. so on this post I will describe how to install cairo-dock and make it work hand to hand with beryl.

You can follow the instructions on the Ubuntu forum for the installation process. since it describes well I will write what is missing.

At the step 5 before download cairo-dock.tar.gz i signed up for the ubuntu forum.

At last after the installation process is done when you run cairo-dock it will appear in the bottom of your desktop with almost no images for the named applications. These application icons are saved as .SVG files in the cairo directory what you have to do is open each of these files and replace the link to the image with your application icon’s path.

xlink:href=”/usr/share/pixmaps/firefox.png
sodipodi:absref=”/usr/share/pixmaps/firefox.png

replace the highlighted link with your icon’s path and secondly you can add/remove applications from the dock by edition the cairo-dock.c file. there in the specified section you have to add the name of the .SVG file, name of the application and the command to launch that application and make it. this is the simple way to make the DOCK running with the applications you want in your desktop. If at the end when you add the DOCK to the session and restart and if then your Desktop crashes, simply write a shell script and save in /usr/bin/ and add that script to run on the beginning of the each session.

my scripted looked like this.

#!/bin/bash
beryl-manager
sleep 5
beryl
sleep 7
cd /opt/cairo-dock
./cairo-dock –no-glitz &

restart your X and you must be smoothly working !!! Enjoy…

Credits :

Sandaru1 & Kasun

Umbrello – UML Modeller for Linux

— @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } –>

Since I haven’t used or haven’t heard that “Rational rose” working on LINUX (on WINE) and of cause for modeling purposes I had to switch to Windows making a headache, I was searching a solution or more likely an alternative within Linux. I was just peeping in the add/remove menu and under the programming category, I found two modeling softwares for Linux. one which failed to install (Gaphor) and the one which i installed (Umbrello 1.5.5).

What made me surprised is that this software almost had all the functionality that was there in “Rational rose” sometimes even more. the software is very much easy to use. simple and well featured.

The software supports forward Engineering as well as Reverse Engineering, meaning when the Model is designed the code structure can be created and vice versa (supporting 12 different programming languages).

Anyhow I would like to say that Umbrello brings an easy approach for UML modelling.