Need to get data back from an HTTP POST

Jan Blok:
It seems not to work well with Servoy Developer, Servoy Server should work the same as manual post.

Jan, Any news of getting this working in Developer? I mostly need clients using Servoy Offline, and need a reliable way to push new versions of solutions into the repository. I thought I hadd it cracked with the method I posted. Using HTTP POST to import a solution to the repository - Classic Servoy - Servoy Community
However this only works for relatively small solutions. For a larger solution, after running this method, the ‘new’ version in the repository is a copy of the previous version, not the real new version. I’ve confirmed this behaviour on two different WIN XP machines running Servoy Devel 3.0.2

Importing the same new solution via the admin pages works (but only after a restart of servoy developer, which I don’t mind at all).

Can you suggest an efficient and automated way to update offline clients, without giving them access to the repository nor the admin pages?

antonio:
Jan, Any news of getting this working in Developer?

It works for us in Servoy 3.0.2

antonio:
I mostly need clients using Servoy Offline, and need a reliable way to push new versions of solutions into the repository. I thought I hadd it cracked with the method I posted. Using HTTP POST to import a solution to the repository - Classic Servoy - Servoy Community
However this only works for relatively small solutions. For a larger solution, after running this method, the ‘new’ version in the repository is a copy of the previous version, not the real new version. I’ve confirmed this behaviour on two different WIN XP machines running Servoy Devel 3.0.2

please check the result from the admin page, something must go wrong.

Hi Jan, what am I meant to check on the admin page? I’m importing using a method, not the Servoy-Admin pages.

Thanks,

antonio:
Hi Jan, what am I meant to check on the admin page?

The database performance page.
Here you see every query send to the database. You can clear it before you fire your import.

Thanks Robert, this is what I see after running the updater method

Total Time (mm:ss:ms) Count Avg Time (mm:ss:ms) SQL Statement
00:00:000 1 00:00:000 select sg.group_id,sg.group_name from servoy_groups sg,servoy_user_groups sug, servoy_users su where sg.group_id = sug.group_id and sug.user_id=su.user_id and su.user_uid=? order by sg.group_name
00:00:000 3 00:00:000 select user_uid from servoy_users su, servoy_user_groups sug, servoy_groups sg where sg.group_name = ? and sg.group_id = sug.group_id and sug.user_id = su.user_id
00:00:000 1 00:00:000 select user_uid from servoy_users where user_name=? and user_password=?

I’ve looked at all the other pages, nothing of note.
Thanks for your help.

Hi,

The problem appeared to be a bug in the http plugin.
When a file is uploaded, the other parameters are actually ignored.

A fix for this problem is included in Servoy 3.1 beta 3

Rob, thanks for the speedy resolution, in true Servoyan style.

The new HTTP plugin works perfectly! Amazing response time from report to resolution, thanks.

David,

The HTTP plugin now works, and I get this pagedata back from a doPost.

Importing file…

[info] Import contains XML version 12 and repository version 29.
[info] Import successful…
[info] Activated solution CuttingEdge release 2
[info] Activated style CuttingEdge release 59
[info] Activated style servoy release 35

However, I still have problems with solution imports using the HTTP POST method. I’m wondering if it is going to be possible to use a method to import a new release of the solution. (in particular the current solution)

From my post above - still behaves much the same.

  1. Although the method has completed, the Stop button in the debug window remains ‘active’
  2. I can no longer go into designer mode - the icon in the form editor window is disabled.
  3. If I click on Open Solution, I don’t get the usual dialog “There is currently an open solution, close and continue?” It just goes straight to the “Open Solution” dialog, as if there’s no solution open.
  4. Same thing with Repository - no warning that there’s a solution open, it goes straight to the respository dialog
  5. ‘Close’ on Menu doesn’t work.
  6. application.closeSolution() in a mthod doesn’t work
  7. Opening any solution after importing to the repository (eg _START_HERE) now takes ~45 -60 seconds, instead of the usual ~1 second. Opening the same solution a second time is rapid.

I got this error immediately after an import, and the solution takes an age (several minutes for larger files) to open on the first attempt, or may not open at all.

I’m very keen to get this working, so I can push updates to Offline Clients.

2006-12-10 14:33:24,250 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Deleting unreferenced blobs
2006-12-10 14:35:49,953 WARN [AWT-EventQueue-0] org.apache.commons.httpclient.HttpMethodBase - Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
2006-12-10 14:35:58,031 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Throwable
javax.swing.text.ChangedCharSetException
	at javax.swing.text.html.parser.DocumentParser.handleEmptyTag(Unknown Source)
	at javax.swing.text.html.parser.Parser.startTag(Unknown Source)
	at javax.swing.text.html.parser.Parser.parseTag(Unknown Source)
	at javax.swing.text.html.parser.Parser.parseContent(Unknown Source)
	at javax.swing.text.html.parser.Parser.parse(Unknown Source)
	at javax.swing.text.html.parser.DocumentParser.parse(Unknown Source)
	at javax.swing.text.html.parser.ParserDelegator.parse(Unknown Source)
	at com.servoy.j2db.util.e.read(Unknown Source)
	at com.servoy.j2db.dataui.DataTextEditor.setValueEx(Unknown Source)
	at com.servoy.j2db.dataui.DataTextEditor.setValueObject(Unknown Source)
	at com.servoy.j2db.dataprocessing.av.a(Unknown Source)
	at com.servoy.j2db.dataprocessing.av.a(Unknown Source)
	at com.servoy.j2db.dataprocessing.d.a(Unknown Source)
	at com.servoy.j2db.scripting.d.a(Unknown Source)
	at com.servoy.j2db.scripting.d.if(Unknown Source)
	at com.servoy.j2db.scripting.d.put(Unknown Source)
	at org.mozilla.javascript.ScriptRuntime.setProp(ScriptRuntime.java:851)
	at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1916)
	at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:94)
	at com.servoy.j2db.scripting.e.call(Unknown Source)
	at com.servoy.j2db.develop.debugger.j.a(Unknown Source)
	at com.servoy.j2db.develop.debugger.j.access$13(Unknown Source)
	at com.servoy.j2db.develop.debugger.j$2.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
2006-12-10 14:38:27,671 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - releaseGUI to many times called
2006-12-10 14:38:27,703 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Throwable
java.lang.NullPointerException
	at com.servoy.j2db.develop.debugger.j.setTitle(Unknown Source)
	at com.servoy.j2db.develop.debugger.j.stateChanged(Unknown Source)
	at com.servoy.j2db.develop.debugger.j.a(Unknown Source)
	at com.servoy.j2db.develop.debugger.j.access$13(Unknown Source)
	at com.servoy.j2db.develop.debugger.j$2.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
2006-12-10 14:38:46,140 ERROR [AWT-EventQueue-0] com.servoy.j2db.util.Debug - Deleting unreferenced blobs

Antonio,

The problem is that when you import a solution through the admin servlet, the open solution is closed.
In your setup, however, developer is running the same solution while it is being closed.
This causes problems in developer resulting in an inconsistent state, it is not really designed for this usage.

I would like to propose that you create a separate solution that is only used for importing/activating other solutions.
The user actively needs to close its open solution, switch to the importing-solution, select the new solution to import and switch back.

Hope this works better,

Rob

Thanks Rob, I’ll give it a try.
An application.openSolution() function would help enormously. See Creating a script to launch a specific solution - Classic Servoy - Servoy Community
I’ve logged a feature request with Support.

Even though I now run a method in a different solution to import my new solution into the repository I still see the same behaviour after importing. This is not a big deal, I can just exit the application. However, after restarting Servoy (and Sybase) it takes up to 8 minutes to load my solution the first time. This doesn’t seem healthy.

Antonio,

The stack trace is caused by the html that the config servlet returns cannot be shown in a html area at the moment.

There should be no need to restart the app and/or sybase.
If the user closes the main solution, opens the upgrader solution, presses the upgrader button, closes the upgrader solution and opens the new solution everything should work fine.
maybe restarting sybase causes the delay.

Rob

Hi Rob, I’ve done exactly as you say, in a squeaky clean installation of Servoy 3.1b3 (and also 3.0.2) using a second solution to import one of the stock standard demo solutions that ship with Servoy. After importing with a script, application.closeSolution() doesn’t work. File>Close doesn’t work. Open Repository doesn’t give a warning that there’s a solution open and doesn’t load any solution the first time after the import. It does load on the second attempt.

I don’t think the delay (when exiting Servoy and restarting) is being caused by Sybase loading, I see that load quite early, and I’ve NEVER seen Servoy take 5-10 minutes to load a solution under any other circumstances.

I posted two example solutions with my support request 60206. Could you try importing at your end and see if it works as you’ve described. Perhaps my method is not right?

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

var L_Poster, L_HttpResult, L_HttpCode, L_TmpFile,L_TmpSiNo, L_AddParam ;
  L_TmpFile = plugins.file.convertStringToJSFile('C:/Program Files/Servoy3.1b3/solutions/_START_HERE3.servoy');
  L_TmpSiNo = L_TmpFile.exists();

if ( L_TmpSiNo == true )
{

   //Import file...
   L_Poster     = plugins.http.getPoster('http://localhost:8080/servoy-admin/solutions/import');
   L_AddParam  = L_Poster.addFile('if','file',L_TmpFile);
   L_AddParam  = L_Poster.addParameter('submit','Import!');
   
   //General options...
   L_AddParam  = L_Poster.addParameter('ac','1'); // 1 = Activate new release of imported solution and modules
   L_AddParam  = L_Poster.addParameter('os','1'); // 1 = Overwrite repository styles with import version
   L_AddParam  = L_Poster.addParameter('om','1'); // 1 = Overwrite repository media with import version
   L_AddParam  = L_Poster.addParameter('og','1'); // 1 = Overwrite repository group security settings with import version
   
   L_AddParam  = L_Poster.addParameter('fs','1'); // 1 = Override auto enter types to the auto enter types contained in the import version.
   //WARNING: This may break other solutions using the same tables, or cause tables to use nonexistent dbidentity or dbsequence sequences or other database auto enter types!

   L_AddParam  = L_Poster.addParameter('ak','0'); // 1 = Allow reserved SQL keywords as table or column names (will fail unless supported by the backend database)
   L_AddParam  = L_Poster.addParameter('sd','0'); // 1 = Import solution sample data
   L_AddParam  = L_Poster.addParameter('id','0'); // 1 = Import internationalization
   L_AddParam  = L_Poster.addParameter('io','0'); // 1 = Insert new internationalization (i18n) keys only
   
   //User import options...
   L_AddParam  = L_Poster.addParameter('up','1');
   // 0 = Do not import users contained in import
   // 1 = Create nonexisting users and add existing users to groups specified in import
   // 2 = Overwrite existing users completely (USE WITH CARE)
   L_AddParam  = L_Poster.addParameter('aa','1'); // 1 = Allow users to be added to the Administrators group
   
   // Merging options   - if merging
//   L_AddParam  = L_Poster.addParameter('ms','0'); // Merge solution if revision information is available, and when a merge conflict arises use:
//   L_AddParam  = L_Poster.addParameter('ul','0'); //  0 = repository version; 1 = import version
   
   // or Merging options   - if not merging
   L_AddParam  = L_Poster.addParameter('ms','1'); // Do not merge solution, and:
   L_AddParam  = L_Poster.addParameter('of','1'); //  overwrite repository forms with import version
   L_AddParam  = L_Poster.addParameter('df','1'); //       delete repository forms which do not exist in import version
   
   // DO POST   
   L_HttpCode   = L_Poster.doPost('xxxxxx', 'xxxxxxx');
	globals.gHTTP = L_HttpCode
	application.updateUI()
   
   if (L_HttpCode == 200  )
   {
      plugins.dialogs.showInfoDialog( "Success!",  "Update successfully completed.\n Restart required. Click OK to exit",  "OK")
//      application.exit()
	application.closeSolution( )
	//Close the current open solution

   }
	else
	{
   // an error occurred, error handling here
   plugins.dialogs.showErrorDialog( "ERROR",  "Import failed",  "OK")
	}
}

Antonio,

It appears that when you import a new solution into the config servlet on developer. the current solution gets to an inconsistent state, this only affects developer.

Your method should follow a slightly different approach.
Close the solution before calling doPost().
After the close call you cannot use any form data; when you want to use variables, use local (var) variables.

I think that the delay is caused by the config servlet in the background completing the import of the large solution, this takes 5-10 min for large solutions.

I had to make a few changes to Servoy to get it working, this is included in the next 3.1 pre-release version.

Btw, http response code 200 does not mean the import was successful.

Rob

Thanks for all the help Rob.
I’ll try it out with the beta.
I did wonder about the if (L_HttpCode == 200 ) as it executed much too quickly. Is the getPageData() step in Jan Aleman’s example crucial? What is the appropriate test to determine if the import was successful?

Thanks again!