deeplink problem

Hi guys,

I have a problem using deeplinks and I was wondering if someone can guide me to solve my problem. I’m trying to use deeplinks to do autobackup for our application. I have the autobackup function as part of the main solution (in globals) so when the application runs, the method would get called on solution onOpen. We have a login page for the application to do the authentication and I need to bypass the login page when I deeplink my solution (as the procedure is supposed to be handled automatically with nobody to enter username password). I still need to authenticate though as after authentication we have some application setups and filters that need to be applied. I pass the methodname and username/password to my url. I need my application to read the login username password and and does the authentication without showing the loginpage, so if the authentication was successful, it opens the main page.I have attached my main solution’s properties section. The solution is called tsm_head, and the first page to open is tsm and I have my login solution as “login solution name”.

I was wondering how can I do this, as currently when I run the solution it goes to the login page (image attached) and get stock there waiting for someone to do the login. I need to know where should I have my function call so that I can grab the user/password from the arguments I’m passing with the url and it redirects me directly to the main page.

Sounds like a job for headless client, not web client. See viewtopic.php?f=9&t=19162&hilit=+headless#p103036 for good roundtrip example.

To get authentication, you can add a couple of parameters to the createSessionBean:

servoy_hc = HeadlessClientFactory.createSessionBean(request,"_dsa_mosaic_WEB_cms", request.getParameter("user"), request.getParameter("password"));

Hi David,
Thanks for your reply but I’m not sure how can I use headless client to achieve this?!
Based on what I understand from the link you have provided, you have a jsp file that has the content you need to call a specific servoy solution with a specific method name and when you call the .jsp file, it will run the solution as a headless client and call the method etc. As far as I know, this can be achieved with the use of deeplinks too, can’t it? because basically I am referring to a solution with some parameters to call a method in my url. So, how is your method different than using deeplink?

Can you please explain it to me if I am misunderstanding what you mean and give me a clear step by step process of how can I perform my autobackup procedure if I want to use that method considering the code needs to be run on a client machine ,server is running on another machine (like a hosting environment with a few client machines sharing the same server), it needs to open the main solution and perform the authentication and set all the filters etc. and then call the method that will handle the backup procedure (it needs to know who is the user so that it only backs up the data for that specific organization and store it locally on the machine).

siavash.roozbehan:
Thanks for your reply but I’m not sure how can I use headless client to achieve this?!
Based on what I understand from the link you have provided, you have a jsp file that has the content you need to call a specific servoy solution with a specific method name and when you call the .jsp file, it will run the solution as a headless client and call the method etc. As far as I know, this can be achieved with the use of deeplinks too, can’t it? because basically I am referring to a solution with some parameters to call a method in my url. So, how is your method different than using deeplink?

It is different from web client in that it runs only on the server, doesn’t block a currently running web client UI, and can be run from a link in an email or website. Example 1: click a link on a website and a link is displayed to download the backup file. Example 2: click a link in an email and a backup file is emailed to the person.

siavash.roozbehan:
Can you please explain it to me if I am misunderstanding what you mean and give me a clear step by step process of how can I perform my autobackup procedure if I want to use that method considering the code needs to be run on a client machine ,server is running on another machine (like a hosting environment with a few client machines sharing the same server), it needs to open the main solution and perform the authentication and set all the filters etc. and then call the method that will handle the backup procedure (it needs to know who is the user so that it only backs up the data for that specific organization and store it locally on the machine).

DeepLink arguments are passed through to the onOpen method of your login solution. Parse the user and password and pass the credentials on to your authenticator method (security.authenticate(moduleName,globalMethodName,[userName,password]). If successful, grab your method to run from the arguments and keep on rolling.

Thanks for your explanation David. I got it to work with using a jsp file and creating a headless client on the server. I have a batch file that will call the url in the browser and run a headless client on the server to run the auto backup. Everything is fine, but my only issue now is that I want to save the backup file on the client machine not on the server and I don’t know how can I do it as the headless client is running on the server machine not the client machine. I would be greatfull if you could give me clue on this one as well :)

Cheers,
Siavash

This is a workflow task as you can’t force something on the user. Zip the file up on the server and give them links to backup files when then they login to download, or email them the zip file, or automatically download the zip file when they login. Probably a few other workflows I missed.

Cool that you got the jsp approach working :)

Well, the problem is not that we are forcing the users on something, but this is the behaviour they expect to see as the autobackup procedure is scheduled on a machine they want (can be a separate machine than the one they use to login and use the application with). So they have this batch file that is triggering the headless client on the server (server can be on another machine too) and the headless client create the backup and they want to have the backup stored on the machine they have the batch file running on, not the server! so, giving them the link to download or auto download the file on login is not a preferred option.

I was thinking if I can get the file back in a return object to my jsp file and download it there on the client’s machine, but I’m still not sure if that works. I have to look for some other options.

Ah ok. If batch processor on the a client machine, my first thought would be to use curl to transfer the file. Sometime after the whole…JSP triggers the backup on the server and in the server method you do the backup and save the results as a file in Servoy’s web server. Use some sort of a naming convention for the file name so curl knows the url. Thinking out loud here…

Once again this is a task where Velocity will help a great deal!
And no need for old school jsp, curl tricks, or headless clients.

Just expose a service in Velocity (simply declaring a solution and a page in your config.json file - see the doc - that is backed by a form with a vr_getContext(request) method).
Velocity will be able to handle authentication by either HTTP basic authentication or form based (meaning you can pass users/pass as parameters to a get/post) or based on a default user.

The vr_getContext method will take care of parsing all the parameters, and give you easy objects to get all the information you need from the request so that you can apply your filters, etc. create your backup and return the backup file either by doing plugins.Velocity.createByteResponse(byte) or plugins.Velocity.createFileResponse(JSFile) - the latter being preferred if you already have a file on the file system as it will then be streamed directly without the need to load it entirely in memory.

So if you haven’t already 1/ get VelocityReport here: https://www.servoyforge.net/projects/ve … port/files
2/ install following the installation instructions: https://www.servoyforge.net/projects/ve … stallation
3/ Get a feel of all you can do with the VelocityWebClient sample solution included (applies to web services as much as web sites/pages)
4/ Then head to the specific Velocity documentation applying to web client/web services here: https://www.servoyforge.net/projects/ve … /WebClient
5/ Enjoy!

Velocity can’t push a file to a random machine anymore than a jsp file can, they are just endpoints. The calling mechanism has to handle the returned file object—and in batch processors curl is hardly a trick. But yes, you could also replicate the headless client jsp piece with Velocity.

Right, missed the part where the curl was actually in the batch file.
So that batch will call Servoy through a http url, and it will be easy with Velocity to deal with authentication and streaming the backup file back to the caller all of that in one simple Servoy form method.

Thanks guys, I have already tried to make the process work with wget instead of curl (same concept basically) as david suggested, so at least I have a working procedure now :)

But I would really like to try it with Servoy tools as much as I can if there is way to do it with velocity report plugin based on what patrick has suggested. I didn’t know velocity report plugin has such a capability, but I just need to read the docs and see if I can figure out what should I do and at the same time make sure that it doesn’t take much time to learn the process as I have to take care of some other tasks. But I’ll try to make it work with velocity report plugin too and I’ll definitely bother you guys with my questions again :P

Cheers,
Siavash