230N/A/*
230N/A * CDDL HEADER START
230N/A *
230N/A * The contents of this file are subject to the terms of the
230N/A * Common Development and Distribution License (the "License").
230N/A * You may not use this file except in compliance with the License.
230N/A *
230N/A * See LICENSE.txt included in this distribution for the specific
230N/A * language governing permissions and limitations under the License.
230N/A *
230N/A * When distributing Covered Code, include this CDDL HEADER in each
230N/A * file and include the License file at LICENSE.txt.
230N/A * If applicable, add the following below this CDDL HEADER, with the
230N/A * fields enclosed by brackets "[]" replaced with your own identifying
230N/A * information: Portions Copyright [yyyy] [name of copyright owner]
230N/A *
230N/A * CDDL HEADER END
230N/A */
230N/A
230N/A/*
1062N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
230N/A */
230N/Apackage org.opensolaris.opengrok;
230N/A
230N/Aimport java.io.IOException;
230N/Aimport java.io.InputStream;
1330N/Aimport java.text.ParseException;
1330N/Aimport java.text.SimpleDateFormat;
1330N/Aimport java.util.Date;
1330N/Aimport java.util.Locale;
230N/Aimport java.util.Properties;
1195N/Aimport org.opensolaris.opengrok.util.IOUtils;
230N/A
230N/A/**
230N/A * Utility class to get information of the OpenGrok version.
1190N/A *
230N/A * @author Trond Norbye
230N/A */
439N/A@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
439N/Apublic final class Info {
230N/A private static final Properties properties = new Properties();
230N/A
368N/A private static final String VERSION;
368N/A private static final String REVISION;
1330N/A private static final long LAST_MODIFIED;
1190N/A
230N/A static {
972N/A InputStream in = null;
230N/A try {
857N/A in = Info.class.getResourceAsStream("info.properties");
230N/A if (in != null) {
230N/A properties.load(in);
230N/A }
340N/A VERSION = properties.getProperty("version", "unknown");
340N/A REVISION = properties.getProperty("changeset", "unknown");
1330N/A // RFC 8222 3.3 compliant
1330N/A SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
1330N/A Date lmdate = null;
1330N/A try {
1330N/A lmdate = df.parse(properties.getProperty("lmdate"));
1330N/A } catch (ParseException e) {
1330N/A lmdate = new Date(); // now
1365N/A } catch (NullPointerException e) {
1365N/A lmdate = new Date(); // now
1330N/A }
1330N/A LAST_MODIFIED = lmdate.getTime();
230N/A } catch (IOException ioe) {
230N/A throw new RuntimeException(ioe);
857N/A } finally {
1195N/A IOUtils.close(in);
972N/A }
230N/A }
230N/A
1062N/A /**
1062N/A * get major version
1062N/A * @return major version
1062N/A */
230N/A public static String getVersion() {
340N/A return VERSION;
340N/A }
1190N/A
1062N/A /**
1062N/A * get full version (product vMajor revMinor)
1062N/A * @return full version
1062N/A */
340N/A public static String getFullVersion() {
340N/A return "OpenGrok v" + VERSION + " rev " + REVISION;
230N/A }
1190N/A
1062N/A /**
1062N/A * get minor version
1062N/A * @return minor version
1062N/A */
230N/A public static String getRevision() {
1190N/A return REVISION;
230N/A }
1190N/A
1330N/A /**
1330N/A * Get the time, when this archive was built/last modified.
1330N/A * @return time of last modification in milliseconds since
1330N/A * January 1, 1970, 00:00:00 GMT
1330N/A */
1330N/A public static long getLastModified() {
1330N/A return LAST_MODIFIED;
1330N/A }
1330N/A
230N/A private Info() {
230N/A }
230N/A}