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

p_mesotten
Champ in-the-making
Champ in-the-making
I'm having problems to get the STAR authentication running on my Liferay 5.2.5 EE + Alfresco 3.2r2 configuration.
Steps I've done so far:
  • Installed the latest STAR amp module in Alfresco using alfresco-mmt (checked with the list command: it is definitely installed).
  • Updated the authentication chain in the alfresco properties in tomcat/shared
  • Created a dummy Hello World web script with user authentication enabled

  • <webscript>
        <shortname>Hello</shortname>
        <description>Polite greeting</description>
        <url>/sample/hello</url>
        <authentication>none</authentication>
    </webscript>

    Hello world!
  • Registered the web script in /alfresco/service/
  • Deployed the awpr portlet in Liferay
  • Modified the preferences to call the Hello World web script
  • Liferay shows The portlet failed to authenticate with Alfresco. and the tomcat log shows WARN  [JSPPortlet:114] Invalid Alfresco Ticket. Attempting to authenticate as guest. When debugging the portlet I can see that an Alfresco ticket is requested with the STAR username and password but the retrieval of the ticket throws an Exception for some reason. What could be causing this?

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

    It work`s ok!!! I think it`s working because the character encoding in the portlet….

    Thanks a lot for your help!!!!

    Yes you're right. It seems that somewhere down the road the encoding call was removed. Good find. I should be thanking you  Smiley Happy

    I've release a new version of AWPr that has this fix. The version is 1.5.1.

    Cheers,

    –Alaaeldin

    rivetlogic
    Champ on-the-rise
    Champ on-the-rise
    I'm having problems to get the STAR authentication running on my Liferay 5.2.5 EE + Alfresco 3.2r2 configuration.
    …What could be causing this?

    Hard to say with the given info.

    I noticed in your post that authentication is set to 'none' yet you're saying user authentication is enabled. Is that a typo?

    Also, could you post the values you're using for the AWPr instance preferences? It might shed some light as to why you're seeing this. Also post your chaining config in alfresco-global.properties.

    Thanks,

    –Alaaeldin

    f_tasso
    Champ in-the-making
    Champ in-the-making
    Hi Alaaeldin,

    i'm using AWPr portlet to interact with Alfresco within Liferay.

    I've modify your source code to bypass the STAr authentication method (liferay and alfresco users are different for now)

    For this:

    String userName = "admin";
    String password = "admin";
    params.add(new NameValuePair(Constants.URL_PARAM_ALFRESCO_LOGIN_SCRIPT_USERNAME, userName));
    params.add(new NameValuePair(Constants.URL_PARAM_ALFRESCO_LOGIN_SCRIPT_PASSWORD, password));
    String targetUrl = wsprefs.getAlfrescoHost() + wsprefs.getAlfrescoContextPath() + Constants.ALFRESCO_LOGIN_SCRIPT_URL;
    alfrescoTicket = this.restExecuter.execute(targetUrl, params);



    My server domain is:
    http://win2003xxxxx:8080 is Liferay
    http://win2003xxxxx:8180 is Alfresco

    Portlet AWPr settings:
    alfrescoHost = http://win2003xxxxx:8180
    alfrescoContextPath = /alfresco
    webscriptUrl = /ui/awprmyspaces
    httpMethod = GET
    webscriptParams = {f}[0],{p}[/Company Home]
    constantScriptParams = {alfUrl}[http://win2003xxxxx:8180/alfresco]
    proxyUrls = {/ui/awprmyspaces}
    jsVariable = uiawprmyspaces
    charEncodingType = UTF-8

    The portlet is loaded but i can't view the space content, i view the next message:
    "Sorry, data currently unavailable."

    If i try the direct URL in the browser:
    http://win2003xxxxx:8180/alfresco/wcservice/ui/awprmyspaces?f=0&p=%2FCompany%20Home%2F&alfUrl=http:/...

    I can see perfectly the portlet.


    Can you help me, please?

    Thank you so much,

    Fabio

    rcarhuatocto
    Champ in-the-making
    Champ in-the-making
    Hi Alaaeldin,

    I'm working with AWPr 1.5.1 on Liferay Portal 5.2.3, STAr 1.2.0 and AWPrExamplesWebScripts 1.6.0
    on Alfresco 3.2r Enterprise Edition.


    I've installed STAr and WebScripts following http://wiki.rivetlogic.com/display/AWPr/Home guide.
    I have configured awprmyspaces Portlet on Liferay but I can not get to run successfully.
    I have tried with Alfresco 3.1 EE and Alfresco 3.2r2 without success.

    Always I get a correct ticket but Portlet can't show the content of alfresco.
    I obtain this message in awpr: "Sorry, data currently unavailable".

    My AWPr portlet preferences are set to:

    1) Alfresco Host: http://localhost:8080
    2) Alfresco Context Path: /alfresco
    3) Script Url: /ui/awprmyspaces
    4) Constant Script Parameters: {alfUrl}[http://localhost:8080/alfresco]
    5) Default Script Parameters : {f}[1],{p}[/Company Home]
    6) Proxy all URLs in this portlet: NO
    7) Proxy URLs: SI: {/ui/awprmyspaces}
    😎 Javascript Variable: uiawprmyspaces
    9) REST Method Type: GET
    10) URL Encoding Type: UTF-8

    My Liferay Host is http://localhost:9090, Liferay and Alfresco both are in different Tomcats on the same PC.

    There isn't any error/exception in Alfresco log files, only a WARN:
    13:37:03,343 WARN  [HttpMethodBase:682] Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.

    Could you help me?

    Thanks a lot.

    –roger

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

    This answer is for both rcarhuatocto and f.tasso….

    You're running into a cross-domain security issue.  Your Alfresco instance must be accessible using the same hostname and port number for the AWPrMySpaces Web script's AJAX calls to work.

    You have two options:

    1. Proxy Liferay and Alfresco instances using a Web server like Apache/Proxy-AJP and use virtual hosts to ensure that Liferay and Alfresco are accessible using the same hostname and port number

    2. Use Flash policy files.

    Hope this helps,

    –Alaaeldin

    f_tasso
    Champ in-the-making
    Champ in-the-making
    First, thank you for the reply.

    I found your portlet very useful for my scopes, you've done a really good work.

    Between 1° and 2° solutions, how is the easier?

    Of this, can you explain a detailed method to perform it?

    Thank you,
    Fabio

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

    In my opinion it is easier to go with option 1.  Just search for a how-to online for using Apache + Tomcat + mod_proxy_ajp and you should be good to go.

    Cheers,

    –Alaaeldin

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

    I have a web-script that outputs an HTML.
    This works fine.

    Inside it i make an AJAX call :

    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);
              }

    This work fine if i run it outside of AWPR.
    But once inside it , it doesn't work anymore.

    I have tried to replace :

    http_request.open("POST", "${url}/alfresco/s/rst/getArticle",true);
    with
    http_request.open("POST", AWPr.encodeUrl("/alfresco/s/rst/getArticle"),true);
    But this doesn't work either.

    Please note , alfresco and liferay are on different servers.
    The original script that awpr calls are GET.

    Any help would be appreciated.

    Thank you

    rivetlogic
    Champ on-the-rise
    Champ on-the-rise
    What error are you getting?  Could it be a cross-domain security issue?

    *HINT*: Try to view the source being returned to your browser from AWPr.  Usually that shows you why things are not working.

    Cheers,

    –Alaaeldin