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/08/20 21:23:37 UTC
svn commit: r987606 [15/25] - in /directory/shared/trunk: ./ all/ asn1-codec/
asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/ asn1/
asn1/src/main/java/org/apache/directory/shared/asn1/ber/grammar/
asn1/src/main/java/org/apache/director...
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ReferralImpl.java Fri Aug 20 19:23:27 2010
@@ -26,7 +26,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.apache.directory.shared.ldap.message.internal.InternalReferral;
/**
@@ -36,17 +35,40 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class ReferralImpl implements InternalReferral
+public class ReferralImpl implements Referral
{
static final long serialVersionUID = 2638820668325359096L;
/** Sequence of LDAPUrls composing this Referral */
private final List<String> urls = new ArrayList<String>();
+ /** The encoded LdapURL */
+ private final List<byte[]> urlsBytes = new ArrayList<byte[]>();
+
+ /** The length of the referral */
+ private int referralLength;
+
// ------------------------------------------------------------------------
// LdapResult Interface Method Implementations
// ------------------------------------------------------------------------
+ /**
+ * {@inheritDoc}
+ */
+ public int getReferralLength()
+ {
+ return referralLength;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReferralLength( int referralLength )
+ {
+ this.referralLength = referralLength;
+ }
+
/**
* Gets an unmodifiable set of alternative referral urls.
@@ -60,10 +82,18 @@ public class ReferralImpl implements Int
/**
+ * {@inheritDoc}
+ */
+ public Collection<byte[]> getLdapUrlsBytes()
+ {
+ return urlsBytes;
+ }
+
+
+ /**
* Adds an LDAPv3 URL to this Referral.
*
- * @param url
- * the LDAPv3 URL to add
+ * @param url the LDAPv3 URL to add
*/
public void addLdapUrl( String url )
{
@@ -72,6 +102,15 @@ public class ReferralImpl implements Int
/**
+ * {@inheritDoc}
+ */
+ public void addLdapUrlBytes( byte[] urlBytes )
+ {
+ urlsBytes.add( urlBytes );
+ }
+
+
+ /**
* Removes an LDAPv3 URL to this Referral.
*
* @param url
@@ -120,9 +159,9 @@ public class ReferralImpl implements Int
return true;
}
- if ( obj instanceof InternalReferral )
+ if ( obj instanceof Referral )
{
- Collection<String> refs = ( ( InternalReferral ) obj ).getLdapUrls();
+ Collection<String> refs = ( ( Referral ) obj ).getLdapUrls();
// if their sizes do not match they are not equal
if ( refs.size() != urls.size() )
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResponseCarryingMessageException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResponseCarryingMessageException.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResponseCarryingMessageException.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/ResponseCarryingMessageException.java Fri Aug 20 19:23:27 2010
@@ -22,7 +22,6 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.ldap.RuntimeMultiException;
-import org.apache.directory.shared.ldap.message.internal.InternalMessage;
/**
@@ -42,7 +41,7 @@ public class ResponseCarryingMessageExce
private static final long serialVersionUID = 1L;
/** The response with the error cause */
- private InternalMessage response;
+ private Message response;
/**
* Constructs an Exception without a message.
@@ -68,7 +67,7 @@ public class ResponseCarryingMessageExce
* Set a response if we get an exception while parsing the message
* @param response the constructed response
*/
- public void setResponse( InternalMessage response )
+ public void setResponse( Message response )
{
this.response = response;
}
@@ -77,7 +76,7 @@ public class ResponseCarryingMessageExce
* Get the constructed response
* @return The constructed response
*/
- public InternalMessage getResponse()
+ public Message getResponse()
{
return response;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SearchRequestImpl.java Fri Aug 20 19:23:27 2010
@@ -20,36 +20,74 @@
package org.apache.directory.shared.ldap.message;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
import org.apache.directory.shared.ldap.codec.LdapConstants;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
+import org.apache.directory.shared.ldap.codec.search.AndFilter;
+import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
+import org.apache.directory.shared.ldap.codec.search.ConnectorFilter;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.ldap.codec.search.Filter;
+import org.apache.directory.shared.ldap.codec.search.NotFilter;
+import org.apache.directory.shared.ldap.codec.search.OrFilter;
+import org.apache.directory.shared.ldap.codec.search.PresentFilter;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.exception.LdapProtocolErrorException;
+import org.apache.directory.shared.ldap.filter.AndNode;
+import org.apache.directory.shared.ldap.filter.ApproximateNode;
+import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.BranchNormalizedVisitor;
+import org.apache.directory.shared.ldap.filter.EqualityNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.ExtensibleNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.apache.directory.shared.ldap.filter.GreaterEqNode;
+import org.apache.directory.shared.ldap.filter.LeafNode;
+import org.apache.directory.shared.ldap.filter.LessEqNode;
+import org.apache.directory.shared.ldap.filter.NotNode;
+import org.apache.directory.shared.ldap.filter.OrNode;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
import org.apache.directory.shared.ldap.filter.SearchScope;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalSearchResponseDone;
+import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.name.DN;
/**
- * Lockable SearchRequest implementation.
+ * SearchRequest implementation.
*
* @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
*/
-public class SearchRequestImpl extends AbstractAbandonableRequest implements InternalSearchRequest
+public class SearchRequestImpl extends AbstractAbandonableRequest implements SearchRequest
{
static final long serialVersionUID = -5655881944020886218L;
/** Search base distinguished name */
private DN baseDn;
+ /** A temporary storage for a terminal Filter */
+ private Filter terminalFilter;
+
/** Search filter expression tree's root node */
- private ExprNode filter;
+ private ExprNode filterNode;
+
+ /** The current filter. This is used while decoding a PDU */
+ private Filter currentFilter;
+
+ /** The SearchRequest TLV id */
+ private int tlvId;
/** Search scope enumeration value */
private SearchScope scope;
@@ -63,26 +101,40 @@ public class SearchRequestImpl extends A
/** Max seconds to wait for search to complete */
private int timeLimit;
- /** Alias dereferencing mode enumeration value */
- private AliasDerefMode aliasDerefMode;
+ /** Alias dereferencing mode enumeration value (default to DEREF_ALWAYS) */
+ private AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
/** Attributes to return */
private List<String> attributes = new ArrayList<String>();
/** The final result containing SearchResponseDone response */
- private InternalSearchResponseDone response;
+ private SearchResultDone response;
+
+ /** The searchRequest length */
+ private int searchRequestLength;
+
+ /** The attributeDescriptionList length */
+ private int attributeDescriptionListLength;
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Creates a SearcRequest implementing object used to search the
+ * DIT.
+ */
+ public SearchRequestImpl()
+ {
+ super( -1, MessageTypeEnum.SEARCH_REQUEST );
+ }
+
/**
* Creates a Lockable SearcRequest implementing object used to search the
* DIT.
*
- * @param id
- * the sequential message identifier
+ * @param id the sequential message identifier
*/
public SearchRequestImpl( final int id )
{
@@ -90,6 +142,294 @@ public class SearchRequestImpl extends A
}
+ /**
+ * Transform the Filter part of a SearchRequest to an ExprNode
+ *
+ * @param codecFilter The filter to be transformed
+ * @return An ExprNode
+ */
+ private ExprNode transform( Filter filter )
+ {
+ if ( filter != null )
+ {
+ // Transform OR, AND or NOT leaves
+ if ( filter instanceof ConnectorFilter )
+ {
+ BranchNode branch = null;
+
+ if ( filter instanceof AndFilter )
+ {
+ branch = new AndNode();
+ }
+ else if ( filter instanceof OrFilter )
+ {
+ branch = new OrNode();
+ }
+ else if ( filter instanceof NotFilter )
+ {
+ branch = new NotNode();
+ }
+
+ List<Filter> filtersSet = ( ( ConnectorFilter ) filter ).getFilterSet();
+
+ // Loop on all AND/OR children
+ if ( filtersSet != null )
+ {
+ for ( Filter node : filtersSet )
+ {
+ branch.addNode( transform( node ) );
+ }
+ }
+
+ return branch;
+ }
+ else
+ {
+ // Transform PRESENT or ATTRIBUTE_VALUE_ASSERTION
+ LeafNode branch = null;
+
+ if ( filter instanceof PresentFilter )
+ {
+ branch = new PresenceNode( ( ( PresentFilter ) filter ).getAttributeDescription() );
+ }
+ else if ( filter instanceof AttributeValueAssertionFilter )
+ {
+ AttributeValueAssertion ava = ( ( AttributeValueAssertionFilter ) filter ).getAssertion();
+
+ // Transform =, >=, <=, ~= filters
+ switch ( ( ( AttributeValueAssertionFilter ) filter ).getFilterType() )
+ {
+ case LdapConstants.EQUALITY_MATCH_FILTER:
+ branch = new EqualityNode( ava.getAttributeDesc(), ava.getAssertionValue() );
+
+ break;
+
+ case LdapConstants.GREATER_OR_EQUAL_FILTER:
+ branch = new GreaterEqNode( ava.getAttributeDesc(), ava.getAssertionValue() );
+
+ break;
+
+ case LdapConstants.LESS_OR_EQUAL_FILTER:
+ branch = new LessEqNode( ava.getAttributeDesc(), ava.getAssertionValue() );
+
+ break;
+
+ case LdapConstants.APPROX_MATCH_FILTER:
+ branch = new ApproximateNode( ava.getAttributeDesc(), ava.getAssertionValue() );
+
+ break;
+ }
+
+ }
+ else if ( filter instanceof SubstringFilter )
+ {
+ // Transform Substring filters
+ SubstringFilter substrFilter = ( SubstringFilter ) filter;
+ String initialString = null;
+ String finalString = null;
+ List<String> anyString = null;
+
+ if ( substrFilter.getInitialSubstrings() != null )
+ {
+ initialString = substrFilter.getInitialSubstrings();
+ }
+
+ if ( substrFilter.getFinalSubstrings() != null )
+ {
+ finalString = substrFilter.getFinalSubstrings();
+ }
+
+ if ( substrFilter.getAnySubstrings() != null )
+ {
+ anyString = new ArrayList<String>();
+
+ for ( String any : substrFilter.getAnySubstrings() )
+ {
+ anyString.add( any );
+ }
+ }
+
+ branch = new SubstringNode( anyString, substrFilter.getType(), initialString, finalString );
+ }
+ else if ( filter instanceof ExtensibleMatchFilter )
+ {
+ // Transform Extensible Match Filter
+ ExtensibleMatchFilter extFilter = ( ExtensibleMatchFilter ) filter;
+ String matchingRule = null;
+
+ Value<?> value = extFilter.getMatchValue();
+
+ if ( extFilter.getMatchingRule() != null )
+ {
+ matchingRule = extFilter.getMatchingRule();
+ }
+
+ branch = new ExtensibleNode( extFilter.getType(), value, matchingRule, extFilter.isDnAttributes() );
+ }
+
+ return branch;
+ }
+ }
+ else
+ {
+ // We have found nothing to transform. Return null then.
+ return null;
+ }
+ }
+
+
+ /**
+ * Transform an ExprNode filter to a Filter
+ *
+ * @param exprNode The filter to be transformed
+ * @return A filter
+ */
+ private static Filter transform( ExprNode exprNode )
+ {
+ if ( exprNode != null )
+ {
+ Filter filter = null;
+
+ // Transform OR, AND or NOT leaves
+ if ( exprNode instanceof BranchNode )
+ {
+ if ( exprNode instanceof AndNode )
+ {
+ filter = new AndFilter();
+ }
+ else if ( exprNode instanceof OrNode )
+ {
+ filter = new OrFilter();
+ }
+ else if ( exprNode instanceof NotNode )
+ {
+ filter = new NotFilter();
+ }
+
+ List<ExprNode> children = ( ( BranchNode ) exprNode ).getChildren();
+
+ // Loop on all AND/OR children
+ if ( children != null )
+ {
+ for ( ExprNode child : children )
+ {
+ try
+ {
+ ( ( ConnectorFilter ) filter ).addFilter( transform( child ) );
+ }
+ catch ( DecoderException de )
+ {
+ return null;
+ }
+ }
+ }
+ }
+ else
+ {
+ if ( exprNode instanceof PresenceNode )
+ {
+ // Transform Presence Node
+ filter = new PresentFilter();
+ ( ( PresentFilter ) filter ).setAttributeDescription( ( ( PresenceNode ) exprNode ).getAttribute() );
+ }
+ else if ( exprNode instanceof SimpleNode<?> )
+ {
+ if ( exprNode instanceof EqualityNode<?> )
+ {
+ filter = new AttributeValueAssertionFilter( LdapConstants.EQUALITY_MATCH_FILTER );
+ AttributeValueAssertion assertion = new AttributeValueAssertion();
+ assertion.setAttributeDesc( ( ( EqualityNode<?> ) exprNode ).getAttribute() );
+ assertion.setAssertionValue( ( ( EqualityNode<?> ) exprNode ).getValue() );
+ ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion );
+ }
+ else if ( exprNode instanceof GreaterEqNode<?> )
+ {
+ filter = new AttributeValueAssertionFilter( LdapConstants.GREATER_OR_EQUAL_FILTER );
+ AttributeValueAssertion assertion = new AttributeValueAssertion();
+ assertion.setAttributeDesc( ( ( GreaterEqNode<?> ) exprNode ).getAttribute() );
+ assertion.setAssertionValue( ( ( GreaterEqNode<?> ) exprNode ).getValue() );
+ ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion );
+ }
+ else if ( exprNode instanceof LessEqNode<?> )
+ {
+ filter = new AttributeValueAssertionFilter( LdapConstants.LESS_OR_EQUAL_FILTER );
+ AttributeValueAssertion assertion = new AttributeValueAssertion();
+ assertion.setAttributeDesc( ( ( LessEqNode<?> ) exprNode ).getAttribute() );
+ assertion.setAssertionValue( ( ( LessEqNode<?> ) exprNode ).getValue() );
+ ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion );
+ }
+ else if ( exprNode instanceof ApproximateNode<?> )
+ {
+ filter = new AttributeValueAssertionFilter( LdapConstants.APPROX_MATCH_FILTER );
+ AttributeValueAssertion assertion = new AttributeValueAssertion();
+ assertion.setAttributeDesc( ( ( ApproximateNode<?> ) exprNode ).getAttribute() );
+ assertion.setAssertionValue( ( ( ApproximateNode<?> ) exprNode ).getValue() );
+ ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion );
+ }
+ }
+ else if ( exprNode instanceof SubstringNode )
+ {
+ // Transform Substring Nodes
+ filter = new SubstringFilter();
+
+ ( ( SubstringFilter ) filter ).setType( ( ( SubstringNode ) exprNode ).getAttribute() );
+ String initialString = ( ( SubstringNode ) exprNode ).getInitial();
+ String finalString = ( ( SubstringNode ) exprNode ).getFinal();
+ List<String> anyStrings = ( ( SubstringNode ) exprNode ).getAny();
+
+ if ( initialString != null )
+ {
+ ( ( SubstringFilter ) filter ).setInitialSubstrings( initialString );
+ }
+
+ if ( finalString != null )
+ {
+ ( ( SubstringFilter ) filter ).setFinalSubstrings( finalString );
+ }
+
+ if ( anyStrings != null )
+ {
+ for ( String any : anyStrings )
+ {
+ ( ( SubstringFilter ) filter ).addAnySubstrings( any );
+ }
+ }
+ }
+ else if ( exprNode instanceof ExtensibleNode )
+ {
+ // Transform Extensible Node
+ filter = new ExtensibleMatchFilter();
+
+ String attribute = ( ( ExtensibleNode ) exprNode ).getAttribute();
+ String matchingRule = ( ( ExtensibleNode ) exprNode ).getMatchingRuleId();
+ boolean dnAttributes = ( ( ExtensibleNode ) exprNode ).hasDnAttributes();
+ Value<?> value = ( ( ExtensibleNode ) exprNode ).getValue();
+
+ if ( attribute != null )
+ {
+ ( ( ExtensibleMatchFilter ) filter ).setType( attribute );
+ }
+
+ if ( matchingRule != null )
+ {
+ ( ( ExtensibleMatchFilter ) filter ).setMatchingRule( matchingRule );
+ }
+
+ ( ( ExtensibleMatchFilter ) filter ).setMatchValue( value );
+ ( ( ExtensibleMatchFilter ) filter ).setDnAttributes( dnAttributes );
+ }
+ }
+
+ return filter;
+ }
+ else
+ {
+ // We have found nothing to transform. Return null then.
+ return null;
+ }
+ }
+
+
// ------------------------------------------------------------------------
// SearchRequest Interface Method Implementations
// ------------------------------------------------------------------------
@@ -175,20 +515,184 @@ public class SearchRequestImpl extends A
*/
public ExprNode getFilter()
{
- return filter;
+ if ( filterNode == null )
+ {
+ filterNode = transform( currentFilter );
+ }
+
+ return filterNode;
+ }
+
+
+ /**
+ * Get the terminal filter
+ *
+ * @return Returns the terminal filter.
+ */
+ public Filter getTerminalFilter()
+ {
+ return terminalFilter;
}
/**
- * Sets the search filter associated with this search request.
+ * Set the terminal filter
*
- * @param filter
- * the expression node for the root of the filter expression
- * tree.
+ * @param terminalFilter the teminalFilter.
+ */
+ public void setTerminalFilter( Filter terminalFilter )
+ {
+ this.terminalFilter = terminalFilter;
+ }
+
+
+ /**
+ * {@inheritDoc}
*/
public void setFilter( ExprNode filter )
{
- this.filter = filter;
+ this.filterNode = filter;
+ }
+
+
+ /**
+ * Set the current filter
+ *
+ * @param filter The filter to set.
+ */
+ public void setCurrentFilter( Filter filter )
+ {
+ currentFilter = filter;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setFilter( String filter ) throws LdapException
+ {
+ try
+ {
+ filterNode = FilterParser.parse( filter );
+ this.currentFilter = transform( filterNode );
+ }
+ catch ( ParseException pe )
+ {
+ String msg = "The filter" + filter + " is invalid.";
+ throw new LdapProtocolErrorException( msg );
+ }
+ }
+
+
+ /**
+ * Get the parent Filter, if any
+ *
+ * @return The parent filter
+ */
+ public Filter getCurrentFilter()
+ {
+ return currentFilter;
+ }
+
+
+ /**
+ * Add a current filter. We have two cases :
+ * - there is no previous current filter : the filter
+ * is the top level filter
+ * - there is a previous current filter : the filter is added
+ * to the currentFilter set, and the current filter is changed
+ *
+ * In any case, the previous current filter will always be a
+ * ConnectorFilter when this method is called.
+ *
+ * @param localFilter The filter to set.
+ */
+ public void addCurrentFilter( Filter localFilter ) throws DecoderException
+ {
+ if ( currentFilter != null )
+ {
+ // Ok, we have a parent. The new Filter will be added to
+ // this parent, and will become the currentFilter if it's a connector.
+ ( ( ConnectorFilter ) currentFilter ).addFilter( localFilter );
+ localFilter.setParent( currentFilter, currentFilter.getTlvId() );
+
+ if ( localFilter instanceof ConnectorFilter )
+ {
+ currentFilter = localFilter;
+ }
+ }
+ else
+ {
+ // No parent. This Filter will become the root.
+ currentFilter = localFilter;
+ currentFilter.setParent( null, tlvId );
+ }
+ }
+
+
+ /**
+ * This method is used to clear the filter's stack for terminated elements. An element
+ * is considered as terminated either if :
+ * - it's a final element (ie an element which cannot contains a Filter)
+ * - its current length equals its expected length.
+ *
+ * @param container The container being decoded
+ */
+ public void unstackFilters( IAsn1Container container )
+ {
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+ TLV localParent = tlv.getParent();
+ Filter localFilter = terminalFilter;
+
+ // The parent has been completed, so fold it
+ while ( ( localParent != null ) && ( localParent.getExpectedLength() == 0 ) )
+ {
+ int parentTlvId = localFilter.getParent() != null ? localFilter.getParent().getTlvId() : localFilter
+ .getParentTlvId();
+
+ if ( localParent.getId() != parentTlvId )
+ {
+ localParent = localParent.getParent();
+
+ }
+ else
+ {
+ Filter filterParent = localFilter.getParent();
+
+ // We have a special case with PresentFilter, which has not been
+ // pushed on the stack, so we need to get its parent's parent
+ if ( localFilter instanceof PresentFilter )
+ {
+ if ( filterParent == null )
+ {
+ // We don't have parent, get out
+ break;
+ }
+
+ filterParent = filterParent.getParent();
+ }
+ else if ( filterParent instanceof Filter )
+ {
+ filterParent = filterParent.getParent();
+ }
+
+ if ( filterParent instanceof Filter )
+ {
+ // The parent is a filter ; it will become the new currentFilter
+ // and we will loop again.
+ currentFilter = ( Filter ) filterParent;
+ localFilter = currentFilter;
+ localParent = localParent.getParent();
+ }
+ else
+ {
+ // We can stop the recursion, we have reached the searchResult Object
+ break;
+ }
+ }
+ }
}
@@ -218,8 +722,7 @@ public class SearchRequestImpl extends A
/**
* Sets the search scope parameter enumeration.
*
- * @param scope
- * the scope enumeration parameter.
+ * @param scope the scope enumeration parameter.
*/
public void setScope( SearchScope scope )
{
@@ -247,8 +750,7 @@ public class SearchRequestImpl extends A
* that no client-requested sizelimit restrictions are in effect for the
* search. Servers may enforce a maximum number of entries to return.
*
- * @param entriesMax
- * maximum search result entries to return.
+ * @param entriesMax maximum search result entries to return.
*/
public void setSizeLimit( long entriesMax )
{
@@ -274,8 +776,7 @@ public class SearchRequestImpl extends A
* for a search. A value of 0 in this field indicates that no client-
* requested timelimit restrictions are in effect for the search.
*
- * @param secondsMax
- * the search time limit in seconds.
+ * @param secondsMax the search time limit in seconds.
*/
public void setTimeLimit( int secondsMax )
{
@@ -303,8 +804,7 @@ public class SearchRequestImpl extends A
* causes only attribute types (no values) to be returned. Setting this
* field to FALSE causes both attribute types and values to be returned.
*
- * @param typesOnly
- * true for only types, false for types and values.
+ * @param typesOnly true for only types, false for types and values.
*/
public void setTypesOnly( boolean typesOnly )
{
@@ -313,22 +813,21 @@ public class SearchRequestImpl extends A
/**
- * Adds an attribute to the set of entry attributes to return.
- *
- * @param attribute
- * the attribute description or identifier.
+ * {@inheritDoc}
*/
- public void addAttribute( String attribute )
+ public void addAttributes( String... attributes )
{
- attributes.add( attribute );
+ for ( String attribute : attributes )
+ {
+ this.attributes.add( attribute );
+ }
}
/**
* Removes an attribute to the set of entry attributes to return.
*
- * @param attribute
- * the attribute description or identifier.
+ * @param attribute the attribute description or identifier.
*/
public void removeAttribute( String attribute )
{
@@ -341,11 +840,11 @@ public class SearchRequestImpl extends A
*
* @return the result containing response for this request
*/
- public InternalResultResponse getResultResponse()
+ public ResultResponse getResultResponse()
{
if ( response == null )
{
- response = new SearchResponseDoneImpl( getMessageId() );
+ response = new SearchResultDoneImpl( getMessageId() );
}
return response;
@@ -353,21 +852,72 @@ public class SearchRequestImpl extends A
/**
+ * Stores the encoded length for the SearchRequest
+ * @param searchRequestLength The encoded length
+ */
+ /*No qualifier*/void setSearchRequestLength( int searchRequestLength )
+ {
+ this.searchRequestLength = searchRequestLength;
+ }
+
+
+ /**
+ * @return The encoded SearchRequest's length
+ */
+ /*No qualifier*/int getSearchRequestLength()
+ {
+ return searchRequestLength;
+ }
+
+
+ /**
+ * Stores the encoded length for the list of attributes
+ * @param attributeDescriptionListLength The encoded length of the attributes
+ */
+ /*No qualifier*/void setAttributeDescriptionListLength( int attributeDescriptionListLength )
+ {
+ this.attributeDescriptionListLength = attributeDescriptionListLength;
+ }
+
+
+ /**
+ * @return The encoded SearchRequest's attributes length
+ */
+ /*No qualifier*/int getAttributeDescriptionListLength()
+ {
+ return attributeDescriptionListLength;
+ }
+
+
+ /**
+ * Set the SearchRequest PDU TLV's Id
+ * @param tlvId The TLV id
+ */
+ public void setTlvId( int tlvId )
+ {
+ this.tlvId = tlvId;
+ }
+
+
+ /**
* {@inheritDoc}
*/
@Override
public int hashCode()
{
int hash = 37;
+
if ( baseDn != null )
{
hash = hash * 17 + baseDn.hashCode();
}
+
hash = hash * 17 + aliasDerefMode.hashCode();
hash = hash * 17 + scope.hashCode();
hash = hash * 17 + Long.valueOf( sizeLimit ).hashCode();
hash = hash * 17 + timeLimit;
hash = hash * 17 + ( typesOnly ? 0 : 1 );
+
if ( attributes != null )
{
hash = hash * 17 + attributes.size();
@@ -378,9 +928,10 @@ public class SearchRequestImpl extends A
hash = hash + attr.hashCode();
}
}
+
BranchNormalizedVisitor visitor = new BranchNormalizedVisitor();
- filter.accept( visitor );
- hash = hash * 17 + filter.toString().hashCode();
+ filterNode.accept( visitor );
+ hash = hash * 17 + currentFilter.toString().hashCode();
hash = hash * 17 + super.hashCode();
return hash;
@@ -395,8 +946,7 @@ public class SearchRequestImpl extends A
* representation which is comparable. For the time being this is a very
* costly operation.
*
- * @param obj
- * the object to check for equality to this SearchRequest
+ * @param obj the object to check for equality to this SearchRequest
* @return true if the obj is a SearchRequest and equals this SearchRequest,
* false otherwise
*/
@@ -412,7 +962,7 @@ public class SearchRequestImpl extends A
return false;
}
- InternalSearchRequest req = ( InternalSearchRequest ) obj;
+ SearchRequest req = ( SearchRequest ) obj;
if ( !req.getBase().equals( baseDn ) )
{
@@ -474,9 +1024,9 @@ public class SearchRequestImpl extends A
BranchNormalizedVisitor visitor = new BranchNormalizedVisitor();
req.getFilter().accept( visitor );
- filter.accept( visitor );
+ filterNode.accept( visitor );
- String myFilterString = filter.toString();
+ String myFilterString = currentFilter.toString();
String reqFilterString = req.getFilter().toString();
return myFilterString.equals( reqFilterString );
@@ -493,10 +1043,10 @@ public class SearchRequestImpl extends A
sb.append( " SearchRequest\n" );
sb.append( " baseDn : '" ).append( baseDn ).append( "'\n" );
- if ( filter != null )
+ if ( currentFilter != null )
{
sb.append( " filter : '" );
- sb.append( filter.toString() );
+ sb.append( currentFilter.toString() );
sb.append( "'\n" );
}
@@ -549,21 +1099,21 @@ public class SearchRequestImpl extends A
sb.append( " Deref Aliases : " );
- switch ( aliasDerefMode.getValue() )
+ switch ( aliasDerefMode )
{
- case LdapConstants.NEVER_DEREF_ALIASES:
+ case NEVER_DEREF_ALIASES:
sb.append( "never Deref Aliases" );
break;
- case LdapConstants.DEREF_IN_SEARCHING:
+ case DEREF_IN_SEARCHING:
sb.append( "deref In Searching" );
break;
- case LdapConstants.DEREF_FINDING_BASE_OBJ:
+ case DEREF_FINDING_BASE_OBJ:
sb.append( "deref Finding Base Obj" );
break;
- case LdapConstants.DEREF_ALWAYS:
+ case DEREF_ALWAYS:
sb.append( "deref Always" );
break;
}
@@ -595,6 +1145,9 @@ public class SearchRequestImpl extends A
sb.append( '\n' );
+ // The controls
+ sb.append( super.toString() );
+
return sb.toString();
}
}
\ No newline at end of file
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SingleReplyRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SingleReplyRequest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SingleReplyRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/SingleReplyRequest.java Fri Aug 20 19:23:27 2010
@@ -20,7 +20,6 @@
package org.apache.directory.shared.ldap.message;
import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponseRequest;
/**
@@ -28,7 +27,7 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public interface SingleReplyRequest extends InternalResultResponseRequest
+public interface SingleReplyRequest extends ResultResponseRequest
{
/**
* Gets the protocol response message type for this request which produces
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/UnbindRequestImpl.java Fri Aug 20 19:23:27 2010
@@ -19,9 +19,8 @@
*/
package org.apache.directory.shared.ldap.message;
+
import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.message.internal.InternalAbstractRequest;
-import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
/**
@@ -29,7 +28,7 @@ import org.apache.directory.shared.ldap.
*
* @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
*/
-public class UnbindRequestImpl extends InternalAbstractRequest implements InternalUnbindRequest
+public class UnbindRequestImpl extends AbstractRequest implements UnbindRequest
{
static final long serialVersionUID = -6217184085100410116L;
@@ -39,10 +38,9 @@ public class UnbindRequestImpl extends I
* outer envelope to disconnect and end a client session on the server
* without producing any response.
*
- * @param id
- * the sequential message identifier.
+ * @param id the sequential message identifier.
*/
- public UnbindRequestImpl(final int id)
+ public UnbindRequestImpl( final int id )
{
super( id, TYPE, false );
}
@@ -56,4 +54,22 @@ public class UnbindRequestImpl extends I
{
throw new UnsupportedOperationException( I18n.err( I18n.ERR_04185 ) );
}
+
+
+ /**
+ * Get a String representation of a UnBindRequest
+ *
+ * @return A UnBindRequest String
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( " UnBind Request" );
+
+ // The controls
+ sb.append( super.toString() );
+
+ return sb.toString();
+ }
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelRequest.java Fri Aug 20 19:23:27 2010
@@ -29,7 +29,7 @@ import org.apache.directory.shared.i18n.
import org.apache.directory.shared.ldap.codec.extended.operations.cancel.Cancel;
import org.apache.directory.shared.ldap.codec.extended.operations.cancel.CancelDecoder;
import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
+import org.apache.directory.shared.ldap.message.ResultResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,72 +71,35 @@ public class CancelRequest extends Exten
public CancelRequest( int messageId, int cancelId )
{
super( messageId );
- setOid( EXTENSION_OID );
+ setRequestName( EXTENSION_OID );
this.cancelId = cancelId;
}
/**
- * Encode the request
- */
- private void encodePayload() throws EncoderException
- {
- Cancel cancel = new Cancel();
- cancel.setCancelId( this.cancelId );
-
- payload = cancel.encode().array();
- }
-
-
- /**
- * Gets the extended request's <b>requestValue</b> portion of the PDU. The
- * form of the data is request specific and is determined by the extended
- * request OID.
- *
- * @return byte array of data
- */
- public byte[] getPayload()
- {
- if ( payload == null )
- {
- try
- {
- encodePayload();
- }
- catch ( EncoderException e )
- {
- LOG.error( I18n.err( I18n.ERR_04164 ), e );
- throw new RuntimeException( e );
- }
- }
-
- return super.getPayload();
- }
-
-
- /**
* Sets the extended request's <b>requestValue</b> portion of the PDU.
*
* @param payload byte array of data encapsulating ext. req. parameters
*/
- public void setPayload( byte[] payload )
+ public void setRequestValue( byte[] requestValue )
{
CancelDecoder decoder = new CancelDecoder();
try
{
- Cancel cancel = ( Cancel ) decoder.decode( payload );
+ Cancel cancel = ( Cancel ) decoder.decode( requestValue );
- if ( payload != null )
+ if ( requestValue != null )
{
- this.payload = new byte[payload.length];
- System.arraycopy( payload, 0, this.payload, 0, payload.length );
+ this.requestValue = new byte[requestValue.length];
+ System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length );
}
else
{
- this.payload = null;
+ this.requestValue = null;
}
+
this.cancelId = cancel.getCancelId();
}
catch ( DecoderException e )
@@ -154,13 +117,32 @@ public class CancelRequest extends Exten
}
- public byte[] getEncodedValue()
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getRequestValue()
{
- return getPayload();
+ if ( requestValue == null )
+ {
+ try
+ {
+ Cancel cancel = new Cancel();
+ cancel.setCancelId( this.cancelId );
+
+ requestValue = cancel.encode().array();
+ }
+ catch ( EncoderException e )
+ {
+ LOG.error( I18n.err( I18n.ERR_04164 ), e );
+ throw new RuntimeException( e );
+ }
+ }
+
+ return requestValue;
}
- public InternalResultResponse getResultResponse()
+ public ResultResponse getResultResponse()
{
if ( response == null )
{
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java Fri Aug 20 19:23:27 2010
@@ -45,7 +45,7 @@ public class CancelResponse extends Exte
*/
public CancelResponse( int messageId, ResultCodeEnum rcode )
{
- super( messageId, null );
+ super( messageId );
switch ( rcode )
{
@@ -68,7 +68,7 @@ public class CancelResponse extends Exte
public CancelResponse( int messageId )
{
- super( messageId, null );
+ super( messageId );
super.getLdapResult().setMatchedDn( null );
super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CertGenerationRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CertGenerationRequest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CertGenerationRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CertGenerationRequest.java Fri Aug 20 19:23:27 2010
@@ -29,7 +29,7 @@ import org.apache.directory.shared.i18n.
import org.apache.directory.shared.ldap.codec.extended.operations.certGeneration.CertGenerationDecoder;
import org.apache.directory.shared.ldap.codec.extended.operations.certGeneration.CertGenerationObject;
import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
+import org.apache.directory.shared.ldap.message.ResultResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,7 +66,7 @@ public class CertGenerationRequest exten
public CertGenerationRequest( int messageId, String targerDN, String issuerDN, String subjectDN, String keyAlgorithm )
{
super( messageId );
- setOid( EXTENSION_OID );
+ setRequestName( EXTENSION_OID );
this.certGenObj = new CertGenerationObject();
certGenObj.setTargetDN( targerDN );
@@ -76,26 +76,22 @@ public class CertGenerationRequest exten
}
- private void encodePayload() throws EncoderException
- {
- payload = certGenObj.encode().array();
- }
-
-
- public void setPayload( byte[] payload )
+ public void setequestValue( byte[] requestValue )
{
CertGenerationDecoder decoder = new CertGenerationDecoder();
+
try
{
- certGenObj = ( CertGenerationObject ) decoder.decode( payload );
- if ( payload != null )
+ certGenObj = ( CertGenerationObject ) decoder.decode( requestValue );
+
+ if ( requestValue != null )
{
- this.payload = new byte[payload.length];
- System.arraycopy( payload, 0, this.payload, 0, payload.length );
+ this.requestValue = new byte[requestValue.length];
+ System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length );
}
else
{
- this.payload = null;
+ this.requestValue = null;
}
}
catch ( DecoderException e )
@@ -113,19 +109,16 @@ public class CertGenerationRequest exten
}
- public byte[] getEncodedValue()
- {
- return getPayload();
- }
-
-
- public byte[] getPayload()
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getRequestValue()
{
- if ( payload == null )
+ if ( requestValue == null )
{
try
{
- encodePayload();
+ requestValue = certGenObj.encode().array();
}
catch ( EncoderException e )
{
@@ -134,18 +127,18 @@ public class CertGenerationRequest exten
}
}
- if ( payload == null )
+ if ( requestValue == null )
{
return null;
}
- final byte[] copy = new byte[payload.length];
- System.arraycopy( payload, 0, copy, 0, payload.length );
+ final byte[] copy = new byte[requestValue.length];
+ System.arraycopy( requestValue, 0, copy, 0, requestValue.length );
return copy;
}
- public InternalResultResponse getResultResponse()
+ public ResultResponse getResultResponse()
{
if ( response == null )
{
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulDisconnect.java Fri Aug 20 19:23:27 2010
@@ -32,9 +32,9 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.codec.extended.operations.gracefulDisconnect.GracefulDisconnectDecoder;
import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
+import org.apache.directory.shared.ldap.message.Referral;
import org.apache.directory.shared.ldap.message.ReferralImpl;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.internal.InternalReferral;
import org.apache.directory.shared.ldap.util.LdapURL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,21 +64,23 @@ public class GracefulDisconnect extends
private int delay;
/** String based LDAP URL that may be followed for replicated namingContexts */
- private InternalReferral replicatedContexts = new ReferralImpl();
+ private Referral replicatedContexts = new ReferralImpl();
- public GracefulDisconnect( byte[] value ) throws DecoderException
+ public GracefulDisconnect( byte[] responseValue ) throws DecoderException
{
super( 0, EXTENSION_OID );
- if ( value != null )
+
+ if ( responseValue != null )
{
- this.value = new byte[value.length];
- System.arraycopy( value, 0, this.value, 0, value.length );
+ this.responseValue = new byte[responseValue.length];
+ System.arraycopy( responseValue, 0, this.responseValue, 0, responseValue.length );
}
else
{
- this.value = null;
+ this.responseValue = null;
}
+
decodeValue();
}
@@ -86,7 +88,7 @@ public class GracefulDisconnect extends
public GracefulDisconnect( int timeOffline, int delay )
{
super( 0, EXTENSION_OID );
- super.oid = EXTENSION_OID;
+ responseName = EXTENSION_OID;
this.timeOffline = timeOffline;
this.delay = delay;
@@ -94,9 +96,9 @@ public class GracefulDisconnect extends
buf.append( "The server will disconnect and will be unavailable for " ).append( timeOffline );
buf.append( " minutes in " ).append( delay ).append( " seconds." );
- super.getLdapResult().setErrorMessage( buf.toString() );
- super.getLdapResult().setMatchedDn( null );
- super.getLdapResult().setResultCode( ResultCodeEnum.UNAVAILABLE );
+ ldapResult.setErrorMessage( buf.toString() );
+ ldapResult.setMatchedDn( null );
+ ldapResult.setResultCode( ResultCodeEnum.UNAVAILABLE );
encodeResponse();
}
@@ -110,15 +112,15 @@ public class GracefulDisconnect extends
try
{
codec = ( org.apache.directory.shared.ldap.codec.extended.operations.gracefulDisconnect.GracefulDisconnect ) decoder
- .decode( value );
+ .decode( responseValue );
this.timeOffline = codec.getTimeOffline();
this.delay = codec.getDelay();
- super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+ ldapResult.setResultCode( ResultCodeEnum.SUCCESS );
List<LdapURL> contexts = codec.getReplicatedContexts();
- for ( int ii = 0; ii < contexts.size(); ii++ )
+ for ( LdapURL ldapUrl : contexts )
{
- replicatedContexts.addLdapUrl( contexts.get( ii ).toString() );
+ replicatedContexts.addLdapUrl( ldapUrl.toString() );
}
}
catch ( DecoderException e )
@@ -136,25 +138,26 @@ public class GracefulDisconnect extends
codec.setDelay( this.delay );
Iterator<String> contexts = this.replicatedContexts.getLdapUrls().iterator();
- while ( contexts.hasNext() )
+ for ( String ldapUrlStr : replicatedContexts.getLdapUrls() )
{
- String urlstr = ( String ) contexts.next();
- LdapURL url = null;
+ LdapURL ldapUrl = null;
+
try
{
- url = new LdapURL( urlstr );
+ ldapUrl = new LdapURL( ldapUrlStr );
}
catch ( LdapURLEncodingException e )
{
- log.error( I18n.err( I18n.ERR_04170, urlstr ), e );
+ log.error( I18n.err( I18n.ERR_04170, ldapUrlStr ), e );
continue;
}
- codec.addReplicatedContexts( url );
+
+ codec.addReplicatedContexts( ldapUrl );
}
try
{
- super.value = codec.encode().array();
+ super.responseValue = codec.encode().array();
}
catch ( EncoderException e )
{
@@ -169,19 +172,19 @@ public class GracefulDisconnect extends
// ------------------------------------------------------------------------
/**
- * Gets the reponse OID specific encoded response values.
+ * Gets the response OID specific encoded response values.
*
* @return the response specific encoded response values.
*/
- public byte[] getResponse()
+ public byte[] getResponseValue()
{
- if ( value == null )
+ if ( responseValue == null )
{
encodeResponse();
}
- final byte[] copy = new byte[value.length];
- System.arraycopy( value, 0, copy, 0, value.length );
+ final byte[] copy = new byte[responseValue.length];
+ System.arraycopy( responseValue, 0, copy, 0, responseValue.length );
return copy;
}
@@ -189,14 +192,14 @@ public class GracefulDisconnect extends
/**
* Sets the reponse OID specific encoded response values.
*
- * @param value
- * the response specific encoded response values.
+ * @param value the response specific encoded response values.
*/
- public void setResponse( byte[] value )
+ public void setResponseValue( byte[] responseValue )
{
- ByteBuffer bb = ByteBuffer.wrap( value );
+ ByteBuffer bb = ByteBuffer.wrap( responseValue );
GracefulDisconnectContainer container = new GracefulDisconnectContainer();
Asn1Decoder decoder = new Asn1Decoder();
+
try
{
decoder.decode( bb, container );
@@ -212,20 +215,19 @@ public class GracefulDisconnect extends
this.timeOffline = codec.getTimeOffline();
List<LdapURL> contexts = codec.getReplicatedContexts();
- for ( int ii = 0; ii < contexts.size(); ii++ )
+ for ( LdapURL ldapUrl : codec.getReplicatedContexts() )
{
- LdapURL url = contexts.get( ii );
- replicatedContexts.addLdapUrl( url.toString() );
+ replicatedContexts.addLdapUrl( ldapUrl.toString() );
}
- if ( value != null )
+ if ( responseValue != null )
{
- this.value = new byte[value.length];
- System.arraycopy( value, 0, this.value, 0, value.length );
+ this.responseValue = new byte[responseValue.length];
+ System.arraycopy( responseValue, 0, this.responseValue, 0, responseValue.length );
}
else
{
- this.value = null;
+ this.responseValue = null;
}
}
@@ -246,8 +248,7 @@ public class GracefulDisconnect extends
* Sets the OID uniquely identifying this extended response (a.k.a. its
* name).
*
- * @param oid
- * the OID of the extended response type.
+ * @param oid the OID of the extended response type.
*/
public void setResponseName( String oid )
{
@@ -283,7 +284,7 @@ public class GracefulDisconnect extends
}
- public InternalReferral getReplicatedContexts()
+ public Referral getReplicatedContexts()
{
return replicatedContexts;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/GracefulShutdownRequest.java Fri Aug 20 19:23:27 2010
@@ -29,7 +29,7 @@ import org.apache.directory.shared.i18n.
import org.apache.directory.shared.ldap.codec.extended.operations.gracefulShutdown.GracefulShutdown;
import org.apache.directory.shared.ldap.codec.extended.operations.gracefulShutdown.GracefulShutdownDecoder;
import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
+import org.apache.directory.shared.ldap.message.ResultResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,36 +73,30 @@ public class GracefulShutdownRequest ext
public GracefulShutdownRequest( int messageId, int timeOffline, int delay )
{
super( messageId );
- setOid( EXTENSION_OID );
+ setRequestName( EXTENSION_OID );
this.timeOffline = timeOffline;
this.delay = delay;
}
- private void encodePayload() throws EncoderException
- {
- GracefulShutdown gs = new GracefulShutdown();
- gs.setDelay( this.delay );
- gs.setTimeOffline( this.timeOffline );
- payload = gs.encode().array();
- }
-
-
- public void setPayload( byte[] payload )
+ public void setRequestValue( byte[] requestValue )
{
GracefulShutdownDecoder decoder = new GracefulShutdownDecoder();
+
try
{
- GracefulShutdown gs = ( GracefulShutdown ) decoder.decode( payload );
- if ( payload != null )
+ GracefulShutdown gs = ( GracefulShutdown ) decoder.decode( requestValue );
+
+ if ( requestValue != null )
{
- this.payload = new byte[payload.length];
- System.arraycopy( payload, 0, this.payload, 0, payload.length );
+ this.requestValue = new byte[requestValue.length];
+ System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length );
}
else
{
- this.payload = null;
+ this.requestValue = null;
}
+
this.timeOffline = gs.getTimeOffline();
this.delay = gs.getDelay();
}
@@ -121,19 +115,19 @@ public class GracefulShutdownRequest ext
}
- public byte[] getEncodedValue()
- {
- return getPayload();
- }
-
-
- public byte[] getPayload()
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getRequestValue()
{
- if ( payload == null )
+ if ( requestValue == null )
{
try
{
- encodePayload();
+ GracefulShutdown gs = new GracefulShutdown();
+ gs.setDelay( this.delay );
+ gs.setTimeOffline( this.timeOffline );
+ requestValue = gs.encode().array();
}
catch ( EncoderException e )
{
@@ -142,11 +136,11 @@ public class GracefulShutdownRequest ext
}
}
- return super.getPayload();
+ return requestValue;
}
- public InternalResultResponse getResultResponse()
+ public ResultResponse getResultResponse()
{
if ( response == null )
{
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/LaunchDiagnosticUiRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/LaunchDiagnosticUiRequest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/LaunchDiagnosticUiRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/LaunchDiagnosticUiRequest.java Fri Aug 20 19:23:27 2010
@@ -45,8 +45,8 @@ public class LaunchDiagnosticUiRequest e
public LaunchDiagnosticUiRequest( int messageId )
{
super( messageId );
- setOid( EXTENSION_OID );
- setPayload( EMPTY_PAYLOAD );
+ setRequestName( EXTENSION_OID );
+ setRequestValue( EMPTY_PAYLOAD );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java Fri Aug 20 19:23:27 2010
@@ -33,7 +33,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.codec.extended.operations.storedProcedure.StoredProcedureDecoder;
import org.apache.directory.shared.ldap.codec.extended.operations.storedProcedure.StoredProcedure.StoredProcedureParameter;
import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
+import org.apache.directory.shared.ldap.message.ResultResponse;
import org.apache.directory.shared.ldap.util.StringTools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +56,7 @@ public class StoredProcedureRequest exte
public StoredProcedureRequest( int messageId )
{
super( messageId );
- this.setOid( EXTENSION_OID );
+ this.setRequestName( EXTENSION_OID );
this.procedure = new StoredProcedure();
}
@@ -64,20 +64,14 @@ public class StoredProcedureRequest exte
public StoredProcedureRequest( int messageId, String procedure, String language )
{
super( messageId );
- this.setOid( EXTENSION_OID );
+ this.setRequestName( EXTENSION_OID );
this.procedure = new StoredProcedure();
this.setLanguage( language );
this.setProcedure( procedure );
}
- private void encodePayload() throws EncoderException
- {
- payload = procedure.encode().array();
- }
-
-
- public void setPayload( byte[] payload )
+ public void setRequestValue( byte[] payload )
{
StoredProcedureDecoder decoder = new StoredProcedureDecoder();
StoredProcedureContainer container = new StoredProcedureContainer();
@@ -99,25 +93,22 @@ public class StoredProcedureRequest exte
throws NamingException
{
StoredProcedureResponse resp = ( StoredProcedureResponse ) getResultResponse();
- resp.setResponse( berValue );
- resp.setOid( id );
+ resp.setResponseValue( berValue );
+ resp.setResponseName( id );
return resp;
}
- public byte[] getEncodedValue()
- {
- return getPayload();
- }
-
-
- public byte[] getPayload()
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getRequestValue()
{
- if ( payload == null )
+ if ( requestValue == null )
{
try
{
- encodePayload();
+ requestValue = procedure.encode().array();
}
catch ( EncoderException e )
{
@@ -126,16 +117,16 @@ public class StoredProcedureRequest exte
}
}
- return payload;
+ return requestValue;
}
- public InternalResultResponse getResultResponse()
+ public ResultResponse getResultResponse()
{
if ( response == null )
{
StoredProcedureResponse spr = new StoredProcedureResponse( getMessageId() );
- spr.setOid( EXTENSION_OID );
+ spr.setResponseName( EXTENSION_OID );
response = spr;
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureResponse.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureResponse.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureResponse.java Fri Aug 20 19:23:27 2010
@@ -32,5 +32,4 @@ public class StoredProcedureResponse ext
private static final long serialVersionUID = 1L;
public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.7";
-
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/spi/ProviderObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/spi/ProviderObject.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/spi/ProviderObject.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/spi/ProviderObject.java Fri Aug 20 19:23:27 2010
@@ -35,7 +35,4 @@ public interface ProviderObject
* @return Provider.
*/
Provider getProvider();
-
- /** @link dependency */
- /* # Provider lnkProvider; */
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/sp/JavaStoredProcUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/sp/JavaStoredProcUtils.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/sp/JavaStoredProcUtils.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/sp/JavaStoredProcUtils.java Fri Aug 20 19:23:27 2010
@@ -18,9 +18,9 @@
*
*/
-
package org.apache.directory.shared.ldap.sp;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -30,12 +30,14 @@ import java.net.URL;
import javax.naming.NamingException;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
+import javax.naming.ldap.ExtendedResponse;
import javax.naming.ldap.LdapContext;
import org.apache.commons.lang.SerializationUtils;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.message.extended.StoredProcedureRequest;
-import org.apache.directory.shared.ldap.message.extended.StoredProcedureResponse;
+import org.apache.directory.shared.ldap.util.JndiUtils;
+
/**
* A utility class for working with Java Stored Procedures at the base level.
@@ -45,7 +47,6 @@ import org.apache.directory.shared.ldap.
public class JavaStoredProcUtils
{
-
/**
* Returns the stream data of a Java class.
*
@@ -66,7 +67,7 @@ public class JavaStoredProcUtils
File file = new File( url.getFile() );
int size = ( int ) file.length();
byte[] buf = new byte[size];
-
+
try
{
in.read( buf );
@@ -78,10 +79,11 @@ public class JavaStoredProcUtils
ne.setRootCause( e );
throw ne;
}
-
+
return buf;
}
-
+
+
/**
* Loads a Java class's stream data as a subcontext of an LdapContext given.
*
@@ -96,21 +98,23 @@ public class JavaStoredProcUtils
{
byte[] buf = getClassFileAsStream( clazz );
String fullClassName = clazz.getName();
-
+
Attributes attributes = new BasicAttributes( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
attributes.get( SchemaConstants.OBJECT_CLASS_AT ).add( "storedProcUnit" );
attributes.get( SchemaConstants.OBJECT_CLASS_AT ).add( "javaStoredProcUnit" );
attributes.put( "storedProcLangId", "Java" );
attributes.put( "storedProcUnitName", fullClassName );
attributes.put( "javaByteCode", buf );
-
- ctx.createSubcontext( "storedProcUnitName=" + fullClassName , attributes );
+
+ ctx.createSubcontext( "storedProcUnitName=" + fullClassName, attributes );
}
-
- public static Object callStoredProcedure( LdapContext ctx, String procedureName, Object[] arguments ) throws NamingException
+
+
+ public static Object callStoredProcedure( LdapContext ctx, String procedureName, Object[] arguments )
+ throws NamingException
{
String language = "Java";
-
+
Object responseObject;
try
{
@@ -118,7 +122,7 @@ public class JavaStoredProcUtils
* Create a new stored procedure execution request.
*/
StoredProcedureRequest req = new StoredProcedureRequest( 0, procedureName, language );
-
+
/**
* For each argument UTF-8-encode the type name
* and Java-serialize the value
@@ -132,13 +136,13 @@ public class JavaStoredProcUtils
value = SerializationUtils.serialize( ( Serializable ) arguments[i] );
req.addParameter( type, value );
}
-
+
/**
* Call the stored procedure via the extended operation
* and get back its return value.
*/
- StoredProcedureResponse resp = ( StoredProcedureResponse ) ctx.extendedOperation( req );
-
+ ExtendedResponse resp = ctx.extendedOperation( JndiUtils.toJndiExtendedRequest( req ) );
+
/**
* Restore a Java object from the return value.
*/
@@ -151,8 +155,8 @@ public class JavaStoredProcUtils
ne.setRootCause( e );
throw ne;
}
-
+
return responseObject;
}
-
+
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java Fri Aug 20 19:23:27 2010
@@ -31,8 +31,7 @@ import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.BasicAttributes;
-import javax.naming.ldap.ExtendedRequest;
-import javax.naming.ldap.ExtendedResponse;
+import javax.naming.directory.InvalidAttributeIdentifierException;
import org.apache.commons.lang.ArrayUtils;
import org.apache.directory.shared.i18n.I18n;
@@ -44,7 +43,6 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeTypeException;
-import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
import org.apache.directory.shared.ldap.name.DN;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -275,7 +273,7 @@ public class AttributeUtils
try
{
String comparedStr = normalizer.normalize( compared.getString() );
-
+
for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); /**/)
{
String value = ( String ) values.nextElement();
@@ -285,7 +283,7 @@ public class AttributeUtils
}
}
}
- catch( NamingException e )
+ catch ( NamingException e )
{
throw new LdapException( e.getMessage() );
}
@@ -358,7 +356,7 @@ public class AttributeUtils
for ( NamingEnumeration<?> values = attr.getAll(); values.hasMoreElements(); /**/)
{
Object value = values.nextElement();
-
+
if ( value instanceof byte[] && ArrayUtils.isEquals( comparedBytes, value ) )
{
return true;
@@ -404,7 +402,7 @@ public class AttributeUtils
{
Object attrVal = attrVals.nextElement();
- if ( attrVal instanceof String && strVal.equalsIgnoreCase( ( String ) attrVal ) )
+ if ( attrVal instanceof String && strVal.equalsIgnoreCase( ( String ) attrVal ) )
{
return true;
}
@@ -420,7 +418,7 @@ public class AttributeUtils
{
Object attrVal = attrVals.nextElement();
- if ( attrVal instanceof byte[] && Arrays.equals( ( byte[] ) attrVal, valueBytes ) )
+ if ( attrVal instanceof byte[] && Arrays.equals( ( byte[] ) attrVal, valueBytes ) )
{
return true;
}
@@ -488,7 +486,6 @@ public class AttributeUtils
}
*/
-
/**
* Creates a new attribute which contains the values representing the
* difference of two attributes. If both attributes are null then we cannot
@@ -877,7 +874,7 @@ public class AttributeUtils
if ( !parseNumber( str, pos ) )
{
- throw new ParseException(I18n.err( I18n.ERR_04345 ), pos.start );
+ throw new ParseException( I18n.err( I18n.ERR_04345 ), pos.start );
}
}
}
@@ -1182,7 +1179,6 @@ public class AttributeUtils
}
*/
-
/**
* Convert a BasicAttributes or a AttributesImpl to a ServerEntry
*
@@ -1327,55 +1323,4 @@ public class AttributeUtils
return null;
}
}
-
-
- public static ExtendedRequest toJndiExtendedRequest( final InternalExtendedRequest request )
- {
- class JndiExtendedRequest implements ExtendedRequest
- {
- public ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset, int length )
- throws NamingException
- {
- return toJndiExtendedResponse( request );
- }
-
- public byte[] getEncodedValue()
- {
- return request.getPayload();
- }
-
- public String getID()
- {
- return request.getOid();
- }
-
- }
-
- return new JndiExtendedRequest();
- }
-
-
- /**
- * TODO toJndiExtendedResponse. This is NOT correct ATM
- *
- * @param request
- * @return
- */
- public static ExtendedResponse toJndiExtendedResponse( final InternalExtendedRequest request )
- {
- class JndiExtendedResponse implements ExtendedResponse
- {
- public byte[] getEncodedValue()
- {
- return request.getEncodedValue();
- }
-
- public String getID()
- {
- return request.getID();
- }
- }
-
- return new JndiExtendedResponse();
- }
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java?rev=987606&r1=987605&r2=987606&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/LdapURL.java Fri Aug 20 19:23:27 2010
@@ -44,6 +44,7 @@ import org.apache.directory.shared.ldap.
/**
* Decodes a LdapUrl, and checks that it complies with
* the RFC 2255. The grammar is the following :
+ * <pre>
* ldapurl = scheme "://" [hostport] ["/"
* [dn ["?" [attributes] ["?" [scope]
* ["?" [filter] ["?" extensions]]]]]]
@@ -60,7 +61,7 @@ import org.apache.directory.shared.ldap.
* exvalue = LDAPString
* token = oid from section 4.1 of RFC 2252
* xtoken = ("X-" / "x-") token
- *
+ * </pre>
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LdapURL
@@ -362,7 +363,8 @@ public class LdapURL
* apply to the byte buffer TODO check that the topLabel is valid
* (it must start with an alpha)
*/
- @SuppressWarnings("PMD.CollapsibleIfStatements") // Used because of comments
+ @SuppressWarnings("PMD.CollapsibleIfStatements")
+ // Used because of comments
private int parseHost( char[] chars, int pos )
{
@@ -400,7 +402,7 @@ public class LdapURL
}
// Let's check the string we had before the dot.
- if ( isHostNumber && nbDots < 4 )
+ if ( isHostNumber && nbDots < 4 )
{
// We had only digits. It may be an IP adress? Check it
@@ -1723,7 +1725,7 @@ public class LdapURL
*/
public void setScope( int scope )
{
- try
+ try
{
this.scope = SearchScope.getSearchScope( scope );
}