Showing posts with label JIRA. Show all posts
Showing posts with label JIRA. Show all posts

Saturday, April 10, 2010

Create a JSR 168 compatible JIRA portlet for Liferay.

Although Liferay web portal has a JIRA portlet which comes under World of Liferay (WOL), it is not a generic portlet which can be configured to work with any JIRA installation. It is written in a way which can display the issue summery from the Liferay organisation's JIRA application. This portlet is tightly bundled with several other portlets which are also in the WOL category. Also the code of the portlet was scattered everywhere, which made it is very difficult to understand. So extending the functionalities and maintaining the code was extremely hard.

But I had a requirement of creating a portlet which can be communicate with any JIRA installation. So I implemented a JSR 168 compatible portlet for JIRA. You can refer to this for get an idea about how I implemented that. Following diagrams shows the JIRA portlet.
  • This is the first view of the portlet when you add that to the portal page.
  • After user click on the link above, he can see the following edit mode of the portlet. Here user needs to enter the URL of the JIRA application and the Login name of the JIRA.
  • After the required values are entered these values are stored as preferences to the portlet and it will display the success message as follows.
  • Finally after the user Return to the full page, it will display the issue counts as follows.
You can download the complete source code of it from here and feel free to use it and give comments.

Tuesday, March 2, 2010

Liferay JIRA with my own JIRA installation.

Although I was able to configure the jira portlet to work with my own JIRA installation (You can find all the steps at my previous post) there was a serious issue with that. When I logged in as a valid user to my Running JIRA (on http://localhost:8090) I can create new projects(only if logged in as administrator), and create new issues to any of projects. In JIRA there is a unique ID for each project. (Eg: 10000, 10010 etc) When you create a new project, JIRA will assign an new unused ID for that and that ID is used everywhere within the database in order to identify the project. Project details are stored in jiradb/project table and issue details are stored in jiradb/jiraissue table. You can go to your database and see them if you want.

The problem with World of Liferay -JIRA portlet was it uses some constant project IDs and names in order to display the issue summery to the user. It stores this constants values in JIRAConstants.java interface. The view_jira.jspf file uses these constant IDs when creating the objects for the projects to display. So in order to change this, I had to change this view_jira.jspf completely.

I connected to the database of JIRA (jiradb) and select all the project IDs, their name and keys from the table project. Then I created the Jiraproject objects according to these data. The code is shown in below.

String[] prjIDs = new String[20];
String[] prjNames = new String[20];
String[] prjKeys = new String[20];
int meme =0;

Connection conn = null;
String myurl = "jdbc:mysql://127.0.0.1:3306/";
String mydbName = "jiradb";
String mydriver = "com.mysql.jdbc.Driver";
String myuserName = "root";
String mypassword = "";
try {
Class.forName(mydriver).newInstance();
conn = DriverManager.getConnection(myurl+mydbName,myuserName,mypassword);
Statement s = conn.createStatement ();
ResultSet resultset = s.executeQuery ("SELECT ID, pname, pkey FROM project");

while (resultset.next() )
{
String myID = resultset.getString("ID");
String myName = resultset.getString("pname");
String myKey = resultset.getString("pkey");

prjIDs[meme] = myID;
prjNames[meme] = myName;
prjKeys[meme] = myKey;
meme = meme+1;
}
} catch (Exception e) {
e.printStackTrace();
}
for (int i = 0; i <>
Object[] jiraProject = new Object[] {Integer.parseInt(prjIDs[i]), prjKeys[i], prjNames[i]};
int projectId = (Integer)jiraProject[0];
String projectKey = (String)jiraProject[1];
String projectName = (String)jiraProject[2];

Saturday, February 27, 2010

Liferay WOL portlets in community pages

Liferay have a set of portlets called World of Liferay (WOL) portlets. Under this category there are list of portlets such as JIRA, SVN, Summery, Friends, summery wall etc. By default these portlets are working only if they are placed on a private page. (eg:My Places -> My Community -> Private pages). If we place these portlets in a community page it will give an error messaye "This application will only function when placed on a user page"

I wanted to place the JIRA portlet in one of the community page and display the content successfully. In order to do that I updated tomcat-6.0.18\webapps\wol-portlet\init.jsp file with the following code.

WindowState windowState = renderRequest.getWindowState();

String currentURL = PortalUtil.getCurrentURL(request);

Group group = GroupLocalServiceUtil.getGroup(scopeGroupId);

Organization organization = null;
User user2 = null;

if (group.isOrganization()) {
organization = OrganizationLocalServiceUtil.getOrganization(group.getClassPK());
}

else if (group.isCommunity()) {
user2 = themeDisplay.getRealUser();
}
else if (group.isUser()) {
user2 = UserLocalServiceUtil.getUserById(group.getClassPK());

}

DateFormat dateFormatDate = DateFormat.getDateInstance(DateFormat.LONG, locale);

dateFormatDate.setTimeZone(timeZone);

DateFormat dateFormatDateTime = DateFormats.getDateTime(locale, timeZone);

NumberFormat numberFormat = NumberFormat.getNumberInstance(locale);


Friday, February 26, 2010

Configuring the JIRA Portlet in Liferay

This is how I configured the world of Liferay portlet-JIRA in Liferay. You can follow the below steps in order to configure that portlets. I'm using atlassian-jira-standard-3.7.4-standalone as my JIRA Installation and liferay-portal-tomcat-6.0-5.2.3 as my Liferay instance.

Installing JIRA:
See my post "Installing JIRA" to install the atlassian-jira-standard-3.7.4-standalone.

Installing MySQL and Connecting JIRA:

In order to configure the JIRA portlet in Liferay, you need to set the JIRA database in to a valid database. You can use any database such as MySQL, Oracle, DB2, Firebird, MaxDB,HSQL etc. Here are the steps to configure the MySQL database for the JIRA. You can find a complete instructions from http://www.atlassian.com/software/jira/docs/v3.7.4/databases/mysql.html

  • I'm using MySQL server 5.0 as my MySQL installation.
  • Create a database for JIRA to store issues (e.g. jiradb). I created it using MySQL Command Line Client.
create database jiradb;
  • Download the MySQL Connector/J JDBC driver from http://mysql.cs.pu.edu.tw/Downloads/Connector-J/mysql-connector-java-5.1.12.zip
  • Add the MySQL JDBC driver jar (mysql-connector-java-3.x.x-bin.jar) to the atlassian-jira-standard-3.7.4-standalone/common/lib/ directory.
  • Edit conf/server.xml and customise the username, password, driverClassName and url parameters for the Datasource.You have to edit followings. Also delete the minEvictableIdleTimeMillis and timeBetweenEvictionRunsMillis parameters.
username="root"
password=""
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/jiradb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8"
  • Edit atlassian-jira/WEB-INF/classes/entityengine.xml. You have to edit following parameters.
change the field-type-name attribute to mysql
delete this, if it exists: schema-name="PUBLIC"
  • Then you can start the JIRA using bin/startup.bat
Configuring Liferay:

Since World of Liferay-JIRA portlet is not an out of the box portlet, you have to configure it before using it. You can find a forum on doing this at http://www.liferay.com/community/forums/-/message_boards/message/4574654
Following is the list of steps that I have followd to configure that portlet.

  • liferay-portal-5.2.3\tomcat-6.0.18\webapps\wol-portlet\jira\view_jira_project.jspf uses hard coded urls to issues.liferay.com. I modified them to my JIRA installation URL. So now it looks like
String jiraURL = "http://localhost:8090/secure/Dashboard.jspa?reset=true&pid=" + projectId;

  • I updated wol-portlet\WEB-INF\jdbc.properties with appropriate values to access the JIRA database. So now it looks like:
jira.driverClassName=com.mysql.jdbc.Driver
jira.url=jdbc:mysql://localhost/jiradb?autoReconnect=true&useUnicode=true&characterEncoding=UTF8
jira.username=root
jira.password=

  • I Updated wol-portlet\WEB-INF\classes\portlet.properties to turn on jira synchronization.Now it looks like:
include-and-override=portlet-ext.properties
jira.synchronization.interval=5
  • After that Strat the liferay using bin/startup.bat

Adding the JIRA portlet to Liferay and customize:

Following are the steps that I followed in order to add the JIRA portlet.

  • Login to the Liferay with your user name and password. (May be default user name= test@liferay.com password=test)
  • Go to My Places -> My Community -> Private Pages and click add application.
  • Select and add JIRA and Summery portlets under the World of Liferay category.
  • Then you should see the "Set JIRA login" link in the JIRA portlet and set the login name here.
  • If you get any porblem with setting it from there, go to summery portlet "edit" link and set it.
  • After return to the previous page you should displayed the JIRA portlet.


Installing JIRA

The steps to install JIRA standalone on windows is listed below.
  1. Download the windows standalone version from http://downloads.atlassian.com/software/jira/downloads/atlassian-jira-standard-3.7.4-standalone.zip
  2. Unzip the folder to anywhere you wish to have your Jira installation.
  3. You can start the JIRA by bin/startup.bat.
  4. It will start the JIRA server and you can access it through your web browser using http://localhost:8080. (By default, JIRA Standalone runs on port 8080)
  5. You should now see the Setup Wizard, which will take you through the brief setup procedure. You can find a guide from http://confluence.atlassian.com/display/JIRA/Running+the+Setup+Wizard
  6. In order to complete the setup you need to have a License key for JiIRA. You can use a evaluation key which is generated by creating an account at Atlassian. http://www.atlassian.com/software/Signup!default.jspa?os_destination=%2Fmy%2Fjira%2FLicenses.jspa
  7. After the setup is completed successfully you can login to JIRA and use it through http://localhost:8080.
Troubleshooting:

  1. If you are already using the port 8080 for any other service you have to change that port. (In my case my Liferay is also running on this port).
  2. You can find a good tutorial on how to change port here. http://confluence.atlassian.com/display/JIRA/Changing+JIRA+Standalone%27s+port
  3. This can be fixed by changing JIRA to use another port (eg. 8090). This is done by editing conf\server.xml.
The start of the file looks like:


  • Here, change "8005" to "8006", and change "8080" to "8090" (or some other free port)
  • If you change the port to 8090, you can access the Jira by http://localhost:8090.

Saturday, February 20, 2010

My first experience with JIRA

JIRA is a proprietary enterprise software product, developed by Atlassian, commonly used for bug tracking, issue tracking, and project management. Since I'm developing a " Workflow Management System" I hope to use Jira as the Bug tracking and issue tracking tool of my system and I started to read about JIRA. JIRA has released initially in October 12, 2004 and it is written in Java. JIRA, is not an acronym but rather a truncation of "Gojira" (the Japanese name for Godzilla) It has Proprietary License but free for noncommercial. I hope to get the free version of it :)


JIRA Concepts


Issue : (http://confluence.atlassian.com/pages/viewpage.action?pageId=185729613)

  • Depending on how your organisation is using JIRA, an issue could represent a software bug, a project task, a helpdesk ticket, a leave request form, etc. Key components of JIRA issue are as below. (As shown in the image above)
  • Key components of JIRA issue are as below. (As shown in the image above)
  1. Key — a unique identifier for this issue.
  2. Type — (Bug, Improvement, New Feature, Task ,Custom Issue)
  3. Status — the stage the issue is currently at in its lifecycle ('workflow'). (Open, In progress, Resolved, Reopened, Closed)
  4. Resolution — a record of the issue's resolution (if the issue has been resolved) (Fixed, Won’t Fixed, Duplicate, Incomplete, Cannot Reproduce)
  5. Priority — the importance of the issue in relation to other issues. (Blocked, critical, major, minor, trivial)
  6. Assignee — the person to whom the issue is currently assigned.
  7. Reporter — the person who entered the issue into the system.
  8. Project — the 'parent' project to which the issue belongs.
  9. Component(s) (if applicable) — project component(s) to which this issue relates.
  10. Affects Version(s) (if applicable) — project version(s) for which the issue is (or was) manifesting.
  11. Fix Version(s) (if applicable) — project version(s) for which the issue was (or will be) fixed.
  12. Summary — a brief one-line summary of the issue.
  13. Environment (if applicable) — the hardware or software environment to which the issue relates.
  14. Description — a detailed description of the issue.
  15. Comments — added by people who are working on the issue.

Project: (http://confluence.atlassian.com/pages/viewpage.action?pageId=185729449)

  • A project is a collection of issues:
  • Some Examples are
a software development project
a marketing campaign
a helpdesk system
a leave request management system
a website enhancement request system
  • Issue Example
Project Name : Web site project
Project Key : WEB
Issue keys : WEB 100, WEB 101, WEB103
  • A project component is a logical grouping of issues within a project. Each project may consist of various components (or none)
Project Name : Web site project
Project Key : WEB
Issue keys : WEB 100, WEB 101, WEB103
Components : Documentation', 'Backend', 'Email Subsystem', 'GUI'
Documentation Issues : WEB 100, WEB 101
Backend issues :WEB 103
  • Version : For some types of projects, particularly software development, it is useful to be able to associate an issue with a particular project version.Version can be in any of three states. (Released, Unreleased or Archived)

Workflow (http://confluence.atlassian.com/pages/viewpage.action?pageId=185729618)

  • Workflow is the movement of an issue through various Statuses during its lifecycle.