掲示板

Display user details in an Orbeon portlet

thumbnail
15年前 に Joseph George Variam によって更新されました。

Display user details in an Orbeon portlet

New Member 投稿: 8 参加年月日: 08/06/22 最新の投稿
Hi,
My aim is to display user details in the orbeon portlet using xforms. Details like: screen name, userId, email etc.

This is what i've done so far:

1. I installed liferay-portal-tomcat-6.0-5.0.1 and got the orbeon portlet war from the community plugins site(sample-orbeon-forms-portlet-5.0.0.1.war). I deployed the war using the Admin portlet and I was able to add the orbeon portlet. The example xforms are working fine.

2. I created an orbeon xform application called liferay-userdetails and have placed it in \webapps\sample-orbeon-forms-portlet\WEB-INF\resources\apps\liferay-userdetails

Here's the page-flow.xml:
<config xmlns="http://www.orbeon.com/oxf/controller">
    <page path-info="/" view="http://localhost:8080/sample-orbeon-forms-portlet/xforms-jsp/test.jsp" />
    <epilogue url="oxf:/config/epilogue.xpl" />
</config>

Instead of using the default view.xhtml, I have set the view to a jsp page under \webapps\sample-orbeon-forms-portlet\xforms-jsp This is beacuse an Orbeon filter has been defined in web.xml with a url-pattern of /xforms-jsp/*

test.jsp - I followed the instructions about using the liferay taglibs from here: [HOWTO] Personalization - Getting current user attributes
&lt;%
    response.setContentType("application/xhtml+xml");
%&gt;

&lt;%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %&gt;
&lt;%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %&gt;

<liferay-theme:defineobjects />
<portlet:defineobjects />

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml">
	<xhtml:head>
		<xhtml:title>Hello World Classic</xhtml:title>		
	</xhtml:head>
	<xhtml:body>		
		<xhtml:p>Hello World!</xhtml:p>
		
		<xhtml:p>
			Your User Id: &lt;%= user==null?"NULL"?user.getUserId() %&gt;<xhtml:br />
		</xhtml:p>
		
	</xhtml:body>
</xhtml:html>


I've also modified page-flow-portlet.xml so that the home page points to my xforms application as shown below:

<config xmlns="http://www.orbeon.com/oxf/controller" xmlns:xu="http://www.xmldb.org/xupdate" xmlns:oxf="http://www.orbeon.com/oxf/processors">

    <!-- Home / welcome application -->
    <page id="home" path-info="/" model="apps/liferay-userdetails/page-flow.xml" />

    <!-- Dispatch request to a specific application -->
    <page id="apps" path-info="/([^/]+)/.*" matcher="oxf:perl5-matcher" model="apps/${1}/page-flow.xml" />

    <!-- "Not Found" page displayed when no page matches the request path -->
    <page id="not-found" path-info="/not-found" view="/config/not-found.xml" />

    <epilogue url="/config/epilogue.xpl" />
    <not-found-handler page="not-found" />

</config>


3. I restarted tomcat and my xforms app gets rendered fine in the orbeon portlet..."Hello World" gets displayed but I get a "NULL" for the user id. I checked the servlet source of this jsp page and this is because the user object is null:

user = (com.liferay.portal.model.User) _jspx_page_context.findAttribute("user");


Why is this happening? Is there any other method I could follow to get the user details?
thumbnail
15年前 に Ray Augé によって更新されました。

Re: [Liferay Forums][6. Third Party Application Integration] Display user d

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
> 3. I restarted tomcat and my xforms app gets rendered fine in the
> orbeon portlet..."Hello World" gets displayed but I get a "NULL" for
> the user id. I checked the servlet source of this jsp page and this is
> because the user object is null:
>
>
> 1user = (com.liferay.portal.model.User)
> _jspx_page_context.findAttribute("user");
>
>
>
> Why is this happening? Is there any other method I could follow to get
> the user details?


It's because the servlet request isn't being called within the security
context of the portal.

You didn't indicate which version of the portal you're using, but if it
happens to be a recent version (like 4.4+) we have a solution for you.

It's called [tt]ServletAuthorizingFilter[/tt].

This filter allows you to wrap any servlet outside the portal and have
it authenticated against the portal's context. It works in conjunction
with our [tt]Auto Login Filter[/tt].

Here is how you might apply it to your [tt]/xforms-jsp/*[/tt] mapping.

	<filter>
		<filter-name>Auto Login Filter</filter-name>

<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
		<init-param>
			<param-name>filter-class</param-name>

<param-value>com.liferay.portal.servlet.filters.autologin.AutoLoginFilter</param-value>
		</init-param>
	</filter>
	<filter>
		<filter-name>Servlet Authorizing Filter</filter-name>

<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
		<init-param>
			<param-name>filter-class</param-name>

<param-value>com.liferay.portal.servlet.filters.servletauthorizing.ServletAuthorizingFilter</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>Auto Login Filter</filter-name>
		<url-pattern>/xforms-jsp/*</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>Servlet Authorizing Filter</filter-name>
		<url-pattern>/xforms-jsp/*</url-pattern>
	</filter-mapping>


Once in place, your jsp should work as you expected.

If you get it to work let us know, as I haven't tested it specifically
with Orbeon. emoticon

添付ファイル:

thumbnail
15年前 に Joseph George Variam によって更新されました。

RE: Re: [Liferay Forums][6. Third Party Application Integration] Display us

New Member 投稿: 8 参加年月日: 08/06/22 最新の投稿
Hi Ray,
I'm using liferay portal 5.0.1 and I added the filter declarations like you suggested to the orbeon portlet's web.xml but still the user object is null.

This is what the web.xml looks like:
<!--?xml version="1.0" encoding="UTF-8"?-->


<web-app>
	<display-name>sample-orbeon-forms-portlet</display-name>
	<description>Orbeon Forms is an open source forms solution that handles the complexity of forms typical of the enterprise or government. It is delivered to standard web browsers (including Internet Explorer, Firefox, Safari and Opera) thanks to XForms and Ajax technology, with no need for client-side software or plugins. Orbeon Forms allows you to build fully interactive forms with features that include as-you-type validation, optional and repeated sections, always up-to-date error summaries, PDF output, full internationalization, and controls like auto-completion, tabs, dialogs, trees and menus.</description>
	<context-param>
		<param-name>oxf.resources.factory</param-name>
		<param-value>org.orbeon.oxf.resources.PriorityResourceManagerFactory</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.resources.priority.1</param-name>
		<param-value>org.orbeon.oxf.resources.WebAppResourceManagerFactory</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.resources.priority.1.oxf.resources.webapp.rootdir</param-name>
		<param-value>/WEB-INF/resources</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.resources.priority.2</param-name>
		<param-value>org.orbeon.oxf.resources.ClassLoaderResourceManagerFactory</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.classloader.enable</param-name>
		<param-value>false</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.classloader.ignore-packages</param-name>
		<param-value>java. javax. org.apache.log4j. org.xml. org.w3c.</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.properties</param-name>
		<param-value>oxf:/config/properties.xml</param-value>
	</context-param>
	<context-param>
		<param-name>oxf.initialize-logging</param-name>
		<param-value>true</param-value>
	</context-param>
	<filter>
		<filter-name>ops-main-filter</filter-name>
		<filter-class>org.orbeon.oxf.servlet.OPSServletFilter</filter-class>
		<init-param>
			<param-name>oxf.main-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.main-processor.input.config</param-name>
			<param-value>oxf:/config/filter.xpl</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.error-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.error-processor.input.config</param-name>
			<param-value>oxf:/config/error.xpl</param-value>
		</init-param>
	</filter>
	<filter>
		<filter-name>Auto Login Filter</filter-name>
		<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
		<init-param>
			<param-name>filter-class</param-name>
			<param-value>com.liferay.portal.servlet.filters.autologin.AutoLoginFilter</param-value>
		</init-param>
	</filter>
	<filter>
		<filter-name>Servlet Authorizing Filter</filter-name>
		<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
		<init-param>
			<param-name>filter-class</param-name>
			<param-value>com.liferay.portal.servlet.filters.servletauthorizing.ServletAuthorizingFilter</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>Auto Login Filter</filter-name>
		<url-pattern>/xforms-jsp/*</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>Servlet Authorizing Filter</filter-name>
		<url-pattern>/xforms-jsp/*</url-pattern>
	</filter-mapping>
	<filter-mapping>
		<filter-name>ops-main-filter</filter-name>
		<url-pattern>/xforms-jsp/*</url-pattern>
	</filter-mapping>

	<listener>
		<listener-class>com.liferay.portal.kernel.servlet.PortletContextListener</listener-class>
	</listener>
	<servlet>
		<servlet-name>ops-main-servlet</servlet-name>
		<servlet-class>org.orbeon.oxf.servlet.OPSServlet</servlet-class>
		<init-param>
			<param-name>oxf.main-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}page-flow</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.main-processor.input.controller</param-name>
			<param-value>oxf:/page-flow.xml</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.error-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.error-processor.input.config</param-name>
			<param-value>oxf:/config/error.xpl</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.http.accept-methods</param-name>
			<param-value>get,post,head</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.servlet-initialized-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.servlet-initialized-processor.input.config</param-name>
			<param-value>oxf:/apps/context/servlet-initialized.xpl</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.servlet-destroyed-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.servlet-destroyed-processor.input.config</param-name>
			<param-value>oxf:/apps/context/servlet-destroyed.xpl</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>ops-xforms-server-servlet</servlet-name>
		<servlet-class>org.orbeon.oxf.servlet.OPSServlet</servlet-class>
		<init-param>
			<param-name>oxf.main-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.main-processor.input.config</param-name>
			<param-value>oxf:/ops/xforms/xforms-server.xpl</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.error-processor.name</param-name>
			<param-value>{http://www.orbeon.com/oxf/processors}pipeline</param-value>
		</init-param>
		<init-param>
			<param-name>oxf.error-processor.input.config</param-name>
			<param-value>oxf:/ops/xforms/xforms-server-error.xpl</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>display-chart-servlet</servlet-name>
		<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>exist-xmlrpc-servlet</servlet-name>
		<servlet-class>org.exist.xmlrpc.RpcServlet</servlet-class>
	</servlet>
	<servlet>
		<servlet-name>exist-rest-servlet</servlet-name>
		<servlet-class>org.exist.http.servlets.EXistServlet</servlet-class>
		<init-param>
			<param-name>basedir</param-name>
			<param-value>WEB-INF/</param-value>
		</init-param>
		<init-param>
			<param-name>configuration</param-name>
			<param-value>exist-conf.xml</param-value>
		</init-param>
		<init-param>
			<param-name>start</param-name>
			<param-value>true</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>exist-webdav-servlet</servlet-name>
		<servlet-class>org.exist.http.servlets.WebDAVServlet</servlet-class>
		<init-param>
			<param-name>authentication</param-name>
			<param-value>basic</param-value>
		</init-param>
	</servlet>
	<servlet>
		<servlet-name>exist-atom-servlet</servlet-name>
		<servlet-class>org.exist.atom.http.AtomServlet</servlet-class>
		<init-param>
			<param-name>authentication</param-name>
			<param-value>basic</param-value>
		</init-param>
	</servlet>
	<servlet>
		<servlet-name>struts-servlet</servlet-name>
		<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>config/examples/struts/module</param-name>
			<param-value>/WEB-INF/struts-module.xml</param-value>
		</init-param>
		<load-on-startup>3</load-on-startup>
	</servlet>
	<servlet>
		<servlet-name>sample_orbeon_forms</servlet-name>
		<servlet-class>com.liferay.portal.kernel.servlet.PortletServlet</servlet-class>
		<init-param>
			<param-name>portlet-class</param-name>
			<param-value>org.orbeon.oxf.portlet.OPSPortlet</param-value>
		</init-param>
		<load-on-startup>0</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>ops-main-servlet</servlet-name>
		<url-pattern>/</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>ops-xforms-server-servlet</servlet-name>
		<url-pattern>/xforms-server/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>exist-xmlrpc-servlet</servlet-name>
		<url-pattern>/exist/xmlrpc</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>exist-rest-servlet</servlet-name>
		<url-pattern>/exist/rest/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>exist-webdav-servlet</servlet-name>
		<url-pattern>/exist/webdav/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>exist-atom-servlet</servlet-name>
		<url-pattern>/exist/atom/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>struts-servlet</servlet-name>
		<url-pattern>/struts/*</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>display-chart-servlet</servlet-name>
		<url-pattern>/chartDisplay</url-pattern>
	</servlet-mapping>
	<servlet-mapping>
		<servlet-name>sample_orbeon_forms</servlet-name>
		<url-pattern>/sample_orbeon_forms/*</url-pattern>
	</servlet-mapping>
	<taglib>
		<taglib-uri>http://liferay.com/tld/theme</taglib-uri>
		<taglib-location>/WEB-INF/tld/liferay-theme.tld</taglib-location>
	</taglib>
	<taglib>
		<taglib-uri>http://liferay.com/tld/ui</taglib-uri>
		<taglib-location>/WEB-INF/tld/liferay-ui.tld</taglib-location>
	</taglib>
	<taglib>
		<taglib-uri>http://java.sun.com/portlet_2_0</taglib-uri>
		<taglib-location>/WEB-INF/tld/liferay-portlet.tld</taglib-location>
	</taglib>
</web-app>
thumbnail
15年前 に Ray Augé によって更新されました。

RE: Re: [Liferay Forums][6. Third Party Application Integration] Display us

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
You're quite right!

I forgot to mention of few key things which will make this slightly more
complicated...

The advice I gave you to use the [tt]ServletAuthorizingFilter[/tt] still
won't give you access to the objects mentioned the personalization blog
post. All you get is a starting point... which is that the thread is now
authenticated to the current user and [tt]request.getRemoteUser()[/tt]
will get you the id of the current user, which you can use to get the
rest of the things you need, starting with the user...

The problem is still the same as before though... Because the call
[tt]http://localhost:8080/sample-orbeon-forms-portlet/xforms-jsp/test.jsp[/tt]
does not pass through the portal.. it will not activate the
ServicePreAction which is the only construction area for
[tt]ThemeDisplay[/tt] objects. So, I'm wonering, isn't there a way in
OPS to call your same jsp, but via a portlet request?

I played with OPS quite a while back but can't recall how much facility
there was to wire in a custom portlet view. I'm thinking that that would
be the easiest for you as you would immediately have the correct
result...

i.e. If you could
change [tt]http://localhost:8080/sample-orbeon-forms-portlet/xforms-jsp/test.jsp[/tt] to a portlet request to that same jsp, it would work. Problem is that OPS doesn't yet support JSR-286 (that I know of), so making a resource request won't work either...

hmm, I think you might be relegated to having to obtain objects
manually...

e.g. (with the filter in place) to get the user you can do:
User user =
UserLocalServiceUtil.getUserById(GetterUtil.getLong(request.getRemoteUser()));
thumbnail
15年前 に Joseph George Variam によって更新されました。

RE: Re: [Liferay Forums][6. Third Party Application Integration] Display us

New Member 投稿: 8 参加年月日: 08/06/22 最新の投稿
Hi ray,
[tt]request.getRemoteUser()[/tt] also returns null in the portlet. But if i go to the url directly in a browser, [tt]http://localhost:8080/sample-orbeon-forms-portlet/xforms-jsp/test.jsp[/tt] i do get a value...

Ray Augé:
i.e. If you could
change [tt]http://localhost:8080/sample-orbeon-forms-portlet/xforms-jsp/test.jsp[/tt] to a portlet request to that same jsp, it would work. Problem is that OPS doesn't yet support JSR-286 (that I know of), so making a resource request won't work either...


I dont quite understand what u mean by a portlet request to that jsp? How would I go about doing that?
thumbnail
15年前 に Joseph George Variam によって更新されました。

RE: Re: [Liferay Forums][6. Third Party Application Integration] Display us

New Member 投稿: 8 参加年月日: 08/06/22 最新の投稿
and I came across a blog by a guy named Peter and he says I should do it the other way around - Modify Liferay's web.xml and put in a couple of orbeon filter defs there with a url-mapping of /html/xforms-jsp i.e. to put the jsp in /ROOT/html/xforms emoticon

here's the post: Peter's Notes
thumbnail
15年前 に Ray Augé によって更新されました。

RE: Re: [Liferay Forums][6. Third Party Application Integration] Display us

Liferay Legend 投稿: 1197 参加年月日: 05/02/08 最新の投稿
That could work as well... I'm never really sure how much modding of the
portal war people are willing to put up with... emoticon

添付ファイル:

thumbnail
15年前 に Joseph George Variam によって更新されました。

RE: Re: [Liferay Forums][6. Third Party Application Integration] Display us

New Member 投稿: 8 参加年月日: 08/06/22 最新の投稿
Ray Augé:
change [tt]http://localhost:8080/sample-orbeon-forms-portlet/xforms-jsp/test.jsp[/tt] to a portlet request to that same jsp, it would work. Problem is that OPS doesn't yet support JSR-286 (that I know of), so making a resource request won't work either...


If I do follow what peter says, then, I have a jsp page at /html/xforms-jsp/test.jsp how would I access this as a Portlet request? What's a portlet request? Does Liferay5.0.1 support JSR268...Can I access this jsp through a Resource request? How's a Portlet request different from a Resource request?
12年前 に chandra sekhar によって更新されました。

RE: Display user details in an Orbeon portlet

Regular Member 投稿: 149 参加年月日: 09/07/07 最新の投稿
Hi Joseph George Variam,

I want to integrate the Orbeon forms with liferay 5.1.2. I think you already worked on it.
Can you share the info related to integration of Orbeon-form-portlet with liferay.


Thanks in advance.


Regards,
Chandrasekhar