* 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,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* construct an application object so that we can use
|
||||
* skins for non-active applications too
|
||||
|
|
|
@ -122,10 +122,10 @@ 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() ) {
|
||||
var users = this.activeUsers.iterator();
|
||||
while (users.hasNext()) {
|
||||
res.write(users.next().__name__);
|
||||
if (users.hasNext()) {
|
||||
res.write(separator);
|
||||
}
|
||||
}
|
||||
|
@ -168,10 +168,10 @@ function cachesize_macro (param) {
|
|||
* 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)
|
||||
if (app.data.stat == null || app.data.stat[this.name] == null)
|
||||
return "not available";
|
||||
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);
|
||||
} else {
|
||||
return 0 + formatCount(0, par);
|
||||
|
@ -183,10 +183,10 @@ function requestCount_macro(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)
|
||||
if (app.data.stat == null || app.data.stat[this.name] == null)
|
||||
return "not available";
|
||||
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);
|
||||
} else {
|
||||
return 0 + formatCount(0, par);
|
||||
|
@ -194,8 +194,6 @@ function errorCount_macro(par) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting app.properties
|
||||
*/
|
||||
|
@ -204,7 +202,9 @@ function properties_macro(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() );
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* get the prototype of any doc-object (either a prototype, a function or a tag)
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
|
@ -13,18 +12,33 @@ function skin_macro(par) {
|
|||
* macro-wrapper for href-function
|
||||
* @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 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); }
|
||||
function comment_macro(param) {
|
||||
return renderComment(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
|
||||
|
||||
|
||||
|
||||
function linkToManage_macro(param) {
|
||||
if (res.data.rendering != true) {
|
||||
return ('<a href="' + root.href("main") + '" target="_top">back to manage console</a>');
|
||||
|
@ -36,7 +50,6 @@ function headline_macro (param) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
function hrefRoot_macro(param) {
|
||||
var obj = this.getChildElement("prototype_root");
|
||||
if (obj == null) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
|
@ -13,18 +12,29 @@ function skin_macro(par) {
|
|||
* macro-wrapper for href-function
|
||||
* @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 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); }
|
||||
function comment_macro(param) {
|
||||
return renderComment(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
|
||||
|
||||
|
||||
|
||||
function headline_macro(param) {
|
||||
var p = this.getParentElement();
|
||||
var handler = (p != null) ? p.getName() : "";
|
||||
|
@ -38,7 +48,7 @@ function headline_macro (param) {
|
|||
for (var i = 0; i < arr.length; i++) {
|
||||
res.write(arr[i]);
|
||||
if (i < arr.length - 1) {
|
||||
res.write (", ");
|
||||
res.write(", ");
|
||||
}
|
||||
}
|
||||
res.write(")");
|
||||
|
@ -56,6 +66,8 @@ function headline_macro (param) {
|
|||
res.write(handler + "/");
|
||||
res.write(this.getName());
|
||||
res.write(".skin");
|
||||
} else if (this.getType() == this.PROPERTIES) {
|
||||
res.write(this.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
<% 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="skins" skin="asParentListItem" prefix="<b>Skins: </b>" suffix="<br/>" %>
|
||||
<% this.methods separator=", " filter="templates" skin="asParentListItem" prefix="<b>Templates: </b>" suffix="<br/>" %>
|
||||
|
||||
</td></tr>
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
///**
|
||||
// * utility function for head_macro, rendering link to app and to prototype
|
||||
// */
|
||||
|
@ -10,18 +9,17 @@
|
|||
//}
|
||||
|
||||
|
||||
|
||||
function translateType(filter) {
|
||||
if (filter == "actions")
|
||||
return Packages.helma.doc.DocElement.ACTION;
|
||||
else if (filter=="templates")
|
||||
return Packages.helma.doc.DocElement.TEMPLATE;
|
||||
else if (filter == "functions")
|
||||
return Packages.helma.doc.DocElement.FUNCTION;
|
||||
else if (filter == "macros")
|
||||
return Packages.helma.doc.DocElement.MACRO;
|
||||
else if (filter == "skins")
|
||||
return Packages.helma.doc.DocElement.SKIN;
|
||||
else if (filter == "properties")
|
||||
return Packages.helma.doc.DocElement.PROPERTIES;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -7,5 +7,4 @@
|
|||
<% 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="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,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
|
@ -13,25 +12,40 @@ function skin_macro(par) {
|
|||
* macro-wrapper for href-function
|
||||
* @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 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); }
|
||||
function comment_macro(param) {
|
||||
return renderComment(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
|
||||
|
||||
|
||||
|
||||
function headline_macro(param) {
|
||||
res.write(this.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 separator
|
||||
* @param desc Description that is passed on to the called skin
|
||||
|
@ -112,12 +126,21 @@ function parentPrototype_macro (param) {
|
|||
*/
|
||||
function typeProperties_macro(param) {
|
||||
var props = this.getTypeProperties();
|
||||
if (props!=null && props.getContent ()!="" ) {
|
||||
var iter = props.getResources();
|
||||
while (iter.hasNext()) {
|
||||
var tmp = this.renderTypePropertiesResource(iter.next(), props);
|
||||
var skinname = (param.skinname) ? param.skinname : "typeproperties";
|
||||
this.renderSkin(skinname, tmp);
|
||||
}
|
||||
}
|
||||
|
||||
function renderTypePropertiesResource(res, props) {
|
||||
if (res.getContent() != "") {
|
||||
var sb = new java.lang.StringBuffer ();
|
||||
// map of all mappings....
|
||||
var mappings = props.getMappings();
|
||||
// parse type.properties linewise:
|
||||
var arr = props.getContent ().split ("\n");
|
||||
var arr = res.getContent().split("\n");
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
arr [i] = arr[i].trim();
|
||||
// look up in mappings table if line matches:
|
||||
|
@ -136,7 +159,7 @@ function typeProperties_macro (param) {
|
|||
}
|
||||
var tmp = new Object ();
|
||||
tmp.content = sb.toString();
|
||||
var skinname = (param.skinname) ? param.skinname : "typeproperties";
|
||||
this.renderSkin (skinname, tmp);
|
||||
tmp.source = res.getName();
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
<a class="navig" href="#functions">FUNCTIONS</a> |
|
||||
<a class="navig" href="#macros">MACROS</a> |
|
||||
<a class="navig" href="#skins">SKINS</a> |
|
||||
<a class="navig" href="#templates">TEMPLATES</a> |
|
||||
<a class="navig" href="#typeproperties">TYPE.PROPERTIES</a>
|
||||
|
||||
<br/><br/>
|
||||
|
@ -62,9 +61,9 @@
|
|||
%>
|
||||
|
||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||
filter="templates"
|
||||
skin="asLargeListItem"
|
||||
prefix="<tr><td class='headline'>Templates<a name='templates'><!-- --></a></td></tr>"
|
||||
filter="properties"
|
||||
skin="asLargeListItemSkin"
|
||||
prefix="<tr><td class='headline'>type.properties<a name='typeproperties'><!-- --></a></td></tr>"
|
||||
suffix="<tr><td height='8'> </td></tr>
|
||||
%>
|
||||
|
||||
|
@ -73,7 +72,7 @@
|
|||
|
||||
<br/><br/>
|
||||
|
||||
<% this.typeProperties %>
|
||||
<!-- % this.typeProperties % -->
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<a name='typeproperties'><!-- --></a>
|
||||
<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>
|
||||
<td class="mainbox"><pre><% param.content %></pre></td>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
/**
|
||||
* scheduler function, runs global.appStat every minute
|
||||
*/
|
||||
|
@ -29,12 +27,12 @@ function createAddressFilter() {
|
|||
if (str != null && str != "") {
|
||||
var arr = str.split(",");
|
||||
for (var i in arr) {
|
||||
var str = new java.lang.String(arr[i]);
|
||||
str = new java.lang.String(arr[i]);
|
||||
try {
|
||||
filter.addAddress(str.trim());
|
||||
} catch (a) {
|
||||
try {
|
||||
var str = java.net.InetAddress.getByName(str.trim()).getHostAddress();
|
||||
str = java.net.InetAddress.getByName(str.trim()).getHostAddress();
|
||||
filter.addAddress(str);
|
||||
} catch (b) {
|
||||
app.log("error using address " + arr[i] + ": " + b);
|
||||
|
@ -58,7 +56,7 @@ function appStat () {
|
|||
return;
|
||||
var arr = root.getApplications();
|
||||
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) {
|
||||
tmp = new HopObject();
|
||||
tmp.lastTotalRequestCount = 0;
|
||||
|
@ -68,7 +66,7 @@ function appStat () {
|
|||
tmp.lastTotalRequestCount = arr[i].getRequestCount();
|
||||
tmp.errorCount = arr[i].getErrorCount() - tmp.lastTotalErrorCount;
|
||||
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();
|
||||
}
|
||||
|
@ -178,7 +176,6 @@ function forceAuth(realm) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* macro-utility: formatting property lists
|
||||
*/
|
||||
|
@ -219,9 +216,9 @@ function formatBytes(bytes) {
|
|||
function formatAge(age) {
|
||||
var str = "";
|
||||
var days = Math.floor(age / 86400);
|
||||
var age = age - days * 86400;
|
||||
age = age - days * 86400;
|
||||
var hours = Math.floor(age / 3600);
|
||||
var age = age - hours * 3600;
|
||||
age = age - hours * 3600;
|
||||
var minutes = Math.floor(age / 60);
|
||||
var seconds = Math.floor(age - minutes * 60);
|
||||
if (days > 0)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<p></p>
|
||||
<div class="list_apps">
|
||||
<i>and <% root.appCount filter="disabled" %> disabled apps:</i>
|
||||
<i>disabled apps:</i>
|
||||
</div>
|
||||
|
||||
<% root.appList filter="disabled" skin="navig_disabled" %>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
function renderLink(docEl, param) {
|
||||
var text = "";
|
||||
if (docEl.getType() == docEl.APPLICATION || docEl.getType() == docEl.PROTOTYPE) {
|
||||
|
@ -15,7 +13,7 @@ function renderLink (docEl, param) {
|
|||
text += str.substring(0, str.length - 6);
|
||||
}
|
||||
} else if (docEl.getType() == docEl.FUNCTION) {
|
||||
var text = docEl.getName () + "(";
|
||||
text = docEl.getName() + "(";
|
||||
var arr = docEl.listParameters();
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
text += arr[i];
|
||||
|
@ -34,8 +32,6 @@ function renderLink (docEl, param) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function renderLinkTag(param) {
|
||||
var sb = new java.lang.StringBuffer ();
|
||||
sb.append('<a');
|
||||
|
@ -50,19 +46,13 @@ function renderLinkTag (param) {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* renders the name of the location relative to the application
|
||||
* root.
|
||||
* renders the name of the location of a doc element.
|
||||
*/
|
||||
function renderLocation (docEl, param) {
|
||||
var f = docEl.getLocation ();
|
||||
// with repositories, always display full file path
|
||||
return f.getAbsolutePath();
|
||||
return docEl.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* renders tag list.
|
||||
* @param param.skin skin to render on found DocTags
|
||||
|
@ -146,8 +136,6 @@ function renderReference (docTagObj, docEl) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* function rendering a comment.
|
||||
* @param param.length comment is shortened to the given length.
|
||||
|
|
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,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* renders the api of a given application. used from commandline.
|
||||
*/
|
||||
|
@ -50,7 +49,7 @@ function getApp(name) {
|
|||
return null;
|
||||
var appObj = this.getApplication(name);
|
||||
if (appObj == null)
|
||||
appObj = new application(name);
|
||||
appObj = new Application(name);
|
||||
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 );
|
||||
|
|
@ -46,7 +46,7 @@ function requestCount_macro(par) {
|
|||
var sum = 0;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
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) {
|
||||
sum += obj.requestCount;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ function errorCount_macro(par) {
|
|||
var sum = 0;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
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) {
|
||||
sum += obj.errorCount;
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ function errorCount_macro(par) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
function extensions_macro(par) {
|
||||
var vec = this.getExtensions();
|
||||
var str = "";
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
@ -8,3 +8,5 @@ _description = Helma's server management console. Start applications, introspect
|
|||
# might take more than one minute on a slow computer
|
||||
requestTimeout = 300
|
||||
|
||||
# run scheduler function each minute
|
||||
cron.scheduler.function = scheduler
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#
|
||||
# define the root class of this application
|
||||
#
|
||||
|
@ -17,10 +16,10 @@ root.factory.method = getServer
|
|||
# and, yes, map the root class again.
|
||||
#
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ To get the manage-application to work you must:
|
|||
- add it to the apps.properties file with the following line:
|
||||
manage
|
||||
|
||||
- use helma distribution 1.2-RC1 or later.
|
||||
- use helma distribution 1.5 or later.
|
||||
|
||||
- add the following properties to server.properties:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue