TIP - how to rollback a solution using a method

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

TIP - how to rollback a solution using a method

Postby antonio » Sat Oct 28, 2006 11:31 pm

REPOSTED

I have a need to support offline sites ( eg Servoy Developer run in Offline mode, server and client on the same machine) . Sometimes this involves instructing them to roll back. I don't necessarily want them to fiddle with the repository nor the admin pages, and I don't really want to do this myself n times.

Here's a method that works from within Servoy. It will roll back the currently opened solution by 1 release (checking first that there's more than 1)

Big thanks to Jan Aleman for the tips on using the POST features of the HTTP plugin. I found the correct parameters to use in the source of the admin pages.

A question for those wiser than me - there's a parameter mode = 3. What's it for and what are the other mode options?

Code: Select all
var L_Poster, L_HttpCode, L_AddParam;

var SolutionName = application.getSolutionName()
var SolutionRelease = application.getSolutionRelease();

if (SolutionRelease == 1)
{
   plugins.dialogs.showErrorDialog( "ERROR",  "Nothing to rollback",  "Cancel")
   return
}

L_Poster   = plugins.http.getPoster('http://localhost:8080/servoy-admin/solutions/activate/' + SolutionName + '.' + parseInt(SolutionRelease-1));
L_AddParam = L_Poster.addParameter('mode','3'); // not sure what mode does but 3 works.
L_AddParam = L_Poster.addParameter('submit','Activate!');
L_HttpCode = L_Poster.doPost(AdminUsername, AdminPassword);
application.output(L_HttpCode)
if (L_HttpCode == 200  )
{
   // successful rollback - close the solution
   plugins.dialogs.showInfoDialog( "Success!",  "The solution has been rolled back 1 version\nClick OK to exit, then reopen the solution.",  "OK")
   application.closeSolution()
}
else
{   
   // an error occurred, error handling here
   plugins.dialogs.showErrorDialog( "ERROR",  "Rollback failed",  "OK")
}
Tony
Servoy Developer Version 5.2.16
Developer MAC OSX 10.8.4 Java version 1.6.0_51
Production Debian Linux Java version 1.6.0_29
antonio
 
Posts: 622
Joined: Sun Apr 02, 2006 2:14 am
Location: Australia

Return to How To

Who is online

Users browsing this forum: No registered users and 3 guests