* Bring manage app up to date with current Helma.
This commit is contained in:
parent
c632c8f8bd
commit
437dfb94d3
33 changed files with 1185 additions and 1152 deletions
67
Application/actions.js
Normal file
67
Application/actions.js
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/**
|
||||||
|
* renders AppManager
|
||||||
|
*/
|
||||||
|
function main_action() {
|
||||||
|
if (checkAddress() == false)
|
||||||
|
return;
|
||||||
|
if (checkAuth(this) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
res.data.body = this.renderSkinAsString("main");
|
||||||
|
renderSkin("global");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prints session- and thread-stats for mrtg-tool
|
||||||
|
* doesn't check username or password, so that we don't have
|
||||||
|
* to write them cleartext in a mrtg-configfile but checks the
|
||||||
|
* remote address.
|
||||||
|
*/
|
||||||
|
function mrtg_action() {
|
||||||
|
if (checkAddress() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this.isActive() == false) {
|
||||||
|
res.write("0\n0\n0\n0\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.data.action == "sessions") {
|
||||||
|
|
||||||
|
res.write(this.sessions.size());
|
||||||
|
res.write("\n0\n0\n0\n");
|
||||||
|
|
||||||
|
} else if (req.data.action == "threads") {
|
||||||
|
|
||||||
|
res.write(this.countActiveEvaluators() + "\n");
|
||||||
|
res.write(this.countEvaluators() + "\n");
|
||||||
|
res.write("0\n0\n");
|
||||||
|
|
||||||
|
} else if (req.data.action == "cache") {
|
||||||
|
|
||||||
|
res.write(this.getCacheUsage() + "\n");
|
||||||
|
res.write(this.getProperty("cachesize", "1000") + "\n");
|
||||||
|
res.write("0\n0\n");
|
||||||
|
|
||||||
|
} else if (req.data.action == "requests") {
|
||||||
|
|
||||||
|
// res.write (
|
||||||
|
|
||||||
|
} else {
|
||||||
|
res.write("0\n0\n0\n0\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* performs a redirect to the public site
|
||||||
|
* (workaround, we can't access application object from docapplication for some reason)
|
||||||
|
* @see application.url_macro
|
||||||
|
*/
|
||||||
|
function redirectpublic_action() {
|
||||||
|
if (checkAddress() == false) return;
|
||||||
|
if (checkAuth(this) == false) return;
|
||||||
|
|
||||||
|
res.redirect(this.url_macro());
|
||||||
|
}
|
|
@ -1,29 +1,28 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* construct an application object so that we can use
|
* construct an application object so that we can use
|
||||||
* skins for non-active applications too
|
* skins for non-active applications too
|
||||||
* @arg name
|
* @arg name
|
||||||
*/
|
*/
|
||||||
function constructor(name) {
|
function constructor(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of no use, just to avoid error message
|
* of no use, just to avoid error message
|
||||||
*/
|
*/
|
||||||
function onRequest () {
|
function onRequest() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true/false to determine if application is running
|
* return true/false to determine if application is running
|
||||||
*/
|
*/
|
||||||
function isActive() {
|
function isActive() {
|
||||||
if ( root.getApplication(this.name)==null )
|
if (root.getApplication(this.name) == null)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
* macro rendering a skin
|
* macro rendering a skin
|
||||||
* @param name name of skin
|
* @param name name of skin
|
||||||
*/
|
*/
|
||||||
function skin_macro(par) {
|
function skin_macro(par) {
|
||||||
if ( par && par.name ) {
|
if (par && par.name) {
|
||||||
this.renderSkin(par.name);
|
this.renderSkin(par.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ function skin_macro(par) {
|
||||||
* macro-wrapper for href-function
|
* macro-wrapper for href-function
|
||||||
* @param action name of action to call on this prototype, default main
|
* @param action name of action to call on this prototype, default main
|
||||||
*/
|
*/
|
||||||
function href_macro(par) {
|
function href_macro(par) {
|
||||||
return this.href( (par&&par.action)?par.action:"main" );
|
return this.href((par && par.action) ? par.action : "main");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,12 +24,12 @@ function href_macro(par) {
|
||||||
* the application (which is using baseURI if set)
|
* the application (which is using baseURI if set)
|
||||||
*/
|
*/
|
||||||
function url_macro() {
|
function url_macro() {
|
||||||
var str = this.getProperty("absoluteuri");
|
var str = this.getProperty("absoluteuri");
|
||||||
if ( str!=null && str!="" ) {
|
if (str != null && str != "") {
|
||||||
return str;
|
return str;
|
||||||
} else {
|
} else {
|
||||||
return this.getRootHref();
|
return this.getRootHref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ function url_macro() {
|
||||||
* Macro returning the title of an application
|
* Macro returning the title of an application
|
||||||
*/
|
*/
|
||||||
function title_macro() {
|
function title_macro() {
|
||||||
var title = this.name;
|
var title = this.name;
|
||||||
return(title);
|
return(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,25 +49,25 @@ function title_macro() {
|
||||||
* @param Object Macro parameter object
|
* @param Object Macro parameter object
|
||||||
*/
|
*/
|
||||||
function description_macro(param) {
|
function description_macro(param) {
|
||||||
var str = "";
|
var str = "";
|
||||||
var appHome = this.getAppDir();
|
var appHome = this.getAppDir();
|
||||||
var f = new File(this.getAppDir().toString(), "description.txt");
|
var f = new File(this.getAppDir().toString(), "description.txt");
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
f = new File(this.getAppDir().toString(), "doc.html");
|
f = new File(this.getAppDir().toString(), "doc.html");
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
str = f.readAll();
|
str = f.readAll();
|
||||||
if (str.length > 200)
|
if (str.length > 200)
|
||||||
str = str.substring(0, 200) + "...";
|
str = str.substring(0, 200) + "...";
|
||||||
}
|
}
|
||||||
return(str);
|
return(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning the server's uptime nicely formatted
|
* Macro returning the server's uptime nicely formatted
|
||||||
*/
|
*/
|
||||||
function uptime_macro() {
|
function uptime_macro() {
|
||||||
return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 );
|
return formatAge((java.lang.System.currentTimeMillis() - this.starttime) / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,11 +76,11 @@ function uptime_macro() {
|
||||||
* parameter used by global.formatCount
|
* parameter used by global.formatCount
|
||||||
* @see global.formatCount
|
* @see global.formatCount
|
||||||
*/
|
*/
|
||||||
function countSessions_macro(par) {
|
function countSessions_macro(par) {
|
||||||
if ( this.isActive()==true )
|
if (this.isActive() == true)
|
||||||
return this.sessions.size() + formatCount(this.sessions.size(),par);
|
return this.sessions.size() + formatCount(this.sessions.size(), par);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,12 +91,12 @@ function countSessions_macro(par) {
|
||||||
* @see application.countUsers_macro
|
* @see application.countUsers_macro
|
||||||
* @see application.listUsers_macro
|
* @see application.listUsers_macro
|
||||||
*/
|
*/
|
||||||
function users_macro(par) {
|
function users_macro(par) {
|
||||||
if ( req.data.showusers=="true" ) {
|
if (req.data.showusers == "true") {
|
||||||
this.listUsers_macro(par);
|
this.listUsers_macro(par);
|
||||||
} else {
|
} else {
|
||||||
this.countUsers_macro(par);
|
this.countUsers_macro(par);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,11 +106,11 @@ function users_macro(par) {
|
||||||
* parameter used by global.formatCount
|
* parameter used by global.formatCount
|
||||||
* @see global.formatCount
|
* @see global.formatCount
|
||||||
*/
|
*/
|
||||||
function countUsers_macro(par) {
|
function countUsers_macro(par) {
|
||||||
if ( this.isActive()==true )
|
if (this.isActive() == true)
|
||||||
return this.activeUsers.size() + formatCount(this.activeUsers.size(),par);
|
return this.activeUsers.size() + formatCount(this.activeUsers.size(), par);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,93 +118,93 @@ function countUsers_macro(par) {
|
||||||
* Macro rendering the list of logged-in users if application is active
|
* Macro rendering the list of logged-in users if application is active
|
||||||
* @param separator html-code written between elements
|
* @param separator html-code written between elements
|
||||||
*/
|
*/
|
||||||
function listUsers_macro(par) {
|
function listUsers_macro(par) {
|
||||||
var separator = (par && par.separator) ? par.separator : ", ";
|
var separator = (par && par.separator) ? par.separator : ", ";
|
||||||
if ( this.activeUsers.size()==0 )
|
if (this.activeUsers.size() == 0)
|
||||||
return "";
|
return "";
|
||||||
var e = this.activeUsers.keys();
|
var users = this.activeUsers.iterator();
|
||||||
while ( e.hasMoreElements() ) {
|
while (users.hasNext()) {
|
||||||
res.write ( e.nextElement() );
|
res.write(users.next().__name__);
|
||||||
if ( e.hasMoreElements() ) {
|
if (users.hasNext()) {
|
||||||
res.write ( separator );
|
res.write(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning the number of active evaluators (=threads)
|
* Macro returning the number of active evaluators (=threads)
|
||||||
*/
|
*/
|
||||||
function countActiveEvaluators_macro() {
|
function countActiveEvaluators_macro() {
|
||||||
return this.countActiveEvaluators();
|
return this.countActiveEvaluators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning the number of free evaluators (=threads)
|
* Macro returning the number of free evaluators (=threads)
|
||||||
*/
|
*/
|
||||||
function countFreeEvaluators_macro() {
|
function countFreeEvaluators_macro() {
|
||||||
return this.countFreeEvaluators();
|
return this.countFreeEvaluators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning the current number of objects in the cache
|
* Macro returning the current number of objects in the cache
|
||||||
*/
|
*/
|
||||||
function cacheusage_macro (param) {
|
function cacheusage_macro(param) {
|
||||||
return this.getCacheUsage ();
|
return this.getCacheUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning the number of objects allowed in the cache
|
* Macro returning the number of objects allowed in the cache
|
||||||
*/
|
*/
|
||||||
function cachesize_macro (param) {
|
function cachesize_macro(param) {
|
||||||
return this.getProperty ("cachesize", "1000");
|
return this.getProperty("cachesize", "1000");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro formatting the number of requests in the last 5 minutes
|
* Macro formatting the number of requests in the last 5 minutes
|
||||||
*/
|
*/
|
||||||
function requestCount_macro(par) {
|
function requestCount_macro(par) {
|
||||||
if (app.data.stat==null || app.data.stat.get (this.name)==null)
|
if (app.data.stat == null || app.data.stat[this.name] == null)
|
||||||
return "not available";
|
return "not available";
|
||||||
if (this.isActive()) {
|
if (this.isActive()) {
|
||||||
var obj = app.data.stat.get (this.name);
|
var obj = app.data.stat[this.name];
|
||||||
return obj.requestCount + formatCount (obj.requestCount, par);
|
return obj.requestCount + formatCount(obj.requestCount, par);
|
||||||
} else {
|
} else {
|
||||||
return 0 + formatCount (0,par);
|
return 0 + formatCount(0, par);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro formatting the number of errors in the last 5 minutes
|
* Macro formatting the number of errors in the last 5 minutes
|
||||||
*/
|
*/
|
||||||
function errorCount_macro(par) {
|
function errorCount_macro(par) {
|
||||||
if (app.data.stat==null || app.data.stat.get (this.name)==null)
|
if (app.data.stat == null || app.data.stat[this.name] == null)
|
||||||
return "not available";
|
return "not available";
|
||||||
if (this.isActive()) {
|
if (this.isActive()) {
|
||||||
var obj = app.data.stat.get (this.name);
|
var obj = app.data.stat[this.name];
|
||||||
return obj.errorCount + formatCount (obj.errorCount, par);
|
return obj.errorCount + formatCount(obj.errorCount, par);
|
||||||
} else {
|
} else {
|
||||||
return 0 + formatCount (0,par);
|
return 0 + formatCount(0, par);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro formatting app.properties
|
* Macro formatting app.properties
|
||||||
*/
|
*/
|
||||||
function properties_macro(par) {
|
function properties_macro(par) {
|
||||||
formatProperties( this.getProperties(), par );
|
formatProperties(this.getProperties(), par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function appdir_macro (param) {
|
function repositories_macro(param) {
|
||||||
return this.getAppDir ().toString ();
|
var repos = this.getRepositories().iterator();
|
||||||
|
while (repos.hasNext())
|
||||||
|
res.writeln(repos.next().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
/**
|
|
||||||
* renders AppManager
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (checkAddress()==false)
|
|
||||||
return;
|
|
||||||
if (checkAuth(this)==false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
res.data.body = this.renderSkinAsString("main");
|
|
||||||
renderSkin ("global");
|
|
||||||
|
|
|
@ -47,9 +47,9 @@
|
||||||
<td class="list_property" align="left"><% this.uptime %></td>
|
<td class="list_property" align="left"><% this.uptime %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="list_property" align="left">app directory</td>
|
<td class="list_property" align="left" valign="top">repositories</td>
|
||||||
<td class="list_property" width="5"> </td>
|
<td class="list_property" width="5"> </td>
|
||||||
<td class="list_property" align="left"><% this.appdir %></td>
|
<td class="list_property" align="left"><% this.repositories %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* prints session- and thread-stats for mrtg-tool
|
|
||||||
* doesn't check username or password, so that we don't have
|
|
||||||
* to write them cleartext in a mrtg-configfile but checks the
|
|
||||||
* remote address.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( checkAddress()==false )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( this.isActive()==false ) {
|
|
||||||
res.write ( "0\n0\n0\n0\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.data.action=="sessions") {
|
|
||||||
|
|
||||||
res.write (this.sessions.size());
|
|
||||||
res.write ("\n0\n0\n0\n");
|
|
||||||
|
|
||||||
} else if (req.data.action=="threads") {
|
|
||||||
|
|
||||||
res.write (this.countActiveEvaluators () + "\n");
|
|
||||||
res.write (this.countEvaluators () + "\n");
|
|
||||||
res.write ("0\n0\n");
|
|
||||||
|
|
||||||
} else if (req.data.action=="cache") {
|
|
||||||
|
|
||||||
res.write (this.getCacheUsage () + "\n");
|
|
||||||
res.write (this.getProperty ("cachesize", "1000") + "\n");
|
|
||||||
res.write ("0\n0\n");
|
|
||||||
|
|
||||||
} else if (req.data.action=="requests") {
|
|
||||||
|
|
||||||
// res.write (
|
|
||||||
|
|
||||||
} else {
|
|
||||||
res.write ( "0\n0\n0\n0\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
/**
|
|
||||||
* performs a redirect to the public site
|
|
||||||
* (workaround, we can't access application object from docapplication for some reason)
|
|
||||||
* @see application.url_macro
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( checkAddress()==false ) return;
|
|
||||||
if ( checkAuth(this)==false ) return;
|
|
||||||
|
|
||||||
res.redirect ( this.url_macro() );
|
|
|
@ -1,59 +1,59 @@
|
||||||
function read_action () {
|
function read_action() {
|
||||||
this.readApplication ();
|
this.readApplication();
|
||||||
res.redirect (this.href("main"));
|
res.redirect(this.href("main"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function main_action () {
|
function main_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth(this.getParentElement ())==false)
|
if (checkAuth(this.getParentElement()) == false)
|
||||||
return;
|
return;
|
||||||
this.renderSkin ("frameset");
|
this.renderSkin("frameset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function prototypes_action () {
|
function prototypes_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth(this.getParentElement ())==false)
|
if (checkAuth(this.getParentElement()) == false)
|
||||||
return;
|
return;
|
||||||
res.data.body = this.renderSkinAsString ("prototypes");
|
res.data.body = this.renderSkinAsString("prototypes");
|
||||||
renderSkin ("api");
|
renderSkin("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function summary_action () {
|
function summary_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth(this.getParentElement ())==false)
|
if (checkAuth(this.getParentElement()) == false)
|
||||||
return;
|
return;
|
||||||
res.data.body = this.renderSkinAsString ("summary");
|
res.data.body = this.renderSkinAsString("summary");
|
||||||
renderSkin ("api");
|
renderSkin("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function functionindex_action () {
|
function functionindex_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth(this.getParentElement ())==false)
|
if (checkAuth(this.getParentElement()) == false)
|
||||||
return;
|
return;
|
||||||
res.data.body = this.renderSkinAsString ("functionindex");
|
res.data.body = this.renderSkinAsString("functionindex");
|
||||||
renderSkin ("api");
|
renderSkin("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function render_action () {
|
function render_action() {
|
||||||
// set res.data.rendering, this will suppress the link back to the manage
|
// set res.data.rendering, this will suppress the link back to the manage
|
||||||
// console in the apidocs actions
|
// console in the apidocs actions
|
||||||
res.data.rendering = true;
|
res.data.rendering = true;
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth(this.getParentElement ())==false)
|
if (checkAuth(this.getParentElement()) == false)
|
||||||
return;
|
return;
|
||||||
var ct = this.renderApi();
|
var ct = this.renderApi();
|
||||||
res.data.body = '<body>rendering API ...<br/>wrote ' + ct + ' files<br/><br/>';
|
res.data.body = '<body>rendering API ...<br/>wrote ' + ct + ' files<br/><br/>';
|
||||||
res.data.body += '<a href="' + root.href ("main") + '">back to manage console</a>';
|
res.data.body += '<a href="' + root.href("main") + '">back to manage console</a>';
|
||||||
res.data.title = "rendering helma api";
|
res.data.title = "rendering helma api";
|
||||||
res.data.head = renderSkinAsString("head");
|
res.data.head = renderSkinAsString("head");
|
||||||
renderSkin ("basic");
|
renderSkin("basic");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,90 +1,89 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the prototype of any doc-object (either a prototype, a function or a tag)
|
* get the prototype of any doc-object (either a prototype, a function or a tag)
|
||||||
*/
|
*/
|
||||||
function getDocPrototype (obj) {
|
function getDocPrototype(obj) {
|
||||||
var tmp = obj;
|
var tmp = obj;
|
||||||
while (tmp!=null && tmp.getType () != this.PROTOTYPE) {
|
while (tmp != null && tmp.getType() != this.PROTOTYPE) {
|
||||||
tmp = tmp.getParentElement ();
|
tmp = tmp.getParentElement();
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a prototype of this docapplication, ie get on of the children of this object
|
* get a prototype of this docapplication, ie get on of the children of this object
|
||||||
*/
|
*/
|
||||||
function getPrototype (name) {
|
function getPrototype(name) {
|
||||||
return this.getChildElement ("prototype_" + name);
|
return this.getChildElement("prototype_" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getDir (dir, obj) {
|
function getDir(dir, obj) {
|
||||||
dir.mkdir ();
|
dir.mkdir();
|
||||||
if (obj.getType () == this.APPLICATION) {
|
if (obj.getType() == this.APPLICATION) {
|
||||||
return dir;
|
return dir;
|
||||||
} else {
|
} else {
|
||||||
var protoObj = this.getDocPrototype (obj);
|
var protoObj = this.getDocPrototype(obj);
|
||||||
var dir = new File (dir, protoObj.getElementName ());
|
var dir = new File (dir, protoObj.getElementName());
|
||||||
dir.mkdir ();
|
dir.mkdir();
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderApi() {
|
function renderApi() {
|
||||||
var prefix = this.href ("");
|
var prefix = this.href("");
|
||||||
this.storePage (this, "main", "", "index.html");
|
this.storePage(this, "main", "", "index.html");
|
||||||
this.storePage (this, "prototypes");
|
this.storePage(this, "prototypes");
|
||||||
this.storePage (this, "summary");
|
this.storePage(this, "summary");
|
||||||
this.storePage (this, "functionindex");
|
this.storePage(this, "functionindex");
|
||||||
var ct = 4;
|
var ct = 4;
|
||||||
var arr = this.listChildren ();
|
var arr = this.listChildren();
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
this.storePage (arr[i], "list", "../");
|
this.storePage(arr[i], "list", "../");
|
||||||
this.storePage (arr[i], "main", "../");
|
this.storePage(arr[i], "main", "../");
|
||||||
ct += 2;
|
ct += 2;
|
||||||
var subarr = arr[i].listChildren ();
|
var subarr = arr[i].listChildren();
|
||||||
for (var j=0; j<subarr.length; j++) {
|
for (var j = 0; j < subarr.length; j++) {
|
||||||
this.storePage (subarr[j], "main", "../", subarr[j].getElementName () + ".html");
|
this.storePage(subarr[j], "main", "../", subarr[j].getElementName() + ".html");
|
||||||
ct += 1;
|
ct += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function storePage (obj, action, backPath, filename) {
|
function storePage(obj, action, backPath, filename) {
|
||||||
if (filename==null)
|
if (filename == null)
|
||||||
var filename = action + ".html";
|
var filename = action + ".html";
|
||||||
var str = this.getPage (obj, action, backPath);
|
var str = this.getPage(obj, action, backPath);
|
||||||
var appObj = this.getParentElement ();
|
var appObj = this.getParentElement();
|
||||||
var dir = new File (appObj.getAppDir ().getAbsolutePath (), ".docs");
|
var dir = new File (appObj.getAppDir().getAbsolutePath(), ".docs");
|
||||||
dir = this.getDir (dir, obj);
|
dir = this.getDir(dir, obj);
|
||||||
var f = new File (dir, filename);
|
var f = new File (dir, filename);
|
||||||
f.remove ();
|
f.remove();
|
||||||
f.open ();
|
f.open();
|
||||||
f.write (str);
|
f.write(str);
|
||||||
f.close ();
|
f.close();
|
||||||
app.log ("wrote file " + f.getAbsolutePath());
|
app.log("wrote file " + f.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getPage (obj, action, backPath) {
|
function getPage(obj, action, backPath) {
|
||||||
backPath = (backPath==null) ? "" : backPath;
|
backPath = (backPath == null) ? "" : backPath;
|
||||||
res.pushStringBuffer ();
|
res.pushStringBuffer();
|
||||||
eval ("obj." + action + "_action ();");
|
eval("obj." + action + "_action ();");
|
||||||
var str = res.popStringBuffer ();
|
var str = res.popStringBuffer();
|
||||||
// get the baseURI out of the url and replace
|
// get the baseURI out of the url and replace
|
||||||
// it with the given relative prefix
|
// it with the given relative prefix
|
||||||
// (keep anchors in regex!)
|
// (keep anchors in regex!)
|
||||||
var reg = new RegExp ("href=\"" + this.href ("") + "([^\"#]+)([^\"]*)\"", "gim");
|
var reg = new RegExp ("href=\"" + this.href("") + "([^\"#]+)([^\"]*)\"", "gim");
|
||||||
str = str.replace (reg, "href=\"" + backPath + "$1.html$2\"");
|
str = str.replace(reg, "href=\"" + backPath + "$1.html$2\"");
|
||||||
var reg = new RegExp ("src=\"" + this.href ("") + "([^\"#]+)([^\"]*)\"", "gim");
|
var reg = new RegExp ("src=\"" + this.href("") + "([^\"#]+)([^\"]*)\"", "gim");
|
||||||
str = str.replace (reg, "src=\"" + backPath + "$1.html$2\"");
|
str = str.replace(reg, "src=\"" + backPath + "$1.html$2\"");
|
||||||
// shorten links, so that function files can move up one directory
|
// shorten links, so that function files can move up one directory
|
||||||
// in the hierarchy
|
// in the hierarchy
|
||||||
var reg = new RegExp ("(prototype_[^/]+/[^/]+)/main.html", "gim");
|
var reg = new RegExp ("(prototype_[^/]+/[^/]+)/main.html", "gim");
|
||||||
str = str.replace (reg, "$1.html");
|
str = str.replace(reg, "$1.html");
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,64 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro rendering a skin
|
* macro rendering a skin
|
||||||
* @param name name of skin
|
* @param name name of skin
|
||||||
*/
|
*/
|
||||||
function skin_macro(par) {
|
function skin_macro(par) {
|
||||||
if ( par && par.name ) {
|
if (par && par.name) {
|
||||||
this.renderSkin(par.name);
|
this.renderSkin(par.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro-wrapper for href-function
|
* macro-wrapper for href-function
|
||||||
* @param action name of action to call on this prototype, default main
|
* @param action name of action to call on this prototype, default main
|
||||||
*/
|
*/
|
||||||
function href_macro(param) { return this.href ((param && param.action) ? param.action : "main"); }
|
function href_macro(param) {
|
||||||
|
return this.href((param && param.action) ? param.action : "main");
|
||||||
|
}
|
||||||
|
|
||||||
function comment_macro (param) { return renderComment (this, param); }
|
function comment_macro(param) {
|
||||||
function content_macro (param) { return this.getContent (); }
|
return renderComment(this, param);
|
||||||
function tags_macro (param) { return renderTags (this, param); }
|
}
|
||||||
function location_macro (param) { return renderLocation (this, param); }
|
|
||||||
function link_macro (param) { return renderLink (this, param); }
|
function content_macro(param) {
|
||||||
|
return this.getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
function tags_macro(param) {
|
||||||
|
return renderTags(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
function location_macro(param) {
|
||||||
|
return renderLocation(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
function link_macro(param) {
|
||||||
|
return renderLink(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
//// END OF COPIED FUNCTIONS
|
//// END OF COPIED FUNCTIONS
|
||||||
|
|
||||||
|
|
||||||
|
function linkToManage_macro(param) {
|
||||||
function linkToManage_macro (param) {
|
if (res.data.rendering != true) {
|
||||||
if (res.data.rendering != true) {
|
return ('<a href="' + root.href("main") + '" target="_top">back to manage console</a>');
|
||||||
return ('<a href="' + root.href ("main") + '" target="_top">back to manage console</a>');
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function headline_macro (param) {
|
function headline_macro(param) {
|
||||||
res.write (this.getName ());
|
res.write(this.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function hrefRoot_macro(param) {
|
||||||
function hrefRoot_macro (param) {
|
var obj = this.getChildElement("prototype_root");
|
||||||
var obj = this.getChildElement ("prototype_root");
|
if (obj == null) {
|
||||||
if (obj == null) {
|
var obj = this.getChildElement("prototype_Root");
|
||||||
var obj = this.getChildElement ("prototype_Root");
|
}
|
||||||
}
|
if (obj != null) {
|
||||||
if (obj!=null) {
|
var action = (param.action) ? param.action : "main";
|
||||||
var action = (param.action) ? param.action : "main";
|
return obj.href(action);
|
||||||
return obj.href (action);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,15 +67,15 @@ function hrefRoot_macro (param) {
|
||||||
* @param skin name of skin to render on prototype
|
* @param skin name of skin to render on prototype
|
||||||
* @param separator
|
* @param separator
|
||||||
*/
|
*/
|
||||||
function prototypes_macro(param) {
|
function prototypes_macro(param) {
|
||||||
var skin = (param.skin) ? param.skin : "asPrototypeList";
|
var skin = (param.skin) ? param.skin : "asPrototypeList";
|
||||||
var separator = (param.separator) ? param.separator : "";
|
var separator = (param.separator) ? param.separator : "";
|
||||||
var arr = this.listChildren ();
|
var arr = this.listChildren();
|
||||||
for ( var i=0; i<arr.length; i++ ) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
arr[i].renderSkin(skin);
|
arr[i].renderSkin(skin);
|
||||||
if (i < arr.length-1)
|
if (i < arr.length - 1)
|
||||||
res.write (separator);
|
res.write(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,23 +84,23 @@ function prototypes_macro(param) {
|
||||||
* @param skin name of skin to render on each method
|
* @param skin name of skin to render on each method
|
||||||
* @param skinSeparator name of skin to render as separator between each letters
|
* @param skinSeparator name of skin to render as separator between each letters
|
||||||
*/
|
*/
|
||||||
function functions_macro(param) {
|
function functions_macro(param) {
|
||||||
var skinname = (param.skin) ? param.skin : "asListItem";
|
var skinname = (param.skin) ? param.skin : "asListItem";
|
||||||
var skinIndexSeparator = (param.indexSeparator) ? param.indexSeparator : "indexSeparator";
|
var skinIndexSeparator = (param.indexSeparator) ? param.indexSeparator : "indexSeparator";
|
||||||
var separator = (param.separator) ? param.separator : "";
|
var separator = (param.separator) ? param.separator : "";
|
||||||
var arr = this.listFunctions ();
|
var arr = this.listFunctions();
|
||||||
var lastLetter = "";
|
var lastLetter = "";
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if (arr[i].getName ().substring (0,1)!=lastLetter) {
|
if (arr[i].getName().substring(0, 1) != lastLetter) {
|
||||||
lastLetter = arr[i].getName ().substring (0,1);
|
lastLetter = arr[i].getName().substring(0, 1);
|
||||||
var tmp = new Object ();
|
var tmp = new Object ();
|
||||||
tmp.letter = lastLetter.toUpperCase ();
|
tmp.letter = lastLetter.toUpperCase();
|
||||||
this.renderSkin (skinIndexSeparator, tmp);
|
this.renderSkin(skinIndexSeparator, tmp);
|
||||||
}
|
}
|
||||||
arr[i].renderSkin (skinname);
|
arr[i].renderSkin(skinname);
|
||||||
if (i < arr.length-1)
|
if (i < arr.length - 1)
|
||||||
res.write (separator);
|
res.write(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
function main_action () {
|
function main_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth()==false)
|
if (checkAuth() == false)
|
||||||
return;
|
return;
|
||||||
res.data.body = this.renderSkinAsString ("main");
|
res.data.body = this.renderSkinAsString("main");
|
||||||
renderSkin ("api");
|
renderSkin("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,85 +1,97 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro rendering a skin
|
* macro rendering a skin
|
||||||
* @param name name of skin
|
* @param name name of skin
|
||||||
*/
|
*/
|
||||||
function skin_macro(par) {
|
function skin_macro(par) {
|
||||||
if ( par && par.name ) {
|
if (par && par.name) {
|
||||||
this.renderSkin(par.name);
|
this.renderSkin(par.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro-wrapper for href-function
|
* macro-wrapper for href-function
|
||||||
* @param action name of action to call on this prototype, default main
|
* @param action name of action to call on this prototype, default main
|
||||||
*/
|
*/
|
||||||
function href_macro(param) { return this.href ((param && param.action) ? param.action : "main"); }
|
function href_macro(param) {
|
||||||
|
return this.href((param && param.action) ? param.action : "main");
|
||||||
|
}
|
||||||
|
|
||||||
function comment_macro (param) { return renderComment (this, param); }
|
function comment_macro(param) {
|
||||||
function content_macro (param) { return this.getContent (); }
|
return renderComment(this, param);
|
||||||
function tags_macro (param) { return renderTags (this, param); }
|
}
|
||||||
function location_macro (param) { return renderLocation (this, param); }
|
function content_macro(param) {
|
||||||
function link_macro (param) { return renderLink (this, param); }
|
return this.getContent();
|
||||||
|
}
|
||||||
|
function tags_macro(param) {
|
||||||
|
return renderTags(this, param);
|
||||||
|
}
|
||||||
|
function location_macro(param) {
|
||||||
|
return renderLocation(this, param);
|
||||||
|
}
|
||||||
|
function link_macro(param) {
|
||||||
|
return renderLink(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
//// END OF COPIED FUNCTIONS
|
//// END OF COPIED FUNCTIONS
|
||||||
|
|
||||||
|
|
||||||
|
function headline_macro(param) {
|
||||||
function headline_macro (param) {
|
var p = this.getParentElement();
|
||||||
var p = this.getParentElement ();
|
var handler = (p != null) ? p.getName() : "";
|
||||||
var handler = (p!=null) ? p.getName () : "";
|
if (this.getType() == this.ACTION) {
|
||||||
if (this.getType () == this.ACTION) {
|
res.write("/" + this.getName());
|
||||||
res.write ("/" + this.getName ());
|
} else if (this.getType() == this.FUNCTION) {
|
||||||
} else if (this.getType () == this.FUNCTION) {
|
if (handler != "" && handler != "global")
|
||||||
if (handler!="" && handler!="global")
|
res.write(handler + ".");
|
||||||
res.write (handler + ".");
|
res.write(this.getName() + " (");
|
||||||
res.write (this.getName () + " (");
|
var arr = this.listParameters();
|
||||||
var arr = this.listParameters ();
|
for (var i = 0; i < arr.length; i++) {
|
||||||
for (var i=0; i<arr.length; i++) {
|
res.write(arr[i]);
|
||||||
res.write (arr[i]);
|
if (i < arr.length - 1) {
|
||||||
if (i<arr.length-1) {
|
res.write(", ");
|
||||||
res.write (", ");
|
}
|
||||||
}
|
}
|
||||||
}
|
res.write(")");
|
||||||
res.write (")");
|
} else if (this.getType() == this.MACRO) {
|
||||||
} else if (this.getType () == this.MACRO) {
|
res.write("<% ");
|
||||||
res.write ("<% ");
|
if (handler != "" && handler != "global")
|
||||||
if (handler!="" && handler!="global")
|
res.write(handler + ".");
|
||||||
res.write (handler + ".");
|
var name = this.getName();
|
||||||
var name = this.getName ();
|
if (name.indexOf("_macro") > -1)
|
||||||
if (name.indexOf("_macro")>-1)
|
name = name.substring(0, name.length - 6);
|
||||||
name = name.substring (0, name.length-6);
|
res.write(name);
|
||||||
res.write (name);
|
res.write(" %>");
|
||||||
res.write (" %>");
|
} else if (this.getType() == this.SKIN) {
|
||||||
} else if (this.getType () == this.SKIN) {
|
if (handler != "" && handler != "global")
|
||||||
if (handler!="" && handler!="global")
|
res.write(handler + "/");
|
||||||
res.write (handler + "/");
|
res.write(this.getName());
|
||||||
res.write (this.getName ());
|
res.write(".skin");
|
||||||
res.write (".skin");
|
} else if (this.getType() == this.PROPERTIES) {
|
||||||
}
|
res.write(this.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function skinparameters_macro (param) {
|
function skinparameters_macro(param) {
|
||||||
if (this.getType () == this.SKIN) {
|
if (this.getType() == this.SKIN) {
|
||||||
this.parameters_macro (param);
|
this.parameters_macro(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function parameters_macro (param) {
|
function parameters_macro(param) {
|
||||||
var separator = (param.separator) ? param.separator : ", ";
|
var separator = (param.separator) ? param.separator : ", ";
|
||||||
var arr = this.listParameters ();
|
var arr = this.listParameters();
|
||||||
for (var i=0; i<arr.length ;i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
res.write (arr[i]);
|
res.write(arr[i]);
|
||||||
if (i<arr.length-1)
|
if (i < arr.length - 1)
|
||||||
res.write (separator);
|
res.write(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function type_macro (param) {
|
function type_macro(param) {
|
||||||
return this.getTypeName ();
|
return this.getTypeName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,15 +101,15 @@ function type_macro (param) {
|
||||||
*/
|
*/
|
||||||
function source_macro(param) {
|
function source_macro(param) {
|
||||||
var sourcecode = this.getContent();
|
var sourcecode = this.getContent();
|
||||||
if (param.as=="highlighted") {
|
if (param.as == "highlighted") {
|
||||||
|
|
||||||
sourcecode = encode(sourcecode);
|
sourcecode = encode(sourcecode);
|
||||||
|
|
||||||
// highlight macro tags
|
// highlight macro tags
|
||||||
r = new RegExp("<%","gim");
|
r = new RegExp("<%", "gim");
|
||||||
sourcecode = sourcecode.replace(r, '<font color="#aa3300"><%');
|
sourcecode = sourcecode.replace(r, '<font color="#aa3300"><%');
|
||||||
|
|
||||||
r = new RegExp("%>","gim");
|
r = new RegExp("%>", "gim");
|
||||||
sourcecode = sourcecode.replace(r, '%></font>');
|
sourcecode = sourcecode.replace(r, '%></font>');
|
||||||
|
|
||||||
// highlight js-comments
|
// highlight js-comments
|
||||||
|
@ -113,24 +125,24 @@ function source_macro(param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all CR and LF, just <br> remains
|
// remove all CR and LF, just <br> remains
|
||||||
var r = new RegExp("[\\r\\n]","gm");
|
var r = new RegExp("[\\r\\n]", "gm");
|
||||||
sourcecode = sourcecode.replace(r, "");
|
sourcecode = sourcecode.replace(r, "");
|
||||||
|
|
||||||
var arr = sourcecode.split("<br />");
|
var arr = sourcecode.split("<br />");
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
res.write('<font color="#aaaaaa">' + (i+1) + ':</font> ');
|
res.write('<font color="#aaaaaa">' + (i + 1) + ':</font> ');
|
||||||
if (i<99) {
|
if (i < 99) {
|
||||||
res.write(' ');
|
res.write(' ');
|
||||||
}
|
}
|
||||||
if (i<9) {
|
if (i < 9) {
|
||||||
res.write(' ');
|
res.write(' ');
|
||||||
}
|
}
|
||||||
res.write(arr[i] + "\n");
|
res.write(arr[i] + "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
res.write(sourcecode);
|
res.write(sourcecode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
function list_action () {
|
function list_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth()==false)
|
if (checkAuth() == false)
|
||||||
return;
|
return;
|
||||||
res.data.body = this.renderSkinAsString ("list");
|
res.data.body = this.renderSkinAsString("list");
|
||||||
renderSkin ("api");
|
renderSkin("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
function main_action () {
|
function main_action() {
|
||||||
if (checkAddress()==false)
|
if (checkAddress() == false)
|
||||||
return;
|
return;
|
||||||
if (checkAuth()==false)
|
if (checkAuth() == false)
|
||||||
return;
|
return;
|
||||||
res.data.body = this.renderSkinAsString ("main");
|
res.data.body = this.renderSkinAsString("main");
|
||||||
renderSkin ("api");
|
renderSkin("api");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
<% this.methods separator=", " filter="functions" skin="asParentListItem" prefix="<b>Functions: </b>" suffix="<br/>" %>
|
<% this.methods separator=", " filter="functions" skin="asParentListItem" prefix="<b>Functions: </b>" suffix="<br/>" %>
|
||||||
<% this.methods separator=", " filter="macros" skin="asParentListItem" prefix="<b>Macros: </b>" suffix="<br/>" %>
|
<% this.methods separator=", " filter="macros" skin="asParentListItem" prefix="<b>Macros: </b>" suffix="<br/>" %>
|
||||||
<% this.methods separator=", " filter="skins" skin="asParentListItem" prefix="<b>Skins: </b>" suffix="<br/>" %>
|
<% this.methods separator=", " filter="skins" skin="asParentListItem" prefix="<b>Skins: </b>" suffix="<br/>" %>
|
||||||
<% this.methods separator=", " filter="templates" skin="asParentListItem" prefix="<b>Templates: </b>" suffix="<br/>" %>
|
|
||||||
|
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
///**
|
///**
|
||||||
// * utility function for head_macro, rendering link to app and to prototype
|
// * utility function for head_macro, rendering link to app and to prototype
|
||||||
// */
|
// */
|
||||||
|
@ -10,25 +9,24 @@
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
function translateType(filter) {
|
||||||
function translateType (filter) {
|
if (filter == "actions")
|
||||||
if (filter=="actions")
|
return Packages.helma.doc.DocElement.ACTION;
|
||||||
return Packages.helma.doc.DocElement.ACTION;
|
else if (filter == "functions")
|
||||||
else if (filter=="templates")
|
return Packages.helma.doc.DocElement.FUNCTION;
|
||||||
return Packages.helma.doc.DocElement.TEMPLATE;
|
else if (filter == "macros")
|
||||||
else if (filter=="functions")
|
return Packages.helma.doc.DocElement.MACRO;
|
||||||
return Packages.helma.doc.DocElement.FUNCTION;
|
else if (filter == "skins")
|
||||||
else if (filter=="macros")
|
return Packages.helma.doc.DocElement.SKIN;
|
||||||
return Packages.helma.doc.DocElement.MACRO;
|
else if (filter == "properties")
|
||||||
else if (filter=="skins")
|
return Packages.helma.doc.DocElement.PROPERTIES;
|
||||||
return Packages.helma.doc.DocElement.SKIN;
|
else
|
||||||
else
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getApplication () {
|
function getApplication() {
|
||||||
return this.getParentElement ();
|
return this.getParentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
<% this.methods filter="functions" skin="asListItem" prefix="<p><b>Functions:</b><br/>" suffix="</p> %>
|
<% this.methods filter="functions" skin="asListItem" prefix="<p><b>Functions:</b><br/>" suffix="</p> %>
|
||||||
<% this.methods filter="macros" skin="asListItem" prefix="<p><b>Macros:</b><br/>" suffix="</p> %>
|
<% this.methods filter="macros" skin="asListItem" prefix="<p><b>Macros:</b><br/>" suffix="</p> %>
|
||||||
<% this.methods filter="skins" skin="asListItem" prefix="<p><b>Skins:</b><br/>" suffix="</p> %>
|
<% this.methods filter="skins" skin="asListItem" prefix="<p><b>Skins:</b><br/>" suffix="</p> %>
|
||||||
<% this.methods filter="templates" skin="asListItem" prefix="<p><b>Templates:</b><br/>" suffix="</p> %>
|
|
||||||
|
|
||||||
|
|
|
@ -1,91 +1,105 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro rendering a skin
|
* macro rendering a skin
|
||||||
* @param name name of skin
|
* @param name name of skin
|
||||||
*/
|
*/
|
||||||
function skin_macro(par) {
|
function skin_macro(par) {
|
||||||
if ( par && par.name ) {
|
if (par && par.name) {
|
||||||
this.renderSkin(par.name);
|
this.renderSkin(par.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro-wrapper for href-function
|
* macro-wrapper for href-function
|
||||||
* @param action name of action to call on this prototype, default main
|
* @param action name of action to call on this prototype, default main
|
||||||
*/
|
*/
|
||||||
function href_macro(param) { return this.href ((param && param.action) ? param.action : "main"); }
|
function href_macro(param) {
|
||||||
|
return this.href((param && param.action) ? param.action : "main");
|
||||||
|
}
|
||||||
|
|
||||||
function comment_macro (param) { return renderComment (this, param); }
|
function comment_macro(param) {
|
||||||
function content_macro (param) { return this.getContent (); }
|
return renderComment(this, param);
|
||||||
function tags_macro (param) { return renderTags (this, param); }
|
}
|
||||||
function location_macro (param) { return renderLocation (this, param); }
|
|
||||||
function link_macro (param) { return renderLink (this, param); }
|
function content_macro(param) {
|
||||||
|
return this.getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
function tags_macro(param) {
|
||||||
|
return renderTags(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
function location_macro(param) {
|
||||||
|
return renderLocation(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
function link_macro(param) {
|
||||||
|
return renderLink(this, param);
|
||||||
|
}
|
||||||
|
|
||||||
//// END OF COPIED FUNCTIONS
|
//// END OF COPIED FUNCTIONS
|
||||||
|
|
||||||
|
|
||||||
|
function headline_macro(param) {
|
||||||
function headline_macro (param) {
|
res.write(this.getName());
|
||||||
res.write (this.getName ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro formatting list of methods of this prototype
|
* macro formatting list of methods of this prototype
|
||||||
* @param filter actions | functions | macros | templates | skins
|
* @param filter actions | functions | macros | skins
|
||||||
* @param skin skin to apply to the docfunction object
|
* @param skin skin to apply to the docfunction object
|
||||||
* @param separator
|
* @param separator
|
||||||
* @param desc Description that is passed on to the called skin
|
* @param desc Description that is passed on to the called skin
|
||||||
*/
|
*/
|
||||||
function methods_macro (param) {
|
function methods_macro(param) {
|
||||||
var skinname = (param.skin) ? param.skin : "list";
|
var skinname = (param.skin) ? param.skin : "list";
|
||||||
var separator = (param.separator) ? param.separator : "";
|
var separator = (param.separator) ? param.separator : "";
|
||||||
var arr = this.listChildren ();
|
var arr = this.listChildren();
|
||||||
var type = this.translateType (param.filter);
|
var type = this.translateType(param.filter);
|
||||||
var sb = new java.lang.StringBuffer ();
|
var sb = new java.lang.StringBuffer ();
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if (arr[i].getType () == type) {
|
if (arr[i].getType() == type) {
|
||||||
sb.append (arr[i].renderSkinAsString (skinname, param));
|
sb.append(arr[i].renderSkinAsString(skinname, param));
|
||||||
sb.append (separator);
|
sb.append(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var str = sb.toString ();
|
var str = sb.toString();
|
||||||
if (str.length>0)
|
if (str.length > 0)
|
||||||
return str.substring (0, str.length - separator.length);
|
return str.substring(0, str.length - separator.length);
|
||||||
else
|
else
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function inheritance_macro (param) {
|
function inheritance_macro(param) {
|
||||||
var action = param.action ? param.action : "main";
|
var action = param.action ? param.action : "main";
|
||||||
var target = param.target ? ('target="' + param.target + '" ') : '';
|
var target = param.target ? ('target="' + param.target + '" ') : '';
|
||||||
var obj = this.getParentPrototype ();
|
var obj = this.getParentPrototype();
|
||||||
if (obj!=null) {
|
if (obj != null) {
|
||||||
obj = this.inheritanceUtil (obj, param);
|
obj = this.inheritanceUtil(obj, param);
|
||||||
}
|
}
|
||||||
if (param.deep=="true") {
|
if (param.deep == "true") {
|
||||||
while (obj!=null) {
|
while (obj != null) {
|
||||||
obj = this.inheritanceUtil (obj, param);
|
obj = this.inheritanceUtil(obj, param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function inheritanceUtil (obj, param) {
|
function inheritanceUtil(obj, param) {
|
||||||
if (obj.getName ()=="hopobject" && param.hopobject!="true")
|
if (obj.getName() == "hopobject" && param.hopobject != "true")
|
||||||
return null;
|
return null;
|
||||||
var tmp = new Object ();
|
var tmp = new Object ();
|
||||||
for (var i in param)
|
for (var i in param)
|
||||||
tmp[i] = param[i];
|
tmp[i] = param[i];
|
||||||
tmp.href = obj.href ((param.action) ? param.action : "main");
|
tmp.href = obj.href((param.action) ? param.action : "main");
|
||||||
delete tmp.hopobject;
|
delete tmp.hopobject;
|
||||||
delete tmp.action;
|
delete tmp.action;
|
||||||
delete tmp.deep;
|
delete tmp.deep;
|
||||||
delete tmp.separator;
|
delete tmp.separator;
|
||||||
res.write (renderLinkTag (tmp));
|
res.write(renderLinkTag(tmp));
|
||||||
res.write (obj.getName () + "</a>");
|
res.write(obj.getName() + "</a>");
|
||||||
if (obj.getParentPrototype ())
|
if (obj.getParentPrototype())
|
||||||
res.write (param.separator);
|
res.write(param.separator);
|
||||||
return obj.getParentPrototype ();
|
return obj.getParentPrototype();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,15 +108,15 @@ function inheritanceUtil (obj, param) {
|
||||||
* if it has got any functions.
|
* if it has got any functions.
|
||||||
* @param skin
|
* @param skin
|
||||||
*/
|
*/
|
||||||
function parentPrototype_macro (param) {
|
function parentPrototype_macro(param) {
|
||||||
var skinname = (param.skin) ? param.skin : "asParentList";
|
var skinname = (param.skin) ? param.skin : "asParentList";
|
||||||
var obj = this.getParentPrototype ();
|
var obj = this.getParentPrototype();
|
||||||
while (obj!=null) {
|
while (obj != null) {
|
||||||
if (obj.listChildren ().length>0) {
|
if (obj.listChildren().length > 0) {
|
||||||
obj.renderSkin (skinname);
|
obj.renderSkin(skinname);
|
||||||
}
|
}
|
||||||
obj = obj.getParentPrototype ();
|
obj = obj.getParentPrototype();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,33 +124,42 @@ function parentPrototype_macro (param) {
|
||||||
* type-properties or not.
|
* type-properties or not.
|
||||||
* @param skin
|
* @param skin
|
||||||
*/
|
*/
|
||||||
function typeProperties_macro (param) {
|
function typeProperties_macro(param) {
|
||||||
var props = this.getTypeProperties ();
|
var props = this.getTypeProperties();
|
||||||
if (props!=null && props.getContent ()!="" ) {
|
var iter = props.getResources();
|
||||||
var sb = new java.lang.StringBuffer ();
|
while (iter.hasNext()) {
|
||||||
// map of all mappings....
|
var tmp = this.renderTypePropertiesResource(iter.next(), props);
|
||||||
var mappings = props.getMappings ();
|
var skinname = (param.skinname) ? param.skinname : "typeproperties";
|
||||||
// parse type.properties linewise:
|
this.renderSkin(skinname, tmp);
|
||||||
var arr = props.getContent ().split ("\n");
|
}
|
||||||
for (var i=0; i<arr.length; i++) {
|
}
|
||||||
arr [i] = arr[i].trim ();
|
|
||||||
// look up in mappings table if line matches:
|
function renderTypePropertiesResource(res, props) {
|
||||||
for (var e = mappings.keys (); e.hasMoreElements (); ) {
|
if (res.getContent() != "") {
|
||||||
var key = e.nextElement ();
|
var sb = new java.lang.StringBuffer ();
|
||||||
var reg = new RegExp ('^' + key + '\\s');
|
// map of all mappings....
|
||||||
if (arr[i].match (reg)) {
|
var mappings = props.getMappings();
|
||||||
// it matched, wrap line in a link to that prototype:
|
// parse type.properties linewise:
|
||||||
var docProtoObj = this.getApplication ().getPrototype (mappings.getProperty (key));
|
var arr = res.getContent().split("\n");
|
||||||
if (docProtoObj!=null) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
arr[i] = '<a href="' + docProtoObj.href ("main") + '#typeproperties">' + arr[i] + '</a>';
|
arr [i] = arr[i].trim();
|
||||||
}
|
// look up in mappings table if line matches:
|
||||||
}
|
for (var e = mappings.keys(); e.hasMoreElements();) {
|
||||||
}
|
var key = e.nextElement();
|
||||||
sb.append (arr[i] + "\n");
|
var reg = new RegExp ('^' + key + '\\s');
|
||||||
}
|
if (arr[i].match(reg)) {
|
||||||
var tmp = new Object ();
|
// it matched, wrap line in a link to that prototype:
|
||||||
tmp.content = sb.toString ();
|
var docProtoObj = this.getApplication().getPrototype(mappings.getProperty(key));
|
||||||
var skinname = (param.skinname) ? param.skinname : "typeproperties";
|
if (docProtoObj != null) {
|
||||||
this.renderSkin (skinname, tmp);
|
arr[i] = '<a href="' + docProtoObj.href("main") + '#typeproperties">' + arr[i] + '</a>';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(arr[i] + "\n");
|
||||||
|
}
|
||||||
|
var tmp = new Object ();
|
||||||
|
tmp.content = sb.toString();
|
||||||
|
tmp.source = res.getName();
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
<a class="navig" href="#functions">FUNCTIONS</a> |
|
<a class="navig" href="#functions">FUNCTIONS</a> |
|
||||||
<a class="navig" href="#macros">MACROS</a> |
|
<a class="navig" href="#macros">MACROS</a> |
|
||||||
<a class="navig" href="#skins">SKINS</a> |
|
<a class="navig" href="#skins">SKINS</a> |
|
||||||
<a class="navig" href="#templates">TEMPLATES</a> |
|
|
||||||
<a class="navig" href="#typeproperties">TYPE.PROPERTIES</a>
|
<a class="navig" href="#typeproperties">TYPE.PROPERTIES</a>
|
||||||
|
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
@ -62,9 +61,9 @@
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||||
filter="templates"
|
filter="properties"
|
||||||
skin="asLargeListItem"
|
skin="asLargeListItemSkin"
|
||||||
prefix="<tr><td class='headline'>Templates<a name='templates'><!-- --></a></td></tr>"
|
prefix="<tr><td class='headline'>type.properties<a name='typeproperties'><!-- --></a></td></tr>"
|
||||||
suffix="<tr><td height='8'> </td></tr>
|
suffix="<tr><td height='8'> </td></tr>
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@
|
||||||
|
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
|
||||||
<% this.typeProperties %>
|
<!-- % this.typeProperties % -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<a name='typeproperties'><!-- --></a>
|
<a name='typeproperties'><!-- --></a>
|
||||||
<table width='90%' border='0' cellspacing='1' cellpadding='5'><tr>
|
<table width='90%' border='0' cellspacing='1' cellpadding='5'><tr>
|
||||||
<td class="headline">type.properties</td>
|
<td class="headline">type.properties in <% param.source %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="mainbox"><pre><% param.content %></pre></td>
|
<td class="mainbox"><pre><% param.content %></pre></td>
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scheduler function, runs global.appStat every minute
|
* scheduler function, runs global.appStat every minute
|
||||||
*/
|
*/
|
||||||
function scheduler() {
|
function scheduler() {
|
||||||
appStat();
|
appStat();
|
||||||
return 60000;
|
return 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,8 +12,8 @@ function scheduler() {
|
||||||
* creates app.data.addressFilter
|
* creates app.data.addressFilter
|
||||||
*/
|
*/
|
||||||
function onStart() {
|
function onStart() {
|
||||||
app.data.addressFilter = createAddressFilter();
|
app.data.addressFilter = createAddressFilter();
|
||||||
app.data.addressString = root.getProperty ("allowadmin");
|
app.data.addressString = root.getProperty("allowadmin");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,80 +21,80 @@ function onStart() {
|
||||||
* hostnames are converted, wildcards are only allowed in ip-addresses
|
* hostnames are converted, wildcards are only allowed in ip-addresses
|
||||||
* (so, no network-names, sorry)
|
* (so, no network-names, sorry)
|
||||||
*/
|
*/
|
||||||
function createAddressFilter() {
|
function createAddressFilter() {
|
||||||
var filter = new Packages.helma.util.InetAddressFilter();
|
var filter = new Packages.helma.util.InetAddressFilter();
|
||||||
var str = root.getProperty("allowadmin");
|
var str = root.getProperty("allowadmin");
|
||||||
if ( str!=null && str!="" ) {
|
if (str != null && str != "") {
|
||||||
var arr = str.split(",");
|
var arr = str.split(",");
|
||||||
for ( var i in arr ) {
|
for (var i in arr) {
|
||||||
var str = new java.lang.String(arr[i]);
|
str = new java.lang.String(arr[i]);
|
||||||
try {
|
try {
|
||||||
filter.addAddress(str.trim());
|
filter.addAddress(str.trim());
|
||||||
} catch (a) {
|
} catch (a) {
|
||||||
try {
|
try {
|
||||||
var str = java.net.InetAddress.getByName(str.trim()).getHostAddress();
|
str = java.net.InetAddress.getByName(str.trim()).getHostAddress();
|
||||||
filter.addAddress (str);
|
filter.addAddress(str);
|
||||||
} catch (b) {
|
} catch (b) {
|
||||||
app.log ("error using address " + arr[i] + ": " + b);
|
app.log("error using address " + arr[i] + ": " + b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.log("no addresses allowed for app manage, all access will be denied");
|
app.log("no addresses allowed for app manage, all access will be denied");
|
||||||
}
|
}
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates the stats in app.data.stat every 5 minutes
|
* updates the stats in app.data.stat every 5 minutes
|
||||||
*/
|
*/
|
||||||
function appStat () {
|
function appStat() {
|
||||||
if (app.data.stat==null)
|
if (app.data.stat == null)
|
||||||
app.data.stat = new HopObject ();
|
app.data.stat = new HopObject ();
|
||||||
if ((new Date()-300000) < app.data.stat.lastRun)
|
if ((new Date() - 300000) < app.data.stat.lastRun)
|
||||||
return;
|
return;
|
||||||
var arr = root.getApplications ();
|
var arr = root.getApplications();
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
var tmp = app.data.stat.get (arr[i].getName());
|
var tmp = app.data.stat[arr[i].getName()];
|
||||||
if (tmp==null) {
|
if (tmp == null) {
|
||||||
tmp = new HopObject();
|
tmp = new HopObject();
|
||||||
tmp.lastTotalRequestCount = 0;
|
tmp.lastTotalRequestCount = 0;
|
||||||
tmp.lastTotalErrorCount = 0;
|
tmp.lastTotalErrorCount = 0;
|
||||||
}
|
}
|
||||||
tmp.requestCount = arr[i].getRequestCount () - tmp.lastTotalRequestCount;
|
tmp.requestCount = arr[i].getRequestCount() - tmp.lastTotalRequestCount;
|
||||||
tmp.lastTotalRequestCount = arr[i].getRequestCount ();
|
tmp.lastTotalRequestCount = arr[i].getRequestCount();
|
||||||
tmp.errorCount = arr[i].getErrorCount () - tmp.lastTotalErrorCount;
|
tmp.errorCount = arr[i].getErrorCount() - tmp.lastTotalErrorCount;
|
||||||
tmp.lastTotalErrorCount = arr[i].getErrorCount ();
|
tmp.lastTotalErrorCount = arr[i].getErrorCount();
|
||||||
app.data.stat.set (arr[i].getName(), tmp);
|
app.data.stat[arr[i].getName()] = tmp;
|
||||||
}
|
}
|
||||||
app.data.stat.lastRun = new Date();
|
app.data.stat.lastRun = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* utility function to sort object-arrays by name
|
* utility function to sort object-arrays by name
|
||||||
*/
|
*/
|
||||||
function sortByName(a,b) {
|
function sortByName(a, b) {
|
||||||
if (a.name > b.name)
|
if (a.name > b.name)
|
||||||
return 1;
|
return 1;
|
||||||
else if (a.name == b.name)
|
else if (a.name == b.name)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* utility function to sort property-arrays by key
|
* utility function to sort property-arrays by key
|
||||||
*/
|
*/
|
||||||
function sortProps(a,b) {
|
function sortProps(a, b) {
|
||||||
if ( a>b )
|
if (a > b)
|
||||||
return 1;
|
return 1;
|
||||||
else if ( a==b )
|
else if (a == b)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,62 +104,62 @@ function sortProps(a,b) {
|
||||||
* object for http-auth and return false.
|
* object for http-auth and return false.
|
||||||
* @arg appObj application object to check against (if adminUsername etc are set in app.properties)
|
* @arg appObj application object to check against (if adminUsername etc are set in app.properties)
|
||||||
*/
|
*/
|
||||||
function checkAuth(appObj) {
|
function checkAuth(appObj) {
|
||||||
if (res && res.data.noWeb==true) {
|
if (res && res.data.noWeb == true) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
var ok = false;
|
var ok = false;
|
||||||
|
|
||||||
// check against root
|
// check against root
|
||||||
var adminAccess = root.getProperty("adminAccess");
|
var adminAccess = root.getProperty("adminAccess");
|
||||||
|
|
||||||
if (adminAccess==null || adminAccess=="") {
|
if (adminAccess == null || adminAccess == "") {
|
||||||
res.redirect (root.href ("makekey"));
|
res.redirect(root.href("makekey"));
|
||||||
}
|
}
|
||||||
|
|
||||||
var uname = req.username;
|
var uname = req.username;
|
||||||
var pwd = req.password;
|
var pwd = req.password;
|
||||||
|
|
||||||
if ( uname==null || uname=="" || pwd==null || pwd=="" )
|
if (uname == null || uname == "" || pwd == null || pwd == "")
|
||||||
return forceAuth();
|
return forceAuth();
|
||||||
|
|
||||||
var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd);
|
var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd);
|
||||||
|
|
||||||
if (md5key==adminAccess)
|
if (md5key == adminAccess)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (appObj!=null && appObj.isActive()) {
|
if (appObj != null && appObj.isActive()) {
|
||||||
// check against application
|
// check against application
|
||||||
adminAccess = appObj.getProperty("adminAccess");
|
adminAccess = appObj.getProperty("adminAccess");
|
||||||
if (md5key==adminAccess)
|
if (md5key == adminAccess)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return forceAuth();
|
return forceAuth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check access to the manage-app by ip-addresses
|
* check access to the manage-app by ip-addresses
|
||||||
*/
|
*/
|
||||||
function checkAddress() {
|
function checkAddress() {
|
||||||
if (res && res.data.noWeb==true) {
|
if (res && res.data.noWeb == true) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// if allowadmin value in server.properties has changed,
|
||||||
|
// re-construct the addressFilter
|
||||||
|
if (app.data.addressString != root.getProperty("allowadmin")) {
|
||||||
|
app.data.addressFilter = createAddressFilter();
|
||||||
|
app.data.addressString = root.getProperty("allowadmin");
|
||||||
|
}
|
||||||
|
if (!app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost))) {
|
||||||
|
app.log("denied request from " + req.data.http_remotehost);
|
||||||
|
// forceStealth seems a bit like overkill here.
|
||||||
|
// display a message that the ip address must be added to server.properties
|
||||||
|
res.write("Access from address " + req.data.http_remotehost + " denied.");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if allowadmin value in server.properties has changed,
|
|
||||||
// re-construct the addressFilter
|
|
||||||
if (app.data.addressString != root.getProperty ("allowadmin")){
|
|
||||||
app.data.addressFilter = createAddressFilter();
|
|
||||||
app.data.addressString = root.getProperty ("allowadmin");
|
|
||||||
}
|
|
||||||
if ( !app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) {
|
|
||||||
app.log("denied request from " + req.data.http_remotehost );
|
|
||||||
// forceStealth seems a bit like overkill here.
|
|
||||||
// display a message that the ip address must be added to server.properties
|
|
||||||
res.write ("Access from address "+req.data.http_remotehost+" denied.");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -169,68 +167,67 @@ function checkAddress() {
|
||||||
* response is reset to 401 / authorization required
|
* response is reset to 401 / authorization required
|
||||||
* @arg realm realm for http-auth
|
* @arg realm realm for http-auth
|
||||||
*/
|
*/
|
||||||
function forceAuth(realm) {
|
function forceAuth(realm) {
|
||||||
res.reset();
|
res.reset();
|
||||||
res.status = 401;
|
res.status = 401;
|
||||||
res.realm = (realm!=null) ? realm : "helma";
|
res.realm = (realm != null) ? realm : "helma";
|
||||||
res.write ("Authorization Required. The server could not verify that you are authorized to access the requested page.");
|
res.write("Authorization Required. The server could not verify that you are authorized to access the requested page.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro-utility: formatting property lists
|
* macro-utility: formatting property lists
|
||||||
*/
|
*/
|
||||||
function formatProperties(props,par) {
|
function formatProperties(props, par) {
|
||||||
if ( props.size()==0 )
|
if (props.size() == 0)
|
||||||
return "";
|
return "";
|
||||||
var e = props.keys();
|
var e = props.keys();
|
||||||
var arr = new Array();
|
var arr = new Array();
|
||||||
while ( e.hasMoreElements() ) {
|
while (e.hasMoreElements()) {
|
||||||
arr[arr.length] = e.nextElement();
|
arr[arr.length] = e.nextElement();
|
||||||
}
|
}
|
||||||
arr.sort(sortProps);
|
arr.sort(sortProps);
|
||||||
for ( var i in arr ) {
|
for (var i in arr) {
|
||||||
// don't print the admin-password
|
// don't print the admin-password
|
||||||
if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue;
|
if (arr[i].toLowerCase() == "adminusername" || arr[i].toLowerCase() == "adminpassword") continue;
|
||||||
res.write ( par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix );
|
res.write(par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro-utility: formatting an integer value as human readable bytes
|
* macro-utility: formatting an integer value as human readable bytes
|
||||||
*/
|
*/
|
||||||
function formatBytes(bytes) {
|
function formatBytes(bytes) {
|
||||||
if ( bytes > Math.pow(2,30) ) {
|
if (bytes > Math.pow(2, 30)) {
|
||||||
res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" );
|
res.write(Math.round(100 * bytes / Math.pow(2, 30)) / 100 + "gb");
|
||||||
} else if ( bytes > Math.pow(2,20) ) {
|
} else if (bytes > Math.pow(2, 20)) {
|
||||||
res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" );
|
res.write(Math.round(100 * bytes / Math.pow(2, 20)) / 100 + "mb");
|
||||||
} else {
|
} else {
|
||||||
res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" );
|
res.write(Math.round(100 * bytes / Math.pow(2, 10)) / 100 + "kb");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* macro-utility: formatting time in millis as human readable age
|
* macro-utility: formatting time in millis as human readable age
|
||||||
*/
|
*/
|
||||||
function formatAge(age) {
|
function formatAge(age) {
|
||||||
var str = "";
|
var str = "";
|
||||||
var days = Math.floor(age/86400);
|
var days = Math.floor(age / 86400);
|
||||||
var age = age - days * 86400;
|
age = age - days * 86400;
|
||||||
var hours = Math.floor(age / 3600);
|
var hours = Math.floor(age / 3600);
|
||||||
var age = age - hours * 3600;
|
age = age - hours * 3600;
|
||||||
var minutes = Math.floor(age / 60);
|
var minutes = Math.floor(age / 60);
|
||||||
var seconds = Math.floor(age - minutes * 60);
|
var seconds = Math.floor(age - minutes * 60);
|
||||||
if (days > 0)
|
if (days > 0)
|
||||||
str += (days + " days, ");
|
str += (days + " days, ");
|
||||||
if (hours>0)
|
if (hours > 0)
|
||||||
str += (hours + "h, ");
|
str += (hours + "h, ");
|
||||||
str += (minutes + "min");
|
str += (minutes + "min");
|
||||||
if (days == 0) str += (", " + seconds + "sec");
|
if (days == 0) str += (", " + seconds + "sec");
|
||||||
return(str);
|
return(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,23 +238,23 @@ function formatAge(age) {
|
||||||
* @param singular string used for value==1
|
* @param singular string used for value==1
|
||||||
* @param plural string used for value!=1
|
* @param plural string used for value!=1
|
||||||
*/
|
*/
|
||||||
function formatCount(ct, par) {
|
function formatCount(ct, par) {
|
||||||
if ( !par || !par.singular || !par.plural ) {
|
if (!par || !par.singular || !par.plural) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if ( ct==1 )
|
if (ct == 1)
|
||||||
return par.singular;
|
return par.singular;
|
||||||
else
|
else
|
||||||
return par.plural;
|
return par.plural;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tries to make out if this server is running linux from java's system properties
|
* tries to make out if this server is running linux from java's system properties
|
||||||
*/
|
*/
|
||||||
function isLinux () {
|
function isLinux() {
|
||||||
var str = java.lang.System.getProperty("os.name");
|
var str = java.lang.System.getProperty("os.name");
|
||||||
return (str!=null && str.toLowerCase().indexOf("linux")!=-1);
|
return (str != null && str.toLowerCase().indexOf("linux") != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
* macro rendering a skin
|
* macro rendering a skin
|
||||||
* @param name name of skin
|
* @param name name of skin
|
||||||
*/
|
*/
|
||||||
function skin_macro(par) {
|
function skin_macro(par) {
|
||||||
if ( par && par.name ) {
|
if (par && par.name) {
|
||||||
renderSkin(par.name);
|
renderSkin(par.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,6 @@ function skin_macro(par) {
|
||||||
* Macro returning the actual date and time.
|
* Macro returning the actual date and time.
|
||||||
*/
|
*/
|
||||||
function now_macro() {
|
function now_macro() {
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
return(date.format("dd.MM.yyyy, HH:mm'h' zzz"));
|
return(date.format("dd.MM.yyyy, HH:mm'h' zzz"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<p></p>
|
<p></p>
|
||||||
<div class="list_apps">
|
<div class="list_apps">
|
||||||
<i>and <% root.appCount filter="disabled" %> disabled apps:</i>
|
<i>disabled apps:</i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% root.appList filter="disabled" skin="navig_disabled" %>
|
<% root.appList filter="disabled" skin="navig_disabled" %>
|
||||||
|
@ -27,4 +27,4 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<li><a href="<% root.href action="makekey" %>">generate server password</a>
|
<li><a href="<% root.href action="makekey" %>">generate server password</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,95 +1,85 @@
|
||||||
|
function renderLink(docEl, param) {
|
||||||
|
var text = "";
|
||||||
function renderLink (docEl, param) {
|
if (docEl.getType() == docEl.APPLICATION || docEl.getType() == docEl.PROTOTYPE) {
|
||||||
var text = "";
|
text = docEl.getName();
|
||||||
if (docEl.getType () == docEl.APPLICATION || docEl.getType () == docEl.PROTOTYPE) {
|
} else if (docEl.getType() == docEl.SKIN) {
|
||||||
text = docEl.getName ();
|
text = docEl.getName() + ".skin";
|
||||||
} else if (docEl.getType () == docEl.SKIN) {
|
} else if (docEl.getType() == docEl.MACRO) {
|
||||||
text = docEl.getName () + ".skin";
|
if (param.handler != "false" && docEl.getParentElement() && docEl.getParentElement().getName() != "global") {
|
||||||
} else if (docEl.getType () == docEl.MACRO) {
|
text = docEl.getParentElement().getName() + ".";
|
||||||
if (param.handler!="false" && docEl.getParentElement () && docEl.getParentElement().getName()!="global") {
|
}
|
||||||
text = docEl.getParentElement ().getName () + ".";
|
var str = docEl.getName();
|
||||||
}
|
if (str.indexOf("_macro")) {
|
||||||
var str = docEl.getName ();
|
text += str.substring(0, str.length - 6);
|
||||||
if (str.indexOf("_macro")) {
|
}
|
||||||
text += str.substring (0, str.length-6);
|
} else if (docEl.getType() == docEl.FUNCTION) {
|
||||||
}
|
text = docEl.getName() + "(";
|
||||||
} else if (docEl.getType () == docEl.FUNCTION) {
|
var arr = docEl.listParameters();
|
||||||
var text = docEl.getName () + "(";
|
for (var i = 0; i < arr.length; i++) {
|
||||||
var arr = docEl.listParameters ();
|
text += arr[i];
|
||||||
for (var i=0; i<arr.length ;i++) {
|
if (i < arr.length - 1)
|
||||||
text += arr[i];
|
text += ", ";
|
||||||
if (i<arr.length-1)
|
}
|
||||||
text += ", ";
|
text += ")";
|
||||||
}
|
} else {
|
||||||
text += ")";
|
text = docEl.getName();
|
||||||
} else {
|
}
|
||||||
text = docEl.getName ();
|
param.href = docEl.href("main");
|
||||||
}
|
if (!param.target) {
|
||||||
param.href = docEl.href ("main");
|
param.target = "main";
|
||||||
if (!param.target) {
|
}
|
||||||
param.target = "main";
|
return renderLinkTag(param) + text + '</a>';
|
||||||
}
|
|
||||||
return renderLinkTag (param) + text + '</a>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function renderLinkTag(param) {
|
||||||
|
var sb = new java.lang.StringBuffer ();
|
||||||
function renderLinkTag (param) {
|
sb.append('<a');
|
||||||
var sb = new java.lang.StringBuffer ();
|
for (var i in param) {
|
||||||
sb.append ('<a');
|
sb.append(' ');
|
||||||
for (var i in param) {
|
sb.append(i);
|
||||||
sb.append (' ');
|
sb.append('="');
|
||||||
sb.append (i);
|
sb.append(param[i]);
|
||||||
sb.append ('="');
|
sb.append('"');
|
||||||
sb.append (param[i]);
|
}
|
||||||
sb.append ('"');
|
sb.append('>');
|
||||||
}
|
return sb.toString();
|
||||||
sb.append ('>');
|
|
||||||
return sb.toString ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renders the name of the location relative to the application
|
* renders the name of the location of a doc element.
|
||||||
* root.
|
*/
|
||||||
*/
|
|
||||||
function renderLocation (docEl, param) {
|
function renderLocation (docEl, param) {
|
||||||
var f = docEl.getLocation ();
|
return docEl.toString();
|
||||||
// with repositories, always display full file path
|
|
||||||
return f.getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renders tag list.
|
* renders tag list.
|
||||||
* @param param.skin skin to render on found DocTags
|
* @param param.skin skin to render on found DocTags
|
||||||
* @param param.separator String printed between tags
|
* @param param.separator String printed between tags
|
||||||
* @param param.type type string (param|return|author|version|see) to filter tags.
|
* @param param.type type string (param|return|author|version|see) to filter tags.
|
||||||
*/
|
*/
|
||||||
function renderTags (docEl, param) {
|
function renderTags(docEl, param) {
|
||||||
var skinname = (param.skin) ? param.skin : "main";
|
var skinname = (param.skin) ? param.skin : "main";
|
||||||
var type = param.type;
|
var type = param.type;
|
||||||
if (type=="params")
|
if (type == "params")
|
||||||
type = "param";
|
|
||||||
else if (type=="returns")
|
|
||||||
type = "return";
|
|
||||||
else if (type=="arg")
|
|
||||||
type = "param";
|
type = "param";
|
||||||
var str = "";
|
else if (type == "returns")
|
||||||
var arr = docEl.listTags ();
|
type = "return";
|
||||||
for (var i=0; i<arr.length; i++) {
|
else if (type == "arg")
|
||||||
if (arr[i].getType () == type) {
|
type = "param";
|
||||||
if (type=="see" || type=="overrides") {
|
var str = "";
|
||||||
param.link = renderReference (arr[i], docEl);
|
var arr = docEl.listTags();
|
||||||
}
|
for (var i = 0; i < arr.length; i++) {
|
||||||
str += arr[i].renderSkinAsString (skinname, param);
|
if (arr[i].getType() == type) {
|
||||||
str += (param.separator) ? param.separator : "";
|
if (type == "see" || type == "overrides") {
|
||||||
}
|
param.link = renderReference(arr[i], docEl);
|
||||||
}
|
}
|
||||||
return str;
|
str += arr[i].renderSkinAsString(skinname, param);
|
||||||
|
str += (param.separator) ? param.separator : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,66 +90,64 @@ function renderTags (docEl, param) {
|
||||||
* @param docTagObj
|
* @param docTagObj
|
||||||
* @param docEl needed to be able to walk up to application object
|
* @param docEl needed to be able to walk up to application object
|
||||||
*/
|
*/
|
||||||
function renderReference (docTagObj, docEl) {
|
function renderReference(docTagObj, docEl) {
|
||||||
// prepare the text:
|
// prepare the text:
|
||||||
var text = docTagObj.getText ();
|
var text = docTagObj.getText();
|
||||||
text = new java.lang.String (text);
|
text = new java.lang.String (text);
|
||||||
text = text.trim ();
|
text = text.trim();
|
||||||
if (text.indexOf("http://")==0) {
|
if (text.indexOf("http://") == 0) {
|
||||||
// an url is a simple job
|
// an url is a simple job
|
||||||
return '<a href="' + text + '" target="_new">' + text + '</a>';
|
return '<a href="' + text + '" target="_new">' + text + '</a>';
|
||||||
} else {
|
} else {
|
||||||
// make sure we only use the first item in the text so that unlinked comments
|
// make sure we only use the first item in the text so that unlinked comments
|
||||||
// can follow, store & split the that
|
// can follow, store & split the that
|
||||||
var tok = new java.util.StringTokenizer (text);
|
var tok = new java.util.StringTokenizer (text);
|
||||||
var tmp = tok.nextToken ();
|
var tmp = tok.nextToken();
|
||||||
text = " " + text.substring (tmp.length + 1);
|
text = " " + text.substring(tmp.length + 1);
|
||||||
var parts = tmp.split(".");
|
var parts = tmp.split(".");
|
||||||
// try to find the application object
|
// try to find the application object
|
||||||
var obj = docEl;
|
var obj = docEl;
|
||||||
while (obj!=null) {
|
while (obj != null) {
|
||||||
if (obj.getType () == Packages.helma.doc.DocElement.APPLICATION) {
|
if (obj.getType() == Packages.helma.doc.DocElement.APPLICATION) {
|
||||||
var appObj = obj;
|
var appObj = obj;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
obj = obj.getParentElement ();
|
obj = obj.getParentElement();
|
||||||
}
|
}
|
||||||
var protoObj = appObj.getChildElement ("prototype_" + parts[0]);
|
var protoObj = appObj.getChildElement("prototype_" + parts[0]);
|
||||||
if (protoObj==null) {
|
if (protoObj == null) {
|
||||||
// prototype wasn't found, return the unlinked tag
|
// prototype wasn't found, return the unlinked tag
|
||||||
return tmp + text;
|
return tmp + text;
|
||||||
}
|
}
|
||||||
if (parts.length==1) {
|
if (parts.length == 1) {
|
||||||
// no function specified, return the linked prototype
|
// no function specified, return the linked prototype
|
||||||
return '<a href="' + protoObj.href ("main") + '">' + format (tmp) + '</a>' + text;
|
return '<a href="' + protoObj.href("main") + '">' + format(tmp) + '</a>' + text;
|
||||||
}
|
}
|
||||||
// try to find a function object:
|
// try to find a function object:
|
||||||
var arr = protoObj.listChildren ();
|
var arr = protoObj.listChildren();
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if (arr[i].getName () == parts [1]) {
|
if (arr[i].getName() == parts [1]) {
|
||||||
return '<a href="' + arr[i].href("main") + '">' + format(tmp) + '</a>' + text;
|
return '<a href="' + arr[i].href("main") + '">' + format(tmp) + '</a>' + text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// function not found:
|
// function not found:
|
||||||
return tmp + text;
|
return tmp + text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function rendering a comment.
|
* function rendering a comment.
|
||||||
* @param param.length comment is shortened to the given length.
|
* @param param.length comment is shortened to the given length.
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
function renderComment (docEl, param) {
|
function renderComment(docEl, param) {
|
||||||
var str = docEl.getComment ();
|
var str = docEl.getComment();
|
||||||
if (param.length) {
|
if (param.length) {
|
||||||
if (param.length < str.length) {
|
if (param.length < str.length) {
|
||||||
return str.substring (0, param.length) + " ...";
|
return str.substring(0, param.length) + " ...";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
130
Root/actions.js
Normal file
130
Root/actions.js
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
/**
|
||||||
|
* main action, show server-stats
|
||||||
|
* perform start, stop, restart and flush-action
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function main_action() {
|
||||||
|
|
||||||
|
if (checkAddress() == false) return;
|
||||||
|
|
||||||
|
if (req.data.app != null && req.data.app != "" && req.data.action != null && req.data.action != "") {
|
||||||
|
|
||||||
|
var appObj = root.getApp(req.data.app);
|
||||||
|
// check access for application. md5-encoded uname/pwd can also be put in
|
||||||
|
// app.properties to limit access to a single app
|
||||||
|
if (checkAuth(appObj) == false) return;
|
||||||
|
|
||||||
|
if (req.data.action == "start") {
|
||||||
|
this.startApplication(req.data.app);
|
||||||
|
res.redirect(appObj.href("main"));
|
||||||
|
|
||||||
|
} else if (req.data.action == "stop") {
|
||||||
|
if (checkAuth() == false) return;
|
||||||
|
this.stopApplication(req.data.app);
|
||||||
|
res.redirect(root.href("main"));
|
||||||
|
|
||||||
|
} else if (req.data.action == "restart") {
|
||||||
|
this.stopApplication(req.data.app);
|
||||||
|
this.startApplication(req.data.app);
|
||||||
|
res.redirect(appObj.href("main"));
|
||||||
|
|
||||||
|
} else if (req.data.action == "flush") {
|
||||||
|
appObj.clearCache();
|
||||||
|
res.redirect(appObj.href("main"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// output only to root
|
||||||
|
if (checkAuth() == false) return;
|
||||||
|
|
||||||
|
res.data.title = "Helma Object Publisher - Serverinfo";
|
||||||
|
res.data.body = this.renderSkinAsString("main");
|
||||||
|
renderSkin("global");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the helma object publisher logo, built into hop core
|
||||||
|
* to be independent of static html-paths
|
||||||
|
*/
|
||||||
|
function image_action() {
|
||||||
|
if (checkAddress() == false) return;
|
||||||
|
|
||||||
|
res.contentType = "image/gif";
|
||||||
|
res.writeBinary(Packages.helma.util.Logo.hop);
|
||||||
|
}
|
||||||
|
|
||||||
|
function makekey_action() {
|
||||||
|
|
||||||
|
if (checkAddress() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var obj = new Object();
|
||||||
|
obj.msg = "";
|
||||||
|
if (req.data.username != null && req.data.password != null) {
|
||||||
|
|
||||||
|
// we have input from webform
|
||||||
|
if (req.data.username == "")
|
||||||
|
obj.msg += "username can't be left empty!<br>";
|
||||||
|
if (req.data.password == "")
|
||||||
|
obj.msg += "password can't be left empty!<br>";
|
||||||
|
if (obj.msg != "") {
|
||||||
|
obj.username = req.data.username;
|
||||||
|
res.reset();
|
||||||
|
res.data.body = renderSkinAsString("pwdform", obj);
|
||||||
|
} else {
|
||||||
|
// render the md5-string:
|
||||||
|
obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "<br>\n";
|
||||||
|
res.data.body = renderSkinAsString("pwdfeedback", obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// no input from webform, so print it
|
||||||
|
res.data.body = renderSkinAsString("pwdform", obj);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
res.data.title = "username & password on " + root.hostname_macro();
|
||||||
|
res.data.head = renderSkinAsString("head");
|
||||||
|
renderSkin("basic");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prints server-stats for mrtg-tool.
|
||||||
|
* doesn't check username or password, so that we don't have
|
||||||
|
* to write them cleartext in a mrtg-configfile but checks the
|
||||||
|
* remote address.
|
||||||
|
*/
|
||||||
|
function mrtg_action() {
|
||||||
|
|
||||||
|
if (checkAddress() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (req.data.action == "memory") {
|
||||||
|
|
||||||
|
res.write(this.jvmTotalMemory_macro() + "\n");
|
||||||
|
res.write(this.jvmFreeMemory_macro() + "\n");
|
||||||
|
res.write("0\n0\n");
|
||||||
|
|
||||||
|
} else if (req.data.action == "netstat" && isLinux()) {
|
||||||
|
|
||||||
|
var str = (new File("/proc/net/tcp")).readAll();
|
||||||
|
var arr = str.split("\n");
|
||||||
|
res.write(arr.length - 2 + "\n");
|
||||||
|
res.write("0\n0\n0\n");
|
||||||
|
|
||||||
|
} else if (req.data.action == "loadavg" && isLinux()) {
|
||||||
|
|
||||||
|
// load average of last 5 minutes:
|
||||||
|
var str = (new File("/proc/loadavg")).readAll();
|
||||||
|
var arr = str.split(" ");
|
||||||
|
res.write(arr[1] * 100 + "\n");
|
||||||
|
res.write("0\n0\n0\n");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
res.write("0\n0\n0\n0\n");
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* renders the api of a given application. used from commandline.
|
* renders the api of a given application. used from commandline.
|
||||||
*/
|
*/
|
||||||
function renderApi(appName) {
|
function renderApi(appName) {
|
||||||
|
|
||||||
// supress security checks when accessing actions
|
// supress security checks when accessing actions
|
||||||
|
@ -15,7 +14,7 @@ function renderApi(appName) {
|
||||||
// now render the api
|
// now render the api
|
||||||
var ct = docApp.renderApi();
|
var ct = docApp.renderApi();
|
||||||
writeln("rendered " + ct + " files");
|
writeln("rendered " + ct + " files");
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
this.stopApplication(appName);
|
this.stopApplication(appName);
|
||||||
}
|
}
|
||||||
|
@ -25,15 +24,15 @@ function renderApi(appName) {
|
||||||
* lists all applications in appdir.
|
* lists all applications in appdir.
|
||||||
* for active apps use this.getApplications() = helma.main.Server.getApplications()
|
* for active apps use this.getApplications() = helma.main.Server.getApplications()
|
||||||
*/
|
*/
|
||||||
function getAllApplications() {
|
function getAllApplications() {
|
||||||
var appsDir = this.getAppsHome();
|
var appsDir = this.getAppsHome();
|
||||||
var dir = appsDir.list();
|
var dir = appsDir.list();
|
||||||
var arr = new Array();
|
var arr = new Array();
|
||||||
for ( var i=0; i<dir.length; i++ ) {
|
for (var i = 0; i < dir.length; i++) {
|
||||||
if ( dir[i].toLowerCase()!="cvs" && dir[i].indexOf(".")==-1 )
|
if (dir[i].toLowerCase() != "cvs" && dir[i].indexOf(".") == -1)
|
||||||
arr[arr.length] = this.getApp(dir[i]);
|
arr[arr.length] = this.getApp(dir[i]);
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,13 +44,13 @@ function getAllApplications() {
|
||||||
* retrieves active applications.
|
* retrieves active applications.
|
||||||
* @arg name of application
|
* @arg name of application
|
||||||
*/
|
*/
|
||||||
function getApp(name) {
|
function getApp(name) {
|
||||||
if ( name==null || name=="" )
|
if (name == null || name == "")
|
||||||
return null;
|
return null;
|
||||||
var appObj = this.getApplication(name);
|
var appObj = this.getApplication(name);
|
||||||
if ( appObj==null )
|
if (appObj == null)
|
||||||
appObj = new application(name);
|
appObj = new Application(name);
|
||||||
return appObj;
|
return appObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* return the helma object publisher logo, built into hop core
|
|
||||||
* to be independent of static html-paths
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( checkAddress()==false ) return;
|
|
||||||
|
|
||||||
res.contentType = "image/gif";
|
|
||||||
res.writeBinary ( Packages.helma.util.Logo.hop );
|
|
||||||
|
|
273
Root/macros.js
273
Root/macros.js
|
@ -2,10 +2,10 @@
|
||||||
* macro rendering a skin
|
* macro rendering a skin
|
||||||
* @param name name of skin
|
* @param name name of skin
|
||||||
*/
|
*/
|
||||||
function skin_macro(par) {
|
function skin_macro(par) {
|
||||||
if ( par && par.name ) {
|
if (par && par.name) {
|
||||||
this.renderSkin(par.name);
|
this.renderSkin(par.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ function skin_macro(par) {
|
||||||
* macro-wrapper for href-function
|
* macro-wrapper for href-function
|
||||||
* @param action name of action to call on this prototype, default main
|
* @param action name of action to call on this prototype, default main
|
||||||
*/
|
*/
|
||||||
function href_macro(par) {
|
function href_macro(par) {
|
||||||
return this.href( (par&&par.action)?par.action:"main" );
|
return this.href((par && par.action)?par.action:"main");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,15 +22,15 @@ function href_macro(par) {
|
||||||
* macro returning the total number of sessions on this server
|
* macro returning the total number of sessions on this server
|
||||||
* @see global.formatCount
|
* @see global.formatCount
|
||||||
*/
|
*/
|
||||||
function countSessions_macro(par) {
|
function countSessions_macro(par) {
|
||||||
var arr = this.getApplications();
|
var arr = this.getApplications();
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for ( var i=0; i<arr.length; i++ ) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if ( arr[i].getName()!=app.__app__.getName() ) {
|
if (arr[i].getName() != app.__app__.getName()) {
|
||||||
sum += arr[i].sessions.size();
|
sum += arr[i].sessions.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum + formatCount(sum,par);
|
return sum + formatCount(sum, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,21 +38,21 @@ function countSessions_macro(par) {
|
||||||
* macro returning the number of requests during the last 5 minutes
|
* macro returning the number of requests during the last 5 minutes
|
||||||
* @see global.formatCount
|
* @see global.formatCount
|
||||||
*/
|
*/
|
||||||
function requestCount_macro(par) {
|
function requestCount_macro(par) {
|
||||||
if (app.data.stat==null) {
|
if (app.data.stat == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var arr = this.getApplications ();
|
var arr = this.getApplications();
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if (arr[i].getName() != app.__app__.getName() ) { // don't include manage app
|
if (arr[i].getName() != app.__app__.getName()) { // don't include manage app
|
||||||
var obj = app.data.stat.get (arr[i].name);
|
var obj = app.data.stat[arr[i].name];
|
||||||
if ( obj!=null ) {
|
if (obj != null) {
|
||||||
sum += obj.requestCount;
|
sum += obj.requestCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum + formatCount (sum,par);
|
return sum + formatCount(sum, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,50 +60,49 @@ function requestCount_macro(par) {
|
||||||
* macro returning the number of errors during the last 5 minutes
|
* macro returning the number of errors during the last 5 minutes
|
||||||
* @see global.formatCount
|
* @see global.formatCount
|
||||||
*/
|
*/
|
||||||
function errorCount_macro(par) {
|
function errorCount_macro(par) {
|
||||||
if (app.data.stat==null) {
|
if (app.data.stat == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var arr = this.getApplications ();
|
var arr = this.getApplications();
|
||||||
var sum = 0;
|
var sum = 0;
|
||||||
for (var i=0; i<arr.length; i++) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
if (arr[i].getName() != app.__app__.getName() ) { // don't include manage app
|
if (arr[i].getName() != app.__app__.getName()) { // don't include manage app
|
||||||
var obj = app.data.stat.get (arr[i].name);
|
var obj = app.data.stat[arr[i].name];
|
||||||
if ( obj!=null ) {
|
if (obj != null) {
|
||||||
sum += obj.errorCount;
|
sum += obj.errorCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sum + formatCount (sum,par);
|
return sum + formatCount(sum, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function extensions_macro(par) {
|
||||||
function extensions_macro (par) {
|
var vec = this.getExtensions();
|
||||||
var vec = this.getExtensions ();
|
var str = "";
|
||||||
var str = "";
|
for (var i = 0; i < vec.size(); i++) {
|
||||||
for (var i=0; i<vec.size(); i++) {
|
str += vec.elementAt(i).getClass().getName();
|
||||||
str += vec.elementAt (i).getClass ().getName ();
|
if (i != (vec.size() - 1)) {
|
||||||
if (i!=(vec.size()-1)) {
|
str += (par && par.separator) ? par.separator : ", ";
|
||||||
str += (par && par.separator) ? par.separator : ", ";
|
}
|
||||||
}
|
}
|
||||||
}
|
return (str == "") ? null : str;
|
||||||
return (str=="") ? null : str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning hostname of this machine
|
* Macro returning hostname of this machine
|
||||||
*/
|
*/
|
||||||
function hostname_macro(par) {
|
function hostname_macro(par) {
|
||||||
return java.net.InetAddress.getLocalHost().getHostName()
|
return java.net.InetAddress.getLocalHost().getHostName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro returning address of this machine
|
* Macro returning address of this machine
|
||||||
*/
|
*/
|
||||||
function hostaddress_macro(par) {
|
function hostaddress_macro(par) {
|
||||||
return java.net.InetAddress.getLocalHost().getHostAddress()
|
return java.net.InetAddress.getLocalHost().getHostAddress()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -112,14 +111,14 @@ function hostaddress_macro(par) {
|
||||||
* the manage application being excluded.
|
* the manage application being excluded.
|
||||||
*/
|
*/
|
||||||
function appCount_macro(par) {
|
function appCount_macro(par) {
|
||||||
if ( par && par.filter=="active" ) {
|
if (par && par.filter == "active") {
|
||||||
var ct = root.getApplications().length-1;
|
var ct = root.getApplications().length - 1;
|
||||||
} else if ( par && par.filter=="disabled" ) {
|
} else if (par && par.filter == "disabled") {
|
||||||
var ct = root.getAllApplications().length - root.getApplications().length;
|
var ct = root.getAllApplications().length - root.getApplications().length;
|
||||||
} else {
|
} else {
|
||||||
var ct = root.getAllApplications().length-1;
|
var ct = root.getAllApplications().length - 1;
|
||||||
}
|
}
|
||||||
return ct + formatCount(ct,par);
|
return ct + formatCount(ct, par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -129,58 +128,58 @@ function appCount_macro(par) {
|
||||||
* @param skin skin of application that will be used.
|
* @param skin skin of application that will be used.
|
||||||
*/
|
*/
|
||||||
function appList_macro(par) {
|
function appList_macro(par) {
|
||||||
var skin = (par && par.skin) ? par.skin : "navig_active";
|
var skin = (par && par.skin) ? par.skin : "navig_active";
|
||||||
var apps = new Array();
|
var apps = new Array();
|
||||||
if ( par && par.filter=="active" ) {
|
if (par && par.filter == "active") {
|
||||||
var arr = root.getApplications();
|
var arr = root.getApplications();
|
||||||
for ( var i=0; i<arr.length; i++ ) {
|
for (var i = 0; i < arr.length; i++) {
|
||||||
apps[apps.length] = arr[i];
|
apps[apps.length] = arr[i];
|
||||||
}
|
}
|
||||||
} else if ( par && par.filter=="disabled" ) {
|
} else if (par && par.filter == "disabled") {
|
||||||
var arr = root.getAllApplications();
|
var arr = root.getAllApplications();
|
||||||
for ( var i in arr ) {
|
for (var i in arr) {
|
||||||
if( arr[i].isActive()==false ) {
|
if (arr[i].isActive() == false) {
|
||||||
apps[apps.length] = arr[i];
|
apps[apps.length] = arr[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var apps = root.getAllApplications();
|
var apps = root.getAllApplications();
|
||||||
}
|
}
|
||||||
apps = apps.sort(sortByName);
|
apps = apps.sort(sortByName);
|
||||||
var html = "";
|
var html = "";
|
||||||
var param = new Object();
|
var param = new Object();
|
||||||
for (var n in apps) {
|
for (var n in apps) {
|
||||||
var a = apps[n];
|
var a = apps[n];
|
||||||
if ( apps[n].name==app.__app__.getName() )
|
if (apps[n].name == app.__app__.getName())
|
||||||
continue;
|
continue;
|
||||||
var item = a.renderSkinAsString(skin);
|
var item = a.renderSkinAsString(skin);
|
||||||
html += item;
|
html += item;
|
||||||
}
|
}
|
||||||
return(html);
|
return(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the server's uptime nicely formatted
|
* Macro that returns the server's uptime nicely formatted
|
||||||
*/
|
*/
|
||||||
function uptime_macro() {
|
function uptime_macro() {
|
||||||
return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 );
|
return formatAge((java.lang.System.currentTimeMillis() - this.starttime) / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the server's version string
|
* Macro that returns the server's version string
|
||||||
*/
|
*/
|
||||||
function version_macro() {
|
function version_macro() {
|
||||||
return this.version;
|
return this.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the home directory of the hop installation
|
* Macro that returns the home directory of the hop installation
|
||||||
*/
|
*/
|
||||||
function home_macro() {
|
function home_macro() {
|
||||||
return this.getHopHome().toString();
|
return this.getHopHome().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,9 +187,9 @@ function home_macro() {
|
||||||
* Macro that returns the free memory in the java virtual machine
|
* Macro that returns the free memory in the java virtual machine
|
||||||
* @param format if "hr", value will be printed human readable
|
* @param format if "hr", value will be printed human readable
|
||||||
*/
|
*/
|
||||||
function jvmFreeMemory_macro (param) {
|
function jvmFreeMemory_macro(param) {
|
||||||
var m = java.lang.Runtime.getRuntime ().freeMemory ();
|
var m = java.lang.Runtime.getRuntime().freeMemory();
|
||||||
return (param && param.hr) ? formatBytes (m) : m;
|
return (param && param.hr) ? formatBytes(m) : m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,9 +197,9 @@ function jvmFreeMemory_macro (param) {
|
||||||
* Macro that returns the total memory available to the java virtual machine
|
* Macro that returns the total memory available to the java virtual machine
|
||||||
* @param format if "hr", value will be printed human readable
|
* @param format if "hr", value will be printed human readable
|
||||||
*/
|
*/
|
||||||
function jvmTotalMemory_macro (param) {
|
function jvmTotalMemory_macro(param) {
|
||||||
var m = java.lang.Runtime.getRuntime().totalMemory();
|
var m = java.lang.Runtime.getRuntime().totalMemory();
|
||||||
return (param && param.hr) ? formatBytes (m) : m;
|
return (param && param.hr) ? formatBytes(m) : m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,25 +207,25 @@ function jvmTotalMemory_macro (param) {
|
||||||
* Macro that returns the used memory in the java virtual machine
|
* Macro that returns the used memory in the java virtual machine
|
||||||
* @param format if "hr", value will be printed human readable
|
* @param format if "hr", value will be printed human readable
|
||||||
*/
|
*/
|
||||||
function jvmUsedMemory_macro(param) {
|
function jvmUsedMemory_macro(param) {
|
||||||
var m = java.lang.Runtime.getRuntime ().totalMemory () - java.lang.Runtime.getRuntime ().freeMemory ();
|
var m = java.lang.Runtime.getRuntime().totalMemory() - java.lang.Runtime.getRuntime().freeMemory();
|
||||||
return (param && param.hr) ? formatBytes (m) : m;
|
return (param && param.hr) ? formatBytes(m) : m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the version and type of the java virtual machine
|
* Macro that returns the version and type of the java virtual machine
|
||||||
*/
|
*/
|
||||||
function jvm_macro() {
|
function jvm_macro() {
|
||||||
return java.lang.System.getProperty("java.version") + " " + java.lang.System.getProperty("java.vendor");
|
return java.lang.System.getProperty("java.version") + " " + java.lang.System.getProperty("java.vendor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the home directory of the java virtual machine
|
* Macro that returns the home directory of the java virtual machine
|
||||||
*/
|
*/
|
||||||
function jvmHome_macro() {
|
function jvmHome_macro() {
|
||||||
return java.lang.System.getProperty("java.home");
|
return java.lang.System.getProperty("java.home");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,52 +233,52 @@ function jvmHome_macro() {
|
||||||
* Macro that greps all jar-files from the class path variable and lists them.
|
* Macro that greps all jar-files from the class path variable and lists them.
|
||||||
* @param separator string that is printed between the items
|
* @param separator string that is printed between the items
|
||||||
*/
|
*/
|
||||||
function jvmJars_macro(par) {
|
function jvmJars_macro(par) {
|
||||||
var separator = (par && par.separator ) ? par.separator : ", ";
|
var separator = (par && par.separator ) ? par.separator : ", ";
|
||||||
var str = java.lang.System.getProperty("java.class.path");
|
var str = java.lang.System.getProperty("java.class.path");
|
||||||
var arr = str.split(".jar");
|
var arr = str.split(".jar");
|
||||||
for ( var i in arr ) {
|
for (var i in arr) {
|
||||||
var str = arr[i];
|
var str = arr[i];
|
||||||
var pos = ( str.lastIndexOf('\\') > str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/');
|
var pos = ( str.lastIndexOf('\\') > str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/');
|
||||||
res.write ( arr[i].substring(pos+1) + ".jar" );
|
res.write(arr[i].substring(pos + 1) + ".jar");
|
||||||
if ( i < arr.length-1 ) res.write ( separator );
|
if (i < arr.length - 1) res.write(separator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the name and version of the server's os
|
* Macro that returns the name and version of the server's os
|
||||||
*/
|
*/
|
||||||
function os_macro() {
|
function os_macro() {
|
||||||
return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version");
|
return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns anything from server.properties
|
* Macro that returns anything from server.properties
|
||||||
*/
|
*/
|
||||||
function property_macro(par) {
|
function property_macro(par) {
|
||||||
if ( par && par.key ) {
|
if (par && par.key) {
|
||||||
return this.getProperty(key);
|
return this.getProperty(key);
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro formatting server.properties
|
* Macro formatting server.properties
|
||||||
*/
|
*/
|
||||||
function properties_macro(par) {
|
function properties_macro(par) {
|
||||||
formatProperties(this.getProperties(),par);
|
formatProperties(this.getProperties(), par);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro that returns the timezone of this server
|
* Macro that returns the timezone of this server
|
||||||
*/
|
*/
|
||||||
function timezone_macro(par) {
|
function timezone_macro(par) {
|
||||||
return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")";
|
return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/**
|
|
||||||
* main action, show server-stats
|
|
||||||
* perform start, stop, restart and flush-action
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
if ( checkAddress()==false ) return;
|
|
||||||
|
|
||||||
if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data.action!="" ) {
|
|
||||||
|
|
||||||
var appObj = root.getApp(req.data.app);
|
|
||||||
// check access for application. md5-encoded uname/pwd can also be put in
|
|
||||||
// app.properties to limit access to a single app
|
|
||||||
if ( checkAuth(appObj)==false ) return;
|
|
||||||
|
|
||||||
if ( req.data.action=="start" ) {
|
|
||||||
this.startApplication(req.data.app);
|
|
||||||
res.redirect ( appObj.href("main") );
|
|
||||||
|
|
||||||
} else if ( req.data.action=="stop" ) {
|
|
||||||
if ( checkAuth()==false ) return;
|
|
||||||
this.stopApplication(req.data.app);
|
|
||||||
res.redirect ( root.href("main") );
|
|
||||||
|
|
||||||
} else if ( req.data.action=="restart" ) {
|
|
||||||
this.stopApplication(req.data.app);
|
|
||||||
this.startApplication(req.data.app);
|
|
||||||
res.redirect ( appObj.href("main") );
|
|
||||||
|
|
||||||
} else if ( req.data.action=="flush" ) {
|
|
||||||
appObj.clearCache();
|
|
||||||
res.redirect ( appObj.href("main") );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// output only to root
|
|
||||||
if ( checkAuth()==false ) return;
|
|
||||||
|
|
||||||
res.data.title = "Helma Object Publisher - Serverinfo";
|
|
||||||
res.data.body = this.renderSkinAsString("main");
|
|
||||||
renderSkin("global");
|
|
|
@ -1,33 +0,0 @@
|
||||||
|
|
||||||
if (checkAddress()==false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var obj = new Object();
|
|
||||||
obj.msg = "";
|
|
||||||
if (req.data.username!=null && req.data.password!=null) {
|
|
||||||
|
|
||||||
// we have input from webform
|
|
||||||
if ( req.data.username=="" )
|
|
||||||
obj.msg += "username can't be left empty!<br>";
|
|
||||||
if ( req.data.password=="" )
|
|
||||||
obj.msg += "password can't be left empty!<br>";
|
|
||||||
if ( obj.msg!="" ) {
|
|
||||||
obj.username = req.data.username;
|
|
||||||
res.reset();
|
|
||||||
res.data.body = renderSkinAsString ("pwdform",obj);
|
|
||||||
} else {
|
|
||||||
// render the md5-string:
|
|
||||||
obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "<br>\n";
|
|
||||||
res.data.body = renderSkinAsString ("pwdfeedback", obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// no input from webform, so print it
|
|
||||||
res.data.body = renderSkinAsString("pwdform",obj);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
res.data.title = "username & password on " + root.hostname_macro();
|
|
||||||
res.data.head = renderSkinAsString("head");
|
|
||||||
renderSkin("basic");
|
|
|
@ -1,37 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* prints server-stats for mrtg-tool.
|
|
||||||
* doesn't check username or password, so that we don't have
|
|
||||||
* to write them cleartext in a mrtg-configfile but checks the
|
|
||||||
* remote address.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( checkAddress()==false )
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
if (req.data.action=="memory") {
|
|
||||||
|
|
||||||
res.write (this.jvmTotalMemory_macro () + "\n");
|
|
||||||
res.write (this.jvmFreeMemory_macro () + "\n");
|
|
||||||
res.write ("0\n0\n");
|
|
||||||
|
|
||||||
} else if (req.data.action=="netstat" && isLinux ()) {
|
|
||||||
|
|
||||||
var str = (new File("/proc/net/tcp")).readAll();
|
|
||||||
var arr = str.split("\n");
|
|
||||||
res.write (arr.length-2 + "\n");
|
|
||||||
res.write ("0\n0\n0\n");
|
|
||||||
|
|
||||||
} else if (req.data.action=="loadavg" && isLinux ()) {
|
|
||||||
|
|
||||||
// load average of last 5 minutes:
|
|
||||||
var str = (new File("/proc/loadavg")).readAll();
|
|
||||||
var arr = str.split(" ");
|
|
||||||
res.write (arr[1]*100 + "\n");
|
|
||||||
res.write ("0\n0\n0\n");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
res.write ( "0\n0\n0\n0\n");
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Set baseURI for application generated URLs, if necessary.
|
# Set baseURI for application generated URLs, if necessary.
|
||||||
#baseURI = /manage
|
# baseURI = /manage
|
||||||
|
|
||||||
# A short description of what this application is about:
|
# A short description of what this application is about:
|
||||||
_description = Helma's server management console. Start applications, introspection etc.
|
_description = Helma's server management console. Start applications, introspection etc.
|
||||||
|
@ -8,3 +8,5 @@ _description = Helma's server management console. Start applications, introspect
|
||||||
# might take more than one minute on a slow computer
|
# might take more than one minute on a slow computer
|
||||||
requestTimeout = 300
|
requestTimeout = 300
|
||||||
|
|
||||||
|
# run scheduler function each minute
|
||||||
|
cron.scheduler.function = scheduler
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#
|
#
|
||||||
# define the root class of this application
|
# define the root class of this application
|
||||||
#
|
#
|
||||||
|
@ -17,10 +16,10 @@ root.factory.method = getServer
|
||||||
# and, yes, map the root class again.
|
# and, yes, map the root class again.
|
||||||
#
|
#
|
||||||
|
|
||||||
helma.main.Server = root
|
helma.main.Server = Root
|
||||||
helma.framework.core.Application = application
|
helma.framework.core.Application = Application
|
||||||
helma.doc.DocApplication = docapplication
|
helma.doc.DocApplication = DocApplication
|
||||||
helma.doc.DocPrototype = docprototype
|
helma.doc.DocPrototype = DocPrototype
|
||||||
helma.doc.DocFunction = docfunction
|
helma.doc.DocFunction = DocFunction
|
||||||
helma.doc.DocTag = doctag
|
helma.doc.DocTag = DocTag
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ To get the manage-application to work you must:
|
||||||
- add it to the apps.properties file with the following line:
|
- add it to the apps.properties file with the following line:
|
||||||
manage
|
manage
|
||||||
|
|
||||||
- use helma distribution 1.2-RC1 or later.
|
- use helma distribution 1.5 or later.
|
||||||
|
|
||||||
- add the following properties to server.properties:
|
- add the following properties to server.properties:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue