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 com.unboundid.util.NotExtensible; 026import com.unboundid.util.ThreadSafety; 027import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031/** 032 * This class provides a data structure that holds information about a log 033 * message that may appear in the Directory Server access log. 034 * <BR> 035 * <BLOCKQUOTE> 036 * <B>NOTE:</B> This class, and other classes within the 037 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 038 * supported for use against Ping Identity, UnboundID, and Alcatel-Lucent 8661 039 * server products. These classes provide support for proprietary 040 * functionality or for external specifications that are not considered stable 041 * or mature enough to be guaranteed to work in an interoperable way with 042 * other types of LDAP servers. 043 * </BLOCKQUOTE> 044 */ 045@NotExtensible() 046@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 047public abstract class AccessLogMessage 048 extends LogMessage 049{ 050 /** 051 * The serial version UID for this serializable class. 052 */ 053 private static final long serialVersionUID = 111497572975341652L; 054 055 056 057 // The connection ID for this access log message. 058 private final Long connectionID; 059 060 // The Directory Server instance name for this access log message. 061 private final String instanceName; 062 063 // The server product name for this access log message. 064 private final String productName; 065 066 // The startup ID for this access log message; 067 private final String startupID; 068 069 070 071 /** 072 * Creates a new access log message from the provided log message. 073 * 074 * @param m The log message to be parsed as an access log message. 075 */ 076 protected AccessLogMessage(final LogMessage m) 077 { 078 super(m); 079 080 productName = getNamedValue("product"); 081 instanceName = getNamedValue("instanceName"); 082 startupID = getNamedValue("startupID"); 083 connectionID = getNamedValueAsLong("conn"); 084 } 085 086 087 088 /** 089 * Parses the provided string as an access log message. 090 * 091 * @param s The string to parse as an access log message. 092 * 093 * @return The parsed access log message. 094 * 095 * @throws LogException If an error occurs while trying to parse the log 096 * message. 097 */ 098 public static AccessLogMessage parse(final String s) 099 throws LogException 100 { 101 return AccessLogReader.parse(s); 102 } 103 104 105 106 107 /** 108 * Retrieves the server product name for this access log message. 109 * 110 * @return The server product name for this access log message, or 111 * {@code null} if it is not included in the log message. 112 */ 113 public final String getProductName() 114 { 115 return productName; 116 } 117 118 119 120 /** 121 * Retrieves the Directory Server instance name for this access log message. 122 * 123 * @return The Directory Server instance name for this access log message, or 124 * {@code null} if it is not included in the log message. 125 */ 126 public final String getInstanceName() 127 { 128 return instanceName; 129 } 130 131 132 133 /** 134 * Retrieves the Directory Server startup ID for this access log message. 135 * 136 * @return The Directory Server startup ID for this access log message, or 137 * {@code null} if it is not included in the log message. 138 */ 139 public final String getStartupID() 140 { 141 return startupID; 142 } 143 144 145 146 /** 147 * Retrieves the connection ID for the connection with which this access log 148 * message is associated. 149 * 150 * @return The connection ID for the connection with which this access log 151 * message is associated, or {@code null} if it is not included in 152 * the log message. 153 */ 154 public final Long getConnectionID() 155 { 156 return connectionID; 157 } 158 159 160 161 /** 162 * Retrieves the message type for this access log message. 163 * 164 * @return The message type for this access log message. 165 */ 166 public abstract AccessLogMessageType getMessageType(); 167}