Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Ana Sir
Run Alfresco webscript as Liferay Portlet
June 14, 2010 6:08 AM
Answer

Ana Sir

Rank: New Member

Posts: 9

Join Date: January 5, 2010

Recent Posts

Hi all!

I want to run an Alfresco webscript as a Liferay Portlet. I red a lot of information about it, but i'm still very lost about this issue...
The Alfresco webscript is one by default, so it works fine through the browser.
I'm using Liferay 6 and Alfresco 3.3 in separate servers, and my code is

portlet.xml
 1<?xml version="1.0"?>
 2
 3<portlet-app
 4    version="2.0"
 5    xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
 6    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 7    xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
 8>
 9    <portlet>
10        <portlet-name>my-first-portlet</portlet-name>
11        <display-name>My First Portlet</display-name>
12        <portlet-class>org.springframework.extensions.webscripts.portlet.WebScriptPortlet</portlet-class>
13        <init-param>
14            <name>authenticator</name>
15            <value>webscripts.authenticator.jsr168.webclient</value>
16        </init-param>
17        <init-param>
18            <name>scriptUrl</name>
19            <value>/alfresco/service/cmis/checkedout</value>
20        </init-param>
21        <expiration-cache>0</expiration-cache>
22        <supports>
23            <mime-type>text/html</mime-type>
24        </supports>
25        <portlet-info>
26            <title>My First Portlet</title>
27            <short-title>My First Portlet</short-title>
28            <keywords>My First Portlet</keywords>
29        </portlet-info>
30        <security-role-ref>
31            <role-name>administrator</role-name>
32        </security-role-ref>
33        <security-role-ref>
34            <role-name>guest</role-name>
35        </security-role-ref>
36        <security-role-ref>
37            <role-name>power-user</role-name>
38        </security-role-ref>
39        <security-role-ref>
40            <role-name>user</role-name>
41        </security-role-ref>
42    </portlet>
43</portlet-app>


An error appeared when I tried to drop the portlet...
 1
 2java.lang.NullPointerException
 3    at org.springframework.extensions.webscripts.portlet.WebScriptPortlet.init(WebScriptPortlet.java:80)
 4    at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:246)
 5    at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:216)
 6    at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:125)
 7    at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:38)
 8    at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(Unknown Source)
 9    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
10    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
11    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
12    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
13    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
14    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
15    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
16    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
17    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
18    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
19    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
20    at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:3415)
21    at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:1063)
22    ...


I'm really lost with this,I really don't know if "WebScriptPortlet" is the class i must use, or maybe "MVCPortlet"...and since Liferay and Alfresco are not in the same server, where do I specify the Alfresco host in the portlet???

I'd really appreaciate someone who already did this, provide a step-by step guide to call a webscript from a portlet, maybe just with the Alfresco hello world webscript...
I think it would help a lot of people.

Kind Regards,
Ana
Luis Rodríguez Fernández
RE: Run Alfresco webscript as Liferay Portlet
June 15, 2010 4:34 AM
Answer

Luis Rodríguez Fernández

Rank: Junior Member

Posts: 86

Join Date: June 26, 2009

Recent Posts

Hi Ana,

What you have to do it's to develop your own portlet, to make the URL of the web script and at last wrap it in a HttpMethodBase object and then executed it. See the next piece of code:

 1private void executeHttpMethod(HttpMethodBase httpMethod) throws IOException, InvalidTicketException {
 2               int statusCode = httpClient.executeMethod(httpMethod);
 3               if (statusCode != 1) {
 4                       if (httpMethod.getStatusCode() == HttpServletResponse.SC_FORBIDDEN
 5                                       || httpMethod.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) {
 6                               throw new InvalidTicketException(httpMethod.getResponseBodyAsString());
 7                       }
 8               } else {
 9                       // TODO: throw exception
10               }
11       }
12


If you want to learn more about this stuff you can search for rivetLogic.com.


Hope it helps,

Luis

ps: as I can see you are working in the integration with Alfresco. I've seen your reply to the CMISHook post of Jonas X. Have you soved that issue? I am going to try to extend the com.liferay.documentlibrary.util.CMISHook. My idea it's trying to load the metadata of the DocumentLibraryFile in the alfresco repository, but I am not very confident in myself, because I think that after that I will have to develop the opposite integration, I mean Alfresco to Liferay...
Ana Sir
RE: Run Alfresco webscript as Liferay Portlet
June 16, 2010 12:49 AM
Answer

Ana Sir

Rank: New Member

Posts: 9

Join Date: January 5, 2010

Recent Posts

Hi Luis!
Thank you very much for the response.
I've been researching for a while about the posibilities of Alfresco-Liferay integration.Now I am focus on the webscript integration, and after reading a lot of information about it, I think it is an easy integration if you have Liferay and Alfresco in the same instance (I tried the webscript with liferay and alfresco in the same instance and thanks to these posts: http://www.liferay.com/community/forums/-/message_boards/message/1451412, http://forums.alfresco.com/en/viewtopic.php?f=36&t=13881&p=45686#p45686 i managed to call the webscript, although I'm still having problems with the authentication...), but if they aren't, the integration gets more complicated.
By the way, I want this integration with Alfresco and Liferay in separate servers, so I'll have a look to your code, reaserch about the HTTP authentication and try inverse ingenieering with webscripts on sourceforgeemoticon. I hope finally achieve this functionallity.


ps:The same idea came through my mind (modify the hook to store the metadata in alfresco), but although I developed things in Alfresco I'm quite new at Liferay. I managed to modify the core classes with the new EXT plugin, but only a couple of things about an openldap integration...I really don't feel confident to do that modification right now.I'll have to learn much more about Liferay!emoticon

Kind Regards,
Ana
Roger CARHUATOCTO
RE: Run Alfresco webscript as Liferay Portlet
September 12, 2011 2:25 PM
Answer

Roger CARHUATOCTO

Rank: Junior Member

Posts: 32

Join Date: November 5, 2009

Recent Posts

I hope it's not too late....
There are 3 ways of integrate (or calling) Alfresco Webscripts inside Liferay Portlets:

1. As Luis Rodríguez Fernández said, you have to develop your own portlet and by HTTPClient call to Alfresco's Webscripts.
Of this way you avoid cross-domain issues and could manage authentication between alfresco -> liferay (or SSO).
Other variant is to create a portlet that extend GenericPortlet and implementing com.liferay.portal.kernel.servlet.PortletServlet also to create a servlet-proxy,
or as in Portlet 2.0 specs is explained, there is a method called serveResource() that does exactly the same.

Luis Rodríguez Fernández:

....
 1
 2private void executeHttpMethod(HttpMethodBase httpMethod) throws IOException, InvalidTicketException {
 3               int statusCode = [b]httpClient.executeMethod(httpMethod);[/b]
 4               if (statusCode != 1) {
 5                       if (httpMethod.getStatusCode() == HttpServletResponse.SC_FORBIDDEN
 6                                       || httpMethod.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) {
 7                               throw new InvalidTicketException(httpMethod.getResponseBodyAsString());
 8                       }
 9               } else {
10                       // TODO: throw exception
11               }
12       }
13

...


2.- To install alfresco-surf-runtime in liferay, this allows the libraries can be used when developing portlet calling alfresco webscripts, as you said at the beginning of the thread. Several times this does not work so you have to install Alfresco Share (share.war) in liferay. IMHO, this method is not viable (is not scalable)...

3. To use AWPr of RivetLogic or Alfresco Web Script Portlet of UnorganizedMachines. Both do the same as Point 1.

any question, email me