You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/09/05 19:14:02 UTC

svn commit: r992827 [4/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...

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/LdapResultCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/LdapResultCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/LdapResultCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/LdapResultCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,122 @@
+/*
+ *   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.codec.json;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+import org.apache.directory.shared.ldap.message.ReferralImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO LdapResultSerializer.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapResultCodec implements JsonSerializer<LdapResultImpl>, JsonDeserializer<LdapResultImpl>
+{
+
+    private static final String ERROR_MESSAGE = "errorMessage";
+    private static final String MATCHED_DN = "matchedDn";
+    private static final String RESULT_CODE = "resultCode";
+
+
+    public JsonElement serialize( LdapResultImpl result, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject obj = new JsonObject();
+
+        if ( result.getMatchedDn() != null )
+        {
+            obj.addProperty( MATCHED_DN, result.getMatchedDn().getName() );
+        }
+
+        if( result.getErrorMessage() != null )
+        {
+            obj.addProperty( ERROR_MESSAGE, result.getErrorMessage() );
+        }
+
+        ResultCodeEnum code = result.getResultCode();
+        int codeVal = -1; // for the cases where result code is null
+
+        if ( code != null )
+        {
+            codeVal = code.getValue();
+        }
+
+        obj.addProperty( RESULT_CODE, codeVal );
+
+        ReferralImpl referral = ( ReferralImpl ) result.getReferral();
+        if ( referral != null )
+        {
+            obj.addProperty( "referral", JsonBuilder.get().toJson( referral ) );
+        }
+
+        return obj;
+    }
+
+
+    public LdapResultImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        try
+        {
+            JsonObject json = element.getAsJsonObject();
+            
+            LdapResultImpl result = new LdapResultImpl();
+            
+            JsonElement matchedDn = json.get( MATCHED_DN );
+            if( matchedDn != null )
+            {
+                result.setMatchedDn( new DN( matchedDn.getAsString() ) );
+            }
+            
+            int resultCodeVal = json.get( RESULT_CODE ).getAsInt();
+            result.setResultCode( ResultCodeEnum.getResultCode( resultCodeVal ) );
+            
+            JsonElement error = json.get( ERROR_MESSAGE );
+            if( error != null )
+            {
+                result.setErrorMessage( error.getAsString() );
+            }
+            
+            //TODO yet to support Referrals
+            
+            return result;
+        }
+        catch( LdapInvalidDnException e )
+        {
+            throw new JsonParseException( e );
+        }
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/ValueCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/ValueCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/ValueCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/ValueCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,91 @@
+/*
+ *   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.codec.json;
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.shared.ldap.entry.AbstractValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
+import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.util.Base64;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+/**
+ * TODO StringValueCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ValueCodec implements JsonSerializer<AbstractValue<?>>, JsonDeserializer<AbstractValue<?>>
+{
+
+    public AbstractValue<?> deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+        JsonElement binaryElement = json.get( "binary" );
+        
+        boolean isBinary = false;
+        
+        if( binaryElement != null )
+        {
+            isBinary = binaryElement.getAsBoolean();
+        }
+        
+        String value = json.get( "value" ).getAsString();
+        
+        if( isBinary )
+        {
+            return new BinaryValue( Base64.decode( value.toCharArray() ) );
+        }
+        
+        return new StringValue( value );
+    }
+
+    public JsonElement serialize( AbstractValue<?> src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+        
+        if( src instanceof BinaryValue )
+        {
+            String val = String.valueOf( Base64.encode( src.getBytes() ) );
+            json.addProperty( "binary", true );
+            json.addProperty( "value", val );
+        }
+        else if( src instanceof StringValue )
+        {
+            json.addProperty( "value", src.getString() );
+        }
+        else
+        {
+            throw new IllegalArgumentException( "unrecogniged attribute value type " + src.getClass().getName() );
+        }
+            
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/add/AddRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/add/AddRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/add/AddRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/add/AddRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,71 @@
+/*
+ *   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.codec.json.operations.add;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.message.AddRequestImpl;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO AddRequestCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AddRequestCodec implements JsonSerializer<AddRequestImpl>, JsonDeserializer<AddRequestImpl>
+{
+
+    public AddRequestImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+
+        AddRequestImpl req = new AddRequestImpl( json.get( AppConstants.MESSAGE_ID_KEY ).getAsInt() );
+
+        req.setEntry( JsonBuilder.fromJson( json.get( "entry" ), DefaultEntry.class ) );
+
+        return req;
+    }
+
+
+    public JsonElement serialize( AddRequestImpl src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        json.addProperty( AppConstants.MESSAGE_ID_KEY, src.getMessageId() );
+        json.add( "entry", JsonBuilder.toJsonTree( src.getEntry() ) );
+
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,108 @@
+/*
+ *   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.codec.json.operations.bind;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.util.Base64;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO BindRequestDecoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindRequestCodec implements JsonSerializer<BindRequestImpl>, JsonDeserializer<BindRequestImpl>
+{
+
+    private static final String SIMPLE = "simple";
+    private static final String MECHANISM = "mechanism";
+    private static final String VERSION3 = "version3";
+    private static final String CREDENTIALS = "credentials";
+    private static final String NAME = "name";
+
+
+    public JsonElement serialize( BindRequestImpl src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject jsonObj = new JsonObject();
+
+        jsonObj.addProperty( NAME, src.getName().getName() );
+        jsonObj.addProperty( CREDENTIALS, String.valueOf( Base64.encode( src.getCredentials() ) ) );
+        jsonObj.addProperty( VERSION3, src.getVersion3() );
+        jsonObj.addProperty( MECHANISM, src.getSaslMechanism() );
+        jsonObj.addProperty( SIMPLE, src.isSimple() );
+
+        return jsonObj;
+    }
+
+
+    public BindRequestImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        try
+        {
+            JsonObject jsonObj = element.getAsJsonObject();
+
+            BindRequestImpl bindReq = new BindRequestImpl();
+            bindReq.setName( new DN( jsonObj.get( NAME ).getAsString() ) );
+
+            String pwd = jsonObj.get( CREDENTIALS ).getAsString();
+            bindReq.setCredentials( Base64.decode( pwd.toCharArray() ) );
+
+            JsonElement version = jsonObj.get( VERSION3 );
+            if ( version != null )
+            {
+                bindReq.setVersion3( version.getAsBoolean() );
+            }
+
+            JsonElement mechanism = jsonObj.get( MECHANISM );
+            if ( mechanism != null )
+            {
+                bindReq.setSaslMechanism( mechanism.getAsString() );
+            }
+
+            JsonElement simple = jsonObj.get( SIMPLE );
+            if ( simple != null )
+            {
+                bindReq.setSimple( simple.getAsBoolean() );
+            }
+
+            return bindReq;
+        }
+        catch ( LdapInvalidDnException e )
+        {
+            throw new JsonParseException( e );
+        }
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindResponseCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindResponseCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindResponseCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/bind/BindResponseCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,83 @@
+/*
+ *   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.codec.json.operations.bind;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO BindResponseEncoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class BindResponseCodec implements JsonSerializer<BindResponseImpl>, JsonDeserializer<BindResponseImpl>
+{
+
+    private static final String MESSAGE_ID = "messageId";
+    private static final String LDAP_RESULT = "ldapResult";
+
+
+    public JsonElement serialize( BindResponseImpl resp, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+        json.addProperty( MESSAGE_ID, resp.getMessageId() );
+
+        LdapResultImpl result = ( LdapResultImpl ) resp.getLdapResult();
+
+        json.add( LDAP_RESULT, JsonBuilder.get().toJsonTree( result ) );
+
+        return json;
+    }
+
+
+    public BindResponseImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+
+        BindResponseImpl resp = new BindResponseImpl( json.get( MESSAGE_ID ).getAsInt() );
+
+        LdapResultImpl receivedResult = JsonBuilder.get().fromJson( json.get( LDAP_RESULT ), LdapResultImpl.class );
+
+        LdapResult sendingResult = resp.getLdapResult();
+        sendingResult.setResultCode( receivedResult.getResultCode() );
+        sendingResult.setErrorMessage( receivedResult.getErrorMessage() );
+        sendingResult.setReferral( receivedResult.getReferral() );
+        sendingResult.setMatchedDn( receivedResult.getMatchedDn() );
+
+        return resp;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/compare/CompareRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/compare/CompareRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/compare/CompareRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/compare/CompareRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,88 @@
+/*
+ *   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.codec.json.operations.compare;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.ldap.entry.AbstractValue;
+import org.apache.directory.shared.ldap.entry.BinaryValue;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.message.CompareRequestImpl;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO CompareRequestCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CompareRequestCodec implements JsonSerializer<CompareRequestImpl>, JsonDeserializer<CompareRequestImpl>
+{
+
+    public CompareRequestImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+
+        CompareRequestImpl req = new CompareRequestImpl( json.get( AppConstants.MESSAGE_ID_KEY ).getAsInt() );
+
+        req.setName( JsonBuilder.decodeDn( json.get( "dn" ) ) );
+
+        req.setAttributeId( json.get( "attributeId" ).getAsString() );
+
+        Value<?> val = JsonBuilder.fromJson( json.get( "value" ), AbstractValue.class );
+
+        if ( val instanceof BinaryValue )
+        {
+            req.setAssertionValue( val.getBytes() );
+        }
+        else
+        {
+            req.setAssertionValue( val.getString() );
+        }
+
+        return req;
+    }
+
+
+    public JsonElement serialize( CompareRequestImpl src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        json.addProperty( AppConstants.MESSAGE_ID_KEY, src.getMessageId() );
+        json.addProperty( "dn", src.getName().getName() );
+        json.addProperty( "attributeId", src.getAttributeId() );
+        json.add( "value", JsonBuilder.toJsonTree( src.getAssertionValue() ) );
+
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/delete/DeleteRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/delete/DeleteRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/delete/DeleteRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/delete/DeleteRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,72 @@
+/*
+ *   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.codec.json.operations.delete;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO DeleteRequestCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DeleteRequestCodec implements JsonSerializer<DeleteRequestImpl>, JsonDeserializer<DeleteRequestImpl>
+{
+
+    private static final String DN = "dn";
+
+
+    public JsonElement serialize( DeleteRequestImpl src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        json.addProperty( AppConstants.MESSAGE_ID_KEY, src.getMessageId() );
+        json.addProperty( DN, src.getName().getName() );
+
+        return json;
+    }
+
+
+    public DeleteRequestImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+        
+        DeleteRequestImpl req = new DeleteRequestImpl( json.get( AppConstants.MESSAGE_ID_KEY ).getAsInt() );
+        req.setName( JsonBuilder.decodeDn( json.get( DN ) ) );
+        
+        return req;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/DefaultModificationCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/DefaultModificationCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/DefaultModificationCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/DefaultModificationCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,80 @@
+/*
+ *   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.codec.json.operations.modify;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO ModificationCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DefaultModificationCodec implements JsonSerializer<DefaultModification>, JsonDeserializer<DefaultModification>
+{
+
+    private static final String OPERATION = "operation";
+    private static final String ATTRIBUTE = "attribute";
+
+
+    public DefaultModification deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+
+        DefaultModification mod = new DefaultModification();
+
+        ModificationOperation operation = ModificationOperation.valueOf( json.get( OPERATION ).getAsString() );
+        mod.setOperation( operation );
+
+        EntryAttribute at = JsonBuilder.get().fromJson( json.get( ATTRIBUTE ), DefaultEntryAttribute.class );
+        mod.setAttribute( at );
+
+        return mod;
+    }
+
+
+    public JsonElement serialize( DefaultModification src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        json.addProperty( OPERATION, src.getOperation().name() );
+        json.add( ATTRIBUTE, JsonBuilder.get().toJsonTree( src.getAttribute() ) );
+
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/ModifyRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/ModifyRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/ModifyRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modify/ModifyRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,106 @@
+/*
+ *   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.codec.json.operations.modify;
+
+
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO ModifyRequestCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyRequestCodec implements JsonSerializer<ModifyRequestImpl>, JsonDeserializer<ModifyRequestImpl>
+{
+
+    private static final String MODS = "mods";
+    private static final String DN = "dn";
+
+
+    public ModifyRequestImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+        
+        
+        ModifyRequestImpl req = new ModifyRequestImpl();
+        
+        JsonElement messageId = json.get( "messageId" );
+        if( messageId != null )
+        {
+            req.setMessageId( messageId.getAsInt() );
+        }
+        
+        req.setName( JsonBuilder.decodeDn( json.get( DN ) ) );
+        
+        JsonArray modsArray = json.get( MODS ).getAsJsonArray();
+        Iterator<JsonElement> itr = modsArray.iterator();
+        
+        while ( itr.hasNext() )
+        {
+            JsonElement modString = itr.next();
+            DefaultModification mod = JsonBuilder.get().fromJson( modString, DefaultModification.class );
+            req.addModification( mod );
+        }
+        
+        return req;
+    }
+
+
+    public JsonElement serialize( ModifyRequestImpl req, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        json.addProperty( "messageId", req.getMessageId() );
+        
+        json.addProperty( DN, req.getName().getName() );
+
+        Collection<Modification> modsList = req.getModifications();
+
+        JsonArray ja = new JsonArray();
+        for ( Modification mod : modsList )
+        {
+            ja.add( JsonBuilder.get().toJsonTree( mod ) );
+        }
+
+        json.add( MODS, ja );
+
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modifydn/ModifyDnRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modifydn/ModifyDnRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modifydn/ModifyDnRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/modifydn/ModifyDnRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,101 @@
+/*
+ *   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.codec.json.operations.modifydn;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.server.http.AppConstants;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO ModifyDnRequestCodec.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ModifyDnRequestCodec implements JsonSerializer<ModifyDnRequestImpl>, JsonDeserializer<ModifyDnRequestImpl>
+{
+
+    private static final String DN_KEY = "dn";
+    private static final String NEW_SUPERIOR = "newSuperior";
+    private static final String NEW_RDN = "newRdn";
+    private static final String DELETE_OLD_RDN = "deleteOldRdn";
+
+
+    public ModifyDnRequestImpl deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        JsonObject json = element.getAsJsonObject();
+        
+        ModifyDnRequestImpl req = new ModifyDnRequestImpl( json.get( AppConstants.MESSAGE_ID_KEY ).getAsInt() );
+        req.setName( JsonBuilder.decodeDn( json.get( DN_KEY ) ) );
+        
+        JsonElement newSuperior = json.get( NEW_SUPERIOR );
+        if( newSuperior != null )
+        {
+            req.setNewSuperior( JsonBuilder.decodeDn( newSuperior ) );
+        }
+        
+        JsonElement newRdn = json.get( NEW_RDN );
+        if( newRdn != null )
+        {
+            req.setNewRdn( JsonBuilder.decodeDn( newRdn ).getRdn() );
+        }
+        
+        req.setDeleteOldRdn( json.get( DELETE_OLD_RDN ).getAsBoolean() );
+        
+        return req;
+    }
+
+
+    public JsonElement serialize( ModifyDnRequestImpl src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        json.addProperty( AppConstants.MESSAGE_ID_KEY, src.getMessageId() );
+        json.addProperty( DN_KEY, src.getName().getName() );
+
+        if ( src.getNewSuperior() != null )
+        {
+            json.addProperty( NEW_SUPERIOR, src.getNewSuperior().getName() );
+        }
+
+        if ( src.getNewRdn() != null )
+        {
+            json.addProperty( NEW_RDN, src.getNewRdn().getName() );
+        }
+
+        json.addProperty( DELETE_OLD_RDN, src.getDeleteOldRdn() );
+
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/ClonedServerEntryCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/ClonedServerEntryCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/ClonedServerEntryCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/ClonedServerEntryCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,59 @@
+/*
+ *   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.codec.json.operations.search;
+
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO ClonedServerEntryEncoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ClonedServerEntryCodec implements JsonSerializer<ClonedServerEntry>, JsonDeserializer<ClonedServerEntry>
+{
+
+    public JsonElement serialize( ClonedServerEntry entry, Type typeOfSrc, JsonSerializationContext context )
+    {
+        return DefaultEntryCodec._serialize( entry, typeOfSrc, context );
+    }
+
+
+    public ClonedServerEntry deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        DefaultEntry entry = DefaultEntryCodec._deserialize( json, typeOfT, context );
+
+        return new ClonedServerEntry( entry );
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/DefaultEntryCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/DefaultEntryCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/DefaultEntryCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/DefaultEntryCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,141 @@
+/*
+ *   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.codec.json.operations.search;
+
+
+import java.lang.reflect.Type;
+import java.util.Iterator;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO EntryEncoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DefaultEntryCodec implements JsonSerializer<DefaultEntry>, JsonDeserializer<DefaultEntry>
+{
+
+    public JsonElement serialize( DefaultEntry entry, Type typeOfSrc, JsonSerializationContext context )
+    {
+        return _serialize( entry, typeOfSrc, context );
+    }
+
+
+    public DefaultEntry deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        return _deserialize( json, typeOfT, context );
+    }
+
+
+    public static DefaultEntry _deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+    {
+        try
+        {
+
+            JsonObject json = element.getAsJsonObject();
+
+            DN dn = JsonBuilder.decodeDn( json.get( "dn" ) );
+
+            SchemaManager sm = JsonBuilder.getSchemaManager();
+
+            DefaultEntry entry = null;
+
+            if ( sm != null )
+            {
+                entry = new DefaultEntry( sm, dn );
+            }
+            else
+            {
+                entry = new DefaultEntry( dn );
+            }
+
+            JsonElement attributes = json.get( "attributes" );
+            if ( attributes != null )
+            {
+                JsonArray atArray = attributes.getAsJsonArray();
+                Iterator<JsonElement> itr = atArray.iterator();
+                while ( itr.hasNext() )
+                {
+                    DefaultEntryAttribute at = JsonBuilder.get().fromJson( itr.next(), DefaultEntryAttribute.class );
+                    entry.add( at );
+                }
+            }
+
+            return entry;
+        }
+        catch ( LdapException e )
+        {
+            throw new JsonParseException( e );
+        }
+
+    }
+
+
+    public static JsonElement _serialize( Entry entry, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+
+        DN dn = entry.getDn();
+        if ( dn == null )
+        {
+            dn = DN.EMPTY_DN;
+        }
+
+        json.addProperty( "dn", dn.getName() );
+
+        JsonArray ja = new JsonArray();
+
+        Gson builder = JsonBuilder.get();
+
+        for ( EntryAttribute at : entry )
+        {
+            ja.add( builder.toJsonTree( at ) );
+        }
+
+        if ( ja.size() > 0 )
+        {
+            json.add( "attributes", ja );
+        }
+
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/EntryAttributeCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/EntryAttributeCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/EntryAttributeCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/EntryAttributeCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,115 @@
+/*
+ *   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.codec.json.operations.search;
+
+
+import java.lang.reflect.Type;
+import java.util.Iterator;
+
+import org.apache.directory.server.codec.json.JsonBuilder;
+import org.apache.directory.shared.ldap.entry.AbstractValue;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * 
+ * TODO Attribute.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EntryAttributeCodec implements JsonSerializer<DefaultEntryAttribute>,
+    JsonDeserializer<DefaultEntryAttribute>
+{
+
+    public JsonElement serialize( DefaultEntryAttribute atSrc, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject attrJson = new JsonObject();
+
+        attrJson.addProperty( "name", atSrc.getId() );
+
+        JsonArray ja = new JsonArray();
+        Iterator<Value<?>> itr = atSrc.iterator();
+        while ( itr.hasNext() )
+        {
+            Value<?> val = itr.next();
+            ja.add( JsonBuilder.toJsonTree( val ) );
+        }
+
+        attrJson.add( "values", ja );
+
+        return attrJson;
+    }
+
+
+    public DefaultEntryAttribute deserialize( JsonElement element, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        try
+        {
+            JsonObject json = element.getAsJsonObject();
+            
+            String name = json.get( "name" ).getAsString();
+            
+            DefaultEntryAttribute at = null;
+            
+            SchemaManager sm = JsonBuilder.getSchemaManager();
+            
+            if( sm != null )
+            {
+                at = new DefaultEntryAttribute( sm.lookupAttributeTypeRegistry( name ) );
+            }
+            else
+            {
+                at = new DefaultEntryAttribute( name );
+            }
+            
+            JsonArray values = json.getAsJsonArray( "values" );
+            
+            if( values != null )
+            {
+                Iterator<JsonElement> itr = values.iterator();
+                while( itr.hasNext() )
+                {
+                    JsonElement val = itr.next();
+                    at.add( JsonBuilder.fromJson( val, AbstractValue.class ) );
+                }
+            }
+            
+            return at;
+        }
+        catch( Exception e )
+        {
+            throw new JsonParseException( e );
+        }
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchRequestCodec.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchRequestCodec.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchRequestCodec.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchRequestCodec.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,158 @@
+/*
+ *   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.codec.json.operations.search;
+
+
+import java.lang.reflect.Type;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.name.DN;
+
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+
+/**
+ * TODO SearchRequestDecoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchRequestCodec implements JsonDeserializer<SearchRequestImpl>, JsonSerializer<SearchRequestImpl>
+{
+
+    private static final String BASE_DN = "baseDn";
+    private static final String FILTER = "filter";
+    private static final String SCOPE = "scope";
+    private static final String TYPES_ONLY = "typesOnly";
+    private static final String SIZE_LIMIT = "sizeLimit";
+    private static final String TIME_LIMIT = "timeLimit";
+    private static final String ALIAS_DEREF_MODE = "aliasDerefMode";
+    private static final String ATTRIBUTES = "attributes";
+
+
+    public SearchRequestImpl deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context )
+        throws JsonParseException
+    {
+        SearchRequestImpl req = null;
+
+        try
+        {
+            JsonObject obj = json.getAsJsonObject();
+
+            req = new SearchRequestImpl();
+
+            req.setBase( new DN( obj.get( BASE_DN ).getAsString() ) );
+            req.setFilter( obj.get( FILTER ).getAsString() );
+
+            JsonElement scopeEl = obj.get( SCOPE );
+            if ( scopeEl != null )
+            {
+                int scope = SearchScope.getSearchScope( scopeEl.getAsString() );
+                req.setScope( SearchScope.getSearchScope( scope ) );
+            }
+
+            JsonElement typesOnlyEl = obj.get( TYPES_ONLY );
+            if ( typesOnlyEl != null )
+            {
+                req.setTypesOnly( typesOnlyEl.getAsBoolean() );
+            }
+
+            JsonElement sizeLimitEl = obj.get( SIZE_LIMIT );
+            if ( sizeLimitEl != null )
+            {
+                req.setSizeLimit( sizeLimitEl.getAsInt() );
+            }
+
+            JsonElement timeLimitEl = obj.get( TIME_LIMIT );
+            if ( timeLimitEl != null )
+            {
+                req.setTimeLimit( timeLimitEl.getAsInt() );
+            }
+
+            JsonElement aliasDerefModeEl = obj.get( ALIAS_DEREF_MODE );
+            if ( aliasDerefModeEl != null )
+            {
+                req.setDerefAliases( AliasDerefMode.getDerefMode( aliasDerefModeEl.getAsInt() ) );
+            }
+
+            JsonElement attributesEl = obj.get( ATTRIBUTES );
+            if ( attributesEl != null )
+            {
+                JsonArray ja = attributesEl.getAsJsonArray();
+                Iterator<JsonElement> itr = ja.iterator();
+                while( itr.hasNext() )
+                {
+                    req.addAttributes( itr.next().getAsString() );
+                }
+            }
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+
+        return req;
+    }
+
+
+    public JsonElement serialize( SearchRequestImpl req, Type typeOfSrc, JsonSerializationContext context )
+    {
+        JsonObject json = new JsonObject();
+        json.addProperty( BASE_DN, req.getBase().getName() );
+        json.addProperty( FILTER, req.getFilter().toString() );
+        
+        if( req.getScope() != null )
+        {
+            json.addProperty( SCOPE, req.getScope().getLdapUrlValue() );
+        }
+        
+        json.addProperty( TYPES_ONLY, req.getTypesOnly() );
+        json.addProperty( SIZE_LIMIT, req.getSizeLimit() );
+        json.addProperty( TIME_LIMIT, req.getTimeLimit() );
+        json.addProperty( ALIAS_DEREF_MODE, req.getDerefAliases().getValue() );
+        
+        List<String> attributes = req.getAttributes();
+        if( !attributes.isEmpty() )
+        {
+            JsonArray ja = new JsonArray();
+            for( String s : attributes )
+            {
+                ja.add( new JsonPrimitive( s ) );
+            }
+            
+            json.add( ATTRIBUTES, ja );
+        }
+        
+        return json;
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchResponseEncoder.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchResponseEncoder.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchResponseEncoder.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/codec/json/operations/search/SearchResponseEncoder.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,44 @@
+/*
+ *   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.codec.json.operations.search;
+
+import java.lang.reflect.Type;
+
+import org.apache.directory.shared.ldap.message.SearchResultEntryImpl;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+/**
+ * TODO SearchResponseEncoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResponseEncoder implements JsonSerializer<SearchResultEntryImpl>
+{
+
+    public JsonElement serialize( SearchResultEntryImpl src, Type typeOfSrc, JsonSerializationContext context )
+    {
+        return null;//JsonBuilder.get().toJson( src );
+    }
+
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/http/AppConstants.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/http/AppConstants.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/http/AppConstants.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/main/java/org/apache/directory/server/http/AppConstants.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,54 @@
+/*
+ *   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;
+
+
+/**
+ * TODO AppConstants.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface AppConstants
+{
+    String SESSION_ID = "sessionid";
+
+    String SEARCH_RESULTS_KEY = "results";
+
+    String LDAP_RESULT_KEY = "ldapResult";
+
+    String MESSAGE_ID_KEY = "messageId";
+
+    String BIND_URI = "/bind";
+
+    String SEARCH_URI = "/search";
+
+    String MODIFY_URI = "/modify";
+
+    String MODIFY_DN_URI = "/modifydn";
+
+    String UNBIND_URI = "/unbind";
+
+    String ADD_URI = "/add";
+
+    String DELETE_URI = "/delete";
+    
+    String COMPARE_URI = "/compare";
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonDecoderTest.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonDecoderTest.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonDecoderTest.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,81 @@
+/*
+ *   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.codec.json;
+
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.SearchRequestImpl;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.Test;
+
+
+/**
+ * TODO JsonDecoderTest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JsonDecoderTest
+{
+
+    @Test
+    public void testDecodeSearchRequest() throws Exception
+    {
+        SearchRequestImpl req = new SearchRequestImpl();
+        req.setBase( new DN( "uid=admin,ou=system" ) );
+        req.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES );
+        req.setFilter( "(objectClass=*)" );
+        req.setScope( SearchScope.OBJECT );
+        req.setTypesOnly( true );
+        req.addAttributes( "cn", "sn" );
+
+        String json = JsonBuilder.get().toJson( req );
+        System.out.println( json );
+
+        SearchRequestImpl decoded = JsonBuilder.get().fromJson( json, SearchRequestImpl.class );
+        System.out.println( decoded );
+        
+        String jsonFromdecoded = JsonBuilder.get().toJson( decoded );
+        System.out.println( jsonFromdecoded );
+    }
+    
+    
+    @Test
+    public void testDecodeEntry() throws Exception
+    {
+        Entry entry = new DefaultEntry( new DN( "uid=admin,ou=system" ) );
+        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.PERSON_OC );
+        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.INET_ORG_PERSON_OC );
+        entry.add( SchemaConstants.CN_AT, "at_cn" );
+
+        entry.add( SchemaConstants.USER_PASSWORD_AT, "secret".getBytes() );
+
+        String json = JsonBuilder.get().toJson( entry );
+        System.out.println( json );
+        
+        ClonedServerEntry clone = new ClonedServerEntry( entry );
+        clone.remove( SchemaConstants.CN_AT, "at_cn" );
+        System.out.println( JsonBuilder.get().toJsonTree( clone ) );
+    }
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonEncoderTest.java?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonEncoderTest.java (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/java/org/apache/directory/server/codec/json/JsonEncoderTest.java Sun Sep  5 17:13:58 2010
@@ -0,0 +1,141 @@
+/*
+ *   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.codec.json;
+
+
+import org.apache.directory.shared.ldap.codec.controls.replication.syncInfoValue.SyncInfoValueControl;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.message.BindRequest;
+import org.apache.directory.shared.ldap.message.BindRequestImpl;
+import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.LdapResult;
+import org.apache.directory.shared.ldap.message.LdapResultImpl;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
+import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.message.control.replication.SynchronizationInfoEnum;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.SingleLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+
+
+/**
+ * TODO JsonEncoderTest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JsonEncoderTest
+{
+
+    private JsonEncoder encoder = new JsonEncoder();
+
+    private static SchemaManager schemaManager;
+
+
+    @BeforeClass
+    public static void loadSchema() throws Exception
+    {
+        SingleLdifSchemaLoader loader = new SingleLdifSchemaLoader();
+        schemaManager = new DefaultSchemaManager( loader );
+        schemaManager.loadAllEnabled();
+        System.out.println( schemaManager.getErrors() );
+    }
+
+
+    @Test
+    public void testEncodeBindResp() throws Exception
+    {
+
+        BindResponseImpl resp = new BindResponseImpl();
+        resp.setMessageId( 1 );
+
+        LdapResult result = resp.getLdapResult();
+        result.setErrorMessage( "add response" );
+        result.setResultCode( ResultCodeEnum.SUCCESS );
+        result.setMatchedDn( new DN( "uid=admin,ou=system" ) );
+        SyncInfoValueControl syncCtrl = new SyncInfoValueControl( SynchronizationInfoEnum.NEW_COOKIE );
+        syncCtrl.setCookie( "cookie".getBytes() );
+
+        resp.addControl( syncCtrl );
+        String json = encoder.encode( resp );
+        System.out.println( json );
+    }
+
+
+    @Test
+    public void testEncodeLdapResult() throws Exception
+    {
+        LdapResultImpl result = new LdapResultImpl();
+        result.setErrorMessage( "add response" );
+        result.setResultCode( ResultCodeEnum.SUCCESS );
+        result.setMatchedDn( new DN( "uid=admin,ou=system" ) );
+
+        String json = encoder.encode( result );
+        //        System.out.println( json );
+    }
+
+
+    @Test
+    public void testDecodeBindRequest() throws Exception
+    {
+        BindRequestImpl req = new BindRequestImpl();
+        req.setCredentials( "secret" );
+        req.setMessageId( 1 );
+        req.setName( new DN( "uid=admin,ou=suystem" ) );
+
+        String json = new Gson().toJson( req );
+        json = "{\"name\":\"uid\u003dadmin,ou\u003dsuystem\",\"credentials\":\"secret\",\"isSimple\":true,\"version\":3,\"controls\":{},\"messageId\":1}";
+        System.out.println( json );
+
+        BindRequest decoded = JsonBuilder.get().fromJson( json, BindRequestImpl.class );
+        //        System.out.println( decoded ); 
+    }
+
+
+    @Test
+    public void testModifyRequestCodec() throws Exception
+    {
+        DefaultModification mod = new DefaultModification();
+        EntryAttribute at = new DefaultEntryAttribute( schemaManager.lookupAttributeTypeRegistry( "cn" ) );
+        at.add( "cn_value" );
+        mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
+        mod.setAttribute( at );
+
+        ModifyRequest req = new ModifyRequestImpl( 2 );
+        req.setName( new DN( "ou=x" ) );
+        req.addModification( mod );
+        
+        String json = JsonBuilder.get().toJson( req );
+        System.out.println( json );
+        
+        req = JsonBuilder.fromJson( json, ModifyRequestImpl.class );
+        
+        System.out.println( req );
+    }
+}

Added: directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/resources/log4j.properties?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/resources/log4j.properties (added)
+++ directory/sandbox/kayyagari/http-directory/ldap-json-codec/src/test/resources/log4j.properties Sun Sep  5 17:13:58 2010
@@ -0,0 +1,45 @@
+#############################################################################
+#    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.
+#############################################################################
+log4j.rootCategory=warn, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=apacheds-rolling.log
+
+log4j.appender.R.MaxFileSize=1024KB
+# Keep some backup files
+log4j.appender.R.MaxBackupIndex=5
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %p [%c] - %m%n
+
+# with these we'll not get innundated when switching to DEBUG
+log4j.logger.org.apache.directory.shared.ldap.name=FATAL
+log4j.logger.org.apache.directory.shared=warn
+log4j.logger.org.apache.directory.server.core=WARN
+
+log4j.logger.org.apache.directory.server.schema.registries=FATAL
+log4j.logger.org.apache.directory.server.http=DEBUG
+log4j.logger.org.mortbay.log=WARN
+log4j.logger.JdbmTable=WARN
+log4j.logger.org.apache.directory.server.xdbm=WARN
+log4j.logger.JdbmIndex=WARN
+log4j.logger.org.apache.directory.server.config=WARN

Added: directory/sandbox/kayyagari/http-directory/pom.xml
URL: http://svn.apache.org/viewvc/directory/sandbox/kayyagari/http-directory/pom.xml?rev=992827&view=auto
==============================================================================
--- directory/sandbox/kayyagari/http-directory/pom.xml (added)
+++ directory/sandbox/kayyagari/http-directory/pom.xml Sun Sep  5 17:13:58 2010
@@ -0,0 +1,61 @@
+<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>
+    <artifactId>apacheds-parent</artifactId>
+    <groupId>org.apache.directory.server</groupId>
+    <version>1.5.8-SNAPSHOT</version>
+  </parent>
+  <artifactId>http-directory</artifactId>
+  <packaging>pom</packaging>
+  <version>1.5.8-SNAPSHOT</version>
+  <name>Accessing Apache Directory SerVICE over HTTP</name>
+
+ <properties>
+    <org.apache.directory.shared.version>0.9.20-SNAPSHOT</org.apache.directory.shared.version>
+    <slf4j.api.version>1.5.11</slf4j.api.version>
+    <slf4j.log4j12.version>1.5.11</slf4j.log4j12.version>
+    <log4j.version>1.2.16</log4j.version>
+ </properties>
+
+ <modules>
+   <module>directory-webapp</module>
+   <module>ldap-json-codec</module>
+    <module>ldap-http-connection</module>
+    <module>directory-http-ui</module>
+ </modules>
+
+<dependencyManagement>
+</dependencyManagement>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.7</version>
+    </dependency>
+    <dependency>
+     <groupId>findbugs</groupId>
+     <artifactId>annotations</artifactId>
+     <version>1.0.0</version>
+    </dependency>
+     <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-api</artifactId>
+        <version>${slf4j.api.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.slf4j</groupId>
+        <artifactId>slf4j-log4j12</artifactId>
+        <version>${slf4j.log4j12.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>${log4j.version}</version>
+      </dependency>
+
+  </dependencies>
+</project>