001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Sep 16, 2007
014: * @author David Kincade
015: */
016: package org.pentaho.plugin.versionchecker;
017:
018: import java.util.Map;
019:
020: import org.pentaho.core.system.PentahoSystem;
021: import org.pentaho.util.VersionHelper;
022: import org.pentaho.util.VersionInfo;
023: import org.pentaho.versionchecker.IVersionCheckDataProvider;
024:
025: public class PentahoVersionCheckDataProvider implements
026: IVersionCheckDataProvider {
027:
028: /**
029: * The version information for the pentaho platform is in the core jar. The PentahoSystem
030: * class will guarantee that we get the information. This information will contain the
031: * product id and the version number.
032: */
033: protected static final VersionInfo versionInfo = VersionHelper
034: .getVersionInfo(PentahoSystem.class);
035:
036: protected int versionRequestFlags = DEPTH_MINOR_MASK
037: + DEPTH_GA_MASK;
038:
039: public void setVersionRequestFlags(int flags) {
040: versionRequestFlags = flags;
041: }
042:
043: /**
044: * Returns the application id (code) for this application (the pentaho platform)
045: */
046: public String getApplicationID() {
047: return versionInfo == null ? null : versionInfo.getProductID();
048: }
049:
050: /**
051: * Returns the application version number found in the manifest
052: */
053: public String getApplicationVersion() {
054: return versionInfo == null ? null : versionInfo
055: .getVersionNumber();
056: }
057:
058: /**
059: * Returns the base url for the connection to the pentaho version checking server.
060: * Currently, there is no reason to use anything other than the default.
061: */
062: public String getBaseURL() {
063: return null;
064: }
065:
066: /**
067: * Returns the extra information that can be provided.
068: */
069: public Map getExtraInformation() {
070: return null;
071: }
072:
073: protected int computeOSMask() {
074: try {
075: String os = System.getProperty("os.name"); //$NON-NLS-1$
076: if (os != null) {
077: os = os.toLowerCase();
078: if (os.indexOf("windows") >= 0) { //$NON-NLS-1$
079: return DEPTH_WINDOWS_MASK;
080: } else if (os.indexOf("mac") >= 0) { //$NON-NLS-1$
081: return DEPTH_MAC_MASK;
082: } else if (os.indexOf("linux") >= 0) { //$NON-NLS-1$
083: return DEPTH_LINUX_MASK;
084: } else {
085: return DEPTH_ALL_MASK;
086: }
087: }
088: } catch (Exception e) {
089: // ignore any issues
090: }
091: return DEPTH_ALL_MASK;
092: }
093:
094: /**
095: * generates the depth flags
096: */
097: public int getDepth() {
098:
099: int depth = versionRequestFlags + computeOSMask();
100: return depth;
101: }
102: }
|