Friday, December 16, 2011

Implementing a Queue Data Structure using JAVA

package QueueImp;

import java.util.LinkedList;

public
class Queue{

   
    private LinkedList<E> list;   

    public Queue(){       
        list = new LinkedList<E>();
    }

    public boolean isEmpty(){      // Check whether the Queue is empty
        return (list.size() == 0);
    }

    public void enqueue(Object item){      // Add element as the tail of Queue       
        list.add(item);
    }

    public Object dequeue(){        // Remove the head of Queue       
        Object item = list.get(1);       
         list.remove(1);       
         return item;
    }

    public Object peek(){       // Retrieve the head of Queue
        return list.get(1);
    }
}

Tuesday, September 27, 2011

Learn Objective C - iPhone App Development

Go through following link to learn Objective C programming language. Mainly that gives a basic Objective C knowledge as a starting point for iPhone App Development.

Learn Objective - C

Monday, September 5, 2011

Retrieve Users from LDAP server

I have already mentioned about how to set up LDAP server within Apache DS.Now you can add users to LDAP server by importing example.ldif file or creating users from scratch using this post.

After  following above steps you can view LDAP browser in Apache DS as follows,

Ex:-




Now it is the time to retrieve the users from LDAP server.
For that mainly I am using JAVA technology and Eclipse IDE.

Following is the simple code stuffs to retrieve all the users in LDAP server relevant to my LDAP browser as above and change colored stuffs which suit for your settings,

LdapSearch.java

import java.util.Properties;
import javax.naming.Context;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;

public class LdapSearch {

public static void main(String[] args) throws Exception {
       
Properties env = new Properties();              env.put("java.naming.factory.initial","com.sun.jndi.ldap.LdapCtxFactory");
env.put("java.naming.ldap.version", "3");
env.put("java.naming.provider.url", "ldap://localhost:10389");
env.put(Context.SECURITY_PRINCIPAL, "cn=jayan,ou=users,o=wso2");env.put(Context.SECURITY_CREDENTIALS, "075");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
       
DirContext ctx = null;
           
            try {
                ctx = new InitialDirContext(env);

                String url="ldap://localhost:10389/ou=users,o=wso2";
                                                                           // try changing yellow stuffs

                NamingEnumeration listResults = null;           
                listResults = ctx.list(url);
         
                while (listResults.hasMore()) {
                    NameClassPair ncp = (NameClassPair) listResults.next();                  
                    System.out.println(ncp.getName());        // users are here             
                }
            } catch (NamingException e) {               
                e.printStackTrace();
            }           
    }





Output :-
  
    
Download LdapSearch.java file ...

Tuesday, August 30, 2011

Setting up Android development Enviornment on linux

Today  there are several APIs to develop Android Applications.In this post,
I am going to work with ANDENGINE API SYSTEM.


prerequisite : JDK - java developmet kit          
                      Eclipse classic Enviornment

Step 1 -
Installing Android SDK

         Download Android SDK from here for linux
         Extract it to Android_SDK (SDK_HOME)

Step 2 -
Installing ADT(Android Development Tools) plug-in for Eclipse

        open Eclipse and go to help > Add New Software.
        then click Add button and dialog  gets popup
        enter ADT_plugin as Name and https://dl-ssl.google.com/android/eclipse/  as          url and continue with button clicks.
        after complete the installation restart the eclipse.

Step 3 -
Configure ADT plugin on Eclipse

        go to Window > Preferences
        Then select Android from left panel and click to proceed.
        use main panel and click browse button to locate the SDK_HOME for SDK           location.
        then click apply.

Step 4 -
Adding component and platforms for SDK

        use command line and goto ~/tools/ directory in SDK_HOME
        then type "android" and hit enter.
        now use eclipse and go to window -> Android SDK and AVD Manager and            that lists all components.
        then select component according to your project and proceed.

Step 5 -
Now you are available to work with android applications within eclipse classic enviornment.Now enjoy with Android.

Next post will be a Android application development example...
      
      
     
        


Thursday, August 25, 2011

Set up LDAP server using Apache Directory Studio on Linux

Basically we can set up LDAP server using command "apt-get install sldap".But when we are going to configure LDAP server which gives some troubles.Because of that, using Apache Directory Studio  we can set up and configure LDAP server easily.

1. Download Apache Directory Studio and extract it.

2. Then use command line and go to Apache DS home and use following command to run the Apache DS environment.
   
                  ~ApacheDS$ ./ApacheDirectoryStudio

3. Now we are going to set up LDAP SERVER within Apache DS.
First you have to open Servers Window using,
          Window -> Show View -> Other.. -> Apache DS -> Servers.

4.Let's create a new server clicking New Server icon in Servers Window and use a name for Server and edit default configuration setting by double clicking server name(server.xml) and start that server by clicking run icon.(I use default settings)

5. I have already created and started LDAP server and now I have to create a LDAP connection with running server to browse it as a tree structure.

6. For that use Menu Bar and open LDAP -> New Connection wizard and type Network Parameters and Authentication Parameters.

Network Parameters :
          Connection Name - {your own one}
          Host Name - {localhost}
          Port - {10389}

Authentication Parameters :
          Authentication Method - Simple Authentication
          Bind DN or User -  uid=admin ,ou =system
          Bind password - secret
         

7. Now go to Connection window and select your connection, then click open connection icon to browse the tree structure of LDAP server within LDAP browser window.

8. Then you can enjoy the LDAP server within Apache Directory Studio.




Friday, July 29, 2011

Search your history on WEB

Go to following URL and type your name in search box and get your history on the WEB ,

Thursday, July 21, 2011

Creating a Jira Soap Client

Mainly there are two ways of remote accessing for JIRA instance either using SOAP or XML-RPC.But easy way is to use SOAP Api.Because Atlassian Pages supply a SOAP Interface to work with more operations on remote accessing.

So following are the steps for creating Jira Soap client.

step 1 :
To work with Soap client, First you have to enable JAVA and MAVEN2 on linux environment.For that open ~/.bashrc file in your home directory and set the following variables.

export JAVA_HOME=path to Java dir
export M2_HOME=path to Maven2 dir
export PATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin

step 2 :
Then open a terminal and go to your project home directory.Then use following command to retrieve svn checkout from demo soap client distribution.

$ svn co http://svn.atlassian.com/svn/public/atlassian/rpc-jira-plugin/tags/atlassian_jira_4_1_1_1/jira-soapclient/

step 3 :
After that you must change the pom.xml of jira-soapclient project as follows,

<properties>
          <jira.soapclient.jiraurl>your_jira_url</jira.soapclient.jiraurl>
</properties>

Then add following repositories to pom.xml file.

<repositories>
      <repository>
         <id>atlassian</id>
         <name>Atlassian Repository</name>
         <url>https://maven.atlassian.com/content/groups/public</url>
      </repository>
    </repositories>


  <pluginRepositories>
       <pluginRepository>
                <id>atlassian</id>
                <name>Atlassian Repository</name>
                <url>https://maven.atlassian.com/content/groups/public</url>
       </pluginRepository>
   </pluginRepositories>



step 4 :
Then download the .WSDL file relevant to your jira instance to your project /src/main/wsdl directory using following command.

mvn -Pfetch-wsdl -Djira.soapclient.jiraurl=http://{your_jira_instance}/

step 5 :
After downloading .wsdl file, now generate/download all the dependencies(.jar s) and other needed classes for Soap client.run following,

mvn -Pbuildclient

step 6 :
Then create your jira-soapclient project as a Eclipse project or Idea project.use following,

mvn eclipse:eclipse        or     mvn idea:idea

and then using File -> import -> Existing project to workspace, import your project to Eclipse IDE.

step 7 :
Let's code the Jira Soap Client.
For that create your class in com.atlassian.jira_soapclient package and then try with following codes.

 //setting base URL
                String baseUrl="<your_jira_url>/rpc/soap/jirasoapservice-v2";

// get  handle to the JIRA SOAP Service from a client point of view
                SOAPSession soapSession = new SOAPSession(new URL(baseUrl));

//Connect to jira
                soapSession.connect(LOGIN_NAME, LOGIN_PASSWORD);

//JIRA SOAP Service, authentication token are used to make authentication calls
                JiraSoapService jiraSoapService = soapSession.getJiraSoapService();

                String authToken = soapSession.getAuthenticationToken();

step 8 :               
After getting authentication to the Jira system, then test the connection with retrieving all the project names under your jira system using following code samples. 

   List<String> names = new ArrayList<String>();

   RemoteProject[] Projects = jiraSoapService.getProjectsNoSchemes(authToken);

            for (RemoteProject project : Projects) {

                names.add(project.getKey());

            }
           
            System.out.print(names);

Then build project and check whether the code samples are working.If not don't forget to make a comment.Now you can also extend this using your functionalities And try to work with different code samples to be with Jira Soap Client practice.

So I think, this doc will become a nice tutorial for who are using JIRA SOAP CLIENT first time.