~etherpad/etherpad/ubuntu-lucid-backport

« back to all changes in this revision

Viewing changes to etherpad/src/etherpad/pne/pne_utils.js

  • Committer: James Page
  • Date: 2011-04-13 08:00:43 UTC
  • Revision ID: james.page@canonical.com-20110413080043-eee2nq7y1v7cv2mp
* Refactoring to use native Ubuntu Java libraries. 
* debian/control:
  - use openjdk instead of sun's java
  - update maintainer
* debian/etherpad.init.orig, debian/etherpad.upstart:
  - move the init script out of the way
  - create a basic upstart script
  - note that the open office document conversion daemon was dropped
    from the upstart configuration; if this behavior is desired, please
    create a separate upstart job for it
* debian/rules:
  - just use basic dh_installinit, as it will pick up the new upstart job
* New release
* Changed maintainer to Packaging
* Fixed installation scripts
* Initial Release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2009 Google Inc.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 * 
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS-IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
import("funhtml.*");
 
18
import("stringutils.md5");
 
19
import("sqlbase.persistent_vars");
 
20
 
 
21
import("etherpad.licensing");
 
22
 
 
23
jimport("java.lang.System.out.println");
 
24
jimport("java.lang.System");
 
25
 
 
26
 
 
27
function isPNE() {
 
28
  if (appjet.cache.fakePNE || appjet.config['etherpad.fakePNE']) {
 
29
    return true;
 
30
  }
 
31
  if (getVersionString()) {
 
32
    return true;
 
33
  }
 
34
  return false;
 
35
}
 
36
 
 
37
/**
 
38
 * Versioning scheme: we basically just use the apache scheme of MAJOR.MINOR.PATCH:
 
39
 *
 
40
 *     Versions are denoted using a standard triplet of integers: MAJOR.MINOR.PATCH. The
 
41
 *     basic intent is that MAJOR versions are incompatible, large-scale upgrades of the API.
 
42
 *     MINOR versions retain source and binary compatibility with older minor versions, and
 
43
 *     changes in the PATCH level are perfectly compatible, forwards and backwards.
 
44
 */
 
45
 
 
46
function getVersionString() {
 
47
  return appjet.config['etherpad.pneVersion'];
 
48
}
 
49
 
 
50
function parseVersionString(x) {
 
51
  var parts = x.split('.');
 
52
  return {
 
53
    major: Number(parts[0] || 0),
 
54
    minor: Number(parts[1] || 0),
 
55
    patch: Number(parts[2] || 0)
 
56
  };
 
57
}
 
58
 
 
59
/* returns {major: int, minor: int, patch: int} */
 
60
function getVersionNumbers() {
 
61
  return parseVersionString(getVersionString());
 
62
}
 
63
 
 
64
function checkDbVersionUpgrade() {
 
65
  var dbVersionString = persistent_vars.get("db_pne_version");
 
66
  var runningVersionString = getVersionString();
 
67
 
 
68
  if (!dbVersionString) {
 
69
    println("Upgrading to Private Network Edition, version: "+runningVersionString);
 
70
    return;
 
71
  }
 
72
 
 
73
  var dbVersion = parseVersionString(dbVersionString);
 
74
  var runningVersion = getVersionNumbers();
 
75
  var trueRegex = /\s*true\s*/i;
 
76
  var force = trueRegex.test(appjet.config['etherpad.forceDbUpgrade']);
 
77
 
 
78
  if (!force && (runningVersion.major != dbVersion.major)) {
 
79
    println("Error: you are attempting to update an EtherPad["+dbVersionString+
 
80
            "] database to version ["+runningVersionString+"].  This is not possible.");
 
81
    println("Exiting...");
 
82
    System.exit(1);
 
83
  }
 
84
  if (!force && (runningVersion.minor < dbVersion.minor)) {
 
85
    println("Error: your etherpad database is at a newer version ["+dbVersionString+"] than"+
 
86
            " the current running etherpad ["+runningVersionString+"].  Please upgrade to the "+
 
87
            " latest version.");
 
88
    println("Exiting...");
 
89
    System.exit(1);
 
90
  }
 
91
  if (!force && (runningVersion.minor > (dbVersion.minor + 1))) {
 
92
    println("\n\nWARNING: you are attempting to upgrade from version "+dbVersionString+" to version "+
 
93
            runningVersionString+".  It is recommended that you upgrade one minor version at a time."+
 
94
            " (The \"minor\" version number is the second number separated by dots.  For example,"+
 
95
            " if you are running version 1.2, it is recommended that you upgrade to 1.3 and then 1.4 "+
 
96
            " instead of going directly from 1.2 to 1.4.");
 
97
    println("\n\nIf you really want to do this, you can force us to attempt the upgrade with "+
 
98
            " the --etherpad.forceDbUpgrade=true flag.");
 
99
    println("\n\nExiting...");
 
100
    System.exit(1);
 
101
  }
 
102
  if (runningVersion.minor > dbVersion.minor) {
 
103
    println("Upgrading database to version "+runningVersionString);
 
104
  }
 
105
}
 
106
 
 
107
function saveDbVersion() {
 
108
  var dbVersionString = persistent_vars.get("db_pne_version");
 
109
  if (getVersionString() != dbVersionString) {
 
110
    persistent_vars.put('db_pne_version', getVersionString());
 
111
    println("Upgraded Private Network Edition version to ["+getVersionString()+"]");
 
112
  }
 
113
}
 
114
 
 
115
// These are a list of some of the config vars documented in the PNE manual.  They are here
 
116
// temporarily, until we move them to the PNE config UI.
 
117
 
 
118
var _eepneAllowedConfigVars = [
 
119
  'configFile',
 
120
  'etherpad.soffice',
 
121
  'etherpad.useMySQL',
 
122
  'etherpad.SQL_JDBC_DRIVER',
 
123
  'etherpad.SQL_JDBC_URL',
 
124
  'etherpad.SQL_PASSWORD',
 
125
  'etherpad.SQL_USERNAME',
 
126
  'etherpad.adminPass',
 
127
  'etherpad.licenseKey',
 
128
  'listen',
 
129
  'listenSecure',
 
130
  'smtpPass',
 
131
  'smtpServer',
 
132
  'smtpUser',
 
133
  'sslKeyPassword',
 
134
  'sslKeyStore'
 
135
];
 
136
 
 
137
function isServerLicensed() {
 
138
  return true;
 
139
}
 
140
 
 
141
function enableTrackingAgain() {
 
142
}
 
143
 
 
144
function pneTrackerHtml() {
 
145
  appjet.cache.noMorePneTracking = true;
 
146
}
 
147
 
 
148
 
 
149