Updated code to new session/app/req/res object layout.

This commit is contained in:
hns 2002-05-31 14:14:37 +00:00
parent 0e9738e95d
commit 32d2230ef5
6 changed files with 36 additions and 37 deletions

View file

@ -5,6 +5,6 @@
if ( checkAddress()==false ) return; if ( checkAddress()==false ) return;
if ( checkAuth(this)==false ) return; if ( checkAuth(this)==false ) return;
res.skin="global"; res.data.body = this.renderSkinAsString("main");
res.body = this.renderSkinAsString("main"); renderSkin ("global");

View file

@ -12,12 +12,12 @@ if ( req.data.action=="reload" ) {
} }
if ( req.data.action=="index" ) { if ( req.data.action=="index" ) {
res.body = this.renderSkinAsString("index"); res.data.body = this.renderSkinAsString("index");
} else { } else {
res.body = this.renderSkinAsString("main"); res.data.body = this.renderSkinAsString("main");
} }
res.skin = "api"; res.data.title = "Application " + this.name;
res.title = "Application " + this.name; renderSkin("api");

View file

@ -1,8 +1,8 @@
if ( checkAddress()==false ) return; if ( checkAddress()==false ) return;
if ( checkAuth(this)==false ) return; if ( checkAuth(this)==false ) return;
res.body = this.renderSkinAsString("main"); res.data.body = this.renderSkinAsString("main");
res.skin = "api"; res.data.title = "Application " + this.name;
res.title = "Application " + this.name; renderSkin("api");

View file

@ -1,8 +1,8 @@
if ( checkAddress()==false ) return; if ( checkAddress()==false ) return;
if ( checkAuth(this)==false ) return; if ( checkAuth(this)==false ) return;
res.body = this.renderSkinAsString("main"); res.data.body = this.renderSkinAsString("main");
res.skin = "api"; res.data.title = "Application " + this.name;
res.title = "Application " + this.name; renderSkin ("api");

View file

@ -10,12 +10,12 @@ function scheduler() {
/** /**
* initializes app.requestStat storage on startup, * initializes app.data.requestStat storage on startup,
* creates app.addressFilter * creates app.data.addressFilter
*/ */
function onStart() { function onStart() {
app.requestStat = new HopObject(); app.data.requestStat = new HopObject();
app.addressFilter = createAddressFilter(); app.data.addressFilter = createAddressFilter();
} }
/** /**
@ -36,29 +36,29 @@ function createAddressFilter() {
var result = tryEval("filter.addAddress(str);"); var result = tryEval("filter.addAddress(str);");
} }
if ( result.error==null ) { if ( result.error==null ) {
app.__app__.logEvent( "allowed address for app manage: " + str ); app.log( "allowed address for app manage: " + str );
} }
} }
} else { } else {
app.__app__.logEvent("no addresses allowed for app manage, all access will be denied"); app.log("no addresses allowed for app manage, all access will be denied");
} }
return filter; return filter;
} }
/** /**
* updates the request stats in app.requestStat every 5 minutes * updates the request stats in app.data.requestStat every 5 minutes
*/ */
function appStat() { function appStat() {
if ( app.requestStat==null ) { if ( app.data.requestStat==null ) {
app.requestStat = new HopObject(); app.data.requestStat = new HopObject();
} }
if( (new Date()-300000) < app.requestStat.lastRun ) { if( (new Date()-300000) < app.data.requestStat.lastRun ) {
return; return;
} }
var arr = root.getApplications(); var arr = root.getApplications();
for ( var i=0; i<arr.length; i++ ) { for ( var i=0; i<arr.length; i++ ) {
var tmp = app.requestStat.get(arr[i].getName()); var tmp = app.data.requestStat.get(arr[i].getName());
if ( tmp==null ) { if ( tmp==null ) {
tmp = new HopObject(); tmp = new HopObject();
tmp.lastTotal = 0; tmp.lastTotal = 0;
@ -67,9 +67,9 @@ function appStat() {
var ct = arr[i].getRequestCount(); var ct = arr[i].getRequestCount();
tmp.last5Min = ct - tmp.lastTotal; tmp.last5Min = ct - tmp.lastTotal;
tmp.lastTotal = ct; tmp.lastTotal = ct;
app.requestStat.set(arr[i].getName(), tmp); app.data.requestStat.set(arr[i].getName(), tmp);
} }
app.requestStat.lastRun = new Date(); app.data.requestStat.lastRun = new Date();
} }
@ -116,8 +116,8 @@ function checkAuth(appObj) {
return createAuth(); return createAuth();
} }
var uname = req.getUsername(); var uname = req.username;
var pwd = req.getPassword(); var pwd = req.password;
if ( uname==null || uname=="" || pwd==null || pwd=="" ) if ( uname==null || uname=="" || pwd==null || pwd=="" )
return forceAuth(); return forceAuth();
@ -145,8 +145,8 @@ function checkAuth(appObj) {
* check access to the base-app by ip-addresses * check access to the base-app by ip-addresses
*/ */
function checkAddress() { function checkAddress() {
if ( !app.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) { if ( !app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) {
app.__app__.logEvent("denied request from " + req.data.http_remotehost ); app.log("denied request from " + req.data.http_remotehost );
return forceStealth(); return forceStealth();
} else { } else {
return true; return true;
@ -213,7 +213,7 @@ function createAuth() {
f.open(); f.open();
f.write(str); f.write(str);
f.close(); f.close();
app.__app__.logEvent( req.data.http_remotehost + " saved new adminUsername/adminPassword to server.properties"); app.log( req.data.http_remotehost + " saved new adminUsername/adminPassword to server.properties");
res.redirect ( root.href("main") ); res.redirect ( root.href("main") );
} else { } else {
@ -227,3 +227,4 @@ function createAuth() {
} }
} }

View file

@ -1,4 +1,3 @@
/** /**
* main action, show server-stats * main action, show server-stats
* perform start, stop, restart and flush-action * perform start, stop, restart and flush-action
@ -40,7 +39,6 @@ if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data
// output only to root // output only to root
if ( checkAuth()==false ) return; if ( checkAuth()==false ) return;
res.skin = "global"; res.data.title = "Helma Object Publisher - Serverinfo";
res.title = "Helma Object Publisher - Serverinfo"; res.data.body = this.renderSkinAsString("main");
res.body = this.renderSkinAsString("main"); renderSkin("global");