Saturday, September 8, 2012

Creating SVN Repository Remotely

Linux distribution of Apache subversion provides svnadmin to create a svn repository.But this is not capable of creating repository remotely.By issuing svnadmin command we can only create a repository within local file system.
Here i am going to describe couple of ways by which we can create svn repositories remotely.Here all my ways achieve above mentioned objective through  java.Here is the list of method that i found.

1.Using ssh to execute svnadmin command remotely.
    a)Using apache sshd library
    b)Using JSch library
2.Using SCM -Manager
3.Using PHP+java Client

Using ssh to execute svnadmin command remotely

In this approach the repository is created by executing svnadmin or relevant command in remote host using ssh.Here there are two ssh opensource libraries available for java.

a) Using apache sshd library

apache sshd is a pure java implementation of ssh available under apache 2.0 license.This is a sub-project of apache Mina.Here is a example code for executing svnadmin command on remote host as a superuser.

To use apache sshd library you have to add following maven dependency. 


b)Using JSch library

This is another popular java implementation of ssh.There are  good examples also available for this libarary.Here is how to execute svnadmin command using JSch library.
Following is the maven dependency which can be used to create maven project.

Using SCM -Manager

Next approach is using a source code management system.SCM Manager is an open source source code management system which is implemented in java.This is
a server which provide user interface to create repository and manage them with users.Currently it support svn ,git and mercurial.In addition to user interface, it expose REST API to manage repositories.Here i am going to use the REST API to create a repository.Before staring writing the REST Client Download the SCM Manager from here and start the server by executing the script which can be found in bin folder of the distribution.
To write the REST client there so many ways.
  1.Using HTTP client
  2.Apache Wink client
  3.Jersey Client
I am using http client wich is very simple to use.All the REST calls are protected by BASIC Auth in SCM  Manager.We have to set the credential in http client.
Here i used Axiom for generating XML payload.

Using PHP+java Client

In this approach a php page that is hosted in apache 2 server in remote host will create a svn repository using svnadmin command and there will be a java client that is used to call the php.The php page is secured using Basic Auth.Here is the very simple php code to create svn repository.

Here is the java client that is used to call the php page.
 
This is how we can create svn repositories remotely.This will be helpful when ever there is a requirement of automatic repository provisioning.
  

Thursday, June 28, 2012

Getting Started with WSO2 Appfactory VMware Image

In this post i am going to describe how to getting started with WSO2 Appfactory VMware image first mile stone  release.

WSO2 Appfactory

WSO2 Appfactory is a new solution that provides a convenient environment to manage Applications between different stages of development.For example each application developed in enterprise goes through so many stages (such as dev and QA)before going to live.While it is moving between stage it goes through so many reviews(such as security review and policy review) by different users and authorities.WSO2 Appfactory provides a convenient and easy to use environment to manage application between different stages.For more information on WSO2 Appfactory refer following blog.

WSO2 Appfactory VMware Image(M1 release)

WSO2 Appfactory team recently released their first appfactory milestone release as a VMware image.The image has following servers
1.WSO2 Appfactory
2.WSO2 Stratos Manager
3.WSO2 Application server (for each stage(dev and live))
4.SCM manager
All the servers are connected to a single LDAP and a remote  governance registry
Following diagram shows the deployment pattern that the image uses.

Now lets play with this image.

Prerequisites

1)VMware player should be installed in 64 bit machine with visualization enabled.
2)The host machine should have at least 4 GB memory and connected to Internet.

Getting Started with vm

1)Download the image from http://builder1.us1.wso2.org/~appfactory/releases/wso2appfactory-image-m1.zip
2)Unzip the downloaded file.
3)Start the VMware player.
4)Open the image as following





5)Edit the image setting as follow

Increase the memory to at least 2 GB(Recommended ~8GB)  and enable bridge network setting.
6)Start the image



use following credentials to login to the image.
User-name: appfactory
Password: appfactory

Note:
1.Change the /etc/hosts entry of vm.svn.appfactory.wso2.com to
 0.0.0.0 vm.svn.appfactory.wso2.com
2.Change keystore location of scm manager.
Open the carbon-auth.xml that can be found in /home/appfactory/final-zip/scm-server/repository/config.
Change the keystore location to /home/appfactory/final-zip/appfactory/wso2appfactory-1.0.0-SNAPSHOT/repository/resources/security/wso2carbon.jks

7)Start all the servers as back-end process.
Start Appfactory
cd /home/appfactory/final-zip/appfactory/wso2appfactory-1.0.0-SNAPSHOT/bin
nohup ./wso2server.sh &
Start Stratos Manager
cd  /home/appfactory/final-zip/cloud-manager/wso2stratos-manager-2.0.0-SNAPSHOT/bin
nohup ./wso2server.sh &
Start Dev cloud Application server
cd /home/appfactory/final-zip/dev-cloud/wso2as-5.0.0-SNAPSHOT/bin
nohup ./wso2server.sh &
Start Live cloud Application server
cd /home/appfactory/final-zip/live-cloud/wso2as-5.0.0-SNAPSHOT/bin
nohup ./wso2server.sh &
Start SCM Manager
cd /home/appfactory/final-zip/scm-server/bin
./scm-server start
8) Get IP address of the VM and enter following to /etc/hosts of the host.
In VM issue sudo ifconfig and get the IP.

172.16.9.130 vm.appfactory.wso2.com
172.16.9.130 vm.cloudmanager.appfactory.wso2.com
172.16.9.130 vm.dev-cloud.appserver.wso2.com
172.16.9.130 vm.live-cloud.appserver.wso2.com
172.16.9.130 vm.svn.appfactory.wso2.com

Add above entries to /etc/hosts of host machine.Here change the IP address as you got in previous step.
Wait for some time to start all the servers success fully then you can access the servers using following link in host machine browser.
Access Appfactory https://vm.appfactory.wso2.com:9443/appmgt/
Access Dev cloud Application server https://vm.dev-cloud.appserver.wso2.com:9445/
Access Live cloud Application server https://vm.live-cloud.appserver.wso2.com:9446/

Getting started with Appfactory

Now it is the time to create a application and deploy it to cloud.
1.Register a new user
 1.Access https://vm.appfactory.wso2.com:9443/appmgt/
 2.Register a user by clicking sign up button at left top of the sign in page as follow.
Fill the sign up form


Check your mail  and click the link sent by mail to validate the email address.


2.Create an App
 Login as created user
By clicking add apps create new app
After successful creation of application it will display the created SVN url.
 When ever user login he always see the list of applications with short details
When the user click on a app depending on the role of the user he will see different dashboards.
All the member can view the dev-view as follow.
The users in admin role can view admin view.The admin user can invite already registered users to application.

The user in devOps role can view devOps view.Here he can deploy the application to stages(dev or live).


3.Invite a user as a developer
Register a new user.
Invite him as a developer to created project.

4.Invite a user as devOps
Same way invite another user to devOps role.
5.Commit a CAR project into svn as developer
Check out the svn repository  displayed on dev-view as developer.
Add a car project  to the checkout directory(use following car project)
Commit the project


6.Login as devOps and you can
              -deploy to dev
              -deploy to live in dev-ops view.

7.Then finally you can check the relevant application server in cloud for the deployed application.
Login to https://vm.appfactory.wso2.com:9443/appmgt/
as the user who created application using user name as {user-name}@{application-id} and check the deployed car applications.


Thats all for milestone one release.I hope wso2 appfactory will come with more functionality with less distribution size in future releases.

Sunday, May 8, 2011

GSOC 2011:Weekly Report(May-01 to May-08)

Last week as i planned before i spent on time designing UI mock-ups and database tables.The good thing is that the designing process was a collaborative work of my both mentors and myself.They have given constructive feedback on the design and finally helped me to come up with the final design.I have updated my design details on wiki page.While designing i am able to realize some insight into theories of database design as well as UI design.

UI Design
I identified that there are four sets of UI should be designed.

Main UI:
This is the place where the list of available apps are displayed on the side bar and the user is allowed to launch the app within a HTML iframe  by clicking on the icon of the app.This is an usual UI every SMART container may contain.Here my job was to identify the best place to put this UI in the OpenMRS.The place should be appropriate to display patient level health data because every SMART UI app is a patient level application.With the help of my mentor i decided to put this UI at patient dashboard where the access to the dashboard is allowed only after selecting a patient.There the patient object can be received which is necessary to create a record in SMART container helper methods.
Main UI



Manage Apps at user level UI:
In medical world there are range of peoples who need different types of applications.For example the doctor uses application that related to diagnosis process but this type of applications are not relevant to a patient.So it is better to provide a UI for user to customize the available application at main UI.It is usual to put all the user level setting under My Profile in OpenMRS.According to the normal convention i decided to put the UI for managing SMART apps at user level in a vertical tab under the My Profile page.
Manage Apps at user level

manage Apps at seystem level(system wide settings) UI:
Normally it is a convention to allow only administrator to install new modules in OpenMRS.This rule is appropriate for SMART apps also.As SMART mentor Josh said i decided to put the add or remove SMART app UI at admin page.
Manage app (add/remove)

UI for installing the Apps:
When the user clicks on the add button on the manage app at admin page, a pop up widow will be displayed.This window will allow user to upload a SMART app manifest or to provide a link to the manifest file.
Add App UI
Database Design
Here the primary data are information about users and the SMART apps.OpenMRS alredy has a user table.The new table should be created for modeling SMART apps.SMART app uses a manifest file to save the information about itself.It is straight forward that there are one to one relationship between app database table and the manifest file.In other words database table is used to save informations in the manifest file.I directly modeled database table using manifest file as a guide and created obvious relationships.
Final Database Table(the user table should contains more field,it can be found here)

Sunday, May 1, 2011

Google Summer Code 2011



I got selected Google Summer Code 2011 this time.I am very proud to be one of the thousand students who are selected this time for this project.I submitted only one proposal to OpenMRS early as possible and i got good response from the mentors.So i got confident and avoid to submit any more proposals.


OpenMRS


OpenMRS is a web based open source enterprise medical recording system completely written using J2EE technology.It is used all over the world specially in developing world where the healthcare is facing resource constraints.
While i was  searching on how can i improve my coding skill i realized that contributing an open source project is the best way.I selected couple of organizations including OpenMRS.As time goes i was very comfortable with OpenMRS because they are very active community throughout the year and they have very good system to assist new comers.After joining the community i solved couple of tickets and developed a module called CleaningVoided.During this time my learning curve was very sharply rising.
As Google announced the GSOC program ,i decided to participate in the program and prepared a good proposal for idea "Enabling Smart Apps in OpenMRS ".Finaly i got selected and got a chance to contribute community further.Now i specially thanking the community for their valuable help they provided me to achive this.By the way this is only staring point ,in my view the success of this program is achieved at the end of the program when the people are using my code.
The proposal i submitted can be found here.
                                                    "Write Code. Save Lives"

Wednesday, January 26, 2011

Maven: Easy Build Tool Part I

Here I am going to post series of small posts about maven.

Introduction
Maven is a project of Apache foundation which ease the software building process.Now this is the famous project management software widely adapted across the software world.The understanding of the philosophy of the maven and familiarity with this software is essential requirement for programmers.If i tell what is maven in one sentence,maven consists of project object model (pom) ,set of standard template ,project life cycle ,a dependency management system and a logic for executing plugin goals during desired phase of the life cycle .The above feature are constructed as a module on the top of core software this is why each lifestyle event can be customized by plugins.
Project Object Model(pom.xml)
This is a XML file representing project setting.When we run the maven in a particular directory the maven scans the directory for this file and do the set up according this file.So it is mandatory for every maven project.Here the overview of the pom.xml file.

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <!-- The Basics -->
  <groupId>...</groupId>
  <artifactId>...</artifactId>
  <version>...</version>
  <packaging>...</packaging>
  <dependencies>...</dependencies>
  <parent>...</parent>
  <dependencyManagement>...</dependencyManagement>
  <modules>...</modules>
  <properties>...</properties>

  <!-- Build Settings -->
  <build>...</build>
  <reporting>...</reporting>

  <!-- More Project Information -->
  <name>...</name>
  <description>...</description>
  <url>...</url>
  <inceptionYear>...</inceptionYear>
  <licenses>...</licenses>
  <organization>...</organization>
  <developers>...</developers>
  <contributors>...</contributors>

  <!-- Environment Settings -->
  <issueManagement>...</issueManagement>
  <ciManagement>...</ciManagement>
  <mailingLists>...</mailingLists>
  <scm>...</scm>
  <prerequisites>...</prerequisites>
  <repositories>...</repositories>
  <pluginRepositories>...</pluginRepositories>
  <distributionManagement>...</distributionManagement>
  <profiles>...</profiles>
</project>
Maven Coordinates
Maven Coordinates is an identifier of the maven project which uniquely represents a maven project.This is used to locate the project artifact when the maven search for the project dependency in local repository.
<project xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
  http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.aja.javaexamples</groupId>
   <artifactId>springIOCExample</artifactId>
   <packaging>war</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>Spring IOC Example</name>
 </project> 

project descried by above minimal POM is located as $M2_REPO/com/ajajavaexamples/springIOCExampl
Usually the groubId represent the company for which the project belongs to and the artifactId uniquely represent the project with in the company .Version is a series number dictate the progress of the project.The package indicates the for example weather it is jar or war project.
Rest of the things will be covered in next post.
References:

  1. http://www.javaworld.com/javaworld/jw-12-2005/jw-1205-maven.html?page=1
  2. http://maven.apache.org/pom.html