001/* 002 * (C) Copyright 2010-2014 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.connect.connector.fake.FakeDownloadablePackage; 021import org.nuxeo.connect.packages.dependencies.TargetPlatformFilterHelper; 022import org.nuxeo.connect.update.Version; 023import org.nuxeo.runtime.api.Framework; 024 025public class PlatformVersionHelper { 026 027 public static final String UNKNOWN = "Unknown"; 028 029 public static String getApplicationName() { 030 return Framework.getProperty("org.nuxeo.ecm.product.name", UNKNOWN); 031 } 032 033 public static String getApplicationVersion() { 034 return Framework.getProperty("org.nuxeo.ecm.product.version", UNKNOWN); 035 } 036 037 public static String getPlatformFilter() { 038 if (getDistributionName().equals(UNKNOWN)) { 039 return null; 040 } 041 return getDistributionName() + "-" + getDistributionVersion(); 042 } 043 044 public static String getDistributionName() { 045 return Framework.getProperty("org.nuxeo.distribution.name", UNKNOWN); 046 } 047 048 public static String getDistributionVersion() { 049 return Framework.getProperty("org.nuxeo.distribution.version", UNKNOWN); 050 } 051 052 public static String getDistributionDate() { 053 return Framework.getProperty("org.nuxeo.distribution.date", UNKNOWN); 054 } 055 056 public static String getDistributionHost() { 057 return Framework.getProperty("org.nuxeo.distribution.server", UNKNOWN); 058 } 059 060 /** 061 * @deprecated Since 6.0. Badly duplicates 062 * {@link TargetPlatformFilterHelper#isCompatibleWithTargetPlatform(org.nuxeo.connect.update.Package, String)} 063 */ 064 @Deprecated 065 public static boolean isCompatible(final String[] targetPlatforms2, String currentPlatform) { 066 return TargetPlatformFilterHelper.isCompatibleWithTargetPlatform(new FakeDownloadablePackage("wrapper", 067 Version.ZERO) { 068 @Override 069 public String[] getTargetPlatforms() { 070 return targetPlatforms2; 071 } 072 }, currentPlatform); 073 } 074 075 @Deprecated 076 public static boolean isCompatible(String[] targetPlatforms) { 077 return isCompatible(targetPlatforms, getPlatformFilter()); 078 } 079 080}