cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript & virtualisation

boneill
Star Contributor
Star Contributor
Hi,

I need to retrieve properties from avm nodes to display as dynamic information in my webapp.    I have written a webscript that retrieves metadata from objects in an avm store.  The webscript will be called from a jsp in the webapp.

The webscript takes a "username" argument in order to create a storeid (webprojectdns + "–" + username).  This ensures that the data I retrieve in my webscript is from the correct store/sandbox.  I can test this script and get great results.  But it is flawed asI need to pass in a username in order to construct the storeid. And how does the jsp understand which username to pass to the webscript.

So how do you write webscripts so that they can be used with wcm virualisation and specific for a sandbox.

Regards

Brian
3 REPLIES 3

pmonks
Star Contributor
Star Contributor
The general approach you describe is sound, although I'd suggest passing in the entire store id as a parameter (not just the username), so that your Web Script can interrogate staging and workflow sandboxes in addition to user sandboxes.  I'd also suggest making the store id parameter optional, with the Web Script defaulting to the staging sandbox for your Web Project if the parameter is not provided - this will help to ensure that your Web Script will work correctly out in an Alfresco Runtime (where there is only a single store).

The following forum thread might help cast light on how all this works: http://forums.alfresco.com/viewtopic.php?t=11845.

Cheers,
Peter

boneill
Star Contributor
Star Contributor
Peter,

I have read through the suggested solutions.  I am working with v2.2 so I assume I can use the new test servers features which has been included in this release. 

Still confused about how it all works.  My webscript takes a storeid (webprojectdns & username) which ensures its getting the correct content.  But the jsp that will call this webscript knows nothing about who the user is that is using the jsp as the jsp is just dumn code in a webapp.  Even if I use the test server approach I do not know how I would pass the correct storeid to the jsp.  I can see how I could use this mechanism for a production webapp that connects to a ASR as their will only ever be one store.  

Regards

Brian

pmonks
Star Contributor
Star Contributor
If you're using test server deployment then you don't need to pass in store ids at all - you would simply have a bank of ASR test servers and users would deploy to them then hit your front end JSPs in order to preview.  This works because each test server ASR would only have a single store, therefore your Web Script can hard code the store id (since there's only ever one store in an ASR, regardless of whether it's a test or live server).

Obviously this is a pretty heavyweight solution (it requires at least as many test server ASRs as you have concurrent preview activity), and the forum thread I linked earlier describes an alternative approach that doesn't require test server deployment at all (and is hence a lot lighter weight).  In summary, that model involves having both the Web Script and your front end web application (your JSP) parameterised to receive the store id.  The store id itself is sent in from the "Eye of Sauron" (preview) button in the Alfresco UI (which is always displayed to the user in the context of a sandbox, and so always "knows" which store id to pass through).

Take another look at that other thread - it goes into a lot more detail about how this model works, as well as describing two different ways to get the "Eye of Sauron" to call your external web application directly (passing through the store id) rather than the virtualisation server.

Cheers,
Peter