Internet Cafe System

April 25th, 2009 Divyen Patel Comments off
Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
Categories: Academic Projects Tags:

Project Management System

April 25th, 2009 Divyen Patel Comments off




This Project was aimed to manage any generic project which can be split up in to well define tasks.

Administrator is the super user and is responsible for creating projects in to system. Each project is assigned the Project leader, who is responsible for creating tasks, managing team and assigning tasks to team members. Team member in turn can create jobs for each of the tasks assigned by project leader. Each job team member creates should have some weight toward entire task, which is assigned by team member in consultation with reviewer. On the daily basis each team member reports their progress on jobs. Using weighted average, entire project progress is calculated.

This system also allows to interact and collaborate with team mates using built in mail system.

Task Alert Engine which runs on different machine continuously scans progress of tasks and their deadlines. Deadline reminder is sent to team members, project leaders and reviewers before the customized days for each project.

Technologies:
ASP.net 1.1 using C# and VB.net 2003, SQL Server Reporting    Service, SQL Server 2000



Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
Categories: Academic Projects Tags:

Consuming PHP Zend Rest API in Java

March 25th, 2009 Divyen Patel 5 comments

Share/Save/Bookmark

In my last Weblog entry, I described the steps on developing Rest API in PHP using Zend Framework.

Now we have Rest API ready to be consumed by the client. Let consume it using Java Client.

Before beginning the coding part, we need to download following library.

The Jakarta Commons HttpClient 3.1 Library

http://mirror.olnevhost.net/pub/apache/httpcomponents/commons-httpclient/binary/commons-httpclient-3.1.tar.gz

Apache Commons Logging Library

http://mirrors.kahuki.com/apache/commons/logging/binaries/commons-logging-1.1.1-bin.tar.gz

Apache Commons Codec Library

http://download.nextag.com/apache/commons/codec/binaries/commons-codec-1.3.tar.gz

First of all lets create the new NetBeans project. Select “java” from the project categories and “java Application” from the projects list. Click Next, name your project as “zend_rest_client” and finally click Finish button.

Snap-1

Snap-1

Snap-2

Snap-2

Right click on the Library and Select the Property. Add downloaded Library files using “Add Jar/Folder”.

Snap-3

Snap-3

Click “OK” and then replace the content of Main.Java file with the following code.

package zend_rest_client;

import com.sun.org.apache.xerces.internal.parsers.DOMParser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringReader;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/* @author divyen patel */

public class Main {

    public static void main(String[] args) throws IOException, SAXException {
        String str_REST_SERVER = "http://localhost";
        String str_Port = "80"; //Default Apache Port
        String str_rest_API_page = "weather_rest.php";
        String str_rest_method = "get_temperature";
        String str_rest_method_argument = "zipcode=95035";
        String str_rest_url = str_REST_SERVER + ":" + str_Port + "/" + str_rest_API_page + "?method=" + str_rest_method + "&" + str_rest_method_argument;
        System.out.println("Request URL:" + str_rest_url + "\n");
// Send GET request
        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(str_rest_url);
        int statusCode = client.executeMethod(method);
        InputStream rstream = null;
        rstream = method.getResponseBodyAsStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(rstream));
        String line;
        String xmlString = "";
        while ((line = br.readLine()) != null) {
            xmlString = xmlString + line;
        }
        System.out.println("Request Response:" + xmlString + "\n");
//Parsing XML Response
        DOMParser parser = new DOMParser();
        parser.parse(new InputSource(new StringReader(xmlString)));
        Document document = parser.getDocument();
        System.out.println("Parsing XML Response");
        if (document.getElementsByTagName("status").item(0).getTextContent().equals("passed")) {
            System.out.println("Status: Passed");
            System.out.println("zipcode:" + document.getElementsByTagName("zipcode").item(0).getTextContent());
            System.out.println("tempHigh:" + document.getElementsByTagName("tempHigh").item(0).getTextContent());
            System.out.println("templow:" + document.getElementsByTagName("templow").item(0).getTextContent());
        } else {
            System.out.println("Status: Failed");
        }
    }
}

Finally right click on the project and Build it. You may see some warnings stating “DOMParser is Sun proprietary API and may be removed in a future release”. You can ignore these warnings.

Run the project and see the output in the IDE

Snap-4

Snap-4

You can also test it in the terminal console, using “java -jar <location of the jar file>”

Snap-5

Snap-5

If you have any better solution for consuming REST API in Java, please share with me. I am egar to learn it.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • Twitter
Categories: JAVA, php Tags: