This commit was generated by cvs2svn to compensate for changes in r2155,
which included commits to RCS files with non-trunk default branches.
This commit is contained in:
parent
72d15e11ab
commit
4a7616d5a0
51 changed files with 1885 additions and 0 deletions
35
Application/functions.js
Normal file
35
Application/functions.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/**
|
||||||
|
* construct an application object so that we can use
|
||||||
|
* skins for non-active applications too
|
||||||
|
* @arg name
|
||||||
|
*/
|
||||||
|
function constructor(name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* overrides the internal href-function, as
|
||||||
|
* helma.framework.core.Application.getNodeHref(Object,String)
|
||||||
|
* isn't able to compute correct urls for non-node objects.
|
||||||
|
* @arg action of application
|
||||||
|
*/
|
||||||
|
function href(action) {
|
||||||
|
var url = getProperty("baseURI");
|
||||||
|
url = (url==null || url=="null") ? "" : url;
|
||||||
|
url += this.name + "/" + ( (action!=null && action!="") ? action : "main" );
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return true/false to determine if application is running
|
||||||
|
*/
|
||||||
|
function isActive() {
|
||||||
|
if ( root.getApplication(this.name)==null )
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
10
Application/head.skin
Normal file
10
Application/head.skin
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<p><big>AppManager <% this.title %></big>
|
||||||
|
<% this.description prefix="<br/>" %>
|
||||||
|
<br/>
|
||||||
|
->
|
||||||
|
<a href="<% this.href action="api" %>/main">AppDoc</a> |
|
||||||
|
<a href="<% this.url %>">public</a> |
|
||||||
|
<a href="<% root.href action="main" %>?app=<% this.title %>&action=flush">flush</a> |
|
||||||
|
<a href="<% root.href action="main" %>?app=<% this.title %>&action=restart">restart</a> |
|
||||||
|
<a href="<% root.href action="main" %>?app=<% this.title %>&action=stop">stop</a>
|
||||||
|
</p>
|
172
Application/macros.js
Normal file
172
Application/macros.js
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
/**
|
||||||
|
* macro rendering a skin
|
||||||
|
* @param name name of skin
|
||||||
|
*/
|
||||||
|
function skin_macro(par) {
|
||||||
|
if ( par && par.name ) {
|
||||||
|
this.renderSkin(par.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the URL of an application.
|
||||||
|
* using absoluteURI if set in app.properties, otherwise we go for the href calculated by
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the title of an application
|
||||||
|
*/
|
||||||
|
function title_macro() {
|
||||||
|
var title = this.name;
|
||||||
|
return(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro rendering a description of an application from a
|
||||||
|
* file called description.txt or doc.html located in the
|
||||||
|
* app's root. Limits description to 200 chars.
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the server's uptime nicely formatted
|
||||||
|
*/
|
||||||
|
function uptime_macro() {
|
||||||
|
return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the number of active sessions.
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the number of logged-in users or the list
|
||||||
|
* of logged-in users if http-parameter showusers is set to true.
|
||||||
|
* Makes use of this.countUsers_macro and this.listUsers_macro
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the number of logged-in users if application
|
||||||
|
* is active
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the number of active evaluators (=threads)
|
||||||
|
*/
|
||||||
|
function countActiveEvaluators_macro() {
|
||||||
|
return this.countActiveEvaluators();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the number of free evaluators (=threads)
|
||||||
|
*/
|
||||||
|
function countFreeEvaluators_macro() {
|
||||||
|
return this.countFreeEvaluators();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro formatting the 5min average of requests.
|
||||||
|
*/
|
||||||
|
function getRequestAvg_macro(par) {
|
||||||
|
if ( app.requestStat==null || app.requestStat.get(this.name)==null )
|
||||||
|
return 0;
|
||||||
|
if ( this.isActive() ) {
|
||||||
|
var obj = app.requestStat.get(this.name);
|
||||||
|
return obj.last5Min + formatCount(obj.last5Min,par);
|
||||||
|
} else {
|
||||||
|
return 0 + formatCount(0,par);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro formatting app.properties
|
||||||
|
*/
|
||||||
|
function properties_macro(par) {
|
||||||
|
formatProperties( this.getProperties(), par );
|
||||||
|
}
|
||||||
|
|
10
Application/main.hac
Normal file
10
Application/main.hac
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* renders AppManager
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ( checkAddress()==false ) return;
|
||||||
|
if ( checkAuth(this)==false ) return;
|
||||||
|
|
||||||
|
res.skin="global";
|
||||||
|
res.body = this.renderSkinAsString("main");
|
||||||
|
|
42
Application/main.skin
Normal file
42
Application/main.skin
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<% this.skin name="head" %>
|
||||||
|
|
||||||
|
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3">application</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">active sessions:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.countSessions %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200"><a href="<% this.href action="main" %>?showusers=true">logged-in users:</a></td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.users %> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">active evaluators:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.countActiveEvaluators %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">free evaluators:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.countFreeEvaluators %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">5min-request-avg:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.getRequestAvg %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">uptime:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.uptime %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3">app.properties</td>
|
||||||
|
</tr>
|
||||||
|
<% this.properties prefix="<tr><td class=\"list_property\" align=\"right\" width=\"200\">" separator="</td><td class=\"list_property\" width=\"5\"> </td><td class=\"list_property\" align=\"left\">" suffix="</td></tr>" %>
|
||||||
|
</table>
|
||||||
|
|
23
Application/mrtg.hac
Normal file
23
Application/mrtg.hac
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
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() + "\n0\n0\n0\n" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( req.data.action=="threads" ) {
|
||||||
|
res.write ( this.countActiveEvaluators() + "\n" + this.countFreeEvaluators() + "\n0\n0\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
15
Application/navig_active.skin
Normal file
15
Application/navig_active.skin
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<div class="list_apps">
|
||||||
|
<b><a href="<% this.href action="main" %>"><% this.title %></a></b><br />
|
||||||
|
<small><% this.countSessions singular=" Session" plural=" Sessions" %>, <% this.getRequestAvg singular=" Request" plural=" Requests" %>/5min</small>
|
||||||
|
<div align="right">
|
||||||
|
<!--<table border="0" cellspacing="0" cellpadding="0">
|
||||||
|
<tr>
|
||||||
|
<td align="right" valign="top"><small>
|
||||||
|
<a href="<% this.href action="api" %>/main">AppDoc</a>
|
||||||
|
<a href="<% root.href action="main" %>?app=<% this.title %>&action=flush">flush</a>
|
||||||
|
<a href="<% root.href action="main" %>?app=<% this.title %>&action=restart">restart</a>
|
||||||
|
</small></td>
|
||||||
|
</tr>
|
||||||
|
</table>-->
|
||||||
|
</div>
|
||||||
|
</div>
|
10
Application/navig_disabled.skin
Normal file
10
Application/navig_disabled.skin
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<div class="list_apps">
|
||||||
|
<table border="0" cellspacing="0" cellpadding="0" align="right">
|
||||||
|
<tr>
|
||||||
|
<td align="right" valign="top"><small>
|
||||||
|
<a href="<% root.href action="main" %>?app=<% this.title %>&action=start">start</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<b><% this.title %></b>
|
||||||
|
</div>
|
10
Application/redirectpublic.hac
Normal file
10
Application/redirectpublic.hac
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* 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() );
|
14
DocApplication/functions.js
Normal file
14
DocApplication/functions.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
/**
|
||||||
|
* overrides the internal href-function, as
|
||||||
|
* helma.framework.core.Application.getNodeHref(Object,String)
|
||||||
|
* isn't able to compute correct urls for non-node objects.
|
||||||
|
* @arg action of application
|
||||||
|
*/
|
||||||
|
function href(action) {
|
||||||
|
var url = getProperty("baseURI");
|
||||||
|
url = (url==null || url=="null") ? "" : url;
|
||||||
|
url += this.name + "/api/" + ( (action!=null && action!="") ? action : "main" );
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
8
DocApplication/head.skin
Normal file
8
DocApplication/head.skin
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<p><big>AppDoc <% this.name %></big>
|
||||||
|
<br/>
|
||||||
|
->
|
||||||
|
<a href="<% this.parentlink %>">AppManager</a> |
|
||||||
|
<a href="<% this.parentlink action="redirectpublic" %>">public</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
11
DocApplication/index.skin
Normal file
11
DocApplication/index.skin
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
<h2>AppDoc <% this.name %></h2>
|
||||||
|
<a name="Index"><!-- --></a>
|
||||||
|
|
||||||
|
|
||||||
|
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||||
|
<% this.index skin="indexList" %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
74
DocApplication/macros.js
Normal file
74
DocApplication/macros.js
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* macro rendering a skin
|
||||||
|
* @param name name of skin
|
||||||
|
*/
|
||||||
|
function skin_macro(par) {
|
||||||
|
if ( par && par.name ) {
|
||||||
|
this.renderSkin(par.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* link to the "real" application object (ie not the DocApplication)
|
||||||
|
*/
|
||||||
|
function parentlink_macro(par) {
|
||||||
|
var url = getProperty("baseURI");
|
||||||
|
url = (url==null || url=="null") ? "" : url;
|
||||||
|
url += this.name + "/";
|
||||||
|
url += (par&&par.action)?par.action:"main";
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list all prototypes of this application
|
||||||
|
* @param skin name of skin to render on prototype
|
||||||
|
*/
|
||||||
|
function prototypes_macro(par) {
|
||||||
|
var skin = (par && par.skin&&par.skin!="")?par.skin:"appList";
|
||||||
|
var arr = this.listPrototypes();
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
arr[i].renderSkin(skin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list all methods of all prototypes, sort and separate them alphabetically
|
||||||
|
* @param skin name of skin to render on method
|
||||||
|
* @param skinSeparator name of skin to render separator between start-letters
|
||||||
|
*/
|
||||||
|
function index_macro(par) {
|
||||||
|
var skin = (par && par.skin && par.skin!="") ? par.skin : "indexList";
|
||||||
|
var skinSeparator = (par && par.skinSeparator && par.skinSeparator!="") ? par.skinSeparator : "indexListSeparator";
|
||||||
|
var arr = this.listFunctions();
|
||||||
|
var lastLetter = '';
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
if ( arr[i].name.substring(0,1)!=lastLetter ) {
|
||||||
|
lastLetter = arr[i].name.substring(0,1);
|
||||||
|
var obj = new Object();
|
||||||
|
obj.letter = lastLetter.toUpperCase();
|
||||||
|
arr[i].renderSkin(skinSeparator,obj);
|
||||||
|
}
|
||||||
|
arr[i].renderSkin(skin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro escaping the request-path, used for handing over redirect urls
|
||||||
|
*/
|
||||||
|
function requestpath_macro(par) {
|
||||||
|
res.write( escape(req.path) );
|
||||||
|
}
|
||||||
|
|
23
DocApplication/main.hac
Normal file
23
DocApplication/main.hac
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
if ( checkAddress()==false ) return;
|
||||||
|
if ( checkAuth(this)==false ) return;
|
||||||
|
|
||||||
|
if ( req.data.action=="reload" ) {
|
||||||
|
var appObj = root.getChildElement(this.name);
|
||||||
|
appObj.docApp = new Packages.helma.doc.DocApplication( this.name, this.location );
|
||||||
|
if ( req.data.redirect != null && req.data.redirect != "" )
|
||||||
|
res.redirect ( getProperty("baseURI") + req.data.redirect );
|
||||||
|
else
|
||||||
|
res.redirect ( this.href("main") );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( req.data.action=="index" ) {
|
||||||
|
res.body = this.renderSkinAsString("index");
|
||||||
|
} else {
|
||||||
|
res.body = this.renderSkinAsString("main");
|
||||||
|
}
|
||||||
|
|
||||||
|
res.skin = "api";
|
||||||
|
res.title = "Application " + this.name;
|
||||||
|
|
||||||
|
|
11
DocApplication/main.skin
Normal file
11
DocApplication/main.skin
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<% this.skin name="head" %>
|
||||||
|
|
||||||
|
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3">Prototypes</td>
|
||||||
|
</tr>
|
||||||
|
<% this.prototypes skin="appList" %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
14
DocApplication/navig.skin
Normal file
14
DocApplication/navig.skin
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<font size="+1"><b><% this.name %></b></font>
|
||||||
|
|
||||||
|
<div class="list_apps">
|
||||||
|
<li><b><a href="<% this.href action="main" %>?action=reload&redirect=<% this.requestpath %>">reload AppDoc</a>
|
||||||
|
<li><b><a href="<% this.href action="main" %>">Application</a></b>
|
||||||
|
<li><b><a href="<% this.href action="main" %>?action=index">Index</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p></p>
|
||||||
|
<p>
|
||||||
|
<i>Prototypes:</i><br />
|
||||||
|
<% this.prototypes skin="navig" %>
|
||||||
|
</p>
|
||||||
|
|
20
DocFunction/functions.js
Normal file
20
DocFunction/functions.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* overrides the internal href-function, as
|
||||||
|
* helma.framework.core.Application.getNodeHref(Object,String)
|
||||||
|
* isn't able to compute correct urls for non-node objects.
|
||||||
|
* @arg action of prototype
|
||||||
|
*/
|
||||||
|
function href(action) {
|
||||||
|
var url = getProperty("baseURI");
|
||||||
|
url = (url==null || url=="null") ? "" : url;
|
||||||
|
url += this.getParentElement().getParentElement().getName() + "/api/" + this.getParentElement().getName() + "/" + this.getTypeName().toLowerCase()+"_"+this.name + "/" + ( (action!=null && action!="") ? action : "main" );
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getApplication() {
|
||||||
|
return this.getParentElement().getParentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
5
DocFunction/indexList.skin
Normal file
5
DocFunction/indexList.skin
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<tr>
|
||||||
|
<td width="200" class="list_property"><b><a href="<% this.prototypehref %>#<% this.name %>"><% this.name %></a></b></td>
|
||||||
|
<td class="list_property"><% this.typename %> in <% this.prototypename %>
|
||||||
|
<td class="list_property"><small>(<a href="<% this.href action="main" %>"><% this.prototypename %>/<% this.location %></a>)</small></td>
|
||||||
|
</tr>
|
3
DocFunction/indexListSeparator.skin
Normal file
3
DocFunction/indexListSeparator.skin
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3"><b> <% param.letter %></b></td>
|
||||||
|
</tr>
|
7
DocFunction/listElementAction.skin
Normal file
7
DocFunction/listElementAction.skin
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||||
|
<code> <% param.group %></code></font></td>
|
||||||
|
<td class="list_property" valign="top"><DL><DT><CODE><B>
|
||||||
|
<a href="<% this.href action="main" %>"><% this.name %></a></B></CODE><DT><DL><% this.comment %><br><small><% this.tags %></small></DT></DL></TD>
|
||||||
|
</tr>
|
||||||
|
|
7
DocFunction/listElementFunction.skin
Normal file
7
DocFunction/listElementFunction.skin
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||||
|
<code> <% param.group %></code></font></td>
|
||||||
|
<td class="list_property" valign="top"><DL><DT><CODE><B>
|
||||||
|
<a href="<% this.href action="main" %>"><% this.name %>(<% this.args %>)</a></B></CODE><small><i> in <% docprototype.name %>/<% this.location %></i></small><DT><DL><% this.comment %><br><small><% this.tags %></small></DT></DL></TD>
|
||||||
|
</tr>
|
||||||
|
|
9
DocFunction/listElementMacro.skin
Normal file
9
DocFunction/listElementMacro.skin
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||||
|
<code> <% param.group %></code></font></td>
|
||||||
|
<td class="list_property" valign="top"><dl><dt><code><b>
|
||||||
|
<a href="<% this.href action="main" %>"><% docprototype.name %>.<% this.name %></a></B></code>
|
||||||
|
<small><i> in <% docprototype.name %>/<% this.location %></i></small>
|
||||||
|
<dt><dl><% this.comment %><br><small><% this.tags %></small></dt></dl></td>
|
||||||
|
</tr>
|
||||||
|
|
7
DocFunction/listElementSkin.skin
Normal file
7
DocFunction/listElementSkin.skin
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||||
|
<code> <% param.group %></code></font></td>
|
||||||
|
<td class="list_property" valign="top"><dl><dt><code><b>
|
||||||
|
<a href="<% this.href action="main" %>"><% docprototype.name %>.<% this.name %></a></B></CODE><DT><DL><% this.comment %><br><small><% this.tags %></small></dt></dl></td>
|
||||||
|
</tr>
|
||||||
|
|
7
DocFunction/listElementTemplate.skin
Normal file
7
DocFunction/listElementTemplate.skin
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||||
|
<code> <% param.group %></code></font></td>
|
||||||
|
<td class="list_property" valign="top"><DL><DT><CODE><B>
|
||||||
|
<a href="<% this.href action="main" %>"><% this.name %>()</a></B></CODE><DT><DL><% this.comment %><br><small><% this.tags %></small></DT></DL></TD>
|
||||||
|
</tr>
|
||||||
|
|
136
DocFunction/macros.js
Normal file
136
DocFunction/macros.js
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
/**
|
||||||
|
* macro rendering a skin
|
||||||
|
* @param name name of skin
|
||||||
|
*/
|
||||||
|
function skin_macro(par) {
|
||||||
|
if ( par && par.name ) {
|
||||||
|
this.renderSkin(par.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning name of file this method resides in
|
||||||
|
*/
|
||||||
|
function location_macro(par) {
|
||||||
|
var f = new File ( this.getLocation() );
|
||||||
|
return f.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the type of this method (Action, Template, Skin, Macro, Function)
|
||||||
|
*/
|
||||||
|
function typename_macro(par) {
|
||||||
|
return this.getTypeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning a link to the prototype page
|
||||||
|
* @param action name of action to call on this prototype, default main
|
||||||
|
*/
|
||||||
|
function prototypehref_macro(par) {
|
||||||
|
return this.getDocPrototype().href( (par&&par.action)?par.action:"main" )
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the name of the prototype this method belongs to
|
||||||
|
*/
|
||||||
|
function prototypename_macro(par) {
|
||||||
|
return this.getDocPrototype().getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the comment text of this method
|
||||||
|
* (excluding the tags!)
|
||||||
|
* @param size (optional) text is cutoff after a number of chars
|
||||||
|
*/
|
||||||
|
function comment_macro(par) {
|
||||||
|
var str = this.getComment();
|
||||||
|
if ( par && par.length && str.length > par.size ) {
|
||||||
|
return ( str.substring(0,par.size) );
|
||||||
|
} else {
|
||||||
|
return ( str );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro rendering the list of tags
|
||||||
|
*/
|
||||||
|
function tags_macro() {
|
||||||
|
var arr = this.listTags();
|
||||||
|
var argCt = 0;
|
||||||
|
for ( var i in arr ) {
|
||||||
|
if ( arr[i].getKind()==Packages.helma.doc.DocTag.ARG )
|
||||||
|
argCt++;
|
||||||
|
res.write( arr[i].render(argCt,this) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro rendering sequence of arg1, arg2 etc
|
||||||
|
* according to number of arguments in doctags.
|
||||||
|
*/
|
||||||
|
function args_macro() {
|
||||||
|
var ct = this.countTags(Packages.helma.doc.DocTag.ARG);
|
||||||
|
for ( var i=0; i<ct; i++) {
|
||||||
|
res.write ( " arg" + (i+1) );
|
||||||
|
if ( i<(ct-1) ) res.write (",");
|
||||||
|
else res.write (" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning nicely formatted sourcecode of this method.
|
||||||
|
* code is encoded, >% %<-tags are colorcoded, line numbers are added
|
||||||
|
*/
|
||||||
|
function source_macro(par) {
|
||||||
|
var str = this.getSource();
|
||||||
|
var arr = str.split("<%");
|
||||||
|
var str2 = "";
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
str2 += encode(arr[i]);
|
||||||
|
if ( i<arr.length-1 )
|
||||||
|
str2 += '<font color="#aa3300"><%';
|
||||||
|
}
|
||||||
|
var arr = str2.split("%>");
|
||||||
|
var str3 = "";
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
str3 += arr[i];
|
||||||
|
if ( i<arr.length-1 )
|
||||||
|
str3 += '%></font>';
|
||||||
|
}
|
||||||
|
var arr = str3.split("<br>");
|
||||||
|
var str4 = "";
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
str4 += '<font color="#aaaaaa">' + (i+1) + ':</font> '
|
||||||
|
if ( i<100 ) str4+=' ';
|
||||||
|
str4 += arr[i] + "<br>";
|
||||||
|
}
|
||||||
|
return ( str4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the fullname of this method
|
||||||
|
*/
|
||||||
|
function fullname_macro(par) {
|
||||||
|
return this.getFullName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
8
DocFunction/main.hac
Normal file
8
DocFunction/main.hac
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
if ( checkAddress()==false ) return;
|
||||||
|
if ( checkAuth(this)==false ) return;
|
||||||
|
|
||||||
|
res.body = this.renderSkinAsString("main");
|
||||||
|
res.skin = "api";
|
||||||
|
res.title = "Application " + this.name;
|
||||||
|
|
||||||
|
|
14
DocFunction/main.skin
Normal file
14
DocFunction/main.skin
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
<a href="<% docprototype.href action="main" %>">Prototype <% docprototype.name %></a><br>
|
||||||
|
<% this.fullname %>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<div class="list_property">
|
||||||
|
<small> <i>in <% docprototype.name%>/<% this.location %>:</i></small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<pre><% this.source %></pre>
|
||||||
|
|
10
DocPrototype/appList.skin
Normal file
10
DocPrototype/appList.skin
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="list_property" align="right" valign="top" width="1%"><font size="-1"><a name="<% this.name %>"><!-- --></a><code> Prototype</code></font>
|
||||||
|
<br></td>
|
||||||
|
<td class="list_property" valign="top"><code><b><a href="<% this.href action="main" %>"><% this.name %></a></b></code><br />
|
||||||
|
<% this.comment %>
|
||||||
|
<br />
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
14
DocPrototype/functions.js
Normal file
14
DocPrototype/functions.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* overrides the internal href-function, as
|
||||||
|
* helma.framework.core.Application.getNodeHref(Object,String)
|
||||||
|
* isn't able to compute correct urls for non-node objects.
|
||||||
|
* @arg action of prototype
|
||||||
|
*/
|
||||||
|
function href(action) {
|
||||||
|
var url = getProperty("baseURI");
|
||||||
|
url = (url==null || url=="null") ? "" : url;
|
||||||
|
url += this.getParentElement().getName() + "/api/" + this.name + "/" + ( (action!=null && action!="") ? action : "main" );
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
3
DocPrototype/listFooter.skin
Normal file
3
DocPrototype/listFooter.skin
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
</table>
|
||||||
|
<br />
|
||||||
|
|
7
DocPrototype/listHeader.skin
Normal file
7
DocPrototype/listHeader.skin
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<a name="<% param.desc %>"><!-- --></a>
|
||||||
|
|
||||||
|
|
||||||
|
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3"><% param.desc %></td>
|
||||||
|
</tr>
|
90
DocPrototype/macros.js
Normal file
90
DocPrototype/macros.js
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/**
|
||||||
|
* macro rendering a skin
|
||||||
|
* @param name name of skin
|
||||||
|
*/
|
||||||
|
function skin_macro(par) {
|
||||||
|
if ( par && par.name ) {
|
||||||
|
this.renderSkin(par.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the comment for this prototype
|
||||||
|
*/
|
||||||
|
function comment_macro(par) {
|
||||||
|
return this.getComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro formatting list of actions of this prototype
|
||||||
|
*/
|
||||||
|
function actions_macro(par) {
|
||||||
|
this.printMethods( Packages.helma.doc.DocElement.ACTION, "listElementAction","Actions" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro formatting list of templates of this prototype
|
||||||
|
*/
|
||||||
|
function templates_macro(par) {
|
||||||
|
this.printMethods( Packages.helma.doc.DocElement.TEMPLATE, "listElementTemplate","Templates" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro formatting list of functions of this prototype
|
||||||
|
*/
|
||||||
|
function functions_macro(par) {
|
||||||
|
this.printMethods( Packages.helma.doc.DocElement.FUNCTION, "listElementFunction","Functions" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro formatting list of skins of this prototype
|
||||||
|
*/
|
||||||
|
function skins_macro(par) {
|
||||||
|
this.printMethods( Packages.helma.doc.DocElement.SKIN, "listElementSkin","Skins" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro formatting list of macros of this prototype
|
||||||
|
*/
|
||||||
|
function macros_macro(par) {
|
||||||
|
this.printMethods( Packages.helma.doc.DocElement.MACRO, "listElementMacro","Macros" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro-utility: renders a list of methods of this prototype
|
||||||
|
* usage of docprototype.listHeader/listFooter skin is hardcoded
|
||||||
|
* @arg type integer - which type of methods are listed
|
||||||
|
* @arg skin skin to be called on method
|
||||||
|
* @arg desc string describing the type of method (ie "Skins", "Actions")
|
||||||
|
*/
|
||||||
|
function printMethods(type,skin,desc) {
|
||||||
|
var arr = this.listFunctions(type);
|
||||||
|
if ( arr.length > 0 ) {
|
||||||
|
var obj = new Object();
|
||||||
|
obj.desc = desc;
|
||||||
|
this.renderSkin("listHeader",obj);
|
||||||
|
for ( var i in arr ) {
|
||||||
|
arr[i].renderSkin(skin,obj);
|
||||||
|
}
|
||||||
|
this.renderSkin("listFooter",obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
8
DocPrototype/main.hac
Normal file
8
DocPrototype/main.hac
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
if ( checkAddress()==false ) return;
|
||||||
|
if ( checkAuth(this)==false ) return;
|
||||||
|
|
||||||
|
res.body = this.renderSkinAsString("main");
|
||||||
|
res.skin = "api";
|
||||||
|
res.title = "Application " + this.name;
|
||||||
|
|
||||||
|
|
9
DocPrototype/main.skin
Normal file
9
DocPrototype/main.skin
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
<h2>Prototype <% this.name %></h2>
|
||||||
|
|
||||||
|
<% this.actions %>
|
||||||
|
<% this.skins %>
|
||||||
|
<% this.macros %>
|
||||||
|
<% this.functions %>
|
||||||
|
<% this.templates %>
|
||||||
|
|
2
DocPrototype/navig.skin
Normal file
2
DocPrototype/navig.skin
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
<a href="<% this.href action="main" %>"><% this.name %></a><br>
|
46
DocTag/renderfunctions.js
Normal file
46
DocTag/renderfunctions.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* function renders list of tags, language is hardcoded here
|
||||||
|
* @arg number of current argument (for formatting arg1, arg2 etc)
|
||||||
|
* @arg method method-object from which we try to find other prototypes/methods
|
||||||
|
* when we're formatting a see tag
|
||||||
|
*/
|
||||||
|
function render(argCt,docFunc) {
|
||||||
|
var str = "";
|
||||||
|
if ( this.getKind() == this.ARG ) {
|
||||||
|
str = "<b>arg" + argCt + ":</b> " + format(this.text);
|
||||||
|
} else if ( this.getKind() == this.PARAM ) {
|
||||||
|
str = "<b>Parameter " + this.name;
|
||||||
|
if ( this.text!=null && this.text!="" ) {
|
||||||
|
str += ":</b> " + format(this.text);
|
||||||
|
}
|
||||||
|
} else if ( this.getKind() == this.RETURNS ) {
|
||||||
|
str = "<b>Returns:</b> " + format(this.text);
|
||||||
|
} else if ( this.getKind() == this.AUTHOR ) {
|
||||||
|
str = "<b>by " + format(this.text) + "</b>";
|
||||||
|
} else if ( this.getKind() == this.VERSION ) {
|
||||||
|
str = "<b>Version " + format(this.text) + "</b>";
|
||||||
|
} else if ( this.getKind() == this.RELEASE ) {
|
||||||
|
str = "<b>since" + format(this.text) + "</b>";
|
||||||
|
} else if ( this.getKind() == this.SEE ) {
|
||||||
|
if ( this.text.indexOf("http://")==0 ) {
|
||||||
|
str = '<a href="' + this.text + '">' + this.text + '</a>';
|
||||||
|
} else {
|
||||||
|
var tmp = new java.lang.String(this.text);
|
||||||
|
tmp = tmp.trim();
|
||||||
|
var arr = tmp.split(".");
|
||||||
|
var obj = docFunc.getApplication().getDocPrototype(arr[0]);
|
||||||
|
if( arr.length>1 && obj.getFunction(arr[1])!=null ) {
|
||||||
|
str = '<b>See also: <a href="' + obj.href("main") + '#' + obj.getFunction(arr[1]).name + '">' + format(tmp) + '</a></b>';
|
||||||
|
} else if ( obj!=null ) {
|
||||||
|
str = '<b>See also: <a href="' + obj.href("main") + '">' + format(tmp) + '</a></b>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( str=="" ) {
|
||||||
|
str = "<b>See also:</b> " + format(this.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return str + "<br />";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
17
Global/api.skin
Normal file
17
Global/api.skin
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||||
|
<HTML>
|
||||||
|
<% skin name="head" %>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table width="90%" border="0" cellspacing="1" cellpadding="5" bgcolor="#000000">
|
||||||
|
<tr>
|
||||||
|
<td width="200" nowrap align="left" valign="top" bgcolor="#cccc99">
|
||||||
|
<p><a href="<% root.href action="main" %>"><img src="<% root.href action="image" %>" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;"></a></p>
|
||||||
|
<% docapplication.skin name="navig" %></td>
|
||||||
|
<td align="left" valign="top" bgcolor="#ffffff"><% response.body %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
155
Global/functions.js
Normal file
155
Global/functions.js
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scheduler function, runs global.appStat every minute
|
||||||
|
*/
|
||||||
|
function scheduler() {
|
||||||
|
appStat();
|
||||||
|
return 60000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initializes requestStat storage on startup
|
||||||
|
*/
|
||||||
|
function onStart() {
|
||||||
|
app.requestStat = new HopObject();
|
||||||
|
app.addressFilter = new Packages.helma.util.InetAddressFilter();
|
||||||
|
var str = root.getProperty("allowadmin");
|
||||||
|
if ( str!=null && str!="" ) {
|
||||||
|
var arr = str.split(",");
|
||||||
|
for ( var i in arr ) {
|
||||||
|
var str = new java.lang.String(arr[i]);
|
||||||
|
app.addressFilter.addAddress(str.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the request stats in app.requestStat every 5 minutes
|
||||||
|
*/
|
||||||
|
function appStat() {
|
||||||
|
if ( app.requestStat==null ) {
|
||||||
|
app.requestStat = new HopObject();
|
||||||
|
}
|
||||||
|
if( (new Date()-300000) < app.requestStat.lastRun ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var arr = root.getApplications();
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
var tmp = app.requestStat.get(arr[i].getName());
|
||||||
|
if ( tmp==null ) {
|
||||||
|
tmp = new HopObject();
|
||||||
|
tmp.lastTotal = 0;
|
||||||
|
tmp.last5Min = 0;
|
||||||
|
}
|
||||||
|
var ct = arr[i].getRequestCount();
|
||||||
|
tmp.last5Min = ct - tmp.lastTotal;
|
||||||
|
tmp.lastTotal = ct;
|
||||||
|
app.requestStat.set(arr[i].getName(), tmp);
|
||||||
|
}
|
||||||
|
app.requestStat.lastRun = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utility function to sort object-arrays by name
|
||||||
|
*/
|
||||||
|
function sortByName(a,b) {
|
||||||
|
if ( a.name>b.name )
|
||||||
|
return 1;
|
||||||
|
else if ( a.name==b.name )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utility function to sort property-arrays by key
|
||||||
|
*/
|
||||||
|
function sortProps(a,b) {
|
||||||
|
if ( a>b )
|
||||||
|
return 1;
|
||||||
|
else if ( a==b )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check access to an application or the whole server, authenticate against md5-encrypted
|
||||||
|
* properties of base-app or the particular application. if username or password aren't set
|
||||||
|
* go into stealth-mode and return a 404. if username|password are wrong, prepare response-
|
||||||
|
* object for http-auth and return false.
|
||||||
|
* @arg application-object
|
||||||
|
*/
|
||||||
|
function checkAuth(appObj) {
|
||||||
|
var ok = false;
|
||||||
|
|
||||||
|
// check against root
|
||||||
|
var rootUsername = root.getProperty("adminusername");
|
||||||
|
var rootPassword = root.getProperty("adminpassword");
|
||||||
|
|
||||||
|
if ( rootUsername==null || rootUsername=="" || rootPassword==null || rootPassword=="" )
|
||||||
|
return forceStealth();
|
||||||
|
|
||||||
|
var uname = req.getUsername();
|
||||||
|
var pwd = req.getPassword();
|
||||||
|
|
||||||
|
if ( uname==null || uname=="" || pwd==null || pwd=="" )
|
||||||
|
return forceAuth();
|
||||||
|
|
||||||
|
var md5password = calcMD5(uname);
|
||||||
|
var md5username = calcMD5(pwd);
|
||||||
|
|
||||||
|
if ( md5username==rootUsername && md5password==rootPassword )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ( appObj!=null && appObj.isActive() ) {
|
||||||
|
// check against application
|
||||||
|
var appUsername = appObj.getProperty("adminusername");
|
||||||
|
var appPassword = appObj.getProperty("adminpassword");
|
||||||
|
if ( appUsername==null || appUsername=="" || appPassword==null || appPassword=="" )
|
||||||
|
return forceStealth();
|
||||||
|
if ( md5username==appUsername && md5password==appPassword )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return forceAuth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check access to the base-app by ip-addresses
|
||||||
|
*/
|
||||||
|
function checkAddress() {
|
||||||
|
if ( !app.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) )
|
||||||
|
return forceStealth();
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* response is reset to 401 / authorization required
|
||||||
|
*/
|
||||||
|
function forceAuth(appObj) {
|
||||||
|
res.status = 401;
|
||||||
|
res.realm = (appObj==null) ? "helma" : appObj.name;
|
||||||
|
res.reset();
|
||||||
|
res.write ("Authorization Required. The server could not verify that you are authorized to access the requested page.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* response is reset to 404 / notfound
|
||||||
|
*/
|
||||||
|
function forceStealth() {
|
||||||
|
res.reset();
|
||||||
|
res.status = 404;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
14
Global/global.skin
Normal file
14
Global/global.skin
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<% skin name="head" %>
|
||||||
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
<table width="90%" border="0" cellspacing="1" cellpadding="5" bgcolor="#000000">
|
||||||
|
<tr>
|
||||||
|
<td width="30%" align="left" valign="top" bgcolor="#cccc99"><% skin name="navig" %></td>
|
||||||
|
<td width="70%" align="left" valign="top" bgcolor="#ffffff"><% response.body %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
53
Global/head.skin
Normal file
53
Global/head.skin
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<head>
|
||||||
|
<title><% response.title %></title>
|
||||||
|
<style type="text/css">
|
||||||
|
<!--
|
||||||
|
|
||||||
|
body, p, td, th, li {
|
||||||
|
font-family: verdana, sans-serif;
|
||||||
|
font-size: 10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list_apps {
|
||||||
|
border-color:#ffffff;
|
||||||
|
padding-top:5px;
|
||||||
|
padding-bottom:5px;
|
||||||
|
border-bottom-width:1px;
|
||||||
|
border-bottom-style:dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list_property {
|
||||||
|
border-color:#999999;
|
||||||
|
padding-top:5px;
|
||||||
|
padding-bottom:5px;
|
||||||
|
border-bottom-width:1px;
|
||||||
|
border-bottom-style:dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list_separator {
|
||||||
|
font-weight:bold;
|
||||||
|
background:#dfdfdf;
|
||||||
|
border-color:#999999;
|
||||||
|
padding-top:5px;
|
||||||
|
padding-bottom:5px;
|
||||||
|
border-bottom-width:1px;
|
||||||
|
border-bottom-style:dotted;
|
||||||
|
}
|
||||||
|
|
||||||
|
big {
|
||||||
|
font-size: 18pt;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
font-weight:bold;
|
||||||
|
color: #cc3333;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration:underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -->
|
||||||
|
</style>
|
||||||
|
</head>
|
97
Global/macros.js
Normal file
97
Global/macros.js
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/**
|
||||||
|
* macro rendering a skin
|
||||||
|
* @param name name of skin
|
||||||
|
*/
|
||||||
|
function skin_macro(par) {
|
||||||
|
if ( par && par.name ) {
|
||||||
|
renderSkin(par.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the actual date and time.
|
||||||
|
*/
|
||||||
|
function now_macro() {
|
||||||
|
var date = new Date();
|
||||||
|
return(date.format("dd.MM.yyyy, HH:mm'h' zzz"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro-utility: formatting property lists
|
||||||
|
*/
|
||||||
|
function formatProperties(props,par) {
|
||||||
|
var prefix = (par && par.prefix) ? par.prefix : "";
|
||||||
|
var suffix = (par && par.suffix) ? par.suffix : "";
|
||||||
|
var separator = (par && par.separator) ? par.separator : "";
|
||||||
|
var e = props.keys();
|
||||||
|
var arr = new Array();
|
||||||
|
if ( e==null )
|
||||||
|
return "";
|
||||||
|
while ( e.hasMoreElements() ) {
|
||||||
|
arr[arr.length] = e.nextElement();
|
||||||
|
}
|
||||||
|
arr.sort(sortProps);
|
||||||
|
for ( var i in arr ) {
|
||||||
|
// don't print the admin-password
|
||||||
|
if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue;
|
||||||
|
res.write ( prefix + arr[i] + separator + props.getProperty(arr[i]) + suffix );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro-utility: formatting an integer value as human readable bytes
|
||||||
|
*/
|
||||||
|
function formatBytes(bytes) {
|
||||||
|
if ( bytes > Math.pow(2,30) ) {
|
||||||
|
res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" );
|
||||||
|
} else if ( bytes > Math.pow(2,20) ) {
|
||||||
|
res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" );
|
||||||
|
} else {
|
||||||
|
res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro-utility: formatting time in millis as human readable age
|
||||||
|
*/
|
||||||
|
function formatAge(age) {
|
||||||
|
var str = "";
|
||||||
|
var days = Math.floor(age/86400);
|
||||||
|
var age = age - days * 86400;
|
||||||
|
var hours = Math.floor(age / 3600);
|
||||||
|
var age = age - hours * 3600;
|
||||||
|
var minutes = Math.floor(age / 60);
|
||||||
|
var seconds = Math.floor(age - minutes * 60);
|
||||||
|
if (days > 0)
|
||||||
|
str += (days + " days, ");
|
||||||
|
if (hours>0)
|
||||||
|
str += (hours + "h, ");
|
||||||
|
str += (minutes + "min");
|
||||||
|
if (days == 0) str += (", " + seconds + "sec");
|
||||||
|
return(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro-utility: formatting a number-suffix by choosing between singular and plural
|
||||||
|
* @arg value number to be formatted
|
||||||
|
* @arg param-object object to get fields
|
||||||
|
* @param singular string used for value==1
|
||||||
|
* @param plural string used for value!=1
|
||||||
|
*/
|
||||||
|
function formatCount(ct, par) {
|
||||||
|
if ( !par || !par.singular || !par.plural ) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if ( ct==1 )
|
||||||
|
return par.singular;
|
||||||
|
else
|
||||||
|
return par.plural;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
178
Global/md5.js
Normal file
178
Global/md5.js
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
/*
|
||||||
|
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||||
|
* Digest Algorithm, as defined in RFC 1321.
|
||||||
|
* Copyright (C) Paul Johnston 1999 - 2000.
|
||||||
|
* Updated by Greg Holt 2000 - 2001.
|
||||||
|
* See http://pajhome.org.uk/site/legal.html for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take a string and return the hex representation of its MD5.
|
||||||
|
* @arg string
|
||||||
|
*/
|
||||||
|
function calcMD5(str)
|
||||||
|
{
|
||||||
|
x = str2blks_MD5(str);
|
||||||
|
a = 1732584193;
|
||||||
|
b = -271733879;
|
||||||
|
c = -1732584194;
|
||||||
|
d = 271733878;
|
||||||
|
|
||||||
|
for(i = 0; i < x.length; i += 16)
|
||||||
|
{
|
||||||
|
olda = a;
|
||||||
|
oldb = b;
|
||||||
|
oldc = c;
|
||||||
|
oldd = d;
|
||||||
|
|
||||||
|
a = ff(a, b, c, d, x[i+ 0], 7 , -680876936);
|
||||||
|
d = ff(d, a, b, c, x[i+ 1], 12, -389564586);
|
||||||
|
c = ff(c, d, a, b, x[i+ 2], 17, 606105819);
|
||||||
|
b = ff(b, c, d, a, x[i+ 3], 22, -1044525330);
|
||||||
|
a = ff(a, b, c, d, x[i+ 4], 7 , -176418897);
|
||||||
|
d = ff(d, a, b, c, x[i+ 5], 12, 1200080426);
|
||||||
|
c = ff(c, d, a, b, x[i+ 6], 17, -1473231341);
|
||||||
|
b = ff(b, c, d, a, x[i+ 7], 22, -45705983);
|
||||||
|
a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
|
||||||
|
d = ff(d, a, b, c, x[i+ 9], 12, -1958414417);
|
||||||
|
c = ff(c, d, a, b, x[i+10], 17, -42063);
|
||||||
|
b = ff(b, c, d, a, x[i+11], 22, -1990404162);
|
||||||
|
a = ff(a, b, c, d, x[i+12], 7 , 1804603682);
|
||||||
|
d = ff(d, a, b, c, x[i+13], 12, -40341101);
|
||||||
|
c = ff(c, d, a, b, x[i+14], 17, -1502002290);
|
||||||
|
b = ff(b, c, d, a, x[i+15], 22, 1236535329);
|
||||||
|
|
||||||
|
a = gg(a, b, c, d, x[i+ 1], 5 , -165796510);
|
||||||
|
d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
|
||||||
|
c = gg(c, d, a, b, x[i+11], 14, 643717713);
|
||||||
|
b = gg(b, c, d, a, x[i+ 0], 20, -373897302);
|
||||||
|
a = gg(a, b, c, d, x[i+ 5], 5 , -701558691);
|
||||||
|
d = gg(d, a, b, c, x[i+10], 9 , 38016083);
|
||||||
|
c = gg(c, d, a, b, x[i+15], 14, -660478335);
|
||||||
|
b = gg(b, c, d, a, x[i+ 4], 20, -405537848);
|
||||||
|
a = gg(a, b, c, d, x[i+ 9], 5 , 568446438);
|
||||||
|
d = gg(d, a, b, c, x[i+14], 9 , -1019803690);
|
||||||
|
c = gg(c, d, a, b, x[i+ 3], 14, -187363961);
|
||||||
|
b = gg(b, c, d, a, x[i+ 8], 20, 1163531501);
|
||||||
|
a = gg(a, b, c, d, x[i+13], 5 , -1444681467);
|
||||||
|
d = gg(d, a, b, c, x[i+ 2], 9 , -51403784);
|
||||||
|
c = gg(c, d, a, b, x[i+ 7], 14, 1735328473);
|
||||||
|
b = gg(b, c, d, a, x[i+12], 20, -1926607734);
|
||||||
|
|
||||||
|
a = hh(a, b, c, d, x[i+ 5], 4 , -378558);
|
||||||
|
d = hh(d, a, b, c, x[i+ 8], 11, -2022574463);
|
||||||
|
c = hh(c, d, a, b, x[i+11], 16, 1839030562);
|
||||||
|
b = hh(b, c, d, a, x[i+14], 23, -35309556);
|
||||||
|
a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
|
||||||
|
d = hh(d, a, b, c, x[i+ 4], 11, 1272893353);
|
||||||
|
c = hh(c, d, a, b, x[i+ 7], 16, -155497632);
|
||||||
|
b = hh(b, c, d, a, x[i+10], 23, -1094730640);
|
||||||
|
a = hh(a, b, c, d, x[i+13], 4 , 681279174);
|
||||||
|
d = hh(d, a, b, c, x[i+ 0], 11, -358537222);
|
||||||
|
c = hh(c, d, a, b, x[i+ 3], 16, -722521979);
|
||||||
|
b = hh(b, c, d, a, x[i+ 6], 23, 76029189);
|
||||||
|
a = hh(a, b, c, d, x[i+ 9], 4 , -640364487);
|
||||||
|
d = hh(d, a, b, c, x[i+12], 11, -421815835);
|
||||||
|
c = hh(c, d, a, b, x[i+15], 16, 530742520);
|
||||||
|
b = hh(b, c, d, a, x[i+ 2], 23, -995338651);
|
||||||
|
|
||||||
|
a = ii(a, b, c, d, x[i+ 0], 6 , -198630844);
|
||||||
|
d = ii(d, a, b, c, x[i+ 7], 10, 1126891415);
|
||||||
|
c = ii(c, d, a, b, x[i+14], 15, -1416354905);
|
||||||
|
b = ii(b, c, d, a, x[i+ 5], 21, -57434055);
|
||||||
|
a = ii(a, b, c, d, x[i+12], 6 , 1700485571);
|
||||||
|
d = ii(d, a, b, c, x[i+ 3], 10, -1894986606);
|
||||||
|
c = ii(c, d, a, b, x[i+10], 15, -1051523);
|
||||||
|
b = ii(b, c, d, a, x[i+ 1], 21, -2054922799);
|
||||||
|
a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
|
||||||
|
d = ii(d, a, b, c, x[i+15], 10, -30611744);
|
||||||
|
c = ii(c, d, a, b, x[i+ 6], 15, -1560198380);
|
||||||
|
b = ii(b, c, d, a, x[i+13], 21, 1309151649);
|
||||||
|
a = ii(a, b, c, d, x[i+ 4], 6 , -145523070);
|
||||||
|
d = ii(d, a, b, c, x[i+11], 10, -1120210379);
|
||||||
|
c = ii(c, d, a, b, x[i+ 2], 15, 718787259);
|
||||||
|
b = ii(b, c, d, a, x[i+ 9], 21, -343485551);
|
||||||
|
|
||||||
|
a = add(a, olda);
|
||||||
|
b = add(b, oldb);
|
||||||
|
c = add(c, oldc);
|
||||||
|
d = add(d, oldd);
|
||||||
|
}
|
||||||
|
return rhex(a) + rhex(b) + rhex(c) + rhex(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a 32-bit number to a hex string with ls-byte first
|
||||||
|
*/
|
||||||
|
var hex_chr = "0123456789abcdef";
|
||||||
|
function rhex(num)
|
||||||
|
{
|
||||||
|
str = "";
|
||||||
|
for(j = 0; j <= 3; j++)
|
||||||
|
str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) +
|
||||||
|
hex_chr.charAt((num >> (j * 8)) & 0x0F);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a string to a sequence of 16-word blocks, stored as an array.
|
||||||
|
* Append padding bits and the length, as described in the MD5 standard.
|
||||||
|
*/
|
||||||
|
function str2blks_MD5(str)
|
||||||
|
{
|
||||||
|
nblk = ((str.length + 8) >> 6) + 1;
|
||||||
|
blks = new Array(nblk * 16);
|
||||||
|
for(i = 0; i < nblk * 16; i++) blks[i] = 0;
|
||||||
|
for(i = 0; i < str.length; i++)
|
||||||
|
blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8);
|
||||||
|
blks[i >> 2] |= 0x80 << ((i % 4) * 8);
|
||||||
|
blks[nblk * 16 - 2] = str.length * 8;
|
||||||
|
return blks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||||
|
* to work around bugs in some JS interpreters.
|
||||||
|
*/
|
||||||
|
function add(x, y)
|
||||||
|
{
|
||||||
|
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||||
|
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||||
|
return (msw << 16) | (lsw & 0xFFFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bitwise rotate a 32-bit number to the left
|
||||||
|
*/
|
||||||
|
function rol(num, cnt)
|
||||||
|
{
|
||||||
|
return (num << cnt) | (num >>> (32 - cnt));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions implement the basic operation for each round of the
|
||||||
|
* algorithm.
|
||||||
|
*/
|
||||||
|
function cmn(q, a, b, x, s, t)
|
||||||
|
{
|
||||||
|
return add(rol(add(add(a, q), add(x, t)), s), b);
|
||||||
|
}
|
||||||
|
function ff(a, b, c, d, x, s, t)
|
||||||
|
{
|
||||||
|
return cmn((b & c) | ((~b) & d), a, b, x, s, t);
|
||||||
|
}
|
||||||
|
function gg(a, b, c, d, x, s, t)
|
||||||
|
{
|
||||||
|
return cmn((b & d) | (c & (~d)), a, b, x, s, t);
|
||||||
|
}
|
||||||
|
function hh(a, b, c, d, x, s, t)
|
||||||
|
{
|
||||||
|
return cmn(b ^ c ^ d, a, b, x, s, t);
|
||||||
|
}
|
||||||
|
function ii(a, b, c, d, x, s, t)
|
||||||
|
{
|
||||||
|
return cmn(c ^ (b | (~d)), a, b, x, s, t);
|
||||||
|
}
|
17
Global/navig.skin
Normal file
17
Global/navig.skin
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<p><a href="<% root.href action="main" %>"><img src="<% root.href action="image" %>" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;"></a></p>
|
||||||
|
<!--<p>at <b><a href="<% root.href action="main" %>?action=server"><% root.hostname %></a></b></p>-->
|
||||||
|
|
||||||
|
<div class="list_apps">
|
||||||
|
<i><% root.appCount filter="active" singular=" app" plural=" apps"%> on <% root.hostname %></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% root.appList filter="active" %>
|
||||||
|
|
||||||
|
<p></p>
|
||||||
|
|
||||||
|
<div class="list_apps">
|
||||||
|
<i>and <% root.appCount filter="disabled" %> disabled apps:</i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% root.appList filter="disabled" skin="navig_disabled" %>
|
||||||
|
|
36
Root/functions.js
Normal file
36
Root/functions.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists all applications in appdir.
|
||||||
|
* for active apps use this.getApplications() = helma.main.Server.getApplications()
|
||||||
|
*/
|
||||||
|
function getAllApplications() {
|
||||||
|
var appsDir = this.getAppsHome();
|
||||||
|
var dir = appsDir.list();
|
||||||
|
var arr = new Array();
|
||||||
|
for ( var i=0; i<dir.length; i++ ) {
|
||||||
|
if ( dir[i].toLowerCase()!="cvs" && dir[i].indexOf(".")==-1 )
|
||||||
|
arr[arr.length] = this.getApp(dir[i]);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get application by name, constructs an hopobject of the prototype application
|
||||||
|
* if the app is not running (and therefore can't be access through
|
||||||
|
* helma.main.ApplicationManager).
|
||||||
|
* ATTENTION: javascript should not overwrite helma.main.Server.getApplication() which
|
||||||
|
* retrieves active applications.
|
||||||
|
* @arg name of application
|
||||||
|
*/
|
||||||
|
function getApp(name) {
|
||||||
|
if ( name==null || name=="" )
|
||||||
|
return null;
|
||||||
|
var appObj = this.getApplication(name);
|
||||||
|
if ( appObj==null )
|
||||||
|
appObj = new application(name);
|
||||||
|
return appObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
11
Root/image.hac
Normal file
11
Root/image.hac
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 );
|
||||||
|
|
240
Root/macros.js
Normal file
240
Root/macros.js
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
/**
|
||||||
|
* macro rendering a skin
|
||||||
|
* @param name name of skin
|
||||||
|
*/
|
||||||
|
function skin_macro(par) {
|
||||||
|
if ( par && par.name ) {
|
||||||
|
this.renderSkin(par.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the total number of sessions on this server
|
||||||
|
* @see global.formatCount
|
||||||
|
*/
|
||||||
|
function countSessions_macro(par) {
|
||||||
|
var arr = this.getApplications();
|
||||||
|
var sum = 0;
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
sum += arr[i].sessions.size();
|
||||||
|
}
|
||||||
|
return sum + formatCount(sum,par);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* macro returning the total number of sessions on this server
|
||||||
|
* @see global.formatCount
|
||||||
|
*/
|
||||||
|
function countRequests_macro(par) {
|
||||||
|
var arr = this.getApplications();
|
||||||
|
var sum = 0;
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
var obj = app.requestStat.get(arr[i].name);
|
||||||
|
sum += obj.last5Min;
|
||||||
|
}
|
||||||
|
return sum + formatCount(sum,par);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning hostname of this machine
|
||||||
|
*/
|
||||||
|
function hostname_macro(par) {
|
||||||
|
return java.net.InetAddress.getLocalHost().getHostName()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning address of this machine
|
||||||
|
*/
|
||||||
|
function hostaddress_macro(par) {
|
||||||
|
return java.net.InetAddress.getLocalHost().getHostAddress()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro returning the number of running applications,
|
||||||
|
* the manage application being excluded.
|
||||||
|
*/
|
||||||
|
function appCount_macro(par) {
|
||||||
|
if ( par && par.filter=="active" ) {
|
||||||
|
var ct = root.getApplications().length-1;
|
||||||
|
} else if ( par && par.filter=="disabled" ) {
|
||||||
|
var ct = root.getAllApplications().length - root.getApplications().length;
|
||||||
|
} else {
|
||||||
|
var ct = root.getAllApplications().length-1;
|
||||||
|
}
|
||||||
|
return ct + formatCount(ct,par);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that lists all running applications,
|
||||||
|
* the manage application being excluded (-1).
|
||||||
|
* @param skin skin of application that will be used.
|
||||||
|
*/
|
||||||
|
function appList_macro(par) {
|
||||||
|
var skin = (par && par.skin) ? par.skin : "navig_active";
|
||||||
|
var apps = new Array();
|
||||||
|
if ( par && par.filter=="active" ) {
|
||||||
|
var arr = root.getApplications();
|
||||||
|
for ( var i=0; i<arr.length; i++ ) {
|
||||||
|
apps[apps.length] = arr[i];
|
||||||
|
}
|
||||||
|
} else if ( par && par.filter=="disabled" ) {
|
||||||
|
var arr = root.getAllApplications();
|
||||||
|
for ( var i in arr ) {
|
||||||
|
if( arr[i].isActive()==false ) {
|
||||||
|
apps[apps.length] = arr[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var apps = root.getAllApplications();
|
||||||
|
}
|
||||||
|
apps = apps.sort(sortByName);
|
||||||
|
var html = "";
|
||||||
|
var param = new Object();
|
||||||
|
for (var n in apps) {
|
||||||
|
var a = apps[n];
|
||||||
|
if ( apps[n].name==app.__app__.getName() )
|
||||||
|
continue;
|
||||||
|
var item = a.renderSkinAsString(skin);
|
||||||
|
html += item;
|
||||||
|
}
|
||||||
|
return(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the server's uptime nicely formatted
|
||||||
|
*/
|
||||||
|
function uptime_macro() {
|
||||||
|
return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the server's version string
|
||||||
|
*/
|
||||||
|
function version_macro() {
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the home directory of the hop installation
|
||||||
|
*/
|
||||||
|
function home_macro() {
|
||||||
|
return this.getHopHome().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the free memory in the java virtual machine
|
||||||
|
*/
|
||||||
|
function jvmFreeMemory_macro() {
|
||||||
|
var m = java.lang.Runtime.getRuntime().freeMemory();
|
||||||
|
return formatBytes(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the total memory available to the java virtual machine
|
||||||
|
*/
|
||||||
|
function jvmTotalMemory_macro() {
|
||||||
|
var m = java.lang.Runtime.getRuntime().totalMemory();
|
||||||
|
return formatBytes(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the used memory in the java virtual machine
|
||||||
|
*/
|
||||||
|
function jvmUsedMemory_macro() {
|
||||||
|
var m = java.lang.Runtime.getRuntime().totalMemory() - java.lang.Runtime.getRuntime().freeMemory();
|
||||||
|
return formatBytes(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the version and type of the java virtual machine
|
||||||
|
*/
|
||||||
|
function jvm_macro() {
|
||||||
|
return java.lang.System.getProperty("java.version") + " " + java.lang.System.getProperty("java.vendor");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the home directory of the java virtual machine
|
||||||
|
*/
|
||||||
|
function jvmHome_macro() {
|
||||||
|
return java.lang.System.getProperty("java.home");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that greps all jar-files from the class path variable and lists them.
|
||||||
|
* @param separator string that is printed between the items
|
||||||
|
*/
|
||||||
|
function jvmJars_macro(par) {
|
||||||
|
var separator = (par && par.separator ) ? par.separator : ", ";
|
||||||
|
var str = java.lang.System.getProperty("java.class.path");
|
||||||
|
var arr = str.split(".jar");
|
||||||
|
for ( var i in arr ) {
|
||||||
|
var str = arr[i];
|
||||||
|
var pos = ( str.lastIndexOf('\\') > str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/');
|
||||||
|
res.write ( arr[i].substring(pos+1) + ".jar" );
|
||||||
|
if ( i < arr.length-1 ) res.write ( separator );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the name and version of the server's os
|
||||||
|
*/
|
||||||
|
function os_macro() {
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
function property_macro(par) {
|
||||||
|
if ( par && par.key ) {
|
||||||
|
return this.getProperty(key);
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro formatting server.properties
|
||||||
|
*/
|
||||||
|
function properties_macro(par) {
|
||||||
|
formatProperties(this.getProperties(),par);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Macro that returns the timezone of this server
|
||||||
|
*/
|
||||||
|
function timezone_macro(par) {
|
||||||
|
return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
46
Root/main.hac
Normal file
46
Root/main.hac
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.clearAppCache();
|
||||||
|
res.redirect ( appObj.href("main") );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// output only to root
|
||||||
|
if ( checkAuth()==false ) return;
|
||||||
|
|
||||||
|
res.skin = "global";
|
||||||
|
res.title = "Helma Object Publisher - Serverinfo";
|
||||||
|
res.body = this.renderSkinAsString("main");
|
||||||
|
|
101
Root/main.skin
Normal file
101
Root/main.skin
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
<big><% this.hostname %> (<% this.hostaddress %>)</big><br/><br/>
|
||||||
|
|
||||||
|
<table border="0" cellspacing="0" cellpadding="3">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3">helma</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">uptime:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.uptime %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">version:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.version %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">homedir:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.home %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200" valign="top">total active sessions</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.countSessions %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200" valign="top">total request 5-min-avg</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.countRequests %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3">jre</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">free memory:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.jvmFreeMemory %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">used memory:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.jvmUsedMemory %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">total memory:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.jvmTotalMemory %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">java:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.jvm %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">javahome:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.jvmHome %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">os:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.os %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200">localtime:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% now %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200" valign="top">timezone:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.timezone %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="list_property" align="right" width="200" valign="top">loaded Jars:</td>
|
||||||
|
<td class="list_property" width="5"> </td>
|
||||||
|
<td class="list_property" align="left"><% this.jvmJars %></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="list_separator" colspan="3">server.properties</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<% this.properties prefix="<tr><td class=\"list_property\" align=\"right\" width=\"200\">" separator="</td><td class=\"list_property\" width=\"5\"> </td><td class=\"list_property\" align=\"left\">" suffix="</td></tr>" %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
10
Root/makekey.hac
Normal file
10
Root/makekey.hac
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
if ( checkAddress()==false ) return;
|
||||||
|
if ( checkAuth()==false ) return;
|
||||||
|
|
||||||
|
if ( req.data.value!=null ) {
|
||||||
|
res.write ( calcMD5(req.data.value) );
|
||||||
|
} else {
|
||||||
|
res.write ( '<html><head></head><body><form method=post action=makekey><input type=password name=value><input type=submit></form></body></html>' );
|
||||||
|
}
|
||||||
|
|
5
app.properties
Normal file
5
app.properties
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Set this property according to your
|
||||||
|
# server configuration:
|
||||||
|
|
||||||
|
baseURI = /manage/
|
||||||
|
|
11
class.properties
Normal file
11
class.properties
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#
|
||||||
|
# Map Java classes to the prototype used to script them
|
||||||
|
#
|
||||||
|
|
||||||
|
helma.main.Server = root
|
||||||
|
helma.framework.core.Application = application
|
||||||
|
helma.doc.DocApplication = docapplication
|
||||||
|
helma.doc.DocPrototype = docprototype
|
||||||
|
helma.doc.DocFunction = docfunction
|
||||||
|
helma.doc.DocTag = doctag
|
||||||
|
|
Loading…
Add table
Reference in a new issue