Class RequestContext

java.lang.Object
org.forgerock.opendj.server.core.RequestContext

public final class RequestContext extends Object
Contextual state associated with the processing of an LDAP client request.
  • Method Details

    • builder

      public static RequestContext.Builder builder(ClientConnection connection)
      Returns a new RequestContext builder with the provided parent context and connection.
      Parameters:
      connection - The client connection associated with this request.
      Returns:
      The builder.
    • getTransactionId

      public org.forgerock.services.TransactionId getTransactionId()
      Returns the transaction ID.
      Returns:
      the non-null transaction ID.
    • getAuthenticationDn

      public Dn getAuthenticationDn()
      Returns the authentication Dn for logging.
      Returns:
      a Dn
    • getAuthorizationDn

      public Dn getAuthorizationDn()
      Returns the authorization Dn for logging, which could be from proxy auth.
      Returns:
      a Dn or Dn#emptyDn() if there is nothing to log.
    • getEntryAsAddedByServer

      public Entry getEntryAsAddedByServer()
      Returns the entry as added by the server, with all additional operational attributes.

      May differ from the entry specified in the Add request as attributes may be encoded, audit log will preferentially use the server entry.

      Returns:
      the entry as added by the server, with all additional operational attributes
    • setEntryAsAddedByServer

      public void setEntryAsAddedByServer(Entry entryAsAddedByServer)
      Sets the entry added as added by the server in the DIT.
      Parameters:
      entryAsAddedByServer - the entry added by the server
    • getModificationsAsAppliedByServer

      public List<Modification> getModificationsAsAppliedByServer()
      Returns the list of modifications applied by the server.

      May differ from client specified modifications as some attributes may be encoded, audit log will preferentially use the returned list.

      Returns:
      the list of modifications applied by the server
    • setModificationsAsAppliedByServer

      public void setModificationsAsAppliedByServer(List<Modification> modificationsAsAppliedByServer)
      Sets the list of modifications applied to an entry by the server while processing a Modify request.
      Parameters:
      modificationsAsAppliedByServer - the list of modifications generated by the server
    • addCancelRequestListener

      public void addCancelRequestListener(Consumer<CancelledResultException> onCancelRequest)
      Registers the provided cancellation listener with this request context so that it can be notified if a cancellation request is received and processing of the request should be aborted if possible. Requests may be cancelled as a result of an abandon request or a cancel extended request sent from the client, or by the server itself (e.g. during server shutdown).
      Parameters:
      onCancelRequest - The listener which should be notified if processing of the request should be aborted. Implementations should, if possible, abort further processing of the request and return an appropriate cancellation result.
      See Also:
    • checkIfCancelled

      public void checkIfCancelled(boolean signalTooLate) throws CancelledResultException
      Throws CancelledResultException if a cancellation request has been received and processing of the request should be aborted if possible. Requests may be cancelled as a result of an abandon request or a cancel extended request sent from the client, or by the server itself (e.g. during server shutdown).
      Parameters:
      signalTooLate - true to signal that, after this method returns, processing of the request will have proceeded too far for it to be aborted by subsequent cancellation requests.
      Throws:
      CancelledResultException - If processing of the request should be aborted if possible.
      See Also:
    • cannotCancel

      public void cannotCancel(LocalizableMessage cannotCancelReason)
      Indicates that the request associated with this request context cannot be cancelled. Any cancellation requests will be rejected with a ResultCode.CANNOT_CANCEL and the provided reason.
      Parameters:
      cannotCancelReason - The reason which will be provided in the cancel responses.
    • hasFlag

      public boolean hasFlag(RequestContext.RequestFlag requestFlag)
      Returns whether this request has the provided flag.
      Parameters:
      requestFlag - the request flag to test for
      Returns:
      true if this request has the provided flag
    • setFlag

      public void setFlag(RequestContext.RequestFlag requestFlag)
      Sets the provided flag for this request.
      Parameters:
      requestFlag - the request flag
    • getMessageId

      public int getMessageId()
      Returns the message id associated to the request.
      Returns:
      the message id
    • getOperationId

      public long getOperationId()
      Returns the operation id associated to the request.
      Returns:
      the operation id
    • hasPrivilege

      public boolean hasPrivilege(Privilege privilege)
      Returns true if the authorized user has the specified privilege.
      Parameters:
      privilege - The required privilege
      Returns:
      true if the authorized user has the specified privilege
    • getClientConnection

      public ClientConnection getClientConnection()
      Returns the client connection associated with this request.
      Returns:
      the client connection associated with this request
    • getJfrRequestEvent

      public RequestEvent getJfrRequestEvent()
      Returns the JFR request event associated with this request.
      Returns:
      the JFR request event associated with this request
    • notifyProcessingStarted

      public void notifyProcessingStarted()
      Signals that this request is no long queuing and is about to be processed.
    • notifyProcessingCompleted

      public void notifyProcessingCompleted()
      Signals that this request has completed processing. This does not include sending the result.
    • getReceiveTime

      public long getReceiveTime()
      Returns the time since the epoch when the request was received.
      Returns:
      the time since the epoch when the request was received
    • getProcessingCompleteTime

      public long getProcessingCompleteTime()
      Returns the time since the epoch when processing the request completed.
      Returns:
      the time since the epoch when processing the request completed
    • getElapsedProcessingTime

      public long getElapsedProcessingTime()
      Returns the elapsed processing time for the request.
      Returns:
      the elapsed processing time for the request
    • getElapsedQueueingTime

      public long getElapsedQueueingTime()
      Returns the elapsed queueing time for the request.
      Returns:
      the elapsed queueing time for the request
    • getElapsedTotalTime

      public long getElapsedTotalTime()
      Returns the elapsed total time for the request.
      Returns:
      the elapsed total time for the request
    • getElapsedTimeUnit

      public TimeUnit getElapsedTimeUnit()
      Returns the time unit that is used for reporting elapsed times of the request.
      Returns:
      the time unit that is used for reporting elapsed times of the request
    • getMaskedResultCode

      public ResultCode getMaskedResultCode()
      Retrieves the real, masked result code for this operation.
      Returns:
      The real, masked result code associated for this operation, or null if there is no need for one
    • setMaskedResultCode

      public void setMaskedResultCode(ResultCode maskedResultCode)
      Specifies the real, masked result code for this operation. This method may not be called by post-response plugins. A null value will reset to not having a masked error code to log.
      Parameters:
      maskedResultCode - The real, masked result code for this operation If null, the masked error message will be removed.
    • getMaskedErrorMessage

      public LocalizableMessage getMaskedErrorMessage()
      Retrieves the real, masked error message for this operation. Its contents may be altered by pre-parse, pre-operation, and post-operation plugins, but not by post-response plugins.
      Returns:
      The real, masked error message for this operation or null if none has been set
    • setMaskedErrorMessage

      public void setMaskedErrorMessage(LocalizableMessage maskedErrorMessage)
      Sets the masked error message. This method may not be called by post-response plugins.
      Parameters:
      maskedErrorMessage - the masked error message
    • setMatchedNamingContext

      public void setMatchedNamingContext(Dn matchedNamingContext)
      Sets the matched naming context. This method may not be called by post-response plugins.
      Parameters:
      matchedNamingContext - the matched naming context
    • getProxiedAuthorizationDn

      public Dn getProxiedAuthorizationDn()
      Returns the proxied authorization DN if proxy authorization has been requested.
      Returns:
      the proxied Authorization DN or null is proxy authorization has not been requested
    • setProxiedAuthorizationDn

      public void setProxiedAuthorizationDn(Dn proxiedAuthorizationDn)
      Set the proxied authorization DN for this operation if any.
      Parameters:
      proxiedAuthorizationDn - The proxied authorization DN. if null this operation will have no proxy authorization.
    • getSearchResultEntryCount

      public int getSearchResultEntryCount()
      Returns the number of entries sent by the search request associated to this context.
      Returns:
      the number of entries sent by the search request associated to this context
    • incrementSearchResultEntryCount

      public void incrementSearchResultEntryCount()
      Increments the number of entries returned by the search request associated to this context.
    • getAdditionalLogItems

      public List<AdditionalLogItem> getAdditionalLogItems()
      Returns additional information to be logged, as a potentially empty List of AdditionalLogItem.
      Returns:
      additional information to be logged, as a potentially empty List of AdditionalLogItem
    • addAdditionalLogItem

      public void addAdditionalLogItem(AdditionalLogItem item)
      Adds a AdditionalLogItem to the list for logging. null items will be ignored.
      Parameters:
      item - the additional log item to add
    • setAdditionalLogItems

      public void setAdditionalLogItems(List<AdditionalLogItem> items)
      Sets the AdditionalLogItems. All existing elements will be deleted.
      Parameters:
      items - the new log items
    • getLargestEntrySize

      public long getLargestEntrySize()
      Returns the size of the largest entry targeted by the request.
      Returns:
      the size of the largest entry targeted by the request
    • getTotalEntriesSize

      public long getTotalEntriesSize()
      Returns the accumulated entries size.
      Returns:
      the accumulated entries size
    • matchedNamingContext

      public Dn matchedNamingContext()
      Returns the matched naming context.
      Returns:
      the matched naming context
    • recordEntrySize

      public void recordEntrySize(long size)
      Update the entry size statistics totalEntriesSize and largestEntrySize of the entries that have been accessed by the request.
      Parameters:
      size - The size of the entry that has been accessed by the request.
    • getThreadNameForRequest

      public String getThreadNameForRequest(Request request)
      Returns the name that should be used for processing a request.
      Parameters:
      request - The request.
      Returns:
      The name of the thread.