001/*
002 * Copyright 2008-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.monitors;
022
023
024
025import java.util.Collections;
026import java.util.LinkedHashMap;
027import java.util.Map;
028
029import com.unboundid.ldap.sdk.Entry;
030import com.unboundid.util.NotMutable;
031import com.unboundid.util.ThreadSafety;
032import com.unboundid.util.ThreadSafetyLevel;
033
034import static com.unboundid.ldap.sdk.unboundidds.monitors.MonitorMessages.*;
035
036
037
038/**
039 * This class defines a monitor entry that provides general information about
040 * the Directory Server version.
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 * <BR>
052 * Information that it may make available includes:
053 * <UL>
054 *   <LI>The full Directory Server version string, which may contain
055 *       spaces.</LI>
056 *   <LI>The compact Directory Server version string, which will not contain
057 *       any spaces and may use a more compact representation than the full
058 *       version string.</LI>
059 *   <LI>The Directory Server product name.</LI>
060 *   <LI>A compact representation of the Directory Server product name.</LI>
061 *   <LI>The server major version number.</LI>
062 *   <LI>The server minor version number.</LI>
063 *   <LI>The server point version number.</LI>
064 *   <LI>A version qualifier string which may provide a more descriptive name
065 *       for the build of the server.</LI>
066 *   <LI>The server build ID string.</LI>
067 *   <LI>The server promoted build number.</LI>
068 *   <LI>The source control revision number for the source used to build the
069 *       server.</LI>
070 *   <LI>A list of the bugfix IDs for any special fixes included in the
071 *       server.</LI>
072 * </UL>
073 * The server should present at most one version monitor entry.  It can be
074 * retrieved using the {@link MonitorManager#getVersionMonitorEntry} method.
075 * This entry provides specific methods for accessing this version information
076 * (e.g., the {@link VersionMonitorEntry#getFullVersion} method can be used to
077 * retrieve the full version string for the server).  Alternately, this
078 * information may be accessed using the generic API.  See the
079 * {@link MonitorManager} class documentation for an example that demonstrates
080 * the use of the generic API for accessing monitor data.
081 */
082@NotMutable()
083@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
084public final class VersionMonitorEntry
085       extends MonitorEntry
086{
087  /**
088   * The structural object class used in version monitor entries.
089   */
090  protected static final String VERSION_MONITOR_OC =
091       "ds-version-monitor-entry";
092
093
094
095  /**
096   * The name of the attribute used to provide the server build ID.
097   */
098  private static final String ATTR_BUILD_ID = "buildID";
099
100
101
102  /**
103   * The name of the attribute used to provide the server promoted build number.
104   */
105  private static final String ATTR_BUILD_NUMBER = "buildNumber";
106
107
108
109  /**
110   * The name of the attribute used to provide a compact server version string.
111   */
112  private static final String ATTR_COMPACT_VERSION = "compactVersion";
113
114
115
116  /**
117   * The name of the attribute used to provide the list of bugfix IDs.
118   */
119  private static final String ATTR_FIX_IDS = "fixIDs";
120
121
122
123  /**
124   * The name of the attribute used to provide a full server version string.
125   */
126  private static final String ATTR_FULL_VERSION = "fullVersion";
127
128
129
130  /**
131   * The name of the attribute used to hold the Groovy library version.
132   */
133  private static final String ATTR_GROOVY_VERSION = "groovyVersion";
134
135
136
137  /**
138   * The name of the attribute used to hold the Berkeley DB JE library version.
139   */
140  private static final String ATTR_JE_VERSION = "jeVersion";
141
142
143
144  /**
145   * The name of the attribute used to hold the jzlib library version.
146   */
147  private static final String ATTR_JZLIB_VERSION = "jzlibVersion";
148
149
150
151  /**
152   * The name of the attribute used to hold the LDAP SDK library version.
153   */
154  private static final String ATTR_LDAP_SDK_VERSION = "ldapSDKVersion";
155
156
157
158  /**
159   * The name of the attribute used to provide the major version number.
160   */
161  private static final String ATTR_MAJOR_VERSION = "majorVersion";
162
163
164
165  /**
166   * The name of the attribute used to provide the minor version number.
167   */
168  private static final String ATTR_MINOR_VERSION = "minorVersion";
169
170
171
172  /**
173   * The name of the attribute used to provide the point version number.
174   */
175  private static final String ATTR_POINT_VERSION = "pointVersion";
176
177
178
179  /**
180   * The name of the attribute used to provide the product name.
181   */
182  private static final String ATTR_PRODUCT_NAME = "productName";
183
184
185
186  /**
187   * The name of the attribute used to provide the source revision number.
188   */
189  private static final String ATTR_REVISION_NUMBER = "revisionNumber";
190
191
192
193  /**
194   * The name of the attribute used to hold the server SDK library version.
195   */
196  private static final String ATTR_SERVER_SDK_VERSION = "serverSDKVersion";
197
198
199
200  /**
201   * The name of the attribute used to provide the short product name.
202   */
203  private static final String ATTR_SHORT_NAME = "shortName";
204
205
206
207  /**
208   * The name of the attribute used to hold the server SNMP4J library version.
209   */
210  private static final String ATTR_SNMP4J_VERSION = "snmp4jVersion";
211
212
213
214  /**
215   * The name of the attribute used to hold the server SNMP4J agent library
216   * version.
217   */
218  private static final String ATTR_SNMP4J_AGENT_VERSION = "snmp4jAgentVersion";
219
220
221
222  /**
223   * The name of the attribute used to hold the server SNMP4J AgentX library
224   * version.
225   */
226  private static final String ATTR_SNMP4J_AGENTX_VERSION =
227       "snmp4jAgentXVersion";
228
229
230
231  /**
232   * The name of the attribute used to provide the server's version qualifier.
233   */
234  private static final String ATTR_VERSION_QUALIFIER = "versionQualifier";
235
236
237
238  /**
239   * The serial version UID for this serializable class.
240   */
241  private static final long serialVersionUID = -8501846678698542926L;
242
243
244
245  // The server build number.
246  private final Long buildNumber;
247
248  // The server major version number.
249  private final Long majorVersion;
250
251  // The server minor version number.
252  private final Long minorVersion;
253
254  // The server point version number.
255  private final Long pointVersion;
256
257  // The server source revision number.
258  private final Long revisionNumber;
259
260  // The server build ID.
261  private final String buildID;
262
263  // The compact server version string.
264  private final String compactVersion;
265
266  // The list of bugfix IDs.
267  private final String fixIDs;
268
269  // The Groovy library version.
270  private final String groovyVersion;
271
272  // The full server version string.
273  private final String fullVersion;
274
275  // The Berkeley DB JE library version.
276  private final String jeVersion;
277
278  // The jzlib library version.
279  private final String jzlibVersion;
280
281  // The LDAP SDK library version.
282  private final String ldapSDKVersion;
283
284  // The server product name.
285  private final String productName;
286
287  // The server SDK library version.
288  private final String serverSDKVersion;
289
290  // The server short product name.
291  private final String shortName;
292
293  // The SNMP4J library version.
294  private final String snmp4jVersion;
295
296  // The SNMP4J agent library version.
297  private final String snmp4jAgentVersion;
298
299  // The SNMP4J AgentX library version.
300  private final String snmp4jAgentXVersion;
301
302  // The server version qualifier string.
303  private final String versionQualifier;
304
305
306
307  /**
308   * Creates a new version monitor entry from the provided entry.
309   *
310   * @param  entry  The entry to be parsed as a version monitor entry.  It must
311   *                not be {@code null}.
312   */
313  public VersionMonitorEntry(final Entry entry)
314  {
315    super(entry);
316
317    buildNumber         = getLong(ATTR_BUILD_NUMBER);
318    majorVersion        = getLong(ATTR_MAJOR_VERSION);
319    minorVersion        = getLong(ATTR_MINOR_VERSION);
320    pointVersion        = getLong(ATTR_POINT_VERSION);
321    revisionNumber      = getLong(ATTR_REVISION_NUMBER);
322    buildID             = getString(ATTR_BUILD_ID);
323    compactVersion      = getString(ATTR_COMPACT_VERSION);
324    fixIDs              = getString(ATTR_FIX_IDS);
325    groovyVersion       = getString(ATTR_GROOVY_VERSION);
326    fullVersion         = getString(ATTR_FULL_VERSION);
327    jeVersion           = getString(ATTR_JE_VERSION);
328    jzlibVersion        = getString(ATTR_JZLIB_VERSION);
329    ldapSDKVersion      = getString(ATTR_LDAP_SDK_VERSION);
330    productName         = getString(ATTR_PRODUCT_NAME);
331    serverSDKVersion    = getString(ATTR_SERVER_SDK_VERSION);
332    shortName           = getString(ATTR_SHORT_NAME);
333    snmp4jVersion       = getString(ATTR_SNMP4J_VERSION);
334    snmp4jAgentVersion  = getString(ATTR_SNMP4J_AGENT_VERSION);
335    snmp4jAgentXVersion = getString(ATTR_SNMP4J_AGENTX_VERSION);
336    versionQualifier    = getString(ATTR_VERSION_QUALIFIER);
337  }
338
339
340
341  /**
342   * Retrieves the Directory Server build ID string.
343   *
344   * @return  The Directory Server build ID string, or {@code null} if it was
345   *          not included in the monitor entry.
346   */
347  public String getBuildID()
348  {
349    return buildID;
350  }
351
352
353
354  /**
355   * Retrieves the Directory Server promoted build number.
356   *
357   * @return  The Directory Server promoted build number, or {@code null} if it
358   *          was not included in the monitor entry.
359   */
360  public Long getBuildNumber()
361  {
362    return buildNumber;
363  }
364
365
366
367  /**
368   * Retrieves a compact representation of the Directory Server version string.
369   * It will not contain any spaces.
370   *
371   * @return  A compact representation of the Directory Server version string,
372   *          or {@code null} if it was not included in the monitor entry.
373   */
374  public String getCompactVersion()
375  {
376    return compactVersion;
377  }
378
379
380
381  /**
382   * Retrieves a space-delimited list of the bugfix IDs for special fixes
383   * included in the Directory Server.
384   *
385   * @return  A space-delimited list of the bugfix IDs for special fixes
386   *          included in the Directory Server, or {@code null} if it was not
387   *          included in the monitor entry.
388   */
389  public String getFixIDs()
390  {
391    return fixIDs;
392  }
393
394
395
396  /**
397   * Retrieves the full Directory Server version string.
398   *
399   * @return  The full Directory Server version string, or {@code null} if it
400   *          was not included in the monitor entry.
401   */
402  public String getFullVersion()
403  {
404    return fullVersion;
405  }
406
407
408
409  /**
410   * Retrieves the Groovy library version string.
411   *
412   * @return  The Groovy library version string, or {@code null} if it was not
413   *          included in the monitor entry.
414   */
415  public String getGroovyVersion()
416  {
417    return groovyVersion;
418  }
419
420
421
422  /**
423   * Retrieves the Berkeley DB Java Edition library version string.
424   *
425   * @return  The Berkeley DB Java Edition library version string, or
426   *          {@code null} if it was not included in the monitor entry.
427   */
428  public String getBerkeleyDBJEVersion()
429  {
430    return jeVersion;
431  }
432
433
434
435  /**
436   * Retrieves the jzlib library version string.
437   *
438   * @return  The jzlib library version string, or {@code null} if it was not
439   *          included in the monitor entry.
440   */
441  public String getJZLibVersion()
442  {
443    return jzlibVersion;
444  }
445
446
447
448  /**
449   * Retrieves the UnboundID LDAP SDK for Java library version string.
450   *
451   * @return  The UnboundID LDAP SDK for Java library version string, or
452   *          {@code null} if it was not included in the monitor entry.
453   */
454  public String getLDAPSDKVersion()
455  {
456    return ldapSDKVersion;
457  }
458
459
460
461  /**
462   * Retrieves the Directory Server major version number.
463   *
464   * @return  The Directory Server major version number, or {@code null} if it
465   *          was not included in the monitor entry.
466   */
467  public Long getMajorVersion()
468  {
469    return majorVersion;
470  }
471
472
473
474  /**
475   * Retrieves the Directory Server minor version number.
476   *
477   * @return  The Directory Server minor version number, or {@code null} if it
478   *          was not included in the monitor entry.
479   */
480  public Long getMinorVersion()
481  {
482    return minorVersion;
483  }
484
485
486
487  /**
488   * Retrieves the Directory Server point version number.
489   *
490   * @return  The Directory Server point version number, or {@code null} if it
491   *          was not included in the monitor entry.
492   */
493  public Long getPointVersion()
494  {
495    return pointVersion;
496  }
497
498
499
500  /**
501   * Retrieves the Directory Server product name (e.g., "Ping Identity Directory
502   * Server").
503   *
504   * @return  The Directory Server product name, or {@code null} if it was not
505   *          included in the monitor entry.
506   */
507  public String getProductName()
508  {
509    return productName;
510  }
511
512
513
514  /**
515   * Retrieves the source revision number from which the Directory Server was
516   * built.
517   *
518   * @return  The source revision number from which the Directory Server was
519   *          built, or {@code null} if it was not included in the monitor
520   *          entry.
521   */
522  public Long getRevisionNumber()
523  {
524    return revisionNumber;
525  }
526
527
528
529  /**
530   * Retrieves the UnboundID Server SDK library version string.
531   *
532   * @return  The UnboundID Server SDK library version string, or {@code null}
533   *          if it was not included in the monitor entry.
534   */
535  public String getServerSDKVersion()
536  {
537    return serverSDKVersion;
538  }
539
540
541
542  /**
543   * Retrieves the Directory Server short product name (e.g.,
544   * "Ping-Identity-DS").
545   *
546   * @return  The Directory Server short product name, or {@code null} if it was
547   *          not included in the monitor entry.
548   */
549  public String getShortProductName()
550  {
551    return shortName;
552  }
553
554
555
556  /**
557   * Retrieves the SNMP4J library version string.
558   *
559   * @return  The SNMP4J library version string, or {@code null} if it was not
560   *          included in the monitor entry.
561   */
562  public String getSNMP4JVersion()
563  {
564    return snmp4jVersion;
565  }
566
567
568
569  /**
570   * Retrieves the SNMP4J agent library version string.
571   *
572   * @return  The SNMP4J agent library version string, or {@code null} if it was
573   *          not included in the monitor entry.
574   */
575  public String getSNMP4JAgentVersion()
576  {
577    return snmp4jAgentVersion;
578  }
579
580
581
582  /**
583   * Retrieves the SNMP4J AgentX library version string.
584   *
585   * @return  The SNMP4J AgentX library version string, or {@code null} if it
586   *          was not included in the monitor entry.
587   */
588  public String getSNMP4JAgentXVersion()
589  {
590    return snmp4jAgentXVersion;
591  }
592
593
594
595  /**
596   * Retrieves the Directory Server version qualifier string (e.g., "-beta1").
597   *
598   * @return  The Directory Server version qualifier string, or {@code null} if
599   *          it was not included in the monitor entry.
600   */
601  public String getVersionQualifier()
602  {
603    return versionQualifier;
604  }
605
606
607
608  /**
609   * {@inheritDoc}
610   */
611  @Override()
612  public String getMonitorDisplayName()
613  {
614    return INFO_VERSION_MONITOR_DISPNAME.get();
615  }
616
617
618
619  /**
620   * {@inheritDoc}
621   */
622  @Override()
623  public String getMonitorDescription()
624  {
625    return INFO_VERSION_MONITOR_DESC.get();
626  }
627
628
629
630  /**
631   * {@inheritDoc}
632   */
633  @Override()
634  public Map<String,MonitorAttribute> getMonitorAttributes()
635  {
636    final LinkedHashMap<String,MonitorAttribute> attrs =
637         new LinkedHashMap<String,MonitorAttribute>(20);
638
639    if (productName != null)
640    {
641      addMonitorAttribute(attrs,
642           ATTR_PRODUCT_NAME,
643           INFO_VERSION_DISPNAME_PRODUCT_NAME.get(),
644           INFO_VERSION_DESC_PRODUCT_NAME.get(),
645           productName);
646    }
647
648    if (shortName != null)
649    {
650      addMonitorAttribute(attrs,
651           ATTR_SHORT_NAME,
652           INFO_VERSION_DISPNAME_SHORT_NAME.get(),
653           INFO_VERSION_DESC_SHORT_NAME.get(),
654           shortName);
655    }
656
657    if (fullVersion != null)
658    {
659      addMonitorAttribute(attrs,
660           ATTR_FULL_VERSION,
661           INFO_VERSION_DISPNAME_FULL_VERSION.get(),
662           INFO_VERSION_DESC_FULL_VERSION.get(),
663           fullVersion);
664    }
665
666    if (compactVersion != null)
667    {
668      addMonitorAttribute(attrs,
669           ATTR_COMPACT_VERSION,
670           INFO_VERSION_DISPNAME_COMPACT_VERSION.get(),
671           INFO_VERSION_DESC_COMPACT_VERSION.get(),
672           compactVersion);
673    }
674
675    if (buildID != null)
676    {
677      addMonitorAttribute(attrs,
678           ATTR_BUILD_ID,
679           INFO_VERSION_DISPNAME_BUILD_ID.get(),
680           INFO_VERSION_DESC_BUILD_ID.get(),
681           buildID);
682    }
683
684    if (majorVersion != null)
685    {
686      addMonitorAttribute(attrs,
687           ATTR_MAJOR_VERSION,
688           INFO_VERSION_DISPNAME_MAJOR_VERSION.get(),
689           INFO_VERSION_DESC_MAJOR_VERSION.get(),
690           majorVersion);
691    }
692
693    if (minorVersion != null)
694    {
695      addMonitorAttribute(attrs,
696           ATTR_MINOR_VERSION,
697           INFO_VERSION_DISPNAME_MINOR_VERSION.get(),
698           INFO_VERSION_DESC_MINOR_VERSION.get(),
699           minorVersion);
700    }
701
702    if (pointVersion != null)
703    {
704      addMonitorAttribute(attrs,
705           ATTR_POINT_VERSION,
706           INFO_VERSION_DISPNAME_POINT_VERSION.get(),
707           INFO_VERSION_DESC_POINT_VERSION.get(),
708           pointVersion);
709    }
710
711    if (buildNumber != null)
712    {
713      addMonitorAttribute(attrs,
714           ATTR_BUILD_NUMBER,
715           INFO_VERSION_DISPNAME_BUILD_NUMBER.get(),
716           INFO_VERSION_DESC_BUILD_NUMBER.get(),
717           buildNumber);
718    }
719
720    if (versionQualifier != null)
721    {
722      addMonitorAttribute(attrs,
723           ATTR_VERSION_QUALIFIER,
724           INFO_VERSION_DISPNAME_VERSION_QUALIFIER.get(),
725           INFO_VERSION_DESC_VERSION_QUALIFIER.get(),
726           versionQualifier);
727    }
728
729    if (revisionNumber != null)
730    {
731      addMonitorAttribute(attrs,
732           ATTR_REVISION_NUMBER,
733           INFO_VERSION_DISPNAME_REVISION_NUMBER.get(),
734           INFO_VERSION_DESC_REVISION_NUMBER.get(),
735           revisionNumber);
736    }
737
738    if (fixIDs != null)
739    {
740      addMonitorAttribute(attrs,
741           ATTR_FIX_IDS,
742           INFO_VERSION_DISPNAME_FIX_IDS.get(),
743           INFO_VERSION_DESC_FIX_IDS.get(),
744           fixIDs);
745    }
746
747    if (groovyVersion != null)
748    {
749      addMonitorAttribute(attrs,
750           ATTR_GROOVY_VERSION,
751           INFO_VERSION_DISPNAME_GROOVY_VERSION.get(),
752           INFO_VERSION_DESC_GROOVY_VERSION.get(),
753           groovyVersion);
754    }
755
756    if (jeVersion != null)
757    {
758      addMonitorAttribute(attrs,
759           ATTR_JE_VERSION,
760           INFO_VERSION_DISPNAME_JE_VERSION.get(),
761           INFO_VERSION_DESC_JE_VERSION.get(),
762           jeVersion);
763    }
764
765    if (jzlibVersion != null)
766    {
767      addMonitorAttribute(attrs,
768           ATTR_JZLIB_VERSION,
769           INFO_VERSION_DISPNAME_JZLIB_VERSION.get(),
770           INFO_VERSION_DESC_JZLIB_VERSION.get(),
771           jzlibVersion);
772    }
773
774    if (ldapSDKVersion != null)
775    {
776      addMonitorAttribute(attrs,
777           ATTR_LDAP_SDK_VERSION,
778           INFO_VERSION_DISPNAME_LDAP_SDK_VERSION.get(),
779           INFO_VERSION_DESC_LDAP_SDK_VERSION.get(),
780           ldapSDKVersion);
781    }
782
783    if (serverSDKVersion != null)
784    {
785      addMonitorAttribute(attrs,
786           ATTR_SERVER_SDK_VERSION,
787           INFO_VERSION_DISPNAME_SERVER_SDK_VERSION.get(),
788           INFO_VERSION_DESC_SERVER_SDK_VERSION.get(),
789           serverSDKVersion);
790    }
791
792    if (snmp4jVersion != null)
793    {
794      addMonitorAttribute(attrs,
795           ATTR_SNMP4J_VERSION,
796           INFO_VERSION_DISPNAME_SNMP4J_VERSION.get(),
797           INFO_VERSION_DESC_SNMP4J_VERSION.get(),
798           snmp4jVersion);
799    }
800
801    if (snmp4jAgentVersion != null)
802    {
803      addMonitorAttribute(attrs,
804           ATTR_SNMP4J_AGENT_VERSION,
805           INFO_VERSION_DISPNAME_SNMP4J_AGENT_VERSION.get(),
806           INFO_VERSION_DESC_SNMP4J_AGENT_VERSION.get(),
807           snmp4jAgentVersion);
808    }
809
810    if (snmp4jAgentXVersion != null)
811    {
812      addMonitorAttribute(attrs,
813           ATTR_SNMP4J_AGENTX_VERSION,
814           INFO_VERSION_DISPNAME_SNMP4J_AGENTX_VERSION.get(),
815           INFO_VERSION_DESC_SNMP4J_AGENTX_VERSION.get(),
816           snmp4jAgentXVersion);
817    }
818
819    return Collections.unmodifiableMap(attrs);
820  }
821}