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