Package org.opends.server.core
Class SearchOperation
- java.lang.Object
-
- org.opends.server.types.Operation
-
- org.opends.server.core.SearchOperation
-
- All Implemented Interfaces:
Runnable,InProgressOperation,InProgressSearchOperation,PluginOperation,PostOperationOperation,PostOperationSearchOperation,PostResponseOperation,PostResponseSearchOperation,PreOperationOperation,PreOperationSearchOperation,PreParseOperation,PreParseSearchOperation
public class SearchOperation extends Operation implements PreOperationSearchOperation, PreParseSearchOperation, PostOperationSearchOperation, PostResponseSearchOperation, InProgressSearchOperation
This class defines an operation used to search for entries in the Directory Server.
-
-
Field Summary
-
Fields inherited from class org.opends.server.types.Operation
requestContext
-
-
Constructor Summary
Constructors Constructor Description SearchOperation(org.forgerock.services.context.Context context, SearchRequest request)Creates a new search operation with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddResponseControl(Control control)Adds the provided control to the set of controls to include in the response to the client.Set<String>getAttributes()Retrieves the set of requested attributes for this search operation.DngetBaseDN()Retrieves the base DN for this search operation.DereferenceAliasesPolicygetDerefPolicy()Retrieves the alias dereferencing policy for this search operation.intgetEntriesSent()Retrieves the number of entries sent to the client for this search operation.FiltergetFilter()Retrieves the filter for this search operation.MatchergetMatcher()Retrieves the matcher derived from the search filter for this search operation.intgetMaxCandidateSetSize()Return the maximum candidate set size for this search operation.OperationTypegetOperationType()Retrieves the operation type for this operation.DngetProxiedAuthorizationDN()Retrieves the proxied authorization DN for this operation if proxied authorization has been requested.intgetReferencesSent()Retrieves the number of search references sent to the client for this search operation.List<Control>getResponseControls()Retrieves the set of controls to include in the response to the client.SearchScopegetScope()Retrieves the scope for this search operation.ServerSideSortRequestControlgetServerSideSortControlOrNull()Return the Server Side Sort Control of the search request ornullif absent.SimplePagedResultsControlgetSimplePagedResultsControlOrNull()Return the Simple Paged Results Control of the search request ornullif absent.intgetSizeLimit()Retrieves the size limit for this search operation.intgetTimeLimit()Retrieves the time limit for this search operation.booleangetTypesOnly()Retrieves the typesOnly flag for this search operation.VirtualListViewRequestControlgetVirtualListViewRequestControlOrNull()Return the Virtual List View Request Control of the search request ornullif absent.booleanisSendResponse()Indicates whether the search result done message has to be sent to the client, or not.voidremoveResponseControl(Control control)Removes the provided control from the set of controls to include in the response to the client.booleanreturnEntry(Entry entry, List<Control> controls)Used as a callback for backends to indicate that the provided entry matches the search criteria and that additional processing should be performed to potentially send it back to the client.booleanreturnReference(Dn dn, SearchResultReference reference)Used as a callback for backends to indicate that the provided search reference was encountered during processing and that additional processing should be performed to potentially send it back to the client.voidrun()Performs the work of actually processing this operation.voidsendSearchEntry(SearchResultEntry entry)Sends the provided search result entry to the client.booleansendSearchReference(SearchResultReference reference)Sends the provided search result reference to the client.voidsendSearchResultDone()Sends the search result done message to the client.voidsetAttributes(Set<String> attributes)Specifies the set of requested attributes for this search operation.voidsetBaseDN(Dn baseDN)Specifies the base DN as included in the request from the client.voidsetDerefPolicy(DereferenceAliasesPolicy derefPolicy)Specifies the alias dereferencing policy for this search operation.voidsetFilter(Filter filter)Specifies the search filter as included in the request from the client.voidsetMaxCandidateSetSize(int maxCandidateSetSize)Set the maximum candidate set size for this search operation.voidsetProxiedAuthorizationDN(Dn proxiedAuthorizationDN)Set the proxied authorization DN for this operation if proxied authorization has been requested.voidsetScope(SearchScope scope)Specifies the scope for this search operation.voidsetSendResponse(boolean sendResponse)Specify whether the search result done message has to be sent to the client, or not.voidsetSizeLimit(int sizeLimit)Specifies the size limit for this search operation.voidsetTimeLimit(int timeLimit)Specifies the time limit for this search operation.voidsetTypesOnly(boolean typesOnly)Specifies the typesOnly flag for this search operation.booleantimeLimitExpired()Returns whether the search operation has reached its time limit.voidtoString(StringBuilder buffer)Appends a string representation of this operation to the provided buffer.-
Methods inherited from class org.opends.server.types.Operation
addAdditionalLogItem, addPasswordPolicyWarningToLog, addPostReadResponse, addPreReadResponse, addRequestControl, appendErrorMessage, appendMaskedErrorMessage, checkAttributeConformsToSyntax, checkIfBackendIsWritable, checkIfCanceled, createLdapException, disconnectClient, dontSynchronize, equals, evaluateProxyAuthControls, filterNonDisclosableMatchedDN, findMatchedDN, getAdditionalLogItems, getAttachment, getAttachments, getAuthorizationDN, getAuthorizationEntry, getClientConnection, getConnectionID, getContext, getErrorMessage, getLargestEntrySize, getLocalBackend, getMatchedDN, getMessageID, getOperationID, getReferralURLs, getRequestControl, getRequestControls, getResultCode, getServerContext, hashCode, hasPrivilege, hasRequestControl, invokePostResponseCallbacks, isHumanReadable, isInnerOperation, isInternalOperation, isProxyAuthzControl, isSynchronizationOperation, mustCheckSchema, operationCompleted, processOperationResult, processOperationResult, registerPostResponseCallback, removeAllDisallowedControls, removeAttachment, setAttachment, setAttachments, setAuthorizationEntry, setDontSynchronize, setErrorMessage, setInnerOperation, setInternalOperation, setMatchedDN, setReferralURLs, setResult, setResult, setResultCode, setResultCodeAndMessageNoInfoDisclosure, setSynchronizationOperation, toString, trySetLargestEntrySize
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opends.server.types.operation.InProgressOperation
addAdditionalLogItem, appendErrorMessage, getAdditionalLogItems, getAuthorizationDN, getErrorMessage, getMatchedDN, getReferralURLs, getResultCode, setErrorMessage, setMatchedDN, setReferralURLs, setResult, setResultCode
-
Methods inherited from interface org.opends.server.types.operation.PluginOperation
checkIfCanceled, disconnectClient, getAttachment, getAttachments, getClientConnection, getConnectionID, getMessageID, getOperationID, getRequestControl, getRequestControl, getRequestControls, isInternalOperation, isSynchronizationOperation, removeAttachment, setAttachment, toString
-
Methods inherited from interface org.opends.server.types.operation.PostOperationOperation
addAdditionalLogItem, appendErrorMessage, getAdditionalLogItems, getAuthorizationDN, getErrorMessage, getMatchedDN, getReferralURLs, getResultCode, setErrorMessage, setMatchedDN, setReferralURLs, setResult, setResultCode
-
Methods inherited from interface org.opends.server.types.operation.PostResponseOperation
getAdditionalLogItems, getAuthorizationDN, getErrorMessage, getMatchedDN, getReferralURLs, getResultCode
-
Methods inherited from interface org.opends.server.types.operation.PreOperationOperation
addAdditionalLogItem, appendErrorMessage, getAdditionalLogItems, getAuthorizationDN, getErrorMessage, setErrorMessage
-
Methods inherited from interface org.opends.server.types.operation.PreParseOperation
addAdditionalLogItem, addRequestControl, appendErrorMessage, getAdditionalLogItems, getErrorMessage, setErrorMessage
-
-
-
-
Constructor Detail
-
SearchOperation
public SearchOperation(org.forgerock.services.context.Context context, SearchRequest request)Creates a new search operation with the provided information.- Parameters:
context- The request context with which this operation is associated.request- The search request.
-
-
Method Detail
-
setBaseDN
public final void setBaseDN(Dn baseDN)
Specifies the base DN as included in the request from the client.This method should only be called by pre-parse plugins or for internal use.
- Specified by:
setBaseDNin interfacePreParseSearchOperation- Parameters:
baseDN- The non-null base DN as included in the request from the client.
-
getBaseDN
public final Dn getBaseDN()
Description copied from interface:PreOperationSearchOperationRetrieves the base DN for this search operation.- Specified by:
getBaseDNin interfaceInProgressSearchOperation- Specified by:
getBaseDNin interfacePostOperationSearchOperation- Specified by:
getBaseDNin interfacePostResponseSearchOperation- Specified by:
getBaseDNin interfacePreOperationSearchOperation- Specified by:
getBaseDNin interfacePreParseSearchOperation- Returns:
- The base DN for this search operation.
-
getScope
public final SearchScope getScope()
Retrieves the scope for this search operation.- Specified by:
getScopein interfaceInProgressSearchOperation- Specified by:
getScopein interfacePostOperationSearchOperation- Specified by:
getScopein interfacePostResponseSearchOperation- Specified by:
getScopein interfacePreOperationSearchOperation- Specified by:
getScopein interfacePreParseSearchOperation- Returns:
- The scope for this search operation.
-
setScope
public final void setScope(SearchScope scope)
Specifies the scope for this search operation. This should only be called by pre-parse plugins.- Specified by:
setScopein interfacePreParseSearchOperation- Parameters:
scope- The scope for this search operation.
-
getDerefPolicy
public final DereferenceAliasesPolicy getDerefPolicy()
Retrieves the alias dereferencing policy for this search operation.- Specified by:
getDerefPolicyin interfaceInProgressSearchOperation- Specified by:
getDerefPolicyin interfacePostOperationSearchOperation- Specified by:
getDerefPolicyin interfacePostResponseSearchOperation- Specified by:
getDerefPolicyin interfacePreOperationSearchOperation- Specified by:
getDerefPolicyin interfacePreParseSearchOperation- Returns:
- The alias dereferencing policy for this search operation.
-
setDerefPolicy
public final void setDerefPolicy(DereferenceAliasesPolicy derefPolicy)
Specifies the alias dereferencing policy for this search operation. This should only be called by pre-parse plugins.- Specified by:
setDerefPolicyin interfacePreParseSearchOperation- Parameters:
derefPolicy- The alias dereferencing policy for this search operation.
-
getSizeLimit
public final int getSizeLimit()
Retrieves the size limit for this search operation.- Specified by:
getSizeLimitin interfaceInProgressSearchOperation- Specified by:
getSizeLimitin interfacePostOperationSearchOperation- Specified by:
getSizeLimitin interfacePostResponseSearchOperation- Specified by:
getSizeLimitin interfacePreOperationSearchOperation- Specified by:
getSizeLimitin interfacePreParseSearchOperation- Returns:
- The size limit for this search operation.
-
setSizeLimit
public final void setSizeLimit(int sizeLimit)
Specifies the size limit for this search operation. This should only be called by pre-parse plugins.- Specified by:
setSizeLimitin interfacePreParseSearchOperation- Parameters:
sizeLimit- The size limit for this search operation.
-
getTimeLimit
public final int getTimeLimit()
Retrieves the time limit for this search operation.- Specified by:
getTimeLimitin interfaceInProgressSearchOperation- Specified by:
getTimeLimitin interfacePostOperationSearchOperation- Specified by:
getTimeLimitin interfacePostResponseSearchOperation- Specified by:
getTimeLimitin interfacePreOperationSearchOperation- Specified by:
getTimeLimitin interfacePreParseSearchOperation- Returns:
- The time limit for this search operation.
-
setTimeLimit
public final void setTimeLimit(int timeLimit)
Specifies the time limit for this search operation. This should only be called by pre-parse plugins.- Specified by:
setTimeLimitin interfacePreParseSearchOperation- Parameters:
timeLimit- The time limit for this search operation.
-
getMaxCandidateSetSize
public final int getMaxCandidateSetSize()
Return the maximum candidate set size for this search operation.- Returns:
- The maximum candidate set size for this search operation.
-
setMaxCandidateSetSize
public final void setMaxCandidateSetSize(int maxCandidateSetSize)
Set the maximum candidate set size for this search operation.- Parameters:
maxCandidateSetSize- The maximum candidate set size for this search operation.
-
getTypesOnly
public final boolean getTypesOnly()
Retrieves the typesOnly flag for this search operation.- Specified by:
getTypesOnlyin interfaceInProgressSearchOperation- Specified by:
getTypesOnlyin interfacePostOperationSearchOperation- Specified by:
getTypesOnlyin interfacePostResponseSearchOperation- Specified by:
getTypesOnlyin interfacePreOperationSearchOperation- Specified by:
getTypesOnlyin interfacePreParseSearchOperation- Returns:
- The typesOnly flag for this search operation.
-
setTypesOnly
public final void setTypesOnly(boolean typesOnly)
Specifies the typesOnly flag for this search operation. This should only be called by pre-parse plugins.- Specified by:
setTypesOnlyin interfacePreParseSearchOperation- Parameters:
typesOnly- The typesOnly flag for this search operation.
-
setFilter
public final void setFilter(Filter filter)
Specifies the search filter as included in the request from the client.This method should only be called by pre-parse plugins.
- Specified by:
setFilterin interfacePreParseSearchOperation- Parameters:
filter- The non-null search filter as included in the request from the client.
-
getFilter
public final Filter getFilter()
Retrieves the filter for this search operation.Only use this method for logging. Prefer to use
getMatcher()for matching entries.- Specified by:
getFilterin interfaceInProgressSearchOperation- Specified by:
getFilterin interfacePostOperationSearchOperation- Specified by:
getFilterin interfacePostResponseSearchOperation- Specified by:
getFilterin interfacePreOperationSearchOperation- Specified by:
getFilterin interfacePreParseSearchOperation- Returns:
- The filter for this search operation.
-
getMatcher
public final Matcher getMatcher()
Retrieves the matcher derived from the search filter for this search operation.- Returns:
- the matcher for this search operation.
-
getAttributes
public final Set<String> getAttributes()
Retrieves the set of requested attributes for this search operation. Its contents should not be altered.- Specified by:
getAttributesin interfaceInProgressSearchOperation- Specified by:
getAttributesin interfacePostOperationSearchOperation- Specified by:
getAttributesin interfacePostResponseSearchOperation- Specified by:
getAttributesin interfacePreOperationSearchOperation- Specified by:
getAttributesin interfacePreParseSearchOperation- Returns:
- The set of requested attributes for this search operation.
-
setAttributes
public final void setAttributes(Set<String> attributes)
Specifies the set of requested attributes for this search operation. It should only be called by pre-parse plugins.- Specified by:
setAttributesin interfacePreParseSearchOperation- Parameters:
attributes- The set of requested attributes for this search operation.
-
getEntriesSent
public final int getEntriesSent()
Retrieves the number of entries sent to the client for this search operation.- Specified by:
getEntriesSentin interfacePostOperationSearchOperation- Specified by:
getEntriesSentin interfacePostResponseSearchOperation- Returns:
- The number of entries sent to the client for this search operation.
-
getReferencesSent
public final int getReferencesSent()
Retrieves the number of search references sent to the client for this search operation.- Specified by:
getReferencesSentin interfacePostOperationSearchOperation- Specified by:
getReferencesSentin interfacePostResponseSearchOperation- Returns:
- The number of search references sent to the client for this search operation.
-
returnEntry
public boolean returnEntry(Entry entry, List<Control> controls)
Used as a callback for backends to indicate that the provided entry matches the search criteria and that additional processing should be performed to potentially send it back to the client.- Specified by:
returnEntryin interfacePreOperationSearchOperation- Specified by:
returnEntryin interfacePreParseSearchOperation- Parameters:
entry- The entry that matches the search criteria and should be sent to the client.controls- The set of controls to include with the entry (may benullif none are needed).- Returns:
trueif the caller should continue processing the search request and sending additional entries and references, orfalseif not for some reason (e.g., the size limit has been reached or the search has been abandoned).
-
timeLimitExpired
public boolean timeLimitExpired()
Returns whether the search operation has reached its time limit.- Returns:
- whether the search operation has reached its time limit
-
returnReference
public boolean returnReference(Dn dn, SearchResultReference reference)
Used as a callback for backends to indicate that the provided search reference was encountered during processing and that additional processing should be performed to potentially send it back to the client.- Specified by:
returnReferencein interfacePreOperationSearchOperation- Specified by:
returnReferencein interfacePreParseSearchOperation- Parameters:
reference- The search reference to send to the client.dn- The DN related to the specified search reference.- Returns:
trueif the caller should continue processing the search request and sending additional entries and references , orfalseif not for some reason (e.g., the size limit has been reached or the search has been abandoned).
-
sendSearchResultDone
public void sendSearchResultDone()
Sends the search result done message to the client. Note that this method should only be called from external classes in special cases (e.g., persistent search) where they are sure that the result won't be sent by the core server. Also note that the result code and optionally the error message should have been set for this operation before this method is called.
-
getOperationType
public final OperationType getOperationType()
Description copied from interface:PluginOperationRetrieves the operation type for this operation.- Specified by:
getOperationTypein interfacePluginOperation- Returns:
- The operation type for this operation.
-
getProxiedAuthorizationDN
public final Dn getProxiedAuthorizationDN()
Description copied from class:OperationRetrieves the proxied authorization DN for this operation if proxied authorization has been requested.- Specified by:
getProxiedAuthorizationDNin classOperation- Returns:
- The proxied authorization DN for this operation if proxied authorization has been requested, or
nullif proxied authorization has not been requested.
-
getResponseControls
public final List<Control> getResponseControls()
Description copied from interface:PluginOperationRetrieves the set of controls to include in the response to the client. The contents of this list must not be altered.- Specified by:
getResponseControlsin interfacePluginOperation- Returns:
- The set of controls to include in the response to the client.
-
addResponseControl
public final void addResponseControl(Control control)
Description copied from class:OperationAdds the provided control to the set of controls to include in the response to the client.This method may not be called by post-response plugins.
- Specified by:
addResponseControlin interfaceInProgressOperation- Specified by:
addResponseControlin interfacePostOperationOperation- Specified by:
addResponseControlin interfacePreOperationOperation- Specified by:
addResponseControlin interfacePreParseOperation- Specified by:
addResponseControlin classOperation- Parameters:
control- The control to add to the set of controls to include in the response to the client.
-
removeResponseControl
public final void removeResponseControl(Control control)
Description copied from class:OperationRemoves the provided control from the set of controls to include in the response to the client.This method may not be called by post-response plugins.
- Specified by:
removeResponseControlin interfaceInProgressOperation- Specified by:
removeResponseControlin interfacePostOperationOperation- Specified by:
removeResponseControlin interfacePreOperationOperation- Specified by:
removeResponseControlin interfacePreParseOperation- Specified by:
removeResponseControlin classOperation- Parameters:
control- The control to remove from the set of controls to include in the response to the client.
-
toString
public void toString(StringBuilder buffer)
Description copied from interface:PluginOperationAppends a string representation of this operation to the provided buffer.- Specified by:
toStringin interfacePluginOperation- Specified by:
toStringin classOperation- Parameters:
buffer- The buffer into which a string representation of this operation should be appended.
-
getSimplePagedResultsControlOrNull
public SimplePagedResultsControl getSimplePagedResultsControlOrNull()
Return the Simple Paged Results Control of the search request ornullif absent.- Returns:
- the Simple Paged Results Control of the search request or
nullif absent
-
getServerSideSortControlOrNull
public ServerSideSortRequestControl getServerSideSortControlOrNull()
Return the Server Side Sort Control of the search request ornullif absent.- Returns:
- the Server Side Sort Control of the search request or
nullif absent
-
getVirtualListViewRequestControlOrNull
public VirtualListViewRequestControl getVirtualListViewRequestControlOrNull()
Return the Virtual List View Request Control of the search request ornullif absent.- Returns:
- the Virtual List View Request Control of the search request or
nullif absent
-
isSendResponse
public final boolean isSendResponse()
Indicates whether the search result done message has to be sent to the client, or not.- Returns:
- true if the search result done message is to be sent to the client
-
setSendResponse
public final void setSendResponse(boolean sendResponse)
Specify whether the search result done message has to be sent to the client, or not.- Parameters:
sendResponse- - boolean indicating whether the search result done message is to send to the client
-
sendSearchEntry
public void sendSearchEntry(SearchResultEntry entry) throws LdapException
Sends the provided search result entry to the client.- Parameters:
entry- The search result entry to be sent to the client.- Throws:
LdapException- If a problem occurs while attempting to send the entry to the client and the search should be terminated.
-
sendSearchReference
public boolean sendSearchReference(SearchResultReference reference) throws LdapException
Sends the provided search result reference to the client.- Parameters:
reference- The search result reference to be sent to the client.- Returns:
trueif the client is able to accept referrals, orfalseif the client cannot handle referrals and no more attempts should be made to send them for the associated search operation.- Throws:
LdapException- If a problem occurs while attempting to send the reference to the client and the search should be terminated.
-
setProxiedAuthorizationDN
public final void setProxiedAuthorizationDN(Dn proxiedAuthorizationDN)
Description copied from class:OperationSet the proxied authorization DN for this operation if proxied authorization has been requested.- Specified by:
setProxiedAuthorizationDNin classOperation- Parameters:
proxiedAuthorizationDN- The proxied authorization DN for this operation if proxied authorization has been requested, ornullif proxied authorization has not been requested.
-
run
public void run()
Description copied from class:OperationPerforms the work of actually processing this operation. This should include all processing for the operation, including invoking pre-parse and post-response plugins, logging messages and any other work that might need to be done in the course of processing.
-
-