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 039 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 040 * for proprietary functionality or for external specifications that are not 041 * considered stable or mature enough to be guaranteed to work in an 042 * interoperable way with 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 * Retrieves the server product name for this access log message. 108 * 109 * @return The server product name for this access log message, or 110 * {@code null} if it is not included in the log message. 111 */ 112 public final String getProductName() 113 { 114 return productName; 115 } 116 117 118 119 /** 120 * Retrieves the Directory Server instance name for this access log message. 121 * 122 * @return The Directory Server instance name for this access log message, or 123 * {@code null} if it is not included in the log message. 124 */ 125 public final String getInstanceName() 126 { 127 return instanceName; 128 } 129 130 131 132 /** 133 * Retrieves the Directory Server startup ID for this access log message. 134 * 135 * @return The Directory Server startup ID for this access log message, or 136 * {@code null} if it is not included in the log message. 137 */ 138 public final String getStartupID() 139 { 140 return startupID; 141 } 142 143 144 145 /** 146 * Retrieves the connection ID for the connection with which this access log 147 * message is associated. 148 * 149 * @return The connection ID for the connection with which this access log 150 * message is associated, or {@code null} if it is not included in 151 * the log message. 152 */ 153 public final Long getConnectionID() 154 { 155 return connectionID; 156 } 157 158 159 160 /** 161 * Retrieves the message type for this access log message. 162 * 163 * @return The message type for this access log message. 164 */ 165 public abstract AccessLogMessageType getMessageType(); 166}