directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r992827 [2/4] - in /directory/sandbox/kayyagari/http-directory: ./ directory-http-ui/ directory-http-ui/src/ directory-http-ui/src/main/ directory-http-ui/src/main/java/ directory-http-ui/src/main/java/org/ directory-http-ui/src/main/java/o...
Date Sun, 05 Sep 2010 17:14:02 GMT
Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/LoginPanel.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/LoginPanel.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/LoginPanel.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/LoginPanel.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,217 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * LoginPanel.java
+ *
+ * Created on Aug 26, 2010, 7:23:14 PM
+ */
+package org.apache.directory.http.client.ui;
+
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.apache.directory.http.client.ui.callback.LoginHandler;
+
+
+/**
+ *
+ * @author kayyagari
+ */
+public class LoginPanel extends javax.swing.JPanel implements ActionListener
+{
+
+    private LoginHandler loginHandler;
+
+
+    /** Creates new form LoginPanel */
+    public LoginPanel()
+    {
+        initComponents();
+
+        txtUserName.setText( "uid=admin,ou=system" );
+        txtPassword.setText( "secret" );
+        
+        btnLogin.addActionListener( this );
+        txtPassword.addActionListener( this );
+    }
+
+
+    public void actionPerformed( ActionEvent e )
+    {
+        if ( getServiceUrl() == null )
+        {
+            txtUrl.requestFocus();
+        }
+        else
+        {
+            login();
+        }
+
+    }
+
+
+    private void login()
+    {
+        if ( loginHandler != null )
+        {
+            loginHandler.login( txtUserName.getText(), txtPassword.getPassword() );
+        }
+
+    }
+
+
+    public URL getServiceUrl()
+    {
+
+        try
+        {
+            return new URL( txtUrl.getText().trim() );
+        }
+        catch ( MalformedURLException e )
+        {
+            return null;
+        }
+    }
+
+
+    public void clearPassword()
+    {
+        txtPassword.setText( "" );
+    }
+
+
+    public void setLoginHandler( LoginHandler loginHandler )
+    {
+        this.loginHandler = loginHandler;
+    }
+
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents()
+    {
+
+        lblPassword = new javax.swing.JLabel();
+        lblUserName = new javax.swing.JLabel();
+        btnLogin = new javax.swing.JButton();
+        jLabel1 = new javax.swing.JLabel();
+        txtUserName = new javax.swing.JTextField();
+        txtPassword = new javax.swing.JPasswordField();
+        lblUrl = new javax.swing.JLabel();
+        txtUrl = new javax.swing.JTextField();
+
+        lblPassword.setText( "Password:" );
+
+        lblUserName.setText( "User Name:" );
+
+        btnLogin.setText( "Login" );
+
+        jLabel1.setText( "e.x uid=admin,ou=system" );
+
+        lblUrl.setText( "ServiceURL:" );
+
+        txtUrl.setText( "http://localhost:7009/adminapp/ldap" );
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout( this );
+        this.setLayout( layout );
+        layout.setHorizontalGroup( layout.createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING )
+            .add(
+                layout
+                    .createSequentialGroup()
+                    .add(
+                        layout
+                            .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING )
+                            .add( layout.createSequentialGroup().add( 177, 177, 177 ).add( jLabel1 ) )
+                            .add( layout.createSequentialGroup().add( 204, 204, 204 ).add( btnLogin ) )
+                            .add(
+                                layout
+                                    .createSequentialGroup()
+                                    .add(
+                                        layout
+                                            .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING, false )
+                                            .add(
+                                                org.jdesktop.layout.GroupLayout.TRAILING,
+                                                layout
+                                                    .createSequentialGroup()
+                                                    .addContainerGap( org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+                                                        Short.MAX_VALUE ).add( lblPassword ).add( 1, 1, 1 ) )
+                                            .add(
+                                                layout
+                                                    .createSequentialGroup()
+                                                    .add( 96, 96, 96 )
+                                                    .add(
+                                                        layout
+                                                            .createParallelGroup(
+                                                                org.jdesktop.layout.GroupLayout.LEADING )
+                                                            .add( lblUrl,
+                                                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73,
+                                                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE )
+                                                            .add( lblUserName ) ) ) )
+                                    .add( 1, 1, 1 )
+                                    .add(
+                                        layout
+                                            .createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING )
+                                            .add( txtUrl, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 269,
+                                                org.jdesktop.layout.GroupLayout.PREFERRED_SIZE )
+                                            .add(
+                                                layout
+                                                    .createParallelGroup( org.jdesktop.layout.GroupLayout.TRAILING,
+                                                        false )
+                                                    .add( org.jdesktop.layout.GroupLayout.LEADING, txtPassword )
+                                                    .add( org.jdesktop.layout.GroupLayout.LEADING, txtUserName,
+                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 206,
+                                                        Short.MAX_VALUE ) ) ) ) )
+                    .addContainerGap( 122, Short.MAX_VALUE ) ) );
+        layout.setVerticalGroup( layout.createParallelGroup( org.jdesktop.layout.GroupLayout.LEADING ).add(
+            layout
+                .createSequentialGroup()
+                .add( 31, 31, 31 )
+                .add(
+                    layout
+                        .createParallelGroup( org.jdesktop.layout.GroupLayout.BASELINE )
+                        .add( txtUrl, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE ).add( lblUrl ) )
+                .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED )
+                .add(
+                    layout
+                        .createParallelGroup( org.jdesktop.layout.GroupLayout.BASELINE )
+                        .add( lblUserName )
+                        .add( txtUserName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE ) )
+                .add( 2, 2, 2 )
+                .add( jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 12,
+                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE )
+                .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED )
+                .add(
+                    layout
+                        .createParallelGroup( org.jdesktop.layout.GroupLayout.BASELINE )
+                        .add( txtPassword, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE ).add( lblPassword ) )
+                .addPreferredGap( org.jdesktop.layout.LayoutStyle.RELATED ).add( btnLogin )
+                .addContainerGap( 64, Short.MAX_VALUE ) ) );
+    }// </editor-fold>//GEN-END:initComponents
+     // Variables declaration - do not modify//GEN-BEGIN:variables
+
+    private javax.swing.JButton btnLogin;
+    private javax.swing.JLabel jLabel1;
+    private javax.swing.JLabel lblPassword;
+    private javax.swing.JLabel lblUrl;
+    private javax.swing.JLabel lblUserName;
+    private javax.swing.JPasswordField txtPassword;
+    private javax.swing.JTextField txtUrl;
+    private javax.swing.JTextField txtUserName;
+    // End of variables declaration//GEN-END:variables
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.form
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.form?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.form (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.form Sun Sep  5 17:13:58 2010
@@ -0,0 +1,71 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="3"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="topPanel" alignment="0" max="32767" attributes="0"/>
+          <Component id="middleSplitPanel" alignment="0" pref="964" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="topPanel" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="middleSplitPanel" pref="488" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JPanel" name="topPanel">
+
+      <Layout>
+        <DimensionLayout dim="0">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Group type="102" alignment="0" attributes="0">
+                  <EmptySpace min="-2" pref="471" max="-2" attributes="0"/>
+                  <Component id="lblUserName" min="-2" pref="159" max="-2" attributes="0"/>
+                  <EmptySpace pref="334" max="32767" attributes="0"/>
+              </Group>
+          </Group>
+        </DimensionLayout>
+        <DimensionLayout dim="1">
+          <Group type="103" groupAlignment="0" attributes="0">
+              <Component id="lblUserName" alignment="0" pref="28" max="32767" attributes="0"/>
+          </Group>
+        </DimensionLayout>
+      </Layout>
+      <SubComponents>
+        <Component class="javax.swing.JLabel" name="lblUserName">
+        </Component>
+      </SubComponents>
+    </Container>
+    <Container class="javax.swing.JSplitPane" name="middleSplitPanel">
+      <Properties>
+        <Property name="dividerLocation" type="int" value="130"/>
+      </Properties>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout"/>
+    </Container>
+  </SubComponents>
+</Form>

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/MainWindow.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,375 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * MainWindow.java
+ *
+ * Created on Aug 26, 2010, 7:25:52 PM
+ */
+package org.apache.directory.http.client.ui;
+
+
+import java.awt.Component;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.event.TreeExpansionEvent;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.event.TreeWillExpandListener;
+import javax.swing.tree.ExpandVetoException;
+import javax.swing.tree.TreePath;
+
+import org.apache.directory.http.client.LdapHttpConnection;
+import org.apache.directory.http.client.data.model.ConfigDataLoader;
+import org.apache.directory.http.client.ui.callback.ConfigButtonSelectionHandler;
+import org.apache.directory.http.client.ui.callback.LoginHandler;
+import org.apache.directory.http.client.ui.model.EntryNode;
+import org.apache.directory.http.client.ui.model.EntryTableModel;
+import org.apache.directory.shared.ldap.cursor.Cursor;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.BindResponse;
+import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
+import org.apache.directory.shared.ldap.name.DN;
+
+
+/**
+ *
+ * @author kayyagari
+ */
+public class MainWindow extends javax.swing.JFrame implements LoginHandler, ConfigButtonSelectionHandler
+{
+
+    private LoginPanel loginPanel;
+
+    private ConfigButtonPanel configBtnPanel;
+
+    private PartitionsPanel partitonsPanel;
+
+    private InterceptorPanel interceptorPanel;
+
+    private LdapHttpConnection connection;
+
+    private ConfigDataLoader dataLoader;
+
+    private BrowserPanel browser;
+
+    private EntryTableModel model;
+    
+    /** Creates new form MainWindow */
+    public MainWindow()
+    {
+        initComponents();
+
+        setTitle( "LDAP browser using HTTP as transport and using JSON for data exchange" );
+        loginPanel = new LoginPanel();
+        loginPanel.setLoginHandler( this );
+
+        configBtnPanel = new ConfigButtonPanel();
+        configBtnPanel.getBtnPartitions().setVisible( false );
+        configBtnPanel.setButtonSelectionHandler( this );
+        middleSplitPanel.setLeftComponent( configBtnPanel );
+        configBtnPanel.setVisible( false );
+        middleSplitPanel.setRightComponent( loginPanel );
+        addWindowListener( new WindowAdapter()
+        {
+
+            @Override
+            public void windowClosing( WindowEvent e )
+            {
+                try
+                {
+                    if( connection != null )
+                    {
+                        connection.unBind();
+                    }
+                }
+                catch( Exception ex )
+                {
+                    ex.printStackTrace();
+                }
+            }
+        });
+    }
+
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        topPanel = new javax.swing.JPanel();
+        lblUserName = new javax.swing.JLabel();
+        middleSplitPanel = new javax.swing.JSplitPane();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+        org.jdesktop.layout.GroupLayout topPanelLayout = new org.jdesktop.layout.GroupLayout(topPanel);
+        topPanel.setLayout(topPanelLayout);
+        topPanelLayout.setHorizontalGroup(
+            topPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(topPanelLayout.createSequentialGroup()
+                .add(471, 471, 471)
+                .add(lblUserName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 159, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(334, Short.MAX_VALUE))
+        );
+        topPanelLayout.setVerticalGroup(
+            topPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(lblUserName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
+        );
+
+        middleSplitPanel.setDividerLocation(130);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(topPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+            .add(middleSplitPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 964, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .add(topPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(middleSplitPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE))
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main( String args[] )
+    {
+        java.awt.EventQueue.invokeLater( new Runnable()
+        {
+
+            public void run()
+            {
+                new MainWindow().setVisible( true );
+            }
+
+        } );
+    }
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JLabel lblUserName;
+    private javax.swing.JSplitPane middleSplitPanel;
+    private javax.swing.JPanel topPanel;
+    // End of variables declaration//GEN-END:variables
+    public void login( String userName, char[] password )
+    {
+        try
+        {
+            connection = new LdapHttpConnection( loginPanel.getServiceUrl() );
+            BindResponse resp = connection.bind( userName, String.valueOf( password ) );
+            if ( resp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+            {
+                loginPanel.clearPassword();
+                loginPanel.setVisible( false );
+                
+                lblUserName.setText( userName.trim() );
+                
+                dataLoader = new ConfigDataLoader( connection );
+                showNavigationPane();
+                setRightPane( new JPanel() );
+            }
+            else
+            {
+                JOptionPane.showMessageDialog( this, resp );
+            }
+
+        }
+        catch ( Exception e )
+        {
+            JOptionPane.showMessageDialog( this, e );
+        }
+    }
+
+
+    public void handleConfigSelection( JButton eventSrc )
+    {
+        try
+        {
+            if ( eventSrc == configBtnPanel.getBtnPartitions() )
+            {
+                partitonsPanel = new PartitionsPanel();
+                setRightPane( partitonsPanel );
+            }
+            else if ( eventSrc == configBtnPanel.getBtnInterceptors() )
+            {
+                interceptorPanel = new InterceptorPanel();
+                interceptorPanel.setEntryData( dataLoader.getInterceptors() );
+                setRightPane( interceptorPanel );
+            }
+            else if ( eventSrc == configBtnPanel.getBtnBrowse() )
+            {
+                showBrowser();
+            }
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void showBrowser()
+    {
+        try
+        {
+            if ( browser == null )
+            {
+                browser = new BrowserPanel();
+                
+                model = new EntryTableModel();
+                
+                browser.getEntryTable().setModel( model );
+
+                EntryNode root = new EntryNode( connection.fetchRootDSE() );
+
+                List<Entry> entries = searchEntriesUnder( DN.EMPTY_DN );
+
+                for ( Entry e : entries )
+                {
+                    EntryNode node = new EntryNode( e );
+                    node.setAllowsChildren( true );
+                    root.add( node );
+                }
+
+                browser.setRootDse( root );
+
+                browser.getEntryTree().addTreeWillExpandListener( new TreeWillExpandListener()
+                {
+
+                    public void treeWillExpand( TreeExpansionEvent event ) throws ExpandVetoException
+                    {
+                        try
+                        {
+                            EntryNode node = ( EntryNode ) event.getPath().getLastPathComponent();
+                            browser.addEntriesToTreeUnder( searchEntriesUnder( node.getDn() ), node );
+                        }
+                        catch ( Exception e )
+                        {
+                            JOptionPane.showMessageDialog( null, e );
+                        }
+                    }
+
+
+                    public void treeWillCollapse( TreeExpansionEvent event ) throws ExpandVetoException
+                    {
+                    }
+                } );
+
+                browser.getEntryTree().addTreeSelectionListener( new TreeSelectionListener()
+                {
+
+                    public void valueChanged( TreeSelectionEvent e )
+                    {
+                        TreePath path = e.getNewLeadSelectionPath();
+                        
+                        EntryNode node = ( EntryNode ) path.getLastPathComponent();
+                        try
+                        {
+                            Entry entry = populateEntry( node.getDn() );
+                            if( entry == null )
+                            {
+                                JOptionPane.showMessageDialog( null, "entry with DN " + node.getDn() + " doesn't exist" );
+                                return;
+                            }
+                            
+                            node.setEntry( entry );
+                            model.setEntry( node.getEntry() );
+                            model.fireTableDataChanged();
+                        }
+                        catch( Exception ex )
+                        {
+                            ex.printStackTrace();
+                            JOptionPane.showMessageDialog( null, ex );
+                        }
+                    }
+                } );
+            }
+
+            setRightPane( browser );
+        }
+        catch ( Exception e )
+        {
+
+        }
+    }
+
+
+    private void showNavigationPane()
+    {
+        middleSplitPanel.getLeftComponent().setVisible( true );
+    }
+
+
+    private void hideNavigationPane()
+    {
+        middleSplitPanel.getLeftComponent().setVisible( false );
+    }
+
+
+    private void setNavigationPane( Component comp )
+    {
+        middleSplitPanel.setLeftComponent( comp );
+    }
+
+
+    private void setRightPane( Component comp )
+    {
+        middleSplitPanel.setRightComponent( comp );
+    }
+
+
+    private void showRightPane()
+    {
+        middleSplitPanel.getRightComponent().setVisible( true );
+    }
+
+
+    private void hideRightPane()
+    {
+        middleSplitPanel.getRightComponent().setVisible( false );
+    }
+   
+    private Entry populateEntry( DN entryDn ) throws Exception
+    {
+        return connection.lookup( entryDn, "*", "+" );
+    }
+    
+    
+    private List<Entry> searchEntriesUnder( DN baseDn ) throws Exception
+    {
+        List<Entry> entries = new ArrayList<Entry>();
+
+        Cursor<Response> cursor = connection.search( baseDn, "(objectClass=*)", SearchScope.ONELEVEL, "1.1" );
+        while ( cursor.next() )
+        {
+            Entry entry = ( ( SearchResultEntry ) cursor.get() ).getEntry();
+            entries.add( entry );
+        }
+
+        cursor.close();
+        return entries;
+    }
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.form
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.form?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.form (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.form Sun Sep  5 17:13:58 2010
@@ -0,0 +1,91 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" attributes="0">
+                  <Component id="jScrollPane2" alignment="0" min="-2" pref="238" max="-2" attributes="0"/>
+                  <Component id="jScrollPane1" alignment="0" min="-2" pref="150" max="-2" attributes="0"/>
+                  <Component id="lblPartitions" alignment="0" min="-2" pref="74" max="-2" attributes="0"/>
+                  <Component id="lblIndexes" alignment="0" min="-2" pref="79" max="-2" attributes="0"/>
+              </Group>
+              <EmptySpace pref="304" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="lblPartitions" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane1" min="-2" pref="102" max="-2" attributes="0"/>
+              <EmptySpace type="separate" max="-2" attributes="0"/>
+              <Component id="lblIndexes" min="-2" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jScrollPane2" min="-2" max="-2" attributes="0"/>
+              <EmptySpace pref="34" max="32767" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Component class="javax.swing.JLabel" name="lblPartitions">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Partitions"/>
+      </Properties>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JList" name="lstPartitions">
+          <Properties>
+            <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
+              <StringArray count="0"/>
+            </Property>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JLabel" name="lblIndexes">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="Indexes"/>
+      </Properties>
+    </Component>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane2">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JList" name="lstIndexes">
+          <Properties>
+            <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
+              <StringArray count="0"/>
+            </Property>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/PartitionsPanel.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,87 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * PartitionsPanel.java
+ *
+ * Created on Aug 22, 2010, 11:41:42 PM
+ */
+
+package org.apache.directory.http.client.ui;
+
+/**
+ *
+ * @author kayyagari
+ */
+public class PartitionsPanel extends javax.swing.JPanel {
+
+    /** Creates new form PartitionsPanel */
+    public PartitionsPanel() {
+        initComponents();
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        lblPartitions = new javax.swing.JLabel();
+        jScrollPane1 = new javax.swing.JScrollPane();
+        lstPartitions = new javax.swing.JList();
+        lblIndexes = new javax.swing.JLabel();
+        jScrollPane2 = new javax.swing.JScrollPane();
+        lstIndexes = new javax.swing.JList();
+
+        lblPartitions.setText("Partitions");
+
+        jScrollPane1.setViewportView(lstPartitions);
+
+        lblIndexes.setText("Indexes");
+
+        jScrollPane2.setViewportView(lstIndexes);
+
+        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 238, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 150, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(lblPartitions, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                    .add(lblIndexes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 79, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+                .addContainerGap(304, Short.MAX_VALUE))
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+            .add(layout.createSequentialGroup()
+                .addContainerGap()
+                .add(lblPartitions)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .add(18, 18, 18)
+                .add(lblIndexes)
+                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap(34, Short.MAX_VALUE))
+        );
+    }// </editor-fold>//GEN-END:initComponents
+
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JScrollPane jScrollPane2;
+    private javax.swing.JLabel lblIndexes;
+    private javax.swing.JLabel lblPartitions;
+    private javax.swing.JList lstIndexes;
+    private javax.swing.JList lstPartitions;
+    // End of variables declaration//GEN-END:variables
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigAware.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigAware.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigAware.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigAware.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,18 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.apache.directory.http.client.ui.callback;
+
+import java.util.List;
+
+import org.apache.directory.http.client.data.model.EntryData;
+
+/**
+ *
+ * @author kayyagari
+ */
+public interface ConfigAware
+{
+    void setEntryData( List<EntryData> data );
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigButtonSelectionHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigButtonSelectionHandler.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigButtonSelectionHandler.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigButtonSelectionHandler.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,16 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.directory.http.client.ui.callback;
+
+import javax.swing.JButton;
+
+/**
+ *
+ * @author kayyagari
+ */
+public interface ConfigButtonSelectionHandler {
+void handleConfigSelection( JButton eventSrc );
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigModificationHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigModificationHandler.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigModificationHandler.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/ConfigModificationHandler.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,16 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.directory.http.client.ui.callback;
+
+/**
+ *
+ * @author kayyagari
+ */
+public interface ConfigModificationHandler {
+
+    void cancel();
+    void apply();
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/LoginHandler.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/LoginHandler.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/LoginHandler.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/callback/LoginHandler.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,15 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.directory.http.client.ui.callback;
+
+/**
+ *
+ * @author kayyagari
+ */
+public interface LoginHandler {
+
+    void login( String userName, char[] password );
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryNode.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryNode.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryNode.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryNode.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,75 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.http.client.ui.model;
+
+
+import javax.swing.tree.DefaultMutableTreeNode;
+
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.name.DN;
+
+
+/**
+ * TODO EntryNode.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EntryNode extends DefaultMutableTreeNode
+{
+    private Entry entry;
+
+
+    public EntryNode( Entry entry )
+    {
+        this.entry = entry;
+    }
+
+
+    public Entry getEntry()
+    {
+        return entry;
+    }
+
+
+    public void setEntry( Entry entry )
+    {
+        this.entry = entry;
+    }
+
+    public DN getDn()
+    {
+        return entry.getDn();
+    }
+
+    @Override
+    public String toString()
+    {
+        DN dn = entry.getDn();
+        
+        if( DN.EMPTY_DN.equals( dn ) )
+        {
+            return "RootDSE";
+        }
+        
+        return dn.getName();
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryTableModel.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryTableModel.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryTableModel.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/model/EntryTableModel.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,155 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.http.client.ui.model;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.swing.table.DefaultTableModel;
+
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+
+
+/**
+ * TODO EntryTableModel.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EntryTableModel extends DefaultTableModel
+{
+    private Entry entry;
+
+    private int rowCount;
+
+    private Map<String, Object> values = new HashMap<String, Object>();
+
+    private static final String[] COLUMNS =
+        { "Name", "Value" };
+
+    private int rowPos = 0;
+
+
+    public void setEntry( Entry entry )
+    {
+        this.entry = entry;
+
+        rowPos = 0;
+        values.clear();
+        rowCount = 0;
+        
+        //first OC
+        EntryAttribute oc = entry.get( SchemaConstants.OBJECT_CLASS_AT );
+
+        if ( oc != null )
+        {
+            rowCount = oc.size();
+            populateValueTable( oc );
+        }
+
+        for ( EntryAttribute ea : entry )
+        {
+            if ( ea.getId().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) )
+            {
+                continue;
+            }
+
+            rowCount += ea.size();
+            populateValueTable( ea );
+        }
+    }
+
+
+    private void populateValueTable( EntryAttribute attr )
+    {
+        String nameCol = null;
+        String valueCol = null;
+        String attrId = attr.getId();
+
+        int attrSize = attr.size();
+
+        for ( int i = 0; i < attrSize; i++ )
+        {
+            nameCol = String.valueOf( rowPos ) + 0;
+            values.put( nameCol, attrId );
+
+            valueCol = String.valueOf( rowPos ) + 1;
+
+            Object val = null;
+            if ( attr.isHR() )
+            {
+                val = attr.get( i ).getString();
+            }
+            else
+            {
+                val = attr.get( i ).getBytes();
+            }
+
+            values.put( valueCol, val );
+
+            rowPos++;
+        }
+    }
+
+
+    @Override
+    public int getColumnCount()
+    {
+        return 2;
+    }
+
+
+    @Override
+    public String getColumnName( int index )
+    {
+        return COLUMNS[index];
+    }
+
+
+    @Override
+    public int getRowCount()
+    {
+        return rowCount;
+    }
+
+
+    @Override
+    public boolean isCellEditable( int row, int column )
+    {
+        return false;
+    }
+
+
+    @Override
+    public Object getValueAt( int row, int column )
+    {
+        Object val = values.get( row + "" + column );
+        if ( val instanceof byte[] )
+        {
+            return "Binary Data, length " + ( ( byte[] ) val ).length + " bytes";
+        }
+
+        return val;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/AttributeTableCellRenderer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/AttributeTableCellRenderer.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/AttributeTableCellRenderer.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/AttributeTableCellRenderer.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,143 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.http.client.ui.renderer;
+
+
+import java.awt.Color;
+import java.awt.Component;
+
+import javax.swing.JTable;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.DefaultTableCellRenderer;
+
+
+/**
+ * TODO AttributeTableCellRenderer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AttributeTableCellRenderer extends DefaultTableCellRenderer
+{
+
+    protected static Border noFocusBorder = new EmptyBorder( 1, 1, 1, 1 );
+    private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder( 1, 1, 1, 1 );
+
+    private Color unselectedForeground;
+    private Color unselectedBackground;
+
+
+    /**
+     * Overrides <code>JComponent.setForeground</code> to assign
+     * the unselected-foreground color to the specified color.
+     * 
+     * @param c set the foreground color to this value
+     */
+    public void setForeground( Color c )
+    {
+        super.setForeground( c );
+        unselectedForeground = c;
+    }
+
+
+    /**
+     * Overrides <code>JComponent.setBackground</code> to assign
+     * the unselected-background color to the specified color.
+     *
+     * @param c set the background color to this value
+     */
+    public void setBackground( Color c )
+    {
+        super.setBackground( c );
+        unselectedBackground = c;
+    }
+
+
+    @Override
+    public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus,
+        int row, int column )
+    {
+        if ( isSelected )
+        {
+            super.setForeground( table.getSelectionForeground() );
+            super.setBackground( table.getSelectionBackground() );
+        }
+        else
+        {
+            super.setForeground( ( unselectedForeground != null ) ? unselectedForeground : table.getForeground() );
+            super.setBackground( ( unselectedBackground != null ) ? unselectedBackground : table.getBackground() );
+        }
+
+        setFont( table.getFont() );
+
+        if ( hasFocus )
+        {
+            Border border = null;
+            if ( isSelected )
+            {
+                border = UIManager.getBorder( "Table.focusSelectedCellHighlightBorder" );
+            }
+            if ( border == null )
+            {
+                border = UIManager.getBorder( "Table.focusCellHighlightBorder" );
+            }
+            setBorder( border );
+
+            if ( !isSelected && table.isCellEditable( row, column ) )
+            {
+                Color col;
+                col = UIManager.getColor( "Table.focusCellForeground" );
+                if ( col != null )
+                {
+                    super.setForeground( col );
+                }
+                col = UIManager.getColor( "Table.focusCellBackground" );
+                if ( col != null )
+                {
+                    super.setBackground( col );
+                }
+            }
+        }
+        else
+        {
+            setBorder( getNoFocusBorder() );
+        }
+
+        setValue( value );
+
+        return this;
+    }
+
+
+    private static Border getNoFocusBorder()
+    {
+        if ( System.getSecurityManager() != null )
+        {
+            return SAFE_NO_FOCUS_BORDER;
+        }
+        else
+        {
+            return noFocusBorder;
+        }
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/EntryDataCellRenderer.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/EntryDataCellRenderer.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/EntryDataCellRenderer.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-http-ui/src/main/java/org/apache/directory/http/client/ui/renderer/EntryDataCellRenderer.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,136 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.http.client.ui.renderer;
+
+
+import java.awt.Component;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+
+import org.apache.directory.http.client.data.model.EntryData;
+
+
+/**
+ * TODO EntryDataCellRenderer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EntryDataCellRenderer extends DefaultListCellRenderer
+{
+
+    private String attrName;
+
+    protected static Border noFocusBorder = new EmptyBorder( 1, 1, 1, 1 );
+    private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder( 1, 1, 1, 1 );
+
+
+    public EntryDataCellRenderer( String attrName )
+    {
+        this.attrName = attrName;
+    }
+
+
+    public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected,
+        boolean cellHasFocus )
+    {
+        setComponentOrientation( list.getComponentOrientation() );
+        if ( isSelected )
+        {
+            setBackground( list.getSelectionBackground() );
+            setForeground( list.getSelectionForeground() );
+        }
+        else
+        {
+            setBackground( list.getBackground() );
+            setForeground( list.getForeground() );
+        }
+
+        if ( value instanceof Icon )
+        {
+            setIcon( ( Icon ) value );
+            setText( "" );
+        }
+        else
+        {
+            setIcon( null );
+            
+            EntryData entry = ( EntryData ) list.getModel().getElementAt( index );
+            try
+            {
+                String name = entry.getString( "ads-interceptorClassName" );
+
+                int dotPos = name.lastIndexOf( '.' ) + 1;
+
+                name = name.substring( dotPos );
+                setText( name );
+            }
+            catch ( Exception e )
+            {
+                setText( entry.toString() );
+                JOptionPane.showMessageDialog( null, e );
+            }
+
+        }
+
+        setEnabled( list.isEnabled() );
+        setFont( list.getFont() );
+
+        Border border = null;
+        if ( cellHasFocus )
+        {
+            if ( isSelected )
+            {
+                border = UIManager.getBorder( "List.focusSelectedCellHighlightBorder" );
+            }
+            if ( border == null )
+            {
+                border = UIManager.getBorder( "List.focusCellHighlightBorder" );
+            }
+        }
+        else
+        {
+            border = getNoFocusBorder();
+        }
+        setBorder( border );
+
+        return this;
+    }
+
+
+    private Border getNoFocusBorder()
+    {
+        if ( System.getSecurityManager() != null )
+        {
+            return SAFE_NO_FOCUS_BORDER;
+        }
+        else
+        {
+            return noFocusBorder;
+        }
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-webapp/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/pom.xml?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/pom.xml (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/pom.xml Sun Sep  5 17:13:58 2010
@@ -0,0 +1,57 @@
+<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>
+	<parent>
+		<groupId>org.apache.directory.server</groupId>
+		<artifactId>http-directory</artifactId>
+		<version>1.5.8-SNAPSHOT</version>
+	</parent>
+
+
+	<groupId>org.apache.directory.server</groupId>
+	<artifactId>directory-webapp</artifactId>
+	<packaging>war</packaging>
+	<name>http-directory</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<artifactId>apacheds-http-directory-bridge</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>${project.groupId}</groupId>
+			<artifactId>ldap-json-codec</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.mortbay.jetty</groupId>
+			<artifactId>servlet-api-2.5</artifactId>
+			<version>6.1.14</version>
+			<scope>provided</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>com.google.code.gson</groupId>
+			<artifactId>gson</artifactId>
+			<version>1.4</version>
+		</dependency>
+
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.1</version>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AppContextListener.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AppContextListener.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AppContextListener.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AppContextListener.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,56 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.http;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.directory.server.HttpDirectoryService;
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO AppContextListener.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AppContextListener implements ServletContextListener
+{
+
+    private static final Logger LOG = LoggerFactory.getLogger( AppContextListener.class );
+    
+    public void contextInitialized( ServletContextEvent sce )
+    {
+        LOG.debug( "initilizing the context {}", sce.getServletContext().getContextPath() );
+        
+        HttpDirectoryService httpDirService = ( HttpDirectoryService ) sce.getServletContext().getAttribute( HttpDirectoryService.KEY );
+        HttpDirectoryServiceHolder.set( httpDirService );
+        JsonBuilder.setSchemaManager( httpDirService.getSchemaManager() );
+    }
+
+
+    public void contextDestroyed( ServletContextEvent sce )
+    {
+        LOG.debug( "destroying the context {}", sce.getServletContext().getContextPath() );
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AuthenticationFilter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AuthenticationFilter.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AuthenticationFilter.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/AuthenticationFilter.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,61 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.http;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO AuthenticationFilter.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AuthenticationFilter implements Filter
+{
+    
+    private static final Logger LOG = LoggerFactory.getLogger( AuthenticationFilter.class );
+    
+    public void init( FilterConfig filterConfig ) throws ServletException
+    {
+    }
+
+
+    public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ) throws IOException,
+        ServletException
+    {
+        request.isSecure();
+    }
+
+
+    public void destroy()
+    {
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServiceHolder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServiceHolder.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServiceHolder.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServiceHolder.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,47 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.http;
+
+
+import org.apache.directory.server.HttpDirectoryService;
+
+
+/**
+ * TODO HttpDirectoryServiceHolder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class HttpDirectoryServiceHolder
+{
+    private static HttpDirectoryService httpDirServie;
+
+
+    public static void set( HttpDirectoryService httpDirServie )
+    {
+        HttpDirectoryServiceHolder.httpDirServie = httpDirServie;
+    }
+
+
+    public static HttpDirectoryService get()
+    {
+        return httpDirServie;
+    }
+}

Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServlet.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServlet.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServlet.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/HttpDirectoryServlet.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,416 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.http;
+
+
+import static org.apache.directory.server.http.AppConstants.*;
+import static org.apache.directory.server.http.AppConstants.BIND_URI;
+import static org.apache.directory.server.http.AppConstants.LDAP_RESULT_KEY;
+import static org.apache.directory.server.http.AppConstants.MODIFY_URI;
+import static org.apache.directory.server.http.AppConstants.SEARCH_RESULTS_KEY;
+import static org.apache.directory.server.http.AppConstants.SEARCH_URI;
+import static org.apache.directory.server.http.AppConstants.SESSION_ID;
+import static org.apache.directory.server.http.AppConstants.UNBIND_URI;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.lang.reflect.Type;
+import java.nio.ByteBuffer;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.server.BindResponseHolder;
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.core.EntryToResponseCursor;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.AbstractResultResponse;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.message.AddResponse;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.message.BindResponse;
+import org.apache.directory.shared.ldap.message.CompareRequestImpl;
+import org.apache.directory.shared.ldap.message.CompareResponse;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+import org.apache.directory.shared.ldap.message.DeleteResponse;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnResponse;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.message.ModifyResponse;
+import org.apache.directory.shared.ldap.message.Response;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.ResultResponse;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.message.SearchResultEntry;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
+
+
+/**
+ * TODO AuthenticationServlet.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class HttpDirectoryServlet extends HttpServlet
+{
+
+    private static final Logger LOG = LoggerFactory.getLogger( HttpDirectoryServlet.class );
+
+    private int sessionInterval = 20 * 60 * 60;
+
+    private static final ConcurrentHashMap<String, LdapConnection> CONNECTIONS = new ConcurrentHashMap<String, LdapConnection>();
+
+    private Type commonRespType = new TypeToken<AbstractResultResponse>()
+    {
+    }.getType();
+
+
+    @Override
+    protected void doPost( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
+    {
+
+        String uri = req.getRequestURI();
+
+        LOG.debug( "received request to {} from {}", uri, req.getRemoteAddr() );
+
+        uri = removeTrailingSlash( uri );
+
+        String sessionId = req.getHeader( SESSION_ID );
+
+        if ( sessionId != null )
+        {
+            if ( !CONNECTIONS.containsKey( sessionId ) )
+            {
+                LOG.debug( "no session exists with the received session id {}", sessionId );
+                sessionId = null;
+            }
+        }
+
+        if ( uri.endsWith( BIND_URI ) )
+        {
+            if ( sessionId != null )
+            {
+                resp.getWriter().write( "{'message':'session already exists'}" );
+                return;
+            }
+
+            bind( req, resp );
+            return;
+        }
+
+        if ( sessionId == null )
+        {
+            resp.getWriter().write( "{'message':'there is no session associated, need to rebind'}" );
+            return;
+        }
+
+        if ( uri.endsWith( UNBIND_URI ) )
+        {
+            unbind( req, resp, sessionId );
+            return;
+        }
+
+        LdapConnection connection = CONNECTIONS.get( sessionId );
+
+        if ( uri.endsWith( SEARCH_URI ) )
+        {
+            search( req, resp, connection );
+        }
+        else if ( uri.endsWith( MODIFY_URI ) )
+        {
+            modify( req, resp, connection );
+        }
+        else if ( uri.endsWith( ADD_URI ) )
+        {
+            add( req, resp, connection );
+        }
+        else if ( uri.endsWith( DELETE_URI ) )
+        {
+            delete( req, resp, connection );
+        }
+        else if ( uri.endsWith( MODIFY_DN_URI ) )
+        {
+            modifyDn( req, resp, connection );
+        }
+        else if ( uri.endsWith( COMPARE_URI ) )
+        {
+            compare( req, resp, connection );
+        }
+    }
+
+
+    private void bind( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException
+    {
+        String json = getPostData( req );
+
+        BindRequestImpl bindReq = JsonBuilder.get().fromJson( json, BindRequestImpl.class );
+        BindResponseHolder bindRespHolder = HttpDirectoryServiceHolder.get().bind( bindReq );
+
+        BindResponse bindResp = bindRespHolder.getResponse();
+
+        if ( bindResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+        {
+            LdapConnection connection = bindRespHolder.getConnection();
+
+            String key = UUID.randomUUID().toString();
+
+            CONNECTIONS.put( key, connection );
+
+            resp.setHeader( SESSION_ID, key );
+        }
+
+        resp.getWriter().write( JsonBuilder.get().toJson( bindResp ) );
+        resp.getWriter().flush();
+    }
+
+
+    private void search( HttpServletRequest req, HttpServletResponse resp, LdapConnection connection )
+        throws ServletException, IOException
+    {
+        String reqJson = getPostData( req );
+
+        SearchRequestImpl searchReq = JsonBuilder.get().fromJson( reqJson, SearchRequestImpl.class );
+        try
+        {
+            EntryToResponseCursor<Response> cursor = ( EntryToResponseCursor<Response> ) connection.search( searchReq );
+            cursor.beforeFirst();
+
+            JsonObject jsonResp = new JsonObject();
+
+            JsonArray ja = new JsonArray();
+            Gson builder = JsonBuilder.get();
+
+            while ( cursor.next() )
+            {
+                Response searchResp = cursor.get();
+                if ( searchResp instanceof SearchResultEntry )
+                {
+                    Entry entry = ( ( SearchResultEntry ) searchResp ).getEntry();
+
+                    LOG.debug( "processing search result entry with dn {}", entry.getDn() );
+
+                    JsonElement entryElement = builder.toJsonTree( entry );
+                    ja.add( entryElement );
+                }
+            }
+
+            cursor.close();
+            
+            jsonResp.add( SEARCH_RESULTS_KEY, ja );
+
+            JsonElement ldapResult = builder.toJsonTree( cursor.getSearchDone() );
+            jsonResp.add( LDAP_RESULT_KEY, ldapResult.getAsJsonObject().get( LDAP_RESULT_KEY ) );
+
+            PrintWriter pw = resp.getWriter();
+            pw.write( jsonResp.toString() );
+            pw.flush();
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void modify( HttpServletRequest req, HttpServletResponse resp, LdapConnection connection )
+        throws ServletException, IOException
+    {
+        String jsonReq = getPostData( req );
+        ModifyRequest modReq = JsonBuilder.fromJson( jsonReq, ModifyRequestImpl.class );
+
+        try
+        {
+            ModifyResponse modResp = connection.modify( modReq );
+            writeResultResponseJson( modResp, resp );
+        }
+        catch ( LdapException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void unbind( HttpServletRequest req, HttpServletResponse resp, String sessionId ) throws ServletException,
+        IOException
+    {
+        try
+        {
+            LdapConnection connection = CONNECTIONS.remove( sessionId );
+            connection.unBind();
+            connection = null;
+            LOG.debug( "connection with session id {} was successfully unbound", sessionId );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void add( HttpServletRequest req, HttpServletResponse resp, LdapConnection connection )
+        throws ServletException, IOException
+    {
+
+        try
+        {
+            String jsonReq = getPostData( req );
+            AddRequestImpl addReq = JsonBuilder.fromJson( jsonReq, AddRequestImpl.class );
+            AddResponse addResp = connection.add( addReq );
+            writeResultResponseJson( addResp, resp );
+        }
+        catch ( LdapException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void delete( HttpServletRequest req, HttpServletResponse resp, LdapConnection connection )
+        throws ServletException, IOException
+    {
+
+        try
+        {
+            String jsonReq = getPostData( req );
+            DeleteRequestImpl deleteReq = JsonBuilder.fromJson( jsonReq, DeleteRequestImpl.class );
+            DeleteResponse deleteResp = connection.delete( deleteReq );
+            writeResultResponseJson( deleteResp, resp );
+        }
+        catch ( LdapException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void modifyDn( HttpServletRequest req, HttpServletResponse resp, LdapConnection connection )
+        throws ServletException, IOException
+    {
+
+        try
+        {
+            String jsonReq = getPostData( req );
+            ModifyDnRequestImpl modDnReq = JsonBuilder.fromJson( jsonReq, ModifyDnRequestImpl.class );
+            ModifyDnResponse modDnResp = connection.modifyDn( modDnReq );
+            writeResultResponseJson( modDnResp, resp );
+        }
+        catch ( LdapException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void compare( HttpServletRequest req, HttpServletResponse resp, LdapConnection connection )
+        throws ServletException, IOException
+    {
+
+        try
+        {
+            String jsonReq = getPostData( req );
+            CompareRequestImpl compareReq = JsonBuilder.fromJson( jsonReq, CompareRequestImpl.class );
+            CompareResponse compareResp = connection.compare( compareReq );
+            writeResultResponseJson( compareResp, resp );
+        }
+        catch ( LdapException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void writeResultResponseJson( ResultResponse resultResponse, HttpServletResponse resp ) throws IOException
+    {
+        String jsonResp = JsonBuilder.toJson( resultResponse, commonRespType );
+
+        PrintWriter pw = resp.getWriter();
+        pw.write( jsonResp.toString() );
+        pw.flush();
+    }
+
+
+    private String getPostData( HttpServletRequest req )
+    {
+        try
+        {
+            int len = req.getContentLength();
+            InputStream in = req.getInputStream();
+
+            ByteBuffer data = ByteBuffer.allocate( len );
+
+            byte[] buf = new byte[1024];
+
+            while ( true )
+            {
+                int read = in.read( buf );
+                if ( read > 0 )
+                {
+                    data.put( buf, 0, read );
+                }
+                else
+                {
+                    break;
+                }
+            }
+
+            data.flip();
+
+            String received = StringTools.utf8ToString( data.array() );
+
+            LOG.debug( "received data {}", received );
+
+            return received;
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+
+    private String removeTrailingSlash( String uri )
+    {
+        if ( uri.endsWith( "/" ) )
+        {
+            uri = uri.substring( 0, uri.length() - 1 );
+            return removeTrailingSlash( uri );
+        }
+
+        return uri;
+    }
+}

Added: directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/LoggingFilter.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/LoggingFilter.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/LoggingFilter.java (added)
+++ directory/sandbox/kayyagari/http-directory/directory-webapp/src/main/java/org/apache/directory/server/http/LoggingFilter.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,60 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.http;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO LoggingFilter.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LoggingFilter implements Filter
+{
+    private static final Logger LOG = LoggerFactory.getLogger( LoggingFilter.class );
+
+    public void init( FilterConfig filterConfig ) throws ServletException
+    {
+    }
+
+    public void doFilter( ServletRequest request, ServletResponse response, FilterChain chain ) throws IOException,
+        ServletException
+    {
+        LOG.debug( "received request from {}", request.getRemoteAddr() );
+        
+        chain.doFilter( request, response );
+    }
+
+    public void destroy()
+    {
+    }
+
+}



Mime
View raw message