001/*
002 * (C) Copyright 2010-2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 */
018package org.nuxeo.ecm.admin.runtime;
019
020import org.nuxeo.common.Environment;
021import org.nuxeo.connect.packages.dependencies.TargetPlatformFilterHelper;
022import org.nuxeo.runtime.api.Framework;
023
024public class PlatformVersionHelper {
025
026    public static final String UNKNOWN = "Unknown";
027
028    public static String getApplicationName() {
029        return Framework.getProperty(Environment.PRODUCT_NAME, UNKNOWN);
030    }
031
032    public static String getApplicationVersion() {
033        return Framework.getProperty(Environment.PRODUCT_VERSION, UNKNOWN);
034    }
035
036    public static String getPlatformFilter() {
037        if (getDistributionName().equals(UNKNOWN)) {
038            return null;
039        }
040        return getDistributionName() + "-" + getDistributionVersion();
041    }
042
043    public static String getDistributionName() {
044        return Framework.getProperty(Environment.DISTRIBUTION_NAME, UNKNOWN);
045    }
046
047    public static String getDistributionVersion() {
048        return Framework.getProperty(Environment.DISTRIBUTION_VERSION, UNKNOWN);
049    }
050
051    public static String getDistributionDate() {
052        return Framework.getProperty(Environment.DISTRIBUTION_DATE, UNKNOWN);
053    }
054
055    public static String getDistributionHost() {
056        return Framework.getProperty(Environment.DISTRIBUTION_SERVER, UNKNOWN);
057    }
058
059    /**
060     * @deprecated Since 6.0. Use {@link TargetPlatformFilterHelper#isCompatibleWithTargetPlatform(String[], String)}
061     * @see TargetPlatformFilterHelper
062     */
063    @Deprecated
064    public static boolean isCompatible(final String[] targetPlatforms, String currentPlatform) {
065        return TargetPlatformFilterHelper.isCompatibleWithTargetPlatform(targetPlatforms, currentPlatform);
066    }
067
068    /**
069     * @deprecated Since 6.0. Use {@link TargetPlatformFilterHelper#isCompatibleWithTargetPlatform(String[], String)}
070     * @see #getPlatformFilter()
071     * @see TargetPlatformFilterHelper
072     */
073    @Deprecated
074    public static boolean isCompatible(String[] targetPlatforms) {
075        return isCompatible(targetPlatforms, getPlatformFilter());
076    }
077
078}