001 /* 002 * Copyright 2009-2015 UnboundID Corp. 003 * All Rights Reserved. 004 */ 005 /* 006 * Copyright (C) 2015 UnboundID Corp. 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 */ 021 package com.unboundid.ldap.sdk.unboundidds.logs; 022 023 024 025 import com.unboundid.util.NotMutable; 026 import com.unboundid.util.ThreadSafety; 027 import com.unboundid.util.ThreadSafetyLevel; 028 029 030 031 /** 032 * <BLOCKQUOTE> 033 * <B>NOTE:</B> This class is part of the Commercial Edition of the UnboundID 034 * LDAP SDK for Java. It is not available for use in applications that 035 * include only the Standard Edition of the LDAP SDK, and is not supported for 036 * use in conjunction with non-UnboundID products. 037 * </BLOCKQUOTE> 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 a 040 * connection that has been closed. 041 */ 042 @NotMutable() 043 @ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 044 public final class DisconnectAccessLogMessage 045 extends AccessLogMessage 046 { 047 /** 048 * The serial version UID for this serializable class. 049 */ 050 private static final long serialVersionUID = -6224280874144845557L; 051 052 053 054 // The message providing additional information about the disconnect. 055 private final String message; 056 057 // The reason for the disconnect. 058 private final String reason; 059 060 061 062 /** 063 * Creates a new disconnect access log message from the provided message 064 * string. 065 * 066 * @param s The string to be parsed as a disconnect access log message. 067 * 068 * @throws LogException If the provided string cannot be parsed as a valid 069 * log message. 070 */ 071 public DisconnectAccessLogMessage(final String s) 072 throws LogException 073 { 074 this(new LogMessage(s)); 075 } 076 077 078 079 /** 080 * Creates a new disconnect access log message from the provided log message. 081 * 082 * @param m The log message to be parsed as a disconnect access log message. 083 */ 084 public DisconnectAccessLogMessage(final LogMessage m) 085 { 086 super(m); 087 088 reason = getNamedValue("reason"); 089 message = getNamedValue("msg"); 090 } 091 092 093 094 /** 095 * Retrieves the disconnect reason for the log message. 096 * 097 * @return The disconnect reason for the log message, or {@code null} if it 098 * is not included in the log message. 099 */ 100 public String getDisconnectReason() 101 { 102 return reason; 103 } 104 105 106 107 /** 108 * Retrieves a message with additional information about the disconnect. 109 * 110 * @return A message with additional information about the disconnect, or 111 * {@code null} if it is not included in the log message. 112 */ 113 public String getMessage() 114 { 115 return message; 116 } 117 118 119 120 /** 121 * {@inheritDoc} 122 */ 123 @Override() 124 public AccessLogMessageType getMessageType() 125 { 126 return AccessLogMessageType.DISCONNECT; 127 } 128 }