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; 037 038 039 040import java.util.Date; 041 042import com.unboundid.ldap.sdk.Entry; 043import com.unboundid.ldap.sdk.ReadOnlyEntry; 044import com.unboundid.util.NotMutable; 045import com.unboundid.util.NotNull; 046import com.unboundid.util.Nullable; 047import com.unboundid.util.ThreadSafety; 048import com.unboundid.util.ThreadSafetyLevel; 049 050 051 052/** 053 * This class provides a data structure for representing an administrative entry 054 * as exposed by the alerts backend in the Directory Server. Alert entries 055 * provide information about warnings, errors, or other significant events that 056 * could impact the availability or function of the Directory Server. 057 * <BR> 058 * <BLOCKQUOTE> 059 * <B>NOTE:</B> This class, and other classes within the 060 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 061 * supported for use against Ping Identity, UnboundID, and 062 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 063 * for proprietary functionality or for external specifications that are not 064 * considered stable or mature enough to be guaranteed to work in an 065 * interoperable way with other types of LDAP servers. 066 * </BLOCKQUOTE> 067 */ 068@NotMutable() 069@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 070public final class AlertEntry 071 extends ReadOnlyEntry 072{ 073 /** 074 * The name of the structural object class that will be used for entries 075 * containing information about administrative alerts. 076 */ 077 @NotNull public static final String OC_ALERT = "ds-admin-alert"; 078 079 080 081 /** 082 * The name of the attribute that contains the fully-qualified name of the 083 * server class that generated the alert notification. 084 */ 085 @NotNull public static final String ATTR_ALERT_GENERATOR = 086 "ds-alert-generator"; 087 088 089 090 /** 091 * The name of the attribute that contains the unique ID assigned to the alert 092 * notification. 093 */ 094 @NotNull public static final String ATTR_ALERT_ID = "ds-alert-id"; 095 096 097 098 /** 099 * The name of the attribute that contains a message with additional 100 * information about the alert notification. 101 */ 102 @NotNull public static final String ATTR_ALERT_MESSAGE = "ds-alert-message"; 103 104 105 106 /** 107 * The name of the attribute that contains the severity of the alert 108 * notification. 109 */ 110 @NotNull public static final String ATTR_ALERT_SEVERITY = "ds-alert-severity"; 111 112 113 114 /** 115 * The name of the attribute that contains the time that the alert 116 * notification was generated. 117 */ 118 @NotNull public static final String ATTR_ALERT_TIME = "ds-alert-time"; 119 120 121 122 /** 123 * The name of the attribute that contains the name of the alert type. 124 */ 125 @NotNull public static final String ATTR_ALERT_TYPE = "ds-alert-type"; 126 127 128 129 /** 130 * The name of the attribute that contains the OID assigned to the alert type. 131 */ 132 @NotNull public static final String ATTR_ALERT_TYPE_OID = "ds-alert-type-oid"; 133 134 135 136 /** 137 * The serial version UID for this serializable class. 138 */ 139 private static final long serialVersionUID = -2912778595612338699L; 140 141 142 143 // The severity for this alert entry. 144 @Nullable private final AlertSeverity alertSeverity; 145 146 // The time that the alert notification was generated. 147 @Nullable private final Date alertTime; 148 149 // The fully-qualified name of the alert generator class. 150 @Nullable private final String alertGeneratorClass; 151 152 // The unique identifier assigned to the alert notification. 153 @Nullable private final String alertID; 154 155 // The message for the alert notification. 156 @Nullable private final String alertMessage; 157 158 // The name of the alert type for the alert notification. 159 @Nullable private final String alertType; 160 161 // The OID for the alert type. 162 @Nullable private final String alertTypeOID; 163 164 165 166 /** 167 * Creates a new alert entry from the provided entry. 168 * 169 * @param entry The entry from which to create this alert entry. 170 */ 171 public AlertEntry(@NotNull final Entry entry) 172 { 173 super(entry); 174 175 alertGeneratorClass = entry.getAttributeValue(ATTR_ALERT_GENERATOR); 176 alertID = entry.getAttributeValue(ATTR_ALERT_ID); 177 alertMessage = entry.getAttributeValue(ATTR_ALERT_MESSAGE); 178 alertType = entry.getAttributeValue(ATTR_ALERT_TYPE); 179 alertTypeOID = entry.getAttributeValue(ATTR_ALERT_TYPE_OID); 180 181 alertTime = entry.getAttributeValueAsDate(ATTR_ALERT_TIME); 182 183 final String severityStr = entry.getAttributeValue(ATTR_ALERT_SEVERITY); 184 if (severityStr == null) 185 { 186 alertSeverity = null; 187 } 188 else 189 { 190 alertSeverity = AlertSeverity.forName(severityStr); 191 } 192 } 193 194 195 196 /** 197 * Retrieves the fully-qualified name of the class that generated the alert 198 * notification. 199 * 200 * @return The fully-qualified name of the class that generated the alert 201 * notification, or {@code null} if it was not included in the alert 202 * entry. 203 */ 204 @Nullable() 205 public String getAlertGeneratorClass() 206 { 207 return alertGeneratorClass; 208 } 209 210 211 212 /** 213 * Retrieves the unique identifier for the alert notification. 214 * 215 * @return The unique identifier for the alert notification, or {@code null} 216 * if it was not included in the alert entry. 217 */ 218 @Nullable() 219 public String getAlertID() 220 { 221 return alertID; 222 } 223 224 225 226 /** 227 * Retrieves the message for the alert notification. 228 * 229 * @return The message for the alert notification, or {@code null} if it was 230 * not included in the alert entry. 231 */ 232 @Nullable() 233 public String getAlertMessage() 234 { 235 return alertMessage; 236 } 237 238 239 240 /** 241 * Retrieves the severity for the alert notification. 242 * 243 * @return The severity for the alert notification, or {@code null} if it was 244 * not included in the alert entry, or if it included an unknown 245 * severity. 246 */ 247 @Nullable() 248 public AlertSeverity getAlertSeverity() 249 { 250 return alertSeverity; 251 } 252 253 254 255 /** 256 * Retrieves the time that the alert notification was generated. 257 * 258 * @return The time that the alert notification was generated, or 259 * {@code null} if it was not included in the alert entry or if the 260 * alert time value could not be parsed. 261 */ 262 @Nullable() 263 public Date getAlertTime() 264 { 265 return alertTime; 266 } 267 268 269 270 /** 271 * Retrieves the name of the alert type for the alert notification. 272 * 273 * @return The name of the alert type for the alert notification, or 274 * {@code null} if it was not included in the alert entry. 275 */ 276 @Nullable() 277 public String getAlertType() 278 { 279 return alertType; 280 } 281 282 283 284 /** 285 * Retrieves the OID of the alert type for the alert notification. 286 * 287 * @return The OID of the alert type for the alert notification, or 288 * {@code null} if it was not included in the alert entry. 289 */ 290 @Nullable() 291 public String getAlertTypeOID() 292 { 293 return alertTypeOID; 294 } 295}