Name

global.MIDPackage

Description

Represents a MID server DistPackage.

Script

var MIDPackage = Class.create();

MIDPackage.BUILDSTAMP_REGEX = /(\d{2})-(\d{2})-(\d{4})_(\d{4})$/;

MIDPackage._DOT = '.';
MIDPackage._FILENAME_SUFFIX = '.zip';
MIDPackage._MSI_SUFFIX = '.msi';
MIDPackage._RPM_SUFFIX = '.rpm';
MIDPackage._DEB_SUFFIX = '.deb';
MIDPackage._DASH = '-';
MIDPackage._UNDERSCORE = '_';
MIDPackage._EMPTY_STRING = '';

/**
* Converts a 'modern' buildstamp (YYYY-MM-DD-hhmm) to the legacy format (MM-DD-YYYY_hhmm).
* @param string modernBuildstamp
* @return string
* @throws IllegalArgumentException If the specified modern buildstamp is invalid.
*/
MIDPackage.createLegacyBuildstamp = function(modernBuildstamp) {
  var matches = MIDPackage.BUILDSTAMP_REGEX.exec(modernBuildstamp);
  if (matches === null)
      throw new IllegalArgumentException('Invalid modern buildstamp `' + modernBuildstamp + '`.');
  
  var legacyBuildstamp = MIDPackage._EMPTY_STRING + matches[1]
  + MIDPackage._DASH + matches[2]
  + MIDPackage._DASH + matches[3]
  + MIDPackage._UNDERSCORE + matches[4];
  return legacyBuildstamp;
};

MIDPackage.prototype = {
initialize: function(name, buildstamp, operatingSystem, architecture) {
  this._name = name;
  this._buildstamp = buildstamp;
  this._operatingSystem = operatingSystem;
  this._architecture = architecture;

  this._suffix = MIDPackage._FILENAME_SUFFIX;
  if (this._name === "mid-windows-installer")
      this._suffix = MIDPackage._MSI_SUFFIX;
  else if (this._name === "mid-linux-rpm-installer") {
      this._name = "mid-linux-installer";
      this._suffix = MIDPackage._RPM_SUFFIX;
  } else if (this._name === "mid-linux-deb-installer") {
      this._name = "mid-linux-installer";
      this._suffix = MIDPackage._DEB_SUFFIX;
  }
},

getName: function() {
  return this._name;
},

getBuildStamp: function() {
  return this._buildstamp;
},

getOperatingSystem: function() {
  return this._operatingSystem;
},

getOperatingSystemName: function() {
  switch(this._operatingSystem) {
    case 'windows':
      return 'Windows';
    case 'linux':
      return 'Linux';
    case 'osx':
      return 'OSX';
  }

  return this._operatingSystem;
},

getArchitecture: function() {
  return this._architecture;
},

getArchitectureName: function() {
  return this._architecture;
},

getFilename: function() {
  var filename = this._name;
  if (JSUtil.notNil(this._buildstamp)) // handle headless build filenames
      filename += MIDPackage._DOT + this._buildstamp;
    
  filename += MIDPackage._DOT + this._operatingSystem
  + MIDPackage._DOT + this._architecture + this._suffix;

  return filename;
},

// Gets pre-geneva file name for backward compatibility, converting the buildstamp
// from 'branchname_MM-DD-YYYY_hhmm' to 'YYYY-MM-DD-hhmm'
getLegacyFilename: function() {
  var matches = MIDPackage.BUILDSTAMP_REGEX.exec(this._buildstamp);
  if (matches === null)
      throw new IllegalArgumentException('Invalid buildstamp `' + this._buildstamp + '`.');
  
  var legacyBuildstamp = matches[3]
    + MIDPackage._DASH + matches[1]
    + MIDPackage._DASH + matches[2]
    + MIDPackage._DASH + matches[4];
  var filename = this._name
    + MIDPackage._DOT + legacyBuildstamp
    + MIDPackage._DOT + this._operatingSystem
    + MIDPackage._DOT + this._architecture
    + MIDPackage._FILENAME_SUFFIX;
  return filename;
},

type: 'MIDPackage'
}

Sys ID

014115813720200003c78c00dfbe5dff

Offical Documentation

Official Docs: