001/*
002 * Copyright 2009-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2009-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2009-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.logs;
037
038
039
040import com.unboundid.util.NotExtensible;
041import com.unboundid.util.NotNull;
042import com.unboundid.util.Nullable;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This class provides a data structure that holds information about a log
050 * message that may appear in the Directory Server access log about an
051 * operation processed by the server.
052 * <BR>
053 * <BLOCKQUOTE>
054 *   <B>NOTE:</B>  This class, and other classes within the
055 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
056 *   supported for use against Ping Identity, UnboundID, and
057 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
058 *   for proprietary functionality or for external specifications that are not
059 *   considered stable or mature enough to be guaranteed to work in an
060 *   interoperable way with other types of LDAP servers.
061 * </BLOCKQUOTE>
062 */
063@NotExtensible()
064@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
065public abstract class OperationAccessLogMessage
066       extends AccessLogMessage
067{
068  /**
069   * The serial version UID for this serializable class.
070   */
071  private static final long serialVersionUID = 5311424730889643655L;
072
073
074
075  // The message ID for this access log message.
076  @Nullable private final Integer messageID;
077
078  // The operation ID for this access log message.
079  @Nullable private final Long operationID;
080
081  // The connection ID for the operation that triggered the associated
082  // operation.
083  @Nullable private final Long triggeredByConnectionID;
084
085  // The operation ID for the operation that triggered the associated operation.
086  @Nullable private final Long triggeredByOperationID;
087
088  // The message origin for this access log message.
089  @Nullable private final String origin;
090
091
092
093  /**
094   * Creates a new operation access log message from the provided log message.
095   *
096   * @param  m  The log message to be parsed as an operation access log message.
097   */
098  protected OperationAccessLogMessage(@NotNull final LogMessage m)
099  {
100    super(m);
101
102    messageID               = getNamedValueAsInteger("msgID");
103    operationID             = getNamedValueAsLong("op");
104    triggeredByConnectionID = getNamedValueAsLong("triggeredByConn");
105    triggeredByOperationID  = getNamedValueAsLong("triggeredByOp");
106    origin                  = getNamedValue("origin");
107  }
108
109
110
111  /**
112   * Retrieves the operation ID for the associated operation.
113   *
114   * @return  The operation ID for the associated operation, or {@code null} if
115   *          it is not included in the log message.
116   */
117  @Nullable()
118  public final Long getOperationID()
119  {
120    return operationID;
121  }
122
123
124
125  /**
126   * Retrieves the connection ID for the connection that triggered the
127   * associated operation.  This is generally used for internal operations that
128   * are processed as a direct result of an externally-requested operation.
129   *
130   * @return  The connection ID for the connection that triggered the associated
131   *          operation, or {@code null} if it is not included in the log
132   *          message.
133   */
134  @Nullable()
135  public final Long getTriggeredByConnectionID()
136  {
137    return triggeredByConnectionID;
138  }
139
140
141
142  /**
143   * Retrieves the operation ID for the operation that triggered the associated
144   * operation.  This is generally used for internal operations that are
145   * processed as a direct result of an externally-requested operation.
146   *
147   * @return  The operation ID for the operation that triggered the associated
148   *          operation, or {@code null} if it is not included in the log
149   *          message.
150   */
151  @Nullable()
152  public final Long getTriggeredByOperationID()
153  {
154    return triggeredByOperationID;
155  }
156
157
158
159  /**
160   * Retrieves the message ID for the associated operation.
161   *
162   * @return  The message ID for the associated operation, or {@code null} if
163   *          it is not included in the log message.
164   */
165  @Nullable()
166  public final Integer getMessageID()
167  {
168    return messageID;
169  }
170
171
172
173  /**
174   * Retrieves the origin of the associated operation.  If present, it may be
175   * "synchronization" if the operation is replicated, or "internal" if it is an
176   * internal operation.
177   *
178   * @return  The origin for the associated operation, or {@code null} if it is
179   *          not included in the log message.
180   */
181  @Nullable()
182  public final String getOrigin()
183  {
184    return origin;
185  }
186
187
188
189  /**
190   * Retrieves the operation type for the associated operation.
191   *
192   * @return  The operation type for this access log message.
193   */
194  @NotNull()
195  public abstract AccessLogOperationType getOperationType();
196}