001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2010 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.monitors; 018 019import org.forgerock.opendj.config.server.ConfigException; 020import org.opends.server.api.MonitorData; 021import org.forgerock.opendj.server.config.server.VersionMonitorProviderCfg; 022import org.opends.server.api.MonitorProvider; 023import org.opends.server.types.InitializationException; 024import org.opends.server.util.DynamicConstants; 025 026/** This class defines a monitor provider that reports Directory Server version information. */ 027public class VersionMonitorProvider 028 extends MonitorProvider<VersionMonitorProviderCfg> 029{ 030 /** The name of the attribute used to provide the product name. */ 031 public static final String ATTR_PRODUCT_NAME = "productName"; 032 /** The name of the attribute used to provide the short name. */ 033 public static final String ATTR_SHORT_NAME = "shortName"; 034 /** The name of the attribute used to provide the major version number. */ 035 public static final String ATTR_MAJOR_VERSION = "majorVersion"; 036 /** The name of the attribute used to provide the minor version number. */ 037 public static final String ATTR_MINOR_VERSION = "minorVersion"; 038 /** The name of the attribute used to provide the point version number. */ 039 public static final String ATTR_POINT_VERSION = "pointVersion"; 040 /** The name of the attribute used to provide the version qualifier string. */ 041 public static final String ATTR_VERSION_QUALIFIER = "versionQualifier"; 042 /** The name of the attribute used to provide the weekly build number. */ 043 public static final String ATTR_BUILD_NUMBER = "buildNumber"; 044 /** The name of the attribute used to provide the list of bugfix IDs. */ 045 public static final String ATTR_FIX_IDS = "fixIDs"; 046 /** The name of the attribute used to provide the revision in the version control system. */ 047 public static final String ATTR_REVISION = "revision"; 048 /** The name of the attribute used to provide the build ID (aka the build timestamp). */ 049 public static final String ATTR_BUILD_ID = "buildID"; 050 /** The name of the attribute used to provide the compact version string. */ 051 public static final String ATTR_COMPACT_VERSION = "compactVersion"; 052 /** The name of the attribute used to provide the full version string. */ 053 public static final String ATTR_FULL_VERSION = "fullVersion"; 054 055 @Override 056 public void initializeMonitorProvider(VersionMonitorProviderCfg configuration) 057 throws ConfigException, InitializationException 058 { 059 // No initialization is required. 060 } 061 062 @Override 063 public String getMonitorInstanceName() 064 { 065 return "Version"; 066 } 067 068 @Override 069 public MonitorData getMonitorData() 070 { 071 MonitorData attrs = new MonitorData(12); 072 073 attrs.add(ATTR_PRODUCT_NAME, DynamicConstants.PRODUCT_NAME); 074 attrs.add(ATTR_SHORT_NAME, DynamicConstants.SHORT_NAME); 075 attrs.add(ATTR_MAJOR_VERSION, DynamicConstants.MAJOR_VERSION); 076 attrs.add(ATTR_MINOR_VERSION, DynamicConstants.MINOR_VERSION); 077 attrs.add(ATTR_POINT_VERSION, DynamicConstants.POINT_VERSION); 078 079 String versionQualifier = DynamicConstants.VERSION_QUALIFIER; 080 if (versionQualifier != null && versionQualifier.length() > 0) 081 { 082 attrs.add(ATTR_VERSION_QUALIFIER, versionQualifier); 083 } 084 085 int buildNumber = DynamicConstants.BUILD_NUMBER; 086 if (buildNumber > 0) 087 { 088 attrs.add(ATTR_BUILD_NUMBER, buildNumber); 089 } 090 091 String fixIDs = DynamicConstants.FIX_IDS; 092 if (fixIDs != null && fixIDs.length() > 0) 093 { 094 attrs.add(ATTR_FIX_IDS, fixIDs); 095 } 096 097 attrs.add(ATTR_REVISION, DynamicConstants.REVISION); 098 attrs.add(ATTR_BUILD_ID, DynamicConstants.BUILD_ID); 099 attrs.add(ATTR_COMPACT_VERSION, DynamicConstants.COMPACT_VERSION_STRING); 100 attrs.add(ATTR_FULL_VERSION, DynamicConstants.FULL_VERSION_STRING); 101 102 return attrs; 103 } 104}