You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2011/01/28 00:28:46 UTC
svn commit: r1064355 - in
/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap:
codec/ codec/actions/ codec/decorators/ model/message/
Author: akarasulu
Date: Thu Jan 27 23:28:46 2011
New Revision: 1064355
URL: http://svn.apache.org/viewvc?rev=1064355&view=rev
Log:
fixing issues with add req decorator
Modified:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequest.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImpl.java
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java Thu Jan 27 23:28:46 2011
@@ -22,15 +22,15 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.asn1.ber.AbstractContainer;
import org.apache.directory.shared.ldap.codec.controls.ControlDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.AddResponseDecorator;
+import org.apache.directory.shared.ldap.codec.decorators.BindRequestDecorator;
import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
import org.apache.directory.shared.ldap.codec.decorators.ModifyRequestDecorator;
import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
import org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator;
import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
import org.apache.directory.shared.ldap.model.message.AbandonRequest;
-import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.model.message.AddResponse;
-import org.apache.directory.shared.ldap.model.message.BindRequest;
import org.apache.directory.shared.ldap.model.message.BindResponse;
import org.apache.directory.shared.ldap.model.message.CompareRequest;
import org.apache.directory.shared.ldap.model.message.CompareResponse;
@@ -52,7 +52,7 @@ import org.apache.directory.shared.ldap.
/**
* The LdapMessage container stores all the messages decoded by the Asn1Decoder.
- * When dealing with an incoding PDU, we will obtain a LdapMessage in the
+ * When dealing with an encoding PDU, we will obtain a LdapMessage in the
* container.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -125,27 +125,27 @@ public class LdapMessageContainer extend
/**
* @return Returns the AddRequest stored in the container
*/
- public AddRequest getAddRequest()
+ public AddRequestDecorator getAddRequest()
{
- return ( AddRequest ) messageDecorator;
+ return ( AddRequestDecorator ) messageDecorator;
}
/**
* @return Returns the AddResponse stored in the container
*/
- public AddResponse getAddResponse()
+ public AddResponseDecorator getAddResponse()
{
- return ( AddResponse ) messageDecorator;
+ return ( AddResponseDecorator ) messageDecorator;
}
/**
* @return Returns the BindRequest stored in the container
*/
- public BindRequest getBindRequest()
+ public BindRequestDecorator getBindRequest()
{
- return ( BindRequest ) messageDecorator;
+ return ( BindRequestDecorator ) messageDecorator;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Thu Jan 27 23:28:46 2011
@@ -71,6 +71,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.codec.actions.StoreTypeMatchingRuleAction;
import org.apache.directory.shared.ldap.codec.actions.ValueAction;
import org.apache.directory.shared.ldap.codec.controls.ControlFactory;
+import org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator;
import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
import org.apache.directory.shared.ldap.codec.decorators.ModifyRequestDecorator;
import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
@@ -1954,7 +1955,7 @@ public final class LdapMessageGrammar ex
{
LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
- AddRequest addRequest = ldapMessageContainer.getAddRequest();
+ AddRequestDecorator addRequest = ldapMessageContainer.getAddRequest();
TLV tlv = ldapMessageContainer.getCurrentTLV();
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java Thu Jan 27 23:28:46 2011
@@ -24,7 +24,7 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.model.message.AddRequest;
+import org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator;
import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ public class ValueAction extends Grammar
{
LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
- AddRequest addRequest = ldapMessageContainer.getAddRequest();
+ AddRequestDecorator addRequest = ( AddRequestDecorator ) ldapMessageContainer.getAddRequest();
TLV tlv = ldapMessageContainer.getCurrentTLV();
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java Thu Jan 27 23:28:46 2011
@@ -22,7 +22,9 @@ package org.apache.directory.shared.ldap
import java.util.List;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
import org.apache.directory.shared.ldap.model.entry.Value;
import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.message.AddRequest;
@@ -48,7 +50,10 @@ public class AddRequestDecorator extends
/** The list of all vals length */
private List<Integer> valuesLength;
+ /** The current attribute being decoded */
+ private EntryAttribute currentAttribute;
+
/**
* Makes a AddRequest a MessageDecorator.
*
@@ -186,42 +191,64 @@ public class AddRequestDecorator extends
}
- //-------------------------------------------------------------------------
- // @TODO ALL THESE MUST BE REMOVED
- //-------------------------------------------------------------------------
-
-
+ /**
+ * Create a new attributeValue
+ *
+ * @param type The attribute's name (called 'type' in the grammar)
+ */
public void addAttributeType( String type ) throws LdapException
{
- // TODO Auto-generated method stub
-
+ // do not create a new attribute if we have seen this attributeType before
+ if ( getAddRequest().getEntry().get( type ) != null )
+ {
+ currentAttribute = getAddRequest().getEntry().get( type );
+ return;
+ }
+
+ // fix this to use AttributeImpl(type.getString().toLowerCase())
+ currentAttribute = new DefaultEntryAttribute( type );
+ getAddRequest().getEntry().put( currentAttribute );
}
+ /**
+ * @return Returns the currentAttribute type.
+ */
public String getCurrentAttributeType()
{
- // TODO Auto-generated method stub
- return null;
+ return currentAttribute.getId();
}
+ /**
+ * Add a new value to the current attribute
+ *
+ * @param value The value to add
+ */
public void addAttributeValue( String value )
{
- // TODO Auto-generated method stub
-
+ currentAttribute.add( value );
}
+ /**
+ * Add a new value to the current attribute
+ *
+ * @param value The value to add
+ */
public void addAttributeValue( Value<?> value )
{
- // TODO Auto-generated method stub
-
+ currentAttribute.add( value );
}
+ /**
+ * Add a new value to the current attribute
+ *
+ * @param value The value to add
+ */
public void addAttributeValue( byte[] value )
{
- // TODO Auto-generated method stub
-
+ currentAttribute.add( value );
}
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequest.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequest.java Thu Jan 27 23:28:46 2011
@@ -22,8 +22,6 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Value;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.name.Dn;
@@ -71,42 +69,4 @@ public interface AddRequest extends Sing
* @param entry the added Entry
*/
void setEntry( Entry entry );
-
-
- /**
- * Create a new attributeValue
- *
- * @param type The attribute's name (called 'type' in the grammar)
- */
- void addAttributeType( String type ) throws LdapException;
-
-
- /**
- * @return Returns the currentAttribute type.
- */
- String getCurrentAttributeType();
-
-
- /**
- * Add a new value to the current attribute
- *
- * @param value The value to add
- */
- void addAttributeValue( String value );
-
-
- /**
- * Add a new value to the current attribute
- *
- * @param value The value to add
- */
- void addAttributeValue( Value<?> value );
-
-
- /**
- * Add a new value to the current attribute
- *
- * @param value The value to add
- */
- void addAttributeValue( byte[] value );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java Thu Jan 27 23:28:46 2011
@@ -22,12 +22,11 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.entry.*;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.entry.Entry;
import org.apache.directory.shared.ldap.model.name.Dn;
/**
- * Lockable add request implemenation.
+ * Lockable add request implementation.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -48,6 +47,7 @@ public class AddRequestImpl extends Abst
// Constructors
// ------------------------------------------------------------------------
+
/**
* Creates an AddRequest implementation to create a new entry.
*/
@@ -70,55 +70,6 @@ public class AddRequestImpl extends Abst
}
- // ------------------------------------------------------------------------
- // AddRequest Interface Method Implementations
- // ------------------------------------------------------------------------
-
-
- /**
- * Gets the distinguished name of the entry to add.
- *
- * @return the Dn of the added entry.
- */
- public Dn getEntryDn()
- {
- return entry.getDn();
- }
-
-
- /**
- * Sets the distinguished name of the entry to add.
- *
- * @param dn the Dn of the added entry.
- */
- public void setEntryDn( Dn dn )
- {
- entry.setDn( dn );
- }
-
-
- /**
- * Gets the entry to add.
- *
- * @return the added Entry
- */
- public Entry getEntry()
- {
- return entry;
- }
-
-
- /**
- * Sets the Entry to add.
- *
- * @param entry the added Entry
- */
- public void setEntry( Entry entry )
- {
- this.entry = entry;
- }
-
-
/**
* Create a new attributeValue
*
@@ -182,6 +133,55 @@ public class AddRequestImpl extends Abst
// ------------------------------------------------------------------------
+ // AddRequest Interface Method Implementations
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * Gets the distinguished name of the entry to add.
+ *
+ * @return the Dn of the added entry.
+ */
+ public Dn getEntryDn()
+ {
+ return entry.getDn();
+ }
+
+
+ /**
+ * Sets the distinguished name of the entry to add.
+ *
+ * @param dn the Dn of the added entry.
+ */
+ public void setEntryDn( Dn dn )
+ {
+ entry.setDn( dn );
+ }
+
+
+ /**
+ * Gets the entry to add.
+ *
+ * @return the added Entry
+ */
+ public Entry getEntry()
+ {
+ return entry;
+ }
+
+
+ /**
+ * Sets the Entry to add.
+ *
+ * @param entry the added Entry
+ */
+ public void setEntry( Entry entry )
+ {
+ this.entry = entry;
+ }
+
+
+ // ------------------------------------------------------------------------
// SingleReplyRequest Interface Method Implementations
// ------------------------------------------------------------------------
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImpl.java?rev=1064355&r1=1064354&r2=1064355&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImpl.java Thu Jan 27 23:28:46 2011
@@ -21,10 +21,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
-import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.message.AbstractResponse;
import org.apache.directory.shared.ldap.model.message.Control;
import org.apache.directory.shared.ldap.model.message.SearchResultEntry;