001/* 002 * (C) Copyright 2010-2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 */ 020package org.nuxeo.ecm.admin.runtime; 021 022import org.nuxeo.common.Environment; 023import org.nuxeo.connect.packages.dependencies.TargetPlatformFilterHelper; 024import org.nuxeo.runtime.api.Framework; 025 026public class PlatformVersionHelper { 027 028 public static final String UNKNOWN = "Unknown"; 029 030 public static String getApplicationName() { 031 return Framework.getProperty(Environment.PRODUCT_NAME, UNKNOWN); 032 } 033 034 public static String getApplicationVersion() { 035 return Framework.getProperty(Environment.PRODUCT_VERSION, UNKNOWN); 036 } 037 038 public static String getPlatformFilter() { 039 if (getDistributionName().equals(UNKNOWN)) { 040 return null; 041 } 042 return getDistributionName() + "-" + getDistributionVersion(); 043 } 044 045 public static String getDistributionName() { 046 return Framework.getProperty(Environment.DISTRIBUTION_NAME, UNKNOWN); 047 } 048 049 public static String getDistributionVersion() { 050 return Framework.getProperty(Environment.DISTRIBUTION_VERSION, UNKNOWN); 051 } 052 053 public static String getDistributionDate() { 054 return Framework.getProperty(Environment.DISTRIBUTION_DATE, UNKNOWN); 055 } 056 057 public static String getDistributionHost() { 058 return Framework.getProperty(Environment.DISTRIBUTION_SERVER, UNKNOWN); 059 } 060 061 /** 062 * @deprecated Since 6.0. Use {@link TargetPlatformFilterHelper#isCompatibleWithTargetPlatform(String[], String)} 063 * @see TargetPlatformFilterHelper 064 */ 065 @Deprecated 066 public static boolean isCompatible(final String[] targetPlatforms, String currentPlatform) { 067 return TargetPlatformFilterHelper.isCompatibleWithTargetPlatform(targetPlatforms, currentPlatform); 068 } 069 070 /** 071 * @deprecated Since 6.0. Use {@link TargetPlatformFilterHelper#isCompatibleWithTargetPlatform(String[], String)} 072 * @see #getPlatformFilter() 073 * @see TargetPlatformFilterHelper 074 */ 075 @Deprecated 076 public static boolean isCompatible(String[] targetPlatforms) { 077 return isCompatible(targetPlatforms, getPlatformFilter()); 078 } 079 080}