掲示板

Run Alfresco webscript as Liferay Portlet

13年前 に Ana Sir によって更新されました。

Run Alfresco webscript as Liferay Portlet

New Member 投稿: 9 参加年月日: 10/01/05 最新の投稿
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
<!--?xml version="1.0"?-->

<portlet-app version="2.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
	<portlet>
		<portlet-name>my-first-portlet</portlet-name>
		<display-name>My First Portlet</display-name>
		<portlet-class>org.springframework.extensions.webscripts.portlet.WebScriptPortlet</portlet-class>
		<init-param>
			<name>authenticator</name>
			<value>webscripts.authenticator.jsr168.webclient</value>
		</init-param>
		<init-param>
			<name>scriptUrl</name>
			<value>/alfresco/service/cmis/checkedout</value>
		</init-param>
		<expiration-cache>0</expiration-cache>
		<supports>
			<mime-type>text/html</mime-type>
		</supports>
		<portlet-info>
			<title>My First Portlet</title>
			<short-title>My First Portlet</short-title>
			<keywords>My First Portlet</keywords>
		</portlet-info>
		<security-role-ref>
			<role-name>administrator</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>guest</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>power-user</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>user</role-name>
		</security-role-ref>
	</portlet>
</portlet-app>


An error appeared when I tried to drop the portlet...

java.lang.NullPointerException
	at org.springframework.extensions.webscripts.portlet.WebScriptPortlet.init(WebScriptPortlet.java:80)
	at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:246)
	at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:216)
	at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:125)
	at com.liferay.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:38)
	at org.apache.jsp.html.portal.render_005fportlet_jsp._jspService(Unknown Source)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
	at com.liferay.portal.util.PortalImpl.renderPortlet(PortalImpl.java:3415)
	at com.liferay.portal.util.PortalUtil.renderPortlet(PortalUtil.java:1063)
	...


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
thumbnail
13年前 に Luis Rodríguez Fernández によって更新されました。

RE: Run Alfresco webscript as Liferay Portlet

Junior Member 投稿: 86 参加年月日: 09/06/26 最新の投稿
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:

private void executeHttpMethod(HttpMethodBase httpMethod) throws IOException, InvalidTicketException {
               int statusCode = httpClient.executeMethod(httpMethod);
               if (statusCode != 1) {
                       if (httpMethod.getStatusCode() == HttpServletResponse.SC_FORBIDDEN
                                       || httpMethod.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) {
                               throw new InvalidTicketException(httpMethod.getResponseBodyAsString());
                       }
               } else {
                       // TODO: throw exception
               }
       }
 


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...
13年前 に Ana Sir によって更新されました。

RE: Run Alfresco webscript as Liferay Portlet

New Member 投稿: 9 参加年月日: 10/01/05 最新の投稿
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
thumbnail
12年前 に Roger CARHUATOCTO によって更新されました。

RE: Run Alfresco webscript as Liferay Portlet

Junior Member 投稿: 32 参加年月日: 09/11/05 最新の投稿
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:

....

private void executeHttpMethod(HttpMethodBase httpMethod) throws IOException, InvalidTicketException {
               int statusCode = [b]httpClient.executeMethod(httpMethod);[/b]
               if (statusCode != 1) {
                       if (httpMethod.getStatusCode() == HttpServletResponse.SC_FORBIDDEN
                                       || httpMethod.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) {
                               throw new InvalidTicketException(httpMethod.getResponseBodyAsString());
                       }
               } else {
                       // TODO: throw exception
               }
       }
 

...


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