Maintenance Plugin

Hi
I have been having a look at the open source servoySecurity plugin. There is a facility to set permissions on database tables and as a concequence a call the server to provide a list of attached database servers. This is using the maintenance plugin to get a list of servers thus

plugins.maintenance.getServerNames(true,true).sort();

this throws the error:

error getting data from global method valuelist
Wrapped java.lang.RuntimeException: Maintenance plugin is only meant to run during solution import using before or after import hook. (/Users/gordon/servoy_workspace/servoySecurity/globals.js#915)
at /Users/gordon/servoy_workspace/servoySecurity/globals.js:915 (secGetTableNames)
at /Users/gordon/servoy_workspace/servoyCommons/forms/comTransactionDialogBase.js:61 (showDialog)
at /Users/gordon/servoy_workspace/servoySecurityProviderExample/forms/secAppPermissionList.js:21 (startEditing)

Is there a way for a solution to get server database servers without having to enter maintenance mode. As far as I can see this means that updates to the security can only be done when the server can be taken off line - is this correct ??

What the solution is trying to do is set security permissions for databases/tables for given users.

Best
Gordon

Hi Gordon,

why not using databaseManager.getServerNames() to retrieve the servernames?

Hi Gordon,

The functions in the maintenance plugin will work only in (you guessed it) maintenance mode (and for obvious reasons also in Developer).
The only (built-in) way to get the connection names is what Marc said, using the databaseManager.getServerNames() function. However this will only return the connections used by the solution you call this function in. This is for security reasons.
If you really need to get all the server names of your server then I think the only way would be to create a plugin yourself that does this.

Hope this helps.

mboegem:
Hi Gordon,

why not using databaseManager.getServerNames() to retrieve the servernames?

I tried this Marc, and concluded it would not work because it only returns the databases used within the current solution.

Having said which, the servoySecurity framework at a user tenant level does not need to know all the databases only those used in the current version, so I will go back and look at the code Sean Devlin used and see if I can work around this.

Many thanks
Gordon

ROCLASI:
Hi Gordon,

The functions in the maintenance plugin will work only in (you guessed it) maintenance mode (and for obvious reasons also in Developer).
The only (built-in) way to get the connection names is what Marc said, using the databaseManager.getServerNames() function. However this will only return the connections used by the solution you call this function in. This is for security reasons.
If you really need to get all the server names of your server then I think the only way would be to create a plugin yourself that does this.

Hope this helps.

…sadly I may aspire to fixing the servoyServoy security frameworks but I can’t run to a plugin, that is a domain best occupied by the more advanced. I think we need to revisit the idea how the security framework gets its value list of tables and databases and whether in a fact you need the entire list

Many thanks …

Gordon McLean:
I tried this Marc, and concluded it would not work because it only returns the databases used within the current solution.

Hi Gordon,

if you download & use the usermanager plugin (servoy-plugins.de), you can easily retrieve information from the servoy.properties file using key/value pairs.
as you probably know there’s a key for the nr. of database servers being defined.

based on that number you can retrieve the server names in a loop from the servoy.properties file…

mboegem:

Gordon McLean:
I tried this Marc, and concluded it would not work because it only returns the databases used within the current solution.

Hi Gordon,
if you download & use the usermanager plugin (servoy-plugins.de), you can easily retrieve information from the servoy.properties file using key/value pairs.
as you probably know there’s a key for the nr. of database servers being defined.
based on that number you can retrieve the server names in a loop from the servoy.properties file…

Based upon this nice tip from Marc, this is the code :)

function ARRAY_getAllServers(){
	var vServerAmount = plugins.UserManager.Server().getSettingsProperty('ServerManager.numberOfServers') -1;
	var vProperty, vServers = [];
	var vPropertiesArray = plugins.UserManager.Server().getServerProperties();
	for(var i = 0 ; i < vServerAmount ; i++){
		vProperty = 'server.' + i + '.serverName';
		vServers.push(plugins.UserManager.Server().getSettingsProperty(vProperty));
	}
	vServers.sort();
	return vServers;
}