Class SearchRequestDecorator
- java.lang.Object
-
- org.apache.directory.api.ldap.codec.api.MessageDecorator<SearchRequest>
-
- org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator
-
- All Implemented Interfaces:
Asn1Object
,Decorator<SearchRequest>
,AbandonableRequest
,ManyReplyRequest
,Message
,Request
,ResultResponseRequest
,SearchRequest
public class SearchRequestDecorator extends MessageDecorator<SearchRequest> implements SearchRequest
A decorator for the SearchRequest message- Author:
- Apache Directory Project
-
-
Field Summary
-
Fields inherited from interface org.apache.directory.api.ldap.model.message.SearchRequest
RESPONSE_TYPES
-
-
Constructor Summary
Constructors Constructor Description SearchRequestDecorator(LdapApiService codec, SearchRequest decoratedMessage)
Makes a SearchRequest encodable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abandon()
Abandons this request.SearchRequest
addAbandonListener(AbandonListener listener)
Adds listener to be notified if this request gets abandoned.SearchRequest
addAllControls(Control[] controls)
Adds an array of controls to this Message.SearchRequest
addAttributes(String... attributes)
Adds some attributes to the set of entry attributes to return.SearchRequest
addControl(Control control)
Adds a control to this Message.void
addCurrentFilter(Filter localFilter)
Add a current filter.int
computeLength()
Compute the SearchRequest length
SearchRequest :ByteBuffer
encode(ByteBuffer buffer)
Encode the SearchRequest message to a PDU.boolean
equals(Object o)
SearchRequest
followReferrals()
Tells the client to follow referrals instead of throwing exceptionsList<String>
getAttributes()
Gets a list of the attributes to be returned from each entry which matches the search filter.Dn
getBase()
Gets the search base as a distinguished name.Filter
getCodecFilter()
Gets the search filter associated with this search request.Filter
getCurrentFilter()
AliasDerefMode
getDerefAliases()
Gets the alias handling parameter.ExprNode
getFilter()
Gets the search filter associated with this search request.ExprNode
getFilterNode()
Gets the search filter associated with this search request.MessageTypeEnum[]
getResponseTypes()
Gets the different response types generated by a search request.SearchResultDone
getResultResponse()
If called for the first time, this method creates a result containing response object for this request.SearchScope
getScope()
Gets the search scope parameter enumeration.long
getSizeLimit()
A sizelimit that restricts the maximum number of entries to be returned as a result of the search.Filter
getTerminalFilter()
Get the terminal filterint
getTimeLimit()
Gets the timelimit that restricts the maximum time (in seconds) allowed for a search.boolean
getTypesOnly()
An indicator as to whether search results will contain both attribute types and values, or just attribute types.int
hashCode()
boolean
hasResponse()
Tests to see if this Request produces one or more response types.SearchRequest
ignoreReferrals()
Tells the client to ignore referrals instead of throwing exceptions.boolean
isAbandoned()
Checks to see if this request has been abandoned.boolean
isFollowReferrals()
Tells the client if it should follow referrals instead of throwing exceptionsboolean
isIgnoreReferrals()
Tells the client if it should ignore referrals instead of throwing exceptionsSearchRequest
removeAttribute(String attribute)
Removes an attribute to the set of entry attributes to return.SearchRequest
removeControl(Control control)
Deletes a control removing it from this Message.SearchRequest
setBase(Dn baseDn)
Sets the search base as a distinguished name.void
setCurrentFilter(Filter filter)
Set the current filterSearchRequest
setDerefAliases(AliasDerefMode aliasDerefAliases)
Sets the alias handling parameter.SearchRequest
setFilter(String filter)
Sets the search filter associated with this search request.SearchRequest
setFilter(ExprNode filter)
Sets the search filter associated with this search request.SearchRequest
setMessageId(int messageId)
Sets the Message ID for this requestSearchRequest
setScope(SearchScope scope)
Sets the search scope parameter enumeration.SearchRequest
setSizeLimit(long entriesMax)
Sets sizelimit that restricts the maximum number of entries to be returned as a result of the search.void
setTerminalFilter(Filter terminalFilter)
Set the terminal filterSearchRequest
setTimeLimit(int secondsMax)
Sets the timelimit that restricts the maximum time (in seconds) allowed for a search.void
setTlvId(int tlvId)
Set the SearchRequest PDU TLV's IdSearchRequest
setTypesOnly(boolean typesOnly)
An indicator as to whether search results will contain both attribute types and values, or just attribute types.void
unstackFilters(Asn1Container container)
This method is used to clear the filter's stack for terminated elements.-
Methods inherited from class org.apache.directory.api.ldap.codec.api.MessageDecorator
get, getCodecService, getControl, getControls, getControlsLength, getCurrentControl, getDecorated, getDecorator, getMessageId, getMessageLength, getType, hasControl, put, setControlsLength, setMessageLength, toString
-
Methods inherited from interface org.apache.directory.api.ldap.model.message.Message
get, getControl, getControls, getMessageId, getType, hasControl, put
-
-
-
-
Constructor Detail
-
SearchRequestDecorator
public SearchRequestDecorator(LdapApiService codec, SearchRequest decoratedMessage)
Makes a SearchRequest encodable.- Parameters:
codec
- The LDAP service instancedecoratedMessage
- the decorated SearchRequest
-
-
Method Detail
-
setTlvId
public void setTlvId(int tlvId)
Set the SearchRequest PDU TLV's Id- Parameters:
tlvId
- The TLV id
-
getCurrentFilter
public Filter getCurrentFilter()
- Returns:
- The current search filter
-
getCodecFilter
public Filter getCodecFilter()
Gets the search filter associated with this search request.- Returns:
- the expression node for the root of the filter expression tree.
-
getFilterNode
public ExprNode getFilterNode() throws LdapSchemaException
Gets the search filter associated with this search request.- Returns:
- the expression node for the root of the filter expression tree.
- Throws:
LdapSchemaException
- If the filter is invalid
-
getTerminalFilter
public Filter getTerminalFilter()
Get the terminal filter- Returns:
- Returns the terminal filter.
-
setTerminalFilter
public void setTerminalFilter(Filter terminalFilter)
Set the terminal filter- Parameters:
terminalFilter
- the teminalFilter.
-
setFilter
public SearchRequest setFilter(ExprNode filter)
Sets the search filter associated with this search request.- Specified by:
setFilter
in interfaceSearchRequest
- Parameters:
filter
- the expression node for the root of the filter expression tree.- Returns:
- The SearchRequest instance
-
setFilter
public SearchRequest setFilter(String filter) throws LdapException
Sets the search filter associated with this search request.- Specified by:
setFilter
in interfaceSearchRequest
- Parameters:
filter
- the expression node for the root of the filter expression tree.- Returns:
- The SearchRequest instance
- Throws:
LdapException
- If the filter can't be added
-
setCurrentFilter
public void setCurrentFilter(Filter filter)
Set the current filter- Parameters:
filter
- The filter to set.
-
addCurrentFilter
public void addCurrentFilter(Filter localFilter) throws DecoderException
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.- Parameters:
localFilter
- The filter to set.- Throws:
DecoderException
- If the filter is invalid
-
unstackFilters
public void unstackFilters(Asn1Container container)
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.- Parameters:
container
- The container being decoded
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classObject
- See Also:
Object.equals(Object)
-
getResponseTypes
public MessageTypeEnum[] getResponseTypes()
Gets the different response types generated by a search request.- Specified by:
getResponseTypes
in interfaceManyReplyRequest
- Specified by:
getResponseTypes
in interfaceSearchRequest
- Returns:
- the RESPONSE_TYPES array
- See Also:
SearchRequest.RESPONSE_TYPES
-
getBase
public Dn getBase()
Gets the search base as a distinguished name.- Specified by:
getBase
in interfaceSearchRequest
- Returns:
- the search base
-
setBase
public SearchRequest setBase(Dn baseDn)
Sets the search base as a distinguished name.- Specified by:
setBase
in interfaceSearchRequest
- Parameters:
baseDn
- the search base- Returns:
- The SearchRequest instance
-
getScope
public SearchScope getScope()
Gets the search scope parameter enumeration.- Specified by:
getScope
in interfaceSearchRequest
- Returns:
- the scope enumeration parameter.
-
setScope
public SearchRequest setScope(SearchScope scope)
Sets the search scope parameter enumeration.- Specified by:
setScope
in interfaceSearchRequest
- Parameters:
scope
- the scope enumeration parameter.- Returns:
- The SearchRequest instance
-
getDerefAliases
public AliasDerefMode getDerefAliases()
Gets the alias handling parameter.- Specified by:
getDerefAliases
in interfaceSearchRequest
- Returns:
- the alias handling parameter enumeration.
-
setDerefAliases
public SearchRequest setDerefAliases(AliasDerefMode aliasDerefAliases)
Sets the alias handling parameter.- Specified by:
setDerefAliases
in interfaceSearchRequest
- Parameters:
aliasDerefAliases
- the alias handling parameter enumeration.- Returns:
- The SearchRequest instance
-
getSizeLimit
public long getSizeLimit()
A sizelimit that restricts the maximum number of entries to be returned as a result of the search. A value of 0 in this field indicates that no client-requested sizelimit restrictions are in effect for the search. Servers may enforce a maximum number of entries to return.- Specified by:
getSizeLimit
in interfaceSearchRequest
- Returns:
- search size limit.
-
setSizeLimit
public SearchRequest setSizeLimit(long entriesMax)
Sets sizelimit that restricts the maximum number of entries to be returned as a result of the search. A value of 0 in this field indicates that no client-requested sizelimit restrictions are in effect for the search. Servers may enforce a maximum number of entries to return.- Specified by:
setSizeLimit
in interfaceSearchRequest
- Parameters:
entriesMax
- maximum search result entries to return.- Returns:
- The SearchRequest instance
-
getTimeLimit
public int getTimeLimit()
Gets the timelimit that restricts the maximum time (in seconds) allowed for a search. A value of 0 in this field indicates that no client- requested timelimit restrictions are in effect for the search.- Specified by:
getTimeLimit
in interfaceSearchRequest
- Returns:
- the search time limit in seconds.
-
setTimeLimit
public SearchRequest setTimeLimit(int secondsMax)
Sets the timelimit that restricts the maximum time (in seconds) allowed for a search. A value of 0 in this field indicates that no client- requested timelimit restrictions are in effect for the search.- Specified by:
setTimeLimit
in interfaceSearchRequest
- Parameters:
secondsMax
- the search time limit in seconds.- Returns:
- The SearchRequest instance
-
getTypesOnly
public boolean getTypesOnly()
An indicator as to whether search results will contain both attribute types and values, or just attribute types. Setting this field to TRUE causes only attribute types (no values) to be returned. Setting this field to FALSE causes both attribute types and values to be returned.- Specified by:
getTypesOnly
in interfaceSearchRequest
- Returns:
- true for only types, false for types and values.
-
setTypesOnly
public SearchRequest setTypesOnly(boolean typesOnly)
An indicator as to whether search results will contain both attribute types and values, or just attribute types. Setting this field to TRUE causes only attribute types (no values) to be returned. Setting this field to FALSE causes both attribute types and values to be returned.- Specified by:
setTypesOnly
in interfaceSearchRequest
- Parameters:
typesOnly
- true for only types, false for types and values.- Returns:
- The SearchRequest instance
-
getFilter
public ExprNode getFilter()
Gets the search filter associated with this search request.- Specified by:
getFilter
in interfaceSearchRequest
- Returns:
- the expression node for the root of the filter expression tree.
-
getAttributes
public List<String> getAttributes()
Gets a list of the attributes to be returned from each entry which matches the search filter. There are two special values which may be used: an empty list with no attributes, and the attribute description string "*". Both of these signify that all user attributes are to be returned. (The "*" allows the client to request all user attributes in addition to specific operational attributes). Attributes MUST be named at most once in the list, and are returned at most once in an entry. If there are attribute descriptions in the list which are not recognized, they are ignored by the server. If the client does not want any attributes returned, it can specify a list containing only the attribute with OID "1.1". This OID was chosen arbitrarily and does not correspond to any attribute in use. Client implementors should note that even if all user attributes are requested, some attributes of the entry may not be included in search results due to access control or other restrictions. Furthermore, servers will not return operational attributes, such as objectClasses or attributeTypes, unless they are listed by name, since there may be extremely large number of values for certain operational attributes.- Specified by:
getAttributes
in interfaceSearchRequest
- Returns:
- the attributes to return for this request
-
addAttributes
public SearchRequest addAttributes(String... attributes)
Adds some attributes to the set of entry attributes to return.- Specified by:
addAttributes
in interfaceSearchRequest
- Parameters:
attributes
- the attributes description or identifier.- Returns:
- The SearchRequest instance
-
removeAttribute
public SearchRequest removeAttribute(String attribute)
Removes an attribute to the set of entry attributes to return.- Specified by:
removeAttribute
in interfaceSearchRequest
- Parameters:
attribute
- the attribute description or identifier.- Returns:
- The SearchRequest instance
-
computeLength
public int computeLength()
Compute the SearchRequest length
SearchRequest :0x63 L1 | +--> 0x04 L2 baseObject +--> 0x0A 0x01 scope +--> 0x0A 0x01 derefAliases +--> 0x02 0x0(1..4) sizeLimit +--> 0x02 0x0(1..4) timeLimit +--> 0x01 0x01 typesOnly +--> filter.computeLength() +--> 0x30 L3 (Attribute description list) | +--> 0x04 L4-1 Attribute description +--> 0x04 L4-2 Attribute description +--> ... +--> 0x04 L4-i Attribute description +--> ... +--> 0x04 L4-n Attribute description
- Specified by:
computeLength
in interfaceAsn1Object
- Returns:
- The object's computed length
-
encode
public ByteBuffer encode(ByteBuffer buffer) throws EncoderException
Encode the SearchRequest message to a PDU.
SearchRequest :0x63 LL 0x04 LL baseObject 0x0A 01 scope 0x0A 01 derefAliases 0x02 0N sizeLimit 0x02 0N timeLimit 0x01 0x01 typesOnly filter.encode() 0x30 LL attributeDescriptionList 0x04 LL attributeDescription ... 0x04 LL attributeDescription
- Specified by:
encode
in interfaceAsn1Object
- Parameters:
buffer
- The buffer where to put the PDU- Returns:
- The PDU.
- Throws:
EncoderException
- if the buffer can't be encoded
-
getResultResponse
public SearchResultDone getResultResponse()
If called for the first time, this method creates a result containing response object for this request.- Specified by:
getResultResponse
in interfaceResultResponseRequest
- Returns:
- a result containing response with defaults and the messageId set in response to this specific request
-
hasResponse
public boolean hasResponse()
Tests to see if this Request produces one or more response types.- Specified by:
hasResponse
in interfaceRequest
- Returns:
- true if a response can be expected, false otherwise.
-
abandon
public void abandon()
Abandons this request.- Specified by:
abandon
in interfaceAbandonableRequest
-
isAbandoned
public boolean isAbandoned()
Checks to see if this request has been abandoned.- Specified by:
isAbandoned
in interfaceAbandonableRequest
- Returns:
- true if the request has been abandoned.
-
addAbandonListener
public SearchRequest addAbandonListener(AbandonListener listener)
Adds listener to be notified if this request gets abandoned.- Specified by:
addAbandonListener
in interfaceAbandonableRequest
- Parameters:
listener
- to be notified if this request gets abandoned.- Returns:
- An AbandonableRequest reference
-
setMessageId
public SearchRequest setMessageId(int messageId)
Sets the Message ID for this request- Specified by:
setMessageId
in interfaceMessage
- Specified by:
setMessageId
in interfaceSearchRequest
- Overrides:
setMessageId
in classMessageDecorator<SearchRequest>
- Parameters:
messageId
- The message Id- Returns:
- A Message reference
-
addControl
public SearchRequest addControl(Control control)
Adds a control to this Message.- Specified by:
addControl
in interfaceMessage
- Specified by:
addControl
in interfaceSearchRequest
- Overrides:
addControl
in classMessageDecorator<SearchRequest>
- Parameters:
control
- the control to add.- Returns:
- A Message reference
-
addAllControls
public SearchRequest addAllControls(Control[] controls)
Adds an array of controls to this Message.- Specified by:
addAllControls
in interfaceMessage
- Specified by:
addAllControls
in interfaceSearchRequest
- Overrides:
addAllControls
in classMessageDecorator<SearchRequest>
- Parameters:
controls
- the controls to add.- Returns:
- A Message reference
-
removeControl
public SearchRequest removeControl(Control control)
Deletes a control removing it from this Message.- Specified by:
removeControl
in interfaceMessage
- Specified by:
removeControl
in interfaceSearchRequest
- Overrides:
removeControl
in classMessageDecorator<SearchRequest>
- Parameters:
control
- the control to remove.- Returns:
- A Message reference
-
isFollowReferrals
public boolean isFollowReferrals()
Tells the client if it should follow referrals instead of throwing exceptions- Specified by:
isFollowReferrals
in interfaceSearchRequest
- Returns:
- true if we should follow the referrals
-
followReferrals
public SearchRequest followReferrals()
Tells the client to follow referrals instead of throwing exceptions- Specified by:
followReferrals
in interfaceSearchRequest
- Returns:
- The SearchRequest instance
-
isIgnoreReferrals
public boolean isIgnoreReferrals()
Tells the client if it should ignore referrals instead of throwing exceptions- Specified by:
isIgnoreReferrals
in interfaceSearchRequest
- Returns:
- true if we should ignore the referrals
-
ignoreReferrals
public SearchRequest ignoreReferrals()
Tells the client to ignore referrals instead of throwing exceptions. The entry will contain the referral attributeType with the link.- Specified by:
ignoreReferrals
in interfaceSearchRequest
- Returns:
- The SearchRequest instance
-
-