001/*
002 * Copyright 2009-2018 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2015-2018 Ping Identity Corporation
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.unboundidds.logs;
022
023
024
025import java.util.ArrayList;
026import java.util.Collections;
027import java.util.List;
028import java.util.StringTokenizer;
029
030import com.unboundid.util.NotExtensible;
031import com.unboundid.util.NotMutable;
032import com.unboundid.util.ThreadSafety;
033import com.unboundid.util.ThreadSafetyLevel;
034
035
036
037/**
038 * This class provides a data structure that holds information about a log
039 * message that may appear in the Directory Server access log about an add
040 * request received from a client.
041 * <BR>
042 * <BLOCKQUOTE>
043 *   <B>NOTE:</B>  This class, and other classes within the
044 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
045 *   supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661
046 *   server products.  These classes provide support for proprietary
047 *   functionality or for external specifications that are not considered stable
048 *   or mature enough to be guaranteed to work in an interoperable way with
049 *   other types of LDAP servers.
050 * </BLOCKQUOTE>
051 */
052@NotExtensible()
053@NotMutable()
054@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
055public class AddRequestAccessLogMessage
056       extends OperationRequestAccessLogMessage
057{
058  /**
059   * The serial version UID for this serializable class.
060   */
061  private static final long serialVersionUID = -1234543653722421757L;
062
063
064
065  // The list of attributes included in the entry.
066  private final List<String> attributeNames;
067
068  // The DN of the entry to add.
069  private final String dn;
070
071
072
073  /**
074   * Creates a new add request access log message from the provided message
075   * string.
076   *
077   * @param  s  The string to be parsed as an add request access log message.
078   *
079   * @throws  LogException  If the provided string cannot be parsed as a valid
080   *                        log message.
081   */
082  public AddRequestAccessLogMessage(final String s)
083         throws LogException
084  {
085    this(new LogMessage(s));
086  }
087
088
089
090  /**
091   * Creates a new add request access log message from the provided message
092   * string.
093   *
094   * @param  m  The log message to be parsed as an add request access log
095   *            message.
096   */
097  public AddRequestAccessLogMessage(final LogMessage m)
098  {
099    super(m);
100
101    dn = getNamedValue("dn");
102
103    final String attrs = getNamedValue("attrs");
104    if (attrs == null)
105    {
106      attributeNames = null;
107    }
108    else
109    {
110      final ArrayList<String> l = new ArrayList<String>(10);
111      final StringTokenizer tokenizer = new StringTokenizer(attrs, ",");
112      while (tokenizer.hasMoreTokens())
113      {
114        l.add(tokenizer.nextToken());
115      }
116
117      attributeNames = Collections.unmodifiableList(l);
118    }
119  }
120
121
122
123  /**
124   * Retrieves the DN of the entry to add.
125   *
126   * @return  The DN of the entry to add, or {@code null} if it is not included
127   *          in the log message.
128   */
129  public final String getDN()
130  {
131    return dn;
132  }
133
134
135
136  /**
137   * Retrieves the names of the attributes included in the add request.
138   *
139   * @return  The names of the attributes included in the add request, or
140   *          {@code null} if that is not included in the log message.
141   */
142  public final List<String> getAttributeNames()
143  {
144    return attributeNames;
145  }
146
147
148
149  /**
150   * {@inheritDoc}
151   */
152  @Override()
153  public final AccessLogOperationType getOperationType()
154  {
155    return AccessLogOperationType.ADD;
156  }
157}