cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Web Script Portlet rivet

rivetlogic
Champ on-the-rise
Champ on-the-rise
AWPr

AWPr is a JSR-168 portlet that can be used to expose remote Alfresco Web scripts, including those that need user authentication. With the help of a custom Alfresco authentication component that we wrote the portlet can carry the user credentials from the portal to Alfresco, authenticate the user in Alfresco and retrieve a ticket that can be used during all subsequent interactions between the end-user, the portlet and ultimately the Alfresco Web script itself.

Motivation for AWPr

When integrating Alfresco Web scripts with JBoss Portal or Liferay Portal AWPr alleviates the need for having to deploy all of Alfresco inside the portal as is the case when using Alfresco's OOTB (out-of-the-box) Web script portlet for Alfresco/Portal integration.

AWPr is also highly configurable. Through the use of portlet preferences you can create multiple instances of AWPr and configure each one with a different Web script URL and a set of parameters with default values if needed. The instance will then RESTfully fetch the result of the Web script's render phase and carry that over to the portlet finally rendering it on the screen within the confines of the portlet window.

It is hence possible to run two instances of AWPr on a single portal page where each instance is exposing a different Web script even if those Web scripts are hosted on two different Alfresco servers regardless of their geographic location.

AWPr lives here:
http://wiki.rivetlogic.org/display/AWPr/

Feel free to ask questions about AWPr in this thread.

–Alaaeldin
125 REPLIES 125

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

Thanks for the quick response.

The source of window is not nice to look at , i do ctrl+U (firefox) and i get one line !!
Its not only the portlet but liferay aswell,

I have firebug installed , when i go to net i don't see any errors.
If if go to javascript it shows me the one line again.
Console shows me everything is ok.

I don't think this is a cross domain issue.
Both machines are next to each other on the same switch.

Also if i run the webscript from the from the liferay machine but with the ip in the browser
eg : http://192.168.1.10:8080/alfresco/s/mywebscript
Then all the ajax calls work fine.

Which is the right format to use the url ?
Should i be using :  AWPr.encodeUrl

unknown-user
Champ on-the-rise
Champ on-the-rise
Well i found something.

I tried the same code on Chrome and it kinda works.
It will POST to alfresco but will not receive anything back.

Firefox does not work.

rivetlogic
Champ on-the-rise
Champ on-the-rise
Check in firebug what the URL being posted to looks like.

–Alaaeldin

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi

if i use ${url} (with the alfresco ip)
the ip that is returned in firebug is localhost !!

If i use AWPR.encode is get :
AWPr is not defined

why would AWPr.encodeUrl not be defined ?

Thank you

rivetlogic
Champ on-the-rise
Champ on-the-rise
From the AWPr wiki:

Starting with version 1.1.0 a new portlet preference was added to allow for the AWPr javascript variable name to be configured per AWPr portlet instance. This allows more than one AWPr instance to exist on one portal page. The Web script developer will have to know the name of the javascript variable in and write the Web script AJAX calls accordingly.

The portlet preference is named jsVariable and works as follows:

jsVariable value: ABC
Javascript variable in browser: var AWPr_ABC.encodeUrl()

jsVariable value: Not set
Javascript variable in browser: var AWPr.encodeUrl()

Hope this helps,

–Alaaeldin

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

Getting close here :

http_request.open("POST", AWPr_rstnews.encodeUrl("/alfresco/s/rst/getArticle"),true);

This code does now indeed run a script. But not the one defined in the url.

In my portlet preferences i have javascript variable rstnews.
This calls a script with url : /rst/news.

When i do the ajax call it loads the first script.
Not /rst/getArticle.

Sorry to be such a pain but getting close here.

Thank you , again.

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

Can you describe the set up that you have?  Basically what IPs are Liferay and Alfresco on and how are you taking care of the cross-domain calls?  Are you fronting Liferay with a web server?\

–Alaaeldin

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

Alfresco
Tomcat
ip : 10.9.67.53

Liferay
Tomcat 6
ip : 10.9.67.118

Open ldap on:
ip : 10.9.67.53
Used for both machines

Both are on a single network.
There is just a small switch between them.
Both are Linux machines (iptables has been disabled)
No Apache installed here.

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi,

I got it to work.

Thank you for all the help.

Please note that the post cannot be done as i did it.

eg:

function goToPage(param){
           
            var parameters = "node="+ encodeURI(param)+
               "&alf_ticket=${ticket}";

            http_request = initialize();
            http_request.open("POST", "${url}/alfresco/s/rst/getArticle",true);
            http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
             http_request.setRequestHeader("Content-length", parameters.length);
             http_request.setRequestHeader("Connection", "close");
           
            http_request.onreadystatechange=function() {
              
              if (http_request.readyState==4) {
                     resultMail = http_request.responseText;
                  document.getElementById('test').innerHTML = resultMail;
                   }
              }
             http_request.send(parameters);
          }

needs to be :

function goToPage(param){
           
            http_request = initialize();
            http_request.open("POST", "${url}/alfresco/s/rst/getArticle?node="+ encodeURI(param)+"&alf_ticket=${ticket}",true);
            http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            http_request.setRequestHeader("Connection", "close");
           
            http_request.onreadystatechange=function() {
              
              if (http_request.readyState==4) {
                     resultMail = http_request.responseText;
                  document.getElementById('test').innerHTML = resultMail;
                   }
              }
          }

It works fine now.

rivetlogic
Champ on-the-rise
Champ on-the-rise
That's great.  Congrats!  Smiley Happy

–Alaaeldin