* 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
|
||||
* skins for non-active applications too
|
||||
* @arg name
|
||||
*/
|
||||
function constructor(name) {
|
||||
this.name = name;
|
||||
* construct an application object so that we can use
|
||||
* skins for non-active applications too
|
||||
* @arg name
|
||||
*/
|
||||
function constructor(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* of no use, just to avoid error message
|
||||
*/
|
||||
function onRequest () {
|
||||
function onRequest() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return true/false to determine if application is running
|
||||
*/
|
||||
function isActive() {
|
||||
if ( root.getApplication(this.name)==null )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
function isActive() {
|
||||
if (root.getApplication(this.name) == null)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
*/
|
||||
function skin_macro(par) {
|
||||
if ( par && par.name ) {
|
||||
this.renderSkin(par.name);
|
||||
}
|
||||
function skin_macro(par) {
|
||||
if (par && par.name) {
|
||||
this.renderSkin(par.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,8 +13,8 @@ function skin_macro(par) {
|
|||
* macro-wrapper for href-function
|
||||
* @param action name of action to call on this prototype, default main
|
||||
*/
|
||||
function href_macro(par) {
|
||||
return this.href( (par&&par.action)?par.action:"main" );
|
||||
function href_macro(par) {
|
||||
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)
|
||||
*/
|
||||
function url_macro() {
|
||||
var str = this.getProperty("absoluteuri");
|
||||
if ( str!=null && str!="" ) {
|
||||
return str;
|
||||
} else {
|
||||
return this.getRootHref();
|
||||
}
|
||||
var str = this.getProperty("absoluteuri");
|
||||
if (str != null && str != "") {
|
||||
return str;
|
||||
} else {
|
||||
return this.getRootHref();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,8 +37,8 @@ function url_macro() {
|
|||
* Macro returning the title of an application
|
||||
*/
|
||||
function title_macro() {
|
||||
var title = this.name;
|
||||
return(title);
|
||||
var title = this.name;
|
||||
return(title);
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,25 +49,25 @@ function title_macro() {
|
|||
* @param Object Macro parameter object
|
||||
*/
|
||||
function description_macro(param) {
|
||||
var str = "";
|
||||
var appHome = this.getAppDir();
|
||||
var f = new File(this.getAppDir().toString(), "description.txt");
|
||||
if (!f.exists())
|
||||
f = new File(this.getAppDir().toString(), "doc.html");
|
||||
if (f.exists()) {
|
||||
str = f.readAll();
|
||||
if (str.length > 200)
|
||||
str = str.substring(0, 200) + "...";
|
||||
}
|
||||
return(str);
|
||||
var str = "";
|
||||
var appHome = this.getAppDir();
|
||||
var f = new File(this.getAppDir().toString(), "description.txt");
|
||||
if (!f.exists())
|
||||
f = new File(this.getAppDir().toString(), "doc.html");
|
||||
if (f.exists()) {
|
||||
str = f.readAll();
|
||||
if (str.length > 200)
|
||||
str = str.substring(0, 200) + "...";
|
||||
}
|
||||
return(str);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the server's uptime nicely formatted
|
||||
*/
|
||||
function uptime_macro() {
|
||||
return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 );
|
||||
function uptime_macro() {
|
||||
return formatAge((java.lang.System.currentTimeMillis() - this.starttime) / 1000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,11 +76,11 @@ function uptime_macro() {
|
|||
* parameter used by global.formatCount
|
||||
* @see global.formatCount
|
||||
*/
|
||||
function countSessions_macro(par) {
|
||||
if ( this.isActive()==true )
|
||||
return this.sessions.size() + formatCount(this.sessions.size(),par);
|
||||
else
|
||||
return 0;
|
||||
function countSessions_macro(par) {
|
||||
if (this.isActive() == true)
|
||||
return this.sessions.size() + formatCount(this.sessions.size(), par);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,12 +91,12 @@ function countSessions_macro(par) {
|
|||
* @see application.countUsers_macro
|
||||
* @see application.listUsers_macro
|
||||
*/
|
||||
function users_macro(par) {
|
||||
if ( req.data.showusers=="true" ) {
|
||||
this.listUsers_macro(par);
|
||||
} else {
|
||||
this.countUsers_macro(par);
|
||||
}
|
||||
function users_macro(par) {
|
||||
if (req.data.showusers == "true") {
|
||||
this.listUsers_macro(par);
|
||||
} else {
|
||||
this.countUsers_macro(par);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,11 +106,11 @@ function users_macro(par) {
|
|||
* parameter used by global.formatCount
|
||||
* @see global.formatCount
|
||||
*/
|
||||
function countUsers_macro(par) {
|
||||
if ( this.isActive()==true )
|
||||
return this.activeUsers.size() + formatCount(this.activeUsers.size(),par);
|
||||
else
|
||||
return 0;
|
||||
function countUsers_macro(par) {
|
||||
if (this.isActive() == true)
|
||||
return this.activeUsers.size() + formatCount(this.activeUsers.size(), par);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,93 +118,93 @@ function countUsers_macro(par) {
|
|||
* Macro rendering the list of logged-in users if application is active
|
||||
* @param separator html-code written between elements
|
||||
*/
|
||||
function listUsers_macro(par) {
|
||||
var separator = (par && par.separator) ? par.separator : ", ";
|
||||
if ( this.activeUsers.size()==0 )
|
||||
return "";
|
||||
var e = this.activeUsers.keys();
|
||||
while ( e.hasMoreElements() ) {
|
||||
res.write ( e.nextElement() );
|
||||
if ( e.hasMoreElements() ) {
|
||||
res.write ( separator );
|
||||
}
|
||||
}
|
||||
function listUsers_macro(par) {
|
||||
var separator = (par && par.separator) ? par.separator : ", ";
|
||||
if (this.activeUsers.size() == 0)
|
||||
return "";
|
||||
var users = this.activeUsers.iterator();
|
||||
while (users.hasNext()) {
|
||||
res.write(users.next().__name__);
|
||||
if (users.hasNext()) {
|
||||
res.write(separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the number of active evaluators (=threads)
|
||||
*/
|
||||
function countActiveEvaluators_macro() {
|
||||
return this.countActiveEvaluators();
|
||||
function countActiveEvaluators_macro() {
|
||||
return this.countActiveEvaluators();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the number of free evaluators (=threads)
|
||||
*/
|
||||
function countFreeEvaluators_macro() {
|
||||
return this.countFreeEvaluators();
|
||||
function countFreeEvaluators_macro() {
|
||||
return this.countFreeEvaluators();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the current number of objects in the cache
|
||||
*/
|
||||
function cacheusage_macro (param) {
|
||||
return this.getCacheUsage ();
|
||||
function cacheusage_macro(param) {
|
||||
return this.getCacheUsage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the number of objects allowed in the cache
|
||||
*/
|
||||
function cachesize_macro (param) {
|
||||
return this.getProperty ("cachesize", "1000");
|
||||
function cachesize_macro(param) {
|
||||
return this.getProperty("cachesize", "1000");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting the number of requests in the last 5 minutes
|
||||
*/
|
||||
function requestCount_macro(par) {
|
||||
if (app.data.stat==null || app.data.stat.get (this.name)==null)
|
||||
return "not available";
|
||||
if (this.isActive()) {
|
||||
var obj = app.data.stat.get (this.name);
|
||||
return obj.requestCount + formatCount (obj.requestCount, par);
|
||||
} else {
|
||||
return 0 + formatCount (0,par);
|
||||
}
|
||||
function requestCount_macro(par) {
|
||||
if (app.data.stat == null || app.data.stat[this.name] == null)
|
||||
return "not available";
|
||||
if (this.isActive()) {
|
||||
var obj = app.data.stat[this.name];
|
||||
return obj.requestCount + formatCount(obj.requestCount, par);
|
||||
} else {
|
||||
return 0 + formatCount(0, par);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting the number of errors in the last 5 minutes
|
||||
*/
|
||||
function errorCount_macro(par) {
|
||||
if (app.data.stat==null || app.data.stat.get (this.name)==null)
|
||||
return "not available";
|
||||
if (this.isActive()) {
|
||||
var obj = app.data.stat.get (this.name);
|
||||
return obj.errorCount + formatCount (obj.errorCount, par);
|
||||
} else {
|
||||
return 0 + formatCount (0,par);
|
||||
}
|
||||
function errorCount_macro(par) {
|
||||
if (app.data.stat == null || app.data.stat[this.name] == null)
|
||||
return "not available";
|
||||
if (this.isActive()) {
|
||||
var obj = app.data.stat[this.name];
|
||||
return obj.errorCount + formatCount(obj.errorCount, par);
|
||||
} else {
|
||||
return 0 + formatCount(0, par);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting app.properties
|
||||
*/
|
||||
function properties_macro(par) {
|
||||
formatProperties( this.getProperties(), par );
|
||||
* Macro formatting app.properties
|
||||
*/
|
||||
function properties_macro(par) {
|
||||
formatProperties(this.getProperties(), par);
|
||||
}
|
||||
|
||||
|
||||
function appdir_macro (param) {
|
||||
return this.getAppDir ().toString ();
|
||||
function repositories_macro(param) {
|
||||
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>
|
||||
</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" align="left"><% this.appdir %></td>
|
||||
<td class="list_property" align="left"><% this.repositories %></td>
|
||||
</tr>
|
||||
</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() );
|
Loading…
Add table
Add a link
Reference in a new issue