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